aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xcompile.sh25
-rwxr-xr-xscripts/bootstrap/init_workspace.sh65
-rw-r--r--scripts/packages/BUILD52
-rw-r--r--scripts/packages/debian/bazel.bazelrc3
-rwxr-xr-xscripts/packages/template_bin.sh25
-rw-r--r--site/docs/bazel-user-manual.html8
6 files changed, 159 insertions, 19 deletions
diff --git a/compile.sh b/compile.sh
index 9f435e0b2b..1cc6ecf545 100755
--- a/compile.sh
+++ b/compile.sh
@@ -27,26 +27,30 @@ cd "$(dirname "$0")"
source scripts/bootstrap/buildenv.sh
function usage() {
- [ -n "${1:-compile}" ] && echo "Invalid command(s): $1" >&2
+ [ -n "${1:-build}" ] && echo "Invalid command(s): $1" >&2
echo "syntax: $0 [command[,command]* [BAZEL_BIN [BAZEL_SUM]]]" >&2
echo " General purpose commands:" >&2
- echo " compile = compile the bazel binary (default)" >&2
+ echo " build = compile,init (default)" >&2
+ echo " compile = compile a Bazel binary for usage" >&2
+ echo " init = initialize the base workspace" >&2
echo " Commands for developers:" >&2
- echo " all = compile,determinism,test" >&2
+ echo " all = build,determinism,test" >&2
echo " determinism = test for stability of Bazel builds" >&2
echo " test = run the full test suite of Bazel" >&2
exit 1
}
function parse_options() {
- local keywords="(compile|all|determinism|bootstrap|test)"
- COMMANDS="${1:-compile}"
+ local keywords="(build|compile|init|all|determinism|bootstrap|test)"
+ COMMANDS="${1:-build}"
[[ "${COMMANDS}" =~ ^$keywords(,$keywords)*$ ]] || usage "$@"
DO_COMPILE=
DO_CHECKSUM=
DO_FULL_CHECKSUM=1
DO_TESTS=
- [[ "${COMMANDS}" =~ (compile|all) ]] && DO_COMPILE=1
+ DO_BASE_WORKSPACE_INIT=
+ [[ "${COMMANDS}" =~ (compile|build|all) ]] && DO_COMPILE=1
+ [[ "${COMMANDS}" =~ (init|build|all) ]] && DO_BASE_WORKSPACE_INIT=1
[[ "${COMMANDS}" =~ (bootstrap|determinism|all) ]] && DO_CHECKSUM=1
[[ "${COMMANDS}" =~ (bootstrap) ]] && DO_FULL_CHECKSUM=
[[ "${COMMANDS}" =~ (test|all) ]] && DO_TESTS=1
@@ -155,5 +159,14 @@ if [ $DO_TESTS ]; then
|| fail "Tests failed"
fi
+#
+# Setup the base workspace
+#
+if [ $DO_BASE_WORKSPACE_INIT ]; then
+ new_step 'Setting up base workspace'
+ display "."
+ source scripts/bootstrap/init_workspace.sh
+fi
+
clear_log
display "Build successful! Binary is here: ${BAZEL}"
diff --git a/scripts/bootstrap/init_workspace.sh b/scripts/bootstrap/init_workspace.sh
new file mode 100755
index 0000000000..79be02bfc5
--- /dev/null
+++ b/scripts/bootstrap/init_workspace.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+# Copyright 2015 The Bazel Authors. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Set-up the base workspace, currently used as package_path to provide
+# the tools directory.
+
+# Create symlinks so we can use tools and examples from the base_workspace.
+function symlink_directory() {
+ local dir=$1
+ rm -fr "${base_workspace}/${dir}"
+ mkdir "${base_workspace}/${dir}"
+
+ for i in $(cd ${dir}; ls | grep -v "^BUILD$"); do
+ ln -s "$(pwd)/${dir}/$i" "${base_workspace}/${dir}/$i";
+ done
+
+ touch "${base_workspace}/${dir}/DONT_FOLLOW_SYMLINKS_WHEN_TRAVERSING_THIS_DIRECTORY_VIA_A_RECURSIVE_TARGET_PATTERN"
+}
+
+base_workspace="${WORKSPACE_DIR}/base_workspace"
+mkdir -p "${base_workspace}"
+
+symlink_directory tools
+cat > "${base_workspace}/tools/BUILD" <<EOF
+package(default_visibility = ["//visibility:public"])
+exports_files(["test_sharding_compliant"])
+EOF
+
+symlink_directory examples
+symlink_directory third_party
+
+# Create a bazelrc file with the base_workspace directory in the package path.
+bazelrc='build --package_path %workspace%:'${base_workspace}
+bazelrc="${bazelrc}"$'\nfetch --package_path %workspace%:'${base_workspace}
+bazelrc="${bazelrc}"$'\nquery --package_path %workspace%:'${base_workspace}
+if [ -z "${HOME-}" ]; then
+ warning="$INFO No \$HOME variable set, cannot write .bazelrc file."
+ warning="$warning Consider adding $base_workspace to your package path"
+ display $warning
+elif [ ! -f $HOME/.bazelrc ]; then
+ display "$INFO Creating a .bazelrc pointing to $base_workspace"
+ echo -e "$bazelrc" > $HOME/.bazelrc
+else
+ while read rcline; do
+ if ! grep -q "$rcline" $HOME/.bazelrc; then
+ warning="$INFO You already have a .bazelrc. Make sure it contains the "
+ warning="$warning following package paths:\n\n$bazelrc\n\n"
+ display "$warning"
+ break
+ fi
+ done <<< "$bazelrc"
+fi
diff --git a/scripts/packages/BUILD b/scripts/packages/BUILD
index 554c626e72..86a3a1f5ae 100644
--- a/scripts/packages/BUILD
+++ b/scripts/packages/BUILD
@@ -93,12 +93,64 @@ pkg_tar(
)
pkg_tar(
+ name = "bazel-tools",
+ files = [
+ "//third_party:srcs",
+ "//third_party/java/jdk/langtools:srcs",
+ "//tools:package-srcs",
+ ],
+ mode = "0644",
+ modes = {f: "0755" for f in [
+ # List made out of `find -type f -executable`
+ "third_party/iossim/iossim",
+ "third_party/ijar/test/zip_test.sh",
+ "third_party/ijar/test/ijar_test.sh",
+ "third_party/ijar/test/testenv.sh",
+ "third_party/protobuf/protoc-osx-x86_32.exe",
+ "third_party/protobuf/protoc-linux-x86_64.exe",
+ "third_party/protobuf/protoc-osx-x86_64.exe",
+ "third_party/protobuf/protoc-linux-x86_32.exe",
+ "third_party/protobuf/protoc-windows-x86_32.exe",
+ "third_party/protobuf/protoc-windows-x86_64.exe",
+ "third_party/py/gflags/tests/flags_modules_for_testing/module_bar.py",
+ "third_party/py/gflags/tests/flags_modules_for_testing/module_baz.py",
+ "third_party/py/gflags/tests/flags_modules_for_testing/module_foo.py",
+ "third_party/py/gflags/tests/gflags_helpxml_test.py",
+ "third_party/py/gflags/tests/gflags_unittest.py",
+ "third_party/py/gflags/tests/gflags_validators_test.py",
+ "third_party/py/gflags/gflags2man.py",
+ "third_party/py/gflags/setup.py",
+ "third_party/py/gflags/debian/rules",
+ "third_party/py/gflags/gflags_validators.py",
+ "third_party/py/mock/setup.py",
+ "tools/android/jack/fail.sh",
+ "tools/android/shuffle_jars.sh",
+ "tools/android/merge_dexzips.sh",
+ "tools/android/idlclass.sh",
+ "tools/android/aar_generator.sh",
+ "tools/android/resources_processor.sh",
+ "tools/j2objc/j2objc_wrapper.py",
+ "tools/genrule/genrule-setup.sh",
+ "tools/objc/j2objc_dead_code_pruner.py",
+ "tools/python/2to3.sh",
+ "tools/cpp/osx_gcc_wrapper.sh",
+ "tools/test/test-setup.sh",
+ "tools/jdk/ijar",
+ "tools/build_defs/docker/testenv.sh",
+ "tools/build_defs/docker/build_test.sh",
+ ]},
+ package_dir = "/usr/share/lib/bazel/tools",
+ strip_prefix = "/",
+)
+
+pkg_tar(
name = "debian-data",
extension = "tar.gz",
deps = [
":bazel-bin",
":bazel-completion",
":bazel-rc",
+ ":bazel-tools",
],
)
diff --git a/scripts/packages/debian/bazel.bazelrc b/scripts/packages/debian/bazel.bazelrc
index e69de29bb2..594b54bca8 100644
--- a/scripts/packages/debian/bazel.bazelrc
+++ b/scripts/packages/debian/bazel.bazelrc
@@ -0,0 +1,3 @@
+build --package_path=%workspace%:/usr/share/lib/bazel/tools
+query --package_path=%workspace%:/usr/share/lib/bazel/tools
+fetch --package_path=%workspace%:/usr/share/lib/bazel/tools
diff --git a/scripts/packages/template_bin.sh b/scripts/packages/template_bin.sh
index 594a19c746..d3f7d3b2ba 100755
--- a/scripts/packages/template_bin.sh
+++ b/scripts/packages/template_bin.sh
@@ -18,7 +18,6 @@
# Installation and etc prefix can be overriden from command line
install_prefix=${1:-"/usr/local"}
-# TODO(kchodorow): delete by April 2016.
bazelrc=${2:-"/etc/bazel.bazelrc"}
progname="$0"
@@ -34,10 +33,11 @@ function usage() {
echo "Usage: $progname [options]" >&2
echo "Options are:" >&2
echo " --prefix=/some/path set the prefix path (default=/usr/local)." >&2
+ echo " --bazelrc= set the bazelrc path (default=/etc/bazel.bazelrc)." >&2
echo " --bin= set the binary folder path (default=%prefix%/bin)." >&2
echo " --base= set the base install path (default=%prefix%/lib/bazel)." >&2
echo " --user configure for user install, expands to" >&2
- echo ' `--bin=$HOME/bin --base=$HOME/.bazel' >&2
+ echo ' `--bin=$HOME/bin --base=$HOME/.bazel --bazelrc=$HOME/.bazelrc`.' >&2
exit 1
}
@@ -139,12 +139,19 @@ if [ -d "${base}" -a -x "${base}/bin/bazel" ]; then
rm -fr "${base}"
fi
-mkdir -p ${bin} ${base} ${base}/bin ${base}/etc
+mkdir -p ${bin} ${base} ${base}/bin ${base}/etc ${base}/base_workspace
echo -n .
unzip -q "${BASH_SOURCE[0]}" bazel bazel-real bazel-complete.bash -d "${base}/bin"
echo -n .
chmod 0755 "${base}/bin/bazel" "${base}/bin/bazel-real"
+unzip -q "${BASH_SOURCE[0]}" -x bazel bazel-real bazel-complete.bash -d "${base}/base_workspace"
+echo -n .
+cat >"${base}/etc/bazel.bazelrc" <<EO
+build --package_path %workspace%:${base}/base_workspace
+fetch --package_path %workspace%:${base}/base_workspace
+query --package_path %workspace%:${base}/base_workspace
+EO
echo -n .
chmod -R og-w "${base}"
chmod -R og+rX "${base}"
@@ -159,14 +166,14 @@ echo -n .
if [ -f "${bazelrc}" ]; then
echo
- echo "${bazelrc} already exists, moving it to ${bazelrc}.bak."
- mv "${bazelrc}" "${bazelrc}.bak"
+ echo "${bazelrc} already exists, ignoring. It is either a link to"
+ echo "${base}/etc/bazel.bazelrc or that it's importing that file with:"
+ echo " import ${base}/etc/bazel.bazelrc"
+else
+ ln -s "${base}/etc/bazel.bazelrc" "${bazelrc}"
+ echo .
fi
-# Not necessary, but this way it matches the Debian package.
-touch "${bazelrc}"
-echo .
-
cat <<EOF
Bazel is now installed!
diff --git a/site/docs/bazel-user-manual.html b/site/docs/bazel-user-manual.html
index 2e1dbcd555..87afb3cc49 100644
--- a/site/docs/bazel-user-manual.html
+++ b/site/docs/bazel-user-manual.html
@@ -1875,7 +1875,7 @@ cores directly from system configuration and will assume 1.0 I/O resource.
When tests (or applications) are executed, their
run-time data dependencies are gathered together in one place, and
may be accessed by the test using paths of the form
- <code>$TEST_SRCDIR/workspace/<var>packagename</var>/<var>filename</var></code>.
+ <code>$TEST_SRCDIR/base_workspace/<var>packagename</var>/<var>filename</var></code>.
The "runfiles" tree ensures that tests have access to all the files
upon which they have a declared dependence, and nothing more. By
default, the runfiles tree is implemented by constructing a set of
@@ -2368,7 +2368,7 @@ either to the terminal, or to additional log files.
<code class='flag'>--symlink_prefix=/</code> will cause Bazel to not
create or update any symlinks, including the <code>bazel-out</code> and
- <code>bazel-&lt;workspace&gt;</code>
+ <code>bazel-base_workspace</code>
symlinks. Use this option to suppress symlink creation entirely.
</p>
</li>
@@ -2959,7 +2959,7 @@ in an environment closer to the current shell environment. Note that none of the
directory for those commands. If the workspace directory is writable, a
symlink named
- <code>bazel-&lt;workspace&gt;</code>
+ <code>bazel-base_workspace</code>
is placed there pointing to this
directory.
</li>
@@ -3763,6 +3763,6 @@ Start time: [time elapsed from the profiling session start] Duration: [tas
<p>
Since you may not be able to run <code>bazel info</code> if bazel is hung, the
- <code>output_base</code> directory is usually the parent of the <code>bazel-&lt;workspace&gt;</code>
+ <code>output_base</code> directory is usually the parent of the <code>bazel-base_workspace</code>
symlink in your workspace directory.
</p>