Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Damien Martin-Guillerez | f88f4d8 | 2015-09-25 13:56:55 +0000 | [diff] [blame] | 3 | # Copyright 2015 The Bazel Authors. All rights reserved. |
Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # Script for building bazel from scratch without bazel |
| 18 | |
| 19 | PROTO_FILES=$(ls src/main/protobuf/*.proto) |
| 20 | LIBRARY_JARS=$(find third_party -name '*.jar' | tr "\n" " ") |
Kristina Chodorow | 86746ce | 2015-06-11 16:46:41 +0000 | [diff] [blame] | 21 | DIRS=$(echo src/{java_tools/singlejar/java/com/google/devtools/build/zip,main/java,tools/xcode-common/java/com/google/devtools/build/xcode/{common,util}} ${OUTPUT_DIR}/src) |
Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 22 | |
Dmitry Lomov | 5f66155 | 2015-07-24 10:42:07 +0000 | [diff] [blame] | 23 | case "${PLATFORM}" in |
| 24 | msys*|mingw*) |
| 25 | BLAZE_UTIL_SUFFIX=mingw |
Dmitry Lomov | 78c0cc7 | 2015-08-11 16:44:21 +0000 | [diff] [blame] | 26 | BLAZE_UTIL_POSIX="" |
Dmitry Lomov | 5f66155 | 2015-07-24 10:42:07 +0000 | [diff] [blame] | 27 | ;; |
| 28 | *) |
| 29 | BLAZE_UTIL_SUFFIX="${PLATFORM}" |
Dmitry Lomov | 78c0cc7 | 2015-08-11 16:44:21 +0000 | [diff] [blame] | 30 | BLAZE_UTIL_POSIX="src/main/cpp/blaze_util_posix.cc" |
Dmitry Lomov | 5f66155 | 2015-07-24 10:42:07 +0000 | [diff] [blame] | 31 | ;; |
| 32 | esac |
| 33 | |
Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 34 | BLAZE_CC_FILES=( |
Nathan Harmata | bf98f39 | 2016-01-07 22:58:29 +0000 | [diff] [blame] | 35 | src/main/cpp/blaze_abrupt_exit.cc |
Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 36 | src/main/cpp/blaze_startup_options.cc |
| 37 | src/main/cpp/blaze_startup_options_common.cc |
| 38 | src/main/cpp/blaze_util.cc |
Dmitry Lomov | 5f66155 | 2015-07-24 10:42:07 +0000 | [diff] [blame] | 39 | src/main/cpp/blaze_util_${BLAZE_UTIL_SUFFIX}.cc |
Dmitry Lomov | 78c0cc7 | 2015-08-11 16:44:21 +0000 | [diff] [blame] | 40 | ${BLAZE_UTIL_POSIX} |
Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 41 | src/main/cpp/blaze.cc |
| 42 | src/main/cpp/option_processor.cc |
| 43 | src/main/cpp/util/errors.cc |
| 44 | src/main/cpp/util/file.cc |
| 45 | src/main/cpp/util/md5.cc |
| 46 | src/main/cpp/util/numbers.cc |
| 47 | src/main/cpp/util/port.cc |
| 48 | src/main/cpp/util/strings.cc |
| 49 | third_party/ijar/zip.cc |
| 50 | ) |
| 51 | |
| 52 | NATIVE_CC_FILES=( |
| 53 | src/main/cpp/util/md5.cc |
| 54 | src/main/native/localsocket.cc |
| 55 | src/main/native/process.cc |
| 56 | src/main/native/unix_jni.cc |
| 57 | src/main/native/unix_jni_${PLATFORM}.cc |
| 58 | ) |
| 59 | |
| 60 | mkdir -p ${OUTPUT_DIR}/classes |
| 61 | mkdir -p ${OUTPUT_DIR}/test_classes |
| 62 | mkdir -p ${OUTPUT_DIR}/src |
| 63 | mkdir -p ${OUTPUT_DIR}/objs |
| 64 | mkdir -p ${OUTPUT_DIR}/native |
| 65 | |
| 66 | # May be passed in from outside. |
| 67 | CXXFLAGS="$CXXFLAGS" |
| 68 | LDFLAGS="$LDFLAGS" |
| 69 | ZIPOPTS="$ZIPOPTS" |
| 70 | |
| 71 | # TODO: CC target architecture needs to match JAVA_HOME. |
Doug Rabson | 709bc61 | 2015-08-25 14:12:00 +0000 | [diff] [blame] | 72 | if [ "${PLATFORM}" = "freebsd" ]; then |
| 73 | CC=${CC:-clang} |
| 74 | CXX=${CXX:-clang++} |
| 75 | else |
| 76 | CC=${CC:-gcc} |
| 77 | CXX=${CXX:-g++} |
| 78 | fi |
Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 79 | CXXSTD="c++0x" |
| 80 | |
| 81 | unset JAVA_TOOL_OPTIONS |
| 82 | unset _JAVA_OPTIONS |
| 83 | |
| 84 | LDFLAGS=${LDFLAGS:-""} |
| 85 | |
| 86 | # Extension for executables (.exe on Windows). |
| 87 | EXE_EXT="" |
| 88 | |
| 89 | MSYS_DLLS="" |
| 90 | PATHSEP=":" |
| 91 | |
| 92 | case "${PLATFORM}" in |
| 93 | linux) |
| 94 | LDFLAGS="-lz -lrt $LDFLAGS" |
| 95 | JNILIB="libunix.so" |
| 96 | MD5SUM="md5sum" |
| 97 | # JAVA_HOME must point to a Java installation. |
| 98 | JAVA_HOME="${JAVA_HOME:-$(readlink -f $(which javac) | sed 's_/bin/javac__')}" |
Philipp Wollermann | 19f3413 | 2015-06-12 08:39:25 +0000 | [diff] [blame] | 99 | if [ "${MACHINE_IS_64BIT}" = 'yes' ]; then |
| 100 | PROTOC=${PROTOC:-third_party/protobuf/protoc-linux-x86_64.exe} |
| 101 | else |
Zhong Wang | 8c28813 | 2015-08-12 15:06:08 +0000 | [diff] [blame] | 102 | if [ "${MACHINE_IS_ARM}" = 'yes' ]; then |
| 103 | PROTOC=${PROTOC:-third_party/protobuf/protoc-linux-arm32.exe} |
| 104 | else |
| 105 | PROTOC=${PROTOC:-third_party/protobuf/protoc-linux-x86_32.exe} |
| 106 | fi |
Philipp Wollermann | 19f3413 | 2015-06-12 08:39:25 +0000 | [diff] [blame] | 107 | fi |
Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 108 | ;; |
| 109 | |
Doug Rabson | 709bc61 | 2015-08-25 14:12:00 +0000 | [diff] [blame] | 110 | freebsd) |
| 111 | LDFLAGS="-lprocstat -lz -lrt $LDFLAGS" |
| 112 | JNILIB="libunix.so" |
Googler | bdbf75f | 2015-11-17 12:50:44 +0000 | [diff] [blame] | 113 | MD5SUM="md5" |
Doug Rabson | 709bc61 | 2015-08-25 14:12:00 +0000 | [diff] [blame] | 114 | # JAVA_HOME must point to a Java installation. |
| 115 | JAVA_HOME="${JAVA_HOME:-/usr/local/openjdk8}" |
| 116 | # Note: the linux protoc binary works on freebsd using linux emulation. |
| 117 | # We choose the 32-bit version for maximum compatiblity since 64-bit |
| 118 | # linux binaries are only supported in FreeBSD-11. |
| 119 | PROTOC=${PROTOC:-third_party/protobuf/protoc-linux-x86_32.exe} |
| 120 | ;; |
| 121 | |
Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 122 | darwin) |
| 123 | JNILIB="libunix.dylib" |
| 124 | MD5SUM="md5" |
| 125 | LDFLAGS="-lz $LDFLAGS" |
| 126 | if [[ -z "$JAVA_HOME" ]]; then |
| 127 | JAVA_HOME="$(/usr/libexec/java_home -v ${JAVA_VERSION}+ 2> /dev/null)" \ |
| 128 | || fail "Could not find JAVA_HOME, please ensure a JDK (version ${JAVA_VERSION}+) is installed." |
| 129 | fi |
Philipp Wollermann | 19f3413 | 2015-06-12 08:39:25 +0000 | [diff] [blame] | 130 | if [ "${MACHINE_IS_64BIT}" = 'yes' ]; then |
| 131 | PROTOC=${PROTOC:-third_party/protobuf/protoc-osx-x86_64.exe} |
| 132 | else |
| 133 | PROTOC=${PROTOC:-third_party/protobuf/protoc-osx-x86_32.exe} |
| 134 | fi |
Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 135 | ;; |
| 136 | |
| 137 | msys*|mingw*) |
| 138 | # Use a simplified platform string. |
| 139 | PLATFORM="mingw" |
| 140 | # Workaround for msys issue which causes omission of std::to_string. |
| 141 | CXXFLAGS="$CXXFLAGS -D_GLIBCXX_USE_C99 -D_GLIBCXX_USE_C99_DYNAMIC" |
| 142 | LDFLAGS="-lz $LDFLAGS" |
| 143 | MD5SUM="md5sum" |
| 144 | EXE_EXT=".exe" |
| 145 | PATHSEP=";" |
| 146 | # Find the latest available version of the SDK. |
| 147 | JAVA_HOME="${JAVA_HOME:-$(ls -d /c/Program\ Files/Java/jdk* | sort | tail -n 1)}" |
| 148 | # We do not use the JNI library on Windows. |
| 149 | JNILIB="" |
Googler | 8a0ce7b | 2015-07-22 09:10:08 +0000 | [diff] [blame] | 150 | if [ "${MACHINE_IS_64BIT}" = 'yes' ]; then |
| 151 | PROTOC=${PROTOC:-third_party/protobuf/protoc-windows-x86_64.exe} |
| 152 | else |
| 153 | PROTOC=${PROTOC:-third_party/protobuf/protoc-windows-x86_32.exe} |
| 154 | fi |
Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 155 | |
| 156 | # The newer version of GCC on msys is stricter and removes some important function |
| 157 | # declarations from the environment if using c++0x / c++11. |
| 158 | CXXSTD="gnu++11" |
| 159 | |
| 160 | # Ensure that we are using the cygwin gcc, not the mingw64 gcc. |
| 161 | ${CC} -v 2>&1 | grep "Target: .*mingw.*" > /dev/null && |
| 162 | fail "mingw gcc detected. Please set CC to point to the msys/Cygwin gcc." |
| 163 | ${CXX} -v 2>&1 | grep "Target: .*mingw.*" > /dev/null && |
| 164 | fail "mingw g++ detected. Please set CXX to point to the msys/Cygwin g++." |
| 165 | |
| 166 | MSYS_DLLS="msys-2.0.dll msys-gcc_s-seh-1.dll msys-stdc++-6.dll" |
| 167 | for dll in $MSYS_DLLS ; do |
| 168 | cp "/usr/bin/$dll" "${OUTPUT_DIR}/$dll" |
| 169 | done |
| 170 | esac |
| 171 | |
| 172 | [[ -x "${PROTOC-}" ]] \ |
| 173 | || fail "Protobuf compiler not found in ${PROTOC-}" |
| 174 | |
Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 175 | # Check that javac -version returns a upper version than $JAVA_VERSION. |
Damien Martin-Guillerez | 338dc56 | 2015-06-23 17:15:12 +0000 | [diff] [blame] | 176 | get_java_version |
| 177 | [ ${JAVA_VERSION#*.} -le ${JAVAC_VERSION#*.} ] || \ |
| 178 | fail "JDK version (${JAVAC_VERSION}) is lower than ${JAVA_VERSION}, please set \$JAVA_HOME." |
Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 179 | |
| 180 | JAR="${JAVA_HOME}/bin/jar" |
| 181 | |
| 182 | # Compiles java classes. |
| 183 | function java_compilation() { |
| 184 | local name=$1 |
| 185 | local directories=$2 |
| 186 | local library_jars=$3 |
| 187 | local output=$4 |
| 188 | |
| 189 | local classpath=${library_jars// /$PATHSEP}:$5 |
| 190 | local sourcepath=${directories// /$PATHSEP} |
| 191 | |
| 192 | tempdir |
| 193 | local tmp="${NEW_TMPDIR}" |
| 194 | local paramfile="${tmp}/param" |
| 195 | touch $paramfile |
| 196 | |
| 197 | mkdir -p "${output}/classes" |
| 198 | |
| 199 | # Compile .java files (incl. generated ones) using javac |
| 200 | log "Compiling $name code..." |
| 201 | find ${directories} -name "*.java" > "$paramfile" |
| 202 | |
| 203 | if [ ! -z "$BAZEL_DEBUG_JAVA_COMPILATION" ]; then |
| 204 | echo "directories=${directories}" >&2 |
| 205 | echo "classpath=${classpath}" >&2 |
| 206 | echo "sourcepath=${sourcepath}" >&2 |
| 207 | echo "libraries=${library_jars}" >&2 |
| 208 | echo "output=${output}/classes" >&2 |
| 209 | echo "List of compiled files:" >&2 |
| 210 | cat "$paramfile" >&2 |
| 211 | fi |
| 212 | |
| 213 | run_silent "${JAVAC}" -classpath "${classpath}" -sourcepath "${sourcepath}" \ |
| 214 | -d "${output}/classes" -source "$JAVA_VERSION" -target "$JAVA_VERSION" \ |
Damien Martin-Guillerez | 45d18d4 | 2015-09-21 11:45:10 +0000 | [diff] [blame] | 215 | -encoding UTF-8 "@${paramfile}" |
Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 216 | |
| 217 | log "Extracting helper classes for $name..." |
| 218 | for f in ${library_jars} ; do |
| 219 | run_silent unzip -qn ${f} -d "${output}/classes" |
| 220 | done |
| 221 | } |
| 222 | |
| 223 | # Create the deploy JAR |
| 224 | function create_deploy_jar() { |
| 225 | local name=$1 |
| 226 | local mainClass=$2 |
| 227 | local output=$3 |
| 228 | shift 3 |
| 229 | local packages="" |
| 230 | for i in $output/classes/*; do |
| 231 | local package=$(basename $i) |
| 232 | if [[ "$package" != "META-INF" ]]; then |
| 233 | packages="$packages -C $output/classes $package" |
| 234 | fi |
| 235 | done |
| 236 | |
| 237 | log "Creating $name.jar..." |
| 238 | echo "Main-Class: $mainClass" > $output/MANIFEST.MF |
| 239 | run_silent "$JAR" cmf $output/MANIFEST.MF $output/$name.jar $packages "$@" |
| 240 | } |
| 241 | |
| 242 | function cc_compile() { |
| 243 | local OBJDIR=$1 |
| 244 | shift |
| 245 | mkdir -p "${OUTPUT_DIR}/${OBJDIR}" |
| 246 | for FILE in "$@"; do |
| 247 | if [[ ! "${FILE}" =~ ^-.*$ ]]; then |
| 248 | local OBJ=$(basename "${FILE}").o |
| 249 | run_silent "${CXX}" \ |
| 250 | -I. \ |
| 251 | ${CFLAGS} \ |
| 252 | -std=$CXXSTD \ |
| 253 | -c \ |
| 254 | -DBLAZE_JAVA_CPU=\"k8\" \ |
| 255 | -DBLAZE_OPENSOURCE=1 \ |
| 256 | -o "${OUTPUT_DIR}/${OBJDIR}/${OBJ}" \ |
| 257 | "${FILE}" |
| 258 | fi |
| 259 | done |
| 260 | } |
| 261 | |
| 262 | function cc_link() { |
| 263 | local OBJDIR=$1 |
| 264 | local OUTPUT=$2 |
| 265 | shift 2 |
| 266 | local FILES=() |
| 267 | for FILE in "$@"; do |
| 268 | local OBJ=$(basename "${FILE}").o |
| 269 | FILES+=("${OUTPUT_DIR}/${OBJDIR}/${OBJ}") |
| 270 | done |
Lukacs Berki | 30bed8f | 2015-10-26 12:18:24 +0000 | [diff] [blame] | 271 | run_silent "${CXX}" -o ${OUTPUT} "${FILES[@]}" ${LDFLAGS} |
Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | function cc_build() { |
| 275 | local NAME=$1 |
| 276 | local OBJDIR=$2 |
| 277 | local OUTPUT=$3 |
| 278 | shift 3 |
| 279 | log "Compiling ${NAME} .cc files..." |
| 280 | cc_compile "${OBJDIR}" "$@" |
| 281 | log "Linking ${NAME}..." |
| 282 | cc_link "${OBJDIR}" "${OUTPUT}" "$@" |
| 283 | } |
| 284 | |
| 285 | if [ -z "${BAZEL_SKIP_JAVA_COMPILATION}" ]; then |
| 286 | log "Compiling Java stubs for protocol buffers..." |
| 287 | for f in $PROTO_FILES ; do |
Damien Martin-Guillerez | 580cd69 | 2015-06-11 05:37:26 +0000 | [diff] [blame] | 288 | run_silent "${PROTOC}" -Isrc/main/protobuf/ --java_out=${OUTPUT_DIR}/src "$f" |
Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 289 | done |
| 290 | |
| 291 | java_compilation "Bazel Java" "$DIRS" "$LIBRARY_JARS" "${OUTPUT_DIR}" |
| 292 | |
| 293 | # help files: all non java and BUILD files in src/main/java. |
| 294 | for i in $(find src/main/java -type f -a \! -name '*.java' -a \! -name 'BUILD' | sed 's|src/main/java/||'); do |
| 295 | mkdir -p $(dirname ${OUTPUT_DIR}/classes/$i) |
| 296 | cp src/main/java/$i ${OUTPUT_DIR}/classes/$i |
| 297 | done |
| 298 | |
Damien Martin-Guillerez | 12c68aa | 2016-01-15 13:18:11 +0000 | [diff] [blame] | 299 | # Overwrite tools.WORKSPACE, this is only for the bootstrap binary |
| 300 | echo "local_repository(name = 'bazel_tools', path = __workspace_dir__)" \ |
| 301 | > ${OUTPUT_DIR}/classes/com/google/devtools/build/lib/bazel/rules/tools.WORKSPACE |
| 302 | |
Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 303 | create_deploy_jar "libblaze" "com.google.devtools.build.lib.bazel.BazelMain" \ |
Han-Wen Nienhuys | a4b6182 | 2015-11-09 13:55:44 +0000 | [diff] [blame] | 304 | ${OUTPUT_DIR} |
Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 305 | fi |
| 306 | |
| 307 | cc_build "client" "objs" "${OUTPUT_DIR}/client" ${BLAZE_CC_FILES[@]} |
| 308 | |
| 309 | if [ ! -z "$JNILIB" ] ; then |
| 310 | log "Compiling JNI libraries..." |
| 311 | for FILE in "${NATIVE_CC_FILES[@]}"; do |
| 312 | OUT=$(basename "${FILE}").o |
| 313 | run_silent "${CXX}" \ |
| 314 | -I . \ |
| 315 | -I "${JAVA_HOME}/include/" \ |
| 316 | -I "${JAVA_HOME}/include/${PLATFORM}" \ |
| 317 | -std=$CXXSTD \ |
| 318 | -fPIC \ |
| 319 | -c \ |
| 320 | -D_JNI_IMPLEMENTATION_ \ |
| 321 | -DBLAZE_JAVA_CPU=\"k8\" \ |
| 322 | -DBLAZE_OPENSOURCE=1 \ |
| 323 | -o "${OUTPUT_DIR}/native/${OUT}" \ |
| 324 | "${FILE}" |
| 325 | done |
| 326 | |
| 327 | log "Linking ${JNILIB}..." |
Lukacs Berki | 30bed8f | 2015-10-26 12:18:24 +0000 | [diff] [blame] | 328 | run_silent "${CXX}" -o ${OUTPUT_DIR}/${JNILIB} $JNI_LD_ARGS -shared ${OUTPUT_DIR}/native/*.o -lstdc++ |
Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 329 | fi |
| 330 | |
Damien Martin-Guillerez | dceee0e | 2016-01-18 11:57:26 +0000 | [diff] [blame] | 331 | # Dummy build-runfiles |
| 332 | cat <<'EOF' >${OUTPUT_DIR}/build-runfiles${EXE_EXT} |
| 333 | #!/bin/bash |
| 334 | mkdir -p $2/MANIFEST |
| 335 | cp $1 $2/MANIFEST |
| 336 | EOF |
| 337 | chmod 0755 ${OUTPUT_DIR}/build-runfiles${EXE_EXT} |
Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 338 | |
| 339 | log "Compiling process-wrapper..." |
Damien Martin-Guillerez | ec758db | 2016-01-18 12:14:28 +0000 | [diff] [blame^] | 340 | cat <<'EOF' >${OUTPUT_DIR}/process-wrapper${EXE_EXT} |
| 341 | #!/bin/bash |
| 342 | # Dummy process wrapper, does not support timeout |
| 343 | shift 2 |
| 344 | stdout="$1" |
| 345 | stderr="$2" |
| 346 | shift 2 |
| 347 | |
| 348 | "$@" 2>"$stderr" >"$stdout" |
| 349 | exit $? |
| 350 | EOF |
Philipp Wollermann | 43c4a1a | 2015-08-25 12:52:57 +0000 | [diff] [blame] | 351 | |
Chris Parsons | f488818 | 2016-01-08 00:42:14 +0000 | [diff] [blame] | 352 | log "Compiling xcode-locator..." |
| 353 | if [[ $PLATFORM == "darwin" ]]; then |
| 354 | run_silent /usr/bin/xcrun clang -fobjc-arc -framework CoreServices -framework Foundation -o ${OUTPUT_DIR}/xcode-locator src/main/tools/xcode_locator.m |
| 355 | else |
| 356 | cp src/main/tools/xcode_locator_stub.sh ${OUTPUT_DIR}/xcode-locator |
| 357 | fi |
| 358 | |
Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 359 | cp src/main/tools/build_interface_so ${OUTPUT_DIR}/build_interface_so |
| 360 | cp src/main/tools/jdk.* ${OUTPUT_DIR} |
| 361 | |
| 362 | log "Creating Bazel self-extracting archive..." |
Lukacs Berki | 8b2e6b8 | 2015-10-06 07:43:36 +0000 | [diff] [blame] | 363 | ARCHIVE_DIR=${OUTPUT_DIR}/archive |
Damien Martin-Guillerez | e5b7c59 | 2016-01-18 11:03:59 +0000 | [diff] [blame] | 364 | for i in libblaze.jar ${JNILIB} build-runfiles${EXE_EXT} process-wrapper${EXE_EXT} xcode-locator${EXE_EXT} build_interface_so ${MSYS_DLLS} jdk.BUILD; do |
Lukacs Berki | 8b2e6b8 | 2015-10-06 07:43:36 +0000 | [diff] [blame] | 365 | mkdir -p $(dirname $ARCHIVE_DIR/$i); |
| 366 | cp $OUTPUT_DIR/$i $ARCHIVE_DIR/$i; |
| 367 | done |
Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 368 | |
Lukacs Berki | 8b2e6b8 | 2015-10-06 07:43:36 +0000 | [diff] [blame] | 369 | cp ${OUTPUT_DIR}/client ${ARCHIVE_DIR} |
| 370 | cp ${OUTPUT_DIR}/libblaze.jar ${ARCHIVE_DIR}/A-server.jar |
| 371 | |
| 372 | (cd ${ARCHIVE_DIR}/ ; find . -type f | xargs cat | ${MD5SUM} | awk '{ print $1; }' > install_base_key) |
| 373 | (cd ${ARCHIVE_DIR}/ ; echo "${JAVA_VERSION}" > java.version) |
| 374 | (cd ${ARCHIVE_DIR}/ ; find . -type f | xargs -P 10 touch -t 198001010000) |
| 375 | (cd ${ARCHIVE_DIR}/ ; run_silent zip $ZIPOPTS -r -q package.zip * install_base_key java.version) |
| 376 | cat ${OUTPUT_DIR}/client ${ARCHIVE_DIR}/package.zip > ${OUTPUT_DIR}/bazel |
Damien Martin-Guillerez | d47a8ef | 2015-06-10 11:54:50 +0000 | [diff] [blame] | 377 | zip -qA ${OUTPUT_DIR}/bazel \ |
| 378 | || echo "(Non-critical error, ignore.)" |
| 379 | |
| 380 | chmod 755 ${OUTPUT_DIR}/bazel |