aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJeff Gaston <jeffrygaston@google.com>2017-01-31 11:08:21 -0800
committerJeff Gaston <jeffrygaston@google.com>2017-02-07 18:24:10 -0800
commita739f24cb27479873abc3343f08d3fd37ae5f5ea (patch)
tree6a2c0f252ab333047278f4dd77f4e84cb19a7f7e /scripts
parente25bc9ba83c5d00a95aa06bda668e731f740a656 (diff)
downloadbuild_soong-a739f24cb27479873abc3343f08d3fd37ae5f5ea.tar.gz
build_soong-a739f24cb27479873abc3343f08d3fd37ae5f5ea.tar.bz2
build_soong-a739f24cb27479873abc3343f08d3fd37ae5f5ea.zip
Add script to make a Go-style workspace for Soong
Test: ./scripts/setup_go_workspace_for_soong.sh Change-Id: If091175d3b69976d3e1488304c4274296cc8afb4
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/setup_go_workspace_for_soong.sh67
1 files changed, 67 insertions, 0 deletions
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