概要
- 参考: Build Bazel
- ソースコード: https://github.com/bazelbuild/bazel.git
-
使うだけなら、
コピペ# 25MB制限なので、分割してある. wget https://github.com/mt08xx/files/raw/master/bazel_0.8.0-20171127.1_armhf.deb.a{a,b,c,d} cat bazel_0.8.0-20171127.1_armhf.deb.a[a-d] > bazel_0.8.0-20171127.1_armhf.deb rm bazel_0.8.0-20171127.1_armhf.deb.a* sudo apt install ./bazel_0.8.0-20171127.1_armhf.deb
環境
ビルド対象:
bazel-0.8.0
-
ビルド環境: Raspbian lite on Tinkerboard
- Raspbian:
2017-09-07-raspbian-stretch-lite.zip
- https://qiita.com/mt08/items/5aee9d3f0dc10a1c1c5a
- Raspbian:
-
実行環境: Raspbian on Raspberry Pi 3
- Raspbian:
2017-09-07-raspbian-stretch.zip
- Raspbian:
ビルド手順
-
必要なパッケージをインストール
他にも必要かも...sudo apt install openjdk-8-jdk sudo apt install pkg-config zip g++ zlib1g-dev unzip
-
ソース取得・解凍
cd ~ wget https://github.com/bazelbuild/bazel/releases/download/0.8.0/bazel-0.8.0-dist.zip unzip -d bazel bazel-0.8.0-dist.zip
-
コード修正
-
scripts/bootstrap/compile.sh
:-J-Xmx500M
を追加するscripts/bootstrap/compile.shrun "${JAVAC}" -classpath "${classpath}" -sourcepath "${sourcepath}" \ -d "${output}/classes" -source "$JAVA_VERSION" -target "$JAVA_VERSION" \ -encoding UTF-8 "@${paramfile}" -J-Xmx500M
tools/cpp/lib_cc_configure.bzl
:_get_cpu_value
関数の最初のほうに、return "arm"
を挿入
-
ビルド開始:
time sudo ./compile
-
確認
pi@raspberrypi:~/bazel $ ls -l output/bazel -rwxr-xr-x 1 root root 91024013 Nov 27 18:31 output/bazel pi@raspberrypi:~/bazel $
-
debパッケージ作成
- パッケージ名:(
bazel
) バージョン(0.8.0-20171127.1
)を決める. -
フォルダ作成
PACKAGE_NAME=bazel_0.8.0-20171127.1_armhf mkdir -p ~/${PACKAGE_NAME}{/usr/local,DEBIAN} cd ~/${PACKAGE_NAME}
-
DEBIAN/control
ファイル作成DEBIAN/control例(適当です)Package: bazel Priority: extra Section: universe/devel Maintainer: mt08 <mt08xx@users.noreply.github.com> Architecture: armhf Version: 0.8.0-20171127.1 Homepage: https://bazel.build/ Description: Bazel is an open-source build and test tool similar to Make, Maven, and Gradle. It uses a human-readable, high-level build language. Bazel supports projects in multiple languages and builds outputs for multiple platforms. Bazel supports large codebases across multiple repositories, and large numbers of users.
-
~/${PACKAGE_NAME}/usr/local
以下に、ファイルを入れる。今回はファイル一つ.ほんとは、ドキュメントとかも入れないといけないと思う。mkdir ~/${PACKAGE_NAME}/usr/local/bin cp ~/bazel/output/bazel ~/${PACKAGE_NAME}/usr/local/bin
-
debパッケージビルド
cd ~ sudo chown -R root:staff ${PACKAGE_NAME} sudo dpkg-deb --build ${PACKAGE_NAME}
6 確認
```shell-session pi@raspberrypi:~ $ ls -l ./bazel*.deb -rw-r--r-- 1 root root 88820222 Nov 27 18:56 ./bazel_0.8.0-20171127.1_armhf.deb pi@raspberrypi:~ $ ```
- パッケージ名:(
-
別のマシンにもっていって、インストール確認
実行例pi@raspberrypi:~ $ uname -a Linux raspberrypi 4.9.59-v7+ #1047 SMP Sun Oct 29 12:19:23 GMT 2017 armv7l GNU/Linux pi@raspberrypi:~ $ sudo apt install ./bazel_0.8.0-20171127.1_armhf.deb Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'bazel' instead of './bazel_0.8.0-20171127.1_armhf.deb' The following NEW packages will be installed: bazel 0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded. Need to get 0 B/88.8 MB of archives. After this operation, 0 B of additional disk space will be used. Get:1 /home/pi/bazel_0.8.0-20171127.1_armhf.deb bazel armhf 0.8.0-20171127.1 [88.8 MB] Selecting previously unselected package bazel. (Reading database ... 105718 files and directories currently installed.) Preparing to unpack .../bazel_0.8.0-20171127.1_armhf.deb ... Unpacking bazel (0.8.0-20171127.1) ... Setting up bazel (0.8.0-20171127.1) ... pi@raspberrypi:~ $ bazel Extracting Bazel installation... [bazel release 0.8.0- (@non-git)] Usage: bazel <command> <options> ... Available commands: analyze-profile Analyzes build profile data. build Builds the specified targets. canonicalize-flags Canonicalizes a list of bazel options. clean Removes output files and optionally stops the server. coverage Generates code coverage report for specified test targets. dump Dumps the internal state of the bazel server process. fetch Fetches external repositories that are prerequisites to the targets. help Prints help for commands, or the index. info Displays runtime info about the bazel server. license Prints the license of this software. mobile-install Installs targets to mobile devices. print_action Prints the command line args for compiling a file. query Executes a dependency graph query. run Runs the specified target. shutdown Stops the bazel server. test Builds and runs the specified test targets. version Prints version information for bazel. Getting more help: bazel help <command> Prints help and options for <command>. bazel help startup_options Options for the JVM hosting bazel. bazel help target-syntax Explains the syntax for specifying targets. bazel help info-keys Displays a list of keys used by the info command. pi@raspberrypi:~ $ sudo apt remove -y bazel Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: bazel 0 upgraded, 0 newly installed, 1 to remove and 1 not upgraded. After this operation, 0 B of additional disk space will be used. (Reading database ... 105719 files and directories currently installed.) Removing bazel (0.8.0-20171127.1) ... pi@raspberrypi:~ $ bazel -bash: /usr/local/bin/bazel: No such file or directory pi@raspberrypi:~ $
TODO
- 今回、時間計測を記録し忘れた..次回..