diff options
author | John Cater <jcater@google.com> | 2018-03-19 08:51:46 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-03-19 08:53:02 -0700 |
commit | 32c5add2088f58560131a70b670566bc5f7efa7d (patch) | |
tree | 521fe133ed9b69a17ad1adfe90caef02095691ed /scripts | |
parent | 9b8e9feaec3568ccb76787c3f0df5d80cc4a894f (diff) |
Update the distfile compile scripts to create a valid embedded tools
repository.
Closes #4860.
Change-Id: I1689fee013d031253d5e55343be174aaa6e638c1
PiperOrigin-RevId: 189588855
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/bootstrap/buildenv.sh | 12 | ||||
-rwxr-xr-x | scripts/bootstrap/compile.sh | 16 |
2 files changed, 27 insertions, 1 deletions
diff --git a/scripts/bootstrap/buildenv.sh b/scripts/bootstrap/buildenv.sh index 8dfb6fe917..0689b95919 100755 --- a/scripts/bootstrap/buildenv.sh +++ b/scripts/bootstrap/buildenv.sh @@ -301,3 +301,15 @@ function get_bind_target() { $BAZEL --bazelrc=${BAZELRC} --nomaster_bazelrc ${BAZEL_DIR_STARTUP_OPTIONS} \ query "deps($1, 1) - $1" } + +# Create a link for a directory on the filesystem +function link_dir() { + local source=$1 + local dest=$2 + + if [[ "${PLATFORM}" == "windows" ]]; then + cmd.exe /C "mklink /J \"$(cygpath -w "$dest")\" \"$(cygpath -w "$source")\"" + else + ln -s "${source}" "${dest}" + fi +} diff --git a/scripts/bootstrap/compile.sh b/scripts/bootstrap/compile.sh index f991e32a22..2ae26f44bd 100755 --- a/scripts/bootstrap/compile.sh +++ b/scripts/bootstrap/compile.sh @@ -207,10 +207,24 @@ if [ -z "${BAZEL_SKIP_JAVA_COMPILATION}" ]; then cp src/main/java/$i ${OUTPUT_DIR}/classes/$i done + # Create the bazel_tools repository. + BAZEL_TOOLS_REPO=${OUTPUT_DIR}/embedded_tools + mkdir -p ${BAZEL_TOOLS_REPO} + cat <<EOF >${BAZEL_TOOLS_REPO}/WORKSPACE +workspace(name = 'bazel_tools') +EOF + link_dir ${PWD}/src ${BAZEL_TOOLS_REPO}/src + link_dir ${PWD}/third_party ${BAZEL_TOOLS_REPO}/third_party + link_dir ${PWD}/tools ${BAZEL_TOOLS_REPO}/tools + + # Set up @bazel_tools//platforms properly + mkdir -p ${BAZEL_TOOLS_REPO}/platforms + cp tools/platforms/platforms.BUILD ${BAZEL_TOOLS_REPO}/platforms/BUILD + # Overwrite tools.WORKSPACE, this is only for the bootstrap binary chmod u+w "${OUTPUT_DIR}/classes/com/google/devtools/build/lib/bazel/rules/tools.WORKSPACE" cat <<EOF >${OUTPUT_DIR}/classes/com/google/devtools/build/lib/bazel/rules/tools.WORKSPACE -local_repository(name = 'bazel_tools', path = __workspace_dir__) +local_repository(name = 'bazel_tools', path = '${BAZEL_TOOLS_REPO}') bind(name = "cc_toolchain", actual = "@bazel_tools//tools/cpp:default-toolchain") EOF |