From a739f24cb27479873abc3343f08d3fd37ae5f5ea Mon Sep 17 00:00:00 2001 From: Jeff Gaston Date: Tue, 31 Jan 2017 11:08:21 -0800 Subject: Add script to make a Go-style workspace for Soong Test: ./scripts/setup_go_workspace_for_soong.sh Change-Id: If091175d3b69976d3e1488304c4274296cc8afb4 --- scripts/setup_go_workspace_for_soong.sh | 67 +++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 scripts/setup_go_workspace_for_soong.sh (limited to 'scripts') diff --git a/scripts/setup_go_workspace_for_soong.sh b/scripts/setup_go_workspace_for_soong.sh new file mode 100755 index 00000000..4b118efb --- /dev/null +++ b/scripts/setup_go_workspace_for_soong.sh @@ -0,0 +1,67 @@ +#!/bin/bash +set -e + +#mounts the components of soong into a directory structure that Go tools and editors expect + +#move to the script's directory +cd "$(dirname $0)" +SCRIPT_PATH="$PWD" + +#find the root of the Repo checkout +cd "${SCRIPT_PATH}"/../../.. +ANDROID_PATH="${PWD}" +OUTPUT_PATH="$(echo ${GOPATH} | sed 's/\:.*//')" #if GOPATH contains multiple paths, use the first one + +if [ -z "${OUTPUT_PATH}" ]; then + echo "Error; could not determine the desired location at which to create a Go-compatible workspace. Please update GOPATH to specify the desired destination directory" + exit 1 +fi + +function confirm() { + while true; do + echo "Will create GOPATH-compatible directory structure at ${OUTPUT_PATH}" + echo -n "Ok [Y/n]?" + read decision + if [ "${decision}" == "y" -o "${decision}" == "Y" -o "${decision}" == "" ]; then + return 0 + else + if [ "${decision}" == "n" ]; then + return 1 + else + echo "Invalid choice ${decision}; choose either 'y' or 'n'" + fi + fi + done +} + +function bindAll() { + bindOne "${ANDROID_PATH}/build/blueprint" "${OUTPUT_PATH}/src/github.com/google/blueprint" + bindOne "${ANDROID_PATH}/build/soong" "${OUTPUT_PATH}/src/android/soong" + + bindOne "${ANDROID_PATH}/art/build" "${OUTPUT_PATH}/src/android/soong/art" + bindOne "${ANDROID_PATH}/external/llvm/soong" "${OUTPUT_PATH}/src/android/soong/llvm" + bindOne "${ANDROID_PATH}/external/clang/soong" "${OUTPUT_PATH}/src/android/soong/clang" + echo + echo "Created GOPATH-compatible directory structure at ${OUTPUT_PATH}" +} + +function bindOne() { + #causes $newPath to mirror $existingPath + existingPath="$1" + newPath="$2" + mkdir -p "$newPath" + echoAndDo bindfs "${existingPath}" "${newPath}" +} + +function echoAndDo() { + echo "$@" + eval "$@" +} + +if confirm; then + echo + bindAll +else + echo "skipping due to user request" + exit 1 +fi -- cgit v1.2.3