From 32c5add2088f58560131a70b670566bc5f7efa7d Mon Sep 17 00:00:00 2001 From: John Cater Date: Mon, 19 Mar 2018 08:51:46 -0700 Subject: Update the distfile compile scripts to create a valid embedded tools repository. Closes #4860. Change-Id: I1689fee013d031253d5e55343be174aaa6e638c1 PiperOrigin-RevId: 189588855 --- compile.sh | 4 ++-- scripts/bootstrap/buildenv.sh | 12 ++++++++++++ scripts/bootstrap/compile.sh | 16 +++++++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/compile.sh b/compile.sh index 31bb9c4f1c..48359e3777 100755 --- a/compile.sh +++ b/compile.sh @@ -93,8 +93,8 @@ log "Building output/bazel" # We set host and target platform directly since the defaults in @bazel_tools # have not yet been generated. bazel_build "src:bazel${EXE_EXT}" \ - --host_platform=//tools/platforms:host_platform \ - --platforms=//tools/platforms:target_platform \ + --host_platform=@bazel_tools//platforms:host_platform \ + --platforms=@bazel_tools//platforms:target_platform \ || fail "Could not build Bazel" bazel_bin_path="$(get_bazel_bin_path)/src/bazel${EXE_EXT}" [ -e "$bazel_bin_path" ] \ 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 <${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 <${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 -- cgit v1.2.3