brillo buildしてみる?


# まずはbuild環境を...

[前回](http://qiita.com/hidenorly/items/1a9834c83548d47a0845) は、build systemなどをみてみましたが、とりあえず、buildしてみます。

http://source.android.com/source/initializing.html
を参考に、環境セットアップをした上で、以下の通りやってみましょう。

# buildはいつもの方法で...

```
~/work/brillo$ source build/envsetup.sh 
including device/generic/brillo/vendorsetup.sh
including device/generic/brillo/brilloemulator_arm/base_product/devicesetup.sh
including device/generic/brillo/brilloemulator_arm64/base_product/devicesetup.sh
including device/generic/brillo/brilloemulator_x86/base_product/devicesetup.sh
including device/generic/brillo/brilloemulator_x86_64/base_product/devicesetup.sh
including device/generic/mini-emulator-arm64/vendorsetup.sh
including device/generic/mini-emulator-armv7-a-neon/vendorsetup.sh
including device/generic/mini-emulator-x86/vendorsetup.sh
including device/generic/mini-emulator-x86_64/vendorsetup.sh
including product/google/common/brillo_gpios/vendorsetup.sh
including product/google/common/brillo_leds/vendorsetup.sh
including product/google/example-ledflasher/vendorsetup.sh
~/work/brillo$ lunch

You're building on Linux

Lunch menu... pick a combo:
     1. aosp_arm-eng
     2. aosp_arm64-eng
     3. aosp_mips-eng
     4. aosp_mips64-eng
     5. aosp_x86-eng
     6. aosp_x86_64-eng
     7. brilloemulator_arm-eng
     8. brilloemulator_arm64-eng
     9. brilloemulator_x86-eng
     10. brilloemulator_x86_64-eng
     11. mini_emulator_arm64-userdebug
     12. m_e_arm-userdebug
     13. mini_emulator_x86-userdebug
     14. mini_emulator_x86_64-userdebug
     15. brillo_gpios-userdebug
     16. brillo_leds-userdebug
     17. ledflasher-userdebug

Which would you like? [aosp_arm-eng] 7 

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=6.0.60
TARGET_PRODUCT=brilloemulator_arm
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86_64
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.13.0-44-generic-x86_64-with-Ubuntu-14.04-trusty
HOST_CROSS_OS=windows
HOST_BUILD_TYPE=release
BUILD_ID=MASTER
OUT_DIR=out
============================================

~/work/brillo$ make -j 8
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=6.0.60
TARGET_PRODUCT=brilloemulator_arm
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86_64
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.13.0-44-generic-x86_64-with-Ubuntu-14.04-trusty
HOST_CROSS_OS=windows
HOST_BUILD_TYPE=release
BUILD_ID=MASTER
OUT_DIR=out
============================================
prebuilts/clang/host/linux-x86/3.6/bin/clang++   -fno-exceptions -Wno-multichar -m64 -Wa,--noexecstack -fPIC -no-canonical-prefixes -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith -D__BRILLO__ -O2 -g -fno-strict-aliasing -DNDEBUG -UDEBUG  -D__compiler_offsetof=__builtin_offsetof -Werror=int-conversion -Wno-reserved-id-macro -Wno-format-pedantic -Wno-unused-command-line-argument -fcolor-diagnostics   --gcc-toolchain=prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8    --gcc-toolchain=prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8 --sysroot=prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot -target x86_64-linux-gnu   -Wsign-promo  -Wno-inconsistent-missing-override   --gcc-toolchain=prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8 --sysroot=prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot -isystem prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/include/c++/4.8 -isystem prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/include/c++/4.8/x86_64-linux -isystem prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/include/c++/4.8/backward -target x86_64-linux-gnu -c -std=c++11 -g -W -Wall -MMD -MP -O -DNOLOG -o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/command.o build/kati/command.cc
...snip..
rebuilts/clang/host/linux-x86/3.6/bin/clang++   -m64 -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now    --gcc-toolchain=prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8 --sysroot=prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot -Bprebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/bin -Bprebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/lib/gcc/x86_64-linux/4.8 -Lprebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/lib/gcc/x86_64-linux/4.8 -Lprebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/lib64/ -target x86_64-linux-gnu -static -std=c++11 -g -W -Wall -MMD -MP -O -DNOLOG -o out/host/linux-x86/bin/ckati out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/command.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/dep.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/eval.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/exec.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/expr.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/file.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/file_cache.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/fileutil.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/find.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/flags.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/func.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/io.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/log.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/main.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/ninja.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/parser.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/rule.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/stats.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/stmt.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/string_piece.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/stringprintf.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/strutil.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/symtab.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/timeutil.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/var.o out/host/linux-x86/obj/EXECUTABLES/ckati_intermediates/version.o -lrt
Running kati to generate build-brilloemulator_arm.ninja...

```

やはり、[前回](http://qiita.com/hidenorly/items/1a9834c83548d47a0845)の通り、NinjaとKatiでbuildされているようですね。

そして、clangが使われていますね。

# 最終的にbuild完了

```
[ 99% 14443/14454] Target userdata fs image: out/target/product/brilloemulator_arm/userdata.img
Running:  mkuserimg.sh out/target/product/brilloemulator_arm/data out/target/product/brilloemulator_arm/userdata.img ext4 data 576716800 -D out/target/product/brilloemulator_arm/system -L data out/target/product/brilloemulator_arm/root/file_contexts.bin
make_ext4fs -T -1 -S out/target/product/brilloemulator_arm/root/file_contexts.bin -L data -l 576716800 -a data out/target/product/brilloemulator_arm/userdata.img out/target/product/brilloemulator_arm/data out/target/product/brilloemulator_arm/system
Creating filesystem with parameters:
    Size: 576716800
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 7040
    Inode size: 256
    Journal blocks: 2200
    Label: data
    Blocks: 140800
    Block groups: 5
    Reserved block group size: 39
Created filesystem with 41/35200 inodes and 8513/140800 blocks
out/target/product/brilloemulator_arm/userdata.img maxsize=588791808 blocksize=2112 total=576716800 reserve=5947392
..snip..
[ 99% 14453/14454] Target system fs image: out/target/product/brilloemulator_arm/obj/PACKAGING/systemimage_intermediates/system.img
Running:  mkuserimg.sh /tmp/tmpwv5qoJ out/target/product/brilloemulator_arm/obj/PACKAGING/systemimage_intermediates/system.img ext4 / 786432000 -D out/target/product/brilloemulator_arm/system -L / out/target/product/brilloemulator_arm/root/file_contexts.bin
make_ext4fs -T -1 -S out/target/product/brilloemulator_arm/root/file_contexts.bin -L / -l 786432000 -a / out/target/product/brilloemulator_arm/obj/PACKAGING/systemimage_intermediates/system.img /tmp/tmpwv5qoJ out/target/product/brilloemulator_arm/system
Creating filesystem with parameters:
    Size: 786432000
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 8000
    Inode size: 256
    Journal blocks: 3000
    Label: /
    Blocks: 192000
    Block groups: 6
    Reserved block group size: 47
Created filesystem with 689/48000 inodes and 24235/192000 blocks
[100% 14454/14454] Install system fs image: out/target/product/brilloemulator_arm/system.img
[100% 14454/14454] Install system fs image: out/target/product/brilloemulator_arm/system.img
out/target/product/brilloemulator_arm/system.img+out/target/product/brilloemulator_arm/recovery.img maxsize=802897920 blocksize=2112 total=791457792 reserve=8110080

#### make completed successfully (49:23 (mm:ss)) ####
```