Patrick Williams | 975a06f | 2022-10-21 14:42:47 -0500 | [diff] [blame] | 1 | LICENSE = "Apache-2.0 & BSD-3-Clause & MIT & Zlib" |
| 2 | |
| 3 | LIC_FILES_CHKSUM = "file://LICENSE;md5=f87516e0b698007e9e75a1fe1012b390 \ |
| 4 | file://buildtools/libcxx/LICENSE.TXT;md5=55d89dd7eec8d3b4204b680e27da3953 \ |
Patrick Williams | 975a06f | 2022-10-21 14:42:47 -0500 | [diff] [blame] | 5 | file://buildtools/libcxxabi/LICENSE.TXT;md5=7b9334635b542c56868400a46b272b1e \ |
| 6 | file://buildtools/libunwind/LICENSE.TXT;md5=f66970035d12f196030658b11725e1a1 \ |
| 7 | file://buildtools/protobuf/LICENSE;md5=37b5762e07f0af8c74ce80a8bda4266b \ |
| 8 | file://buildtools/zlib/LICENSE;md5=f09575dbfb09420642318b413159496f \ |
| 9 | file://debian/copyright;md5=4e08364c82141f181de69d0a2b89d612 \ |
| 10 | file://python/LICENSE;md5=c602a632c34ade9c78a976734077bce7" |
| 11 | |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 12 | SRC_URI:append = " \ |
Patrick Williams | 975a06f | 2022-10-21 14:42:47 -0500 | [diff] [blame] | 13 | git://github.com/protocolbuffers/protobuf.git;branch=3.9.x;protocol=https;destsuffix=git/buildtools/protobuf;name=protobuf \ |
| 14 | git://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx.git;protocol=https;destsuffix=git/buildtools/libcxx;branch=main;name=libcxx \ |
| 15 | git://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git;protocol=https;destsuffix=git/buildtools/libcxxabi;branch=main;name=libcxxabi \ |
| 16 | git://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git;protocol=https;destsuffix=git/buildtools/libunwind;branch=main;name=libunwind \ |
Patrick Williams | 864cc43 | 2023-02-09 14:54:44 -0600 | [diff] [blame] | 17 | git://android.googlesource.com/platform/system/libbase.git;branch=master;protocol=https;destsuffix=git/buildtools/android-libbase;name=libbase \ |
| 18 | git://android.googlesource.com/platform/system/unwinding.git;branch=master;protocol=https;destsuffix=git/buildtools/android-unwinding;name=unwinding \ |
| 19 | git://android.googlesource.com/platform/system/logging.git;branch=master;protocol=https;destsuffix=git/buildtools/android-logging;name=logging \ |
| 20 | git://android.googlesource.com/platform/system/libprocinfo.git;branch=master;protocol=https;destsuffix=git/buildtools/android-libprocinfo;name=libprocinfo \ |
| 21 | git://android.googlesource.com/platform/system/core.git;branch=master;protocol=https;destsuffix=git/buildtools/android-core;name=core \ |
| 22 | git://android.googlesource.com/platform/bionic.git;branch=master;protocol=https;destsuffix=git/buildtools/bionic;name=bionic \ |
Patrick Williams | 975a06f | 2022-10-21 14:42:47 -0500 | [diff] [blame] | 23 | git://android.googlesource.com/platform/external/zlib.git;branch=master;protocol=https;destsuffix=git/buildtools/zlib;name=zlib \ |
Patrick Williams | 864cc43 | 2023-02-09 14:54:44 -0600 | [diff] [blame] | 24 | git://android.googlesource.com/platform/external/lzma.git;branch=master;protocol=https;destsuffix=git/buildtools/lzma;name=lzma \ |
Patrick Williams | 975a06f | 2022-10-21 14:42:47 -0500 | [diff] [blame] | 25 | https://storage.googleapis.com/perfetto/gn-linux64-1968-0725d782;subdir=git/buildtools/;name=gn \ |
Patrick Williams | 864cc43 | 2023-02-09 14:54:44 -0600 | [diff] [blame] | 26 | \ |
| 27 | file://0001-Remove-check_build_deps-build-steps.patch \ |
| 28 | file://0001-Add-missing-header-cstdint-for-uintXX_t-types.patch" |
Patrick Williams | 975a06f | 2022-10-21 14:42:47 -0500 | [diff] [blame] | 29 | |
Patrick Williams | 864cc43 | 2023-02-09 14:54:44 -0600 | [diff] [blame] | 30 | SRCREV_bionic = "4b0e16bc72a82a63c699977376a7d6eadca1b206" |
| 31 | SRCREV_core = "9e6cef7f07d8c11b3ea820938aeb7ff2e9dbaa52" |
| 32 | SRCREV_lzma = "7851dce6f4ca17f5caa1c93a4e0a45686b1d56c3" |
| 33 | SRCREV_libprocinfo = "fd214c13ededecae97a3b15b5fccc8925a749a84" |
| 34 | SRCREV_logging = "7b36b566c9113fc703d68f76e8f40c0c2432481c" |
| 35 | SRCREV_unwinding = "d66882575ebe3700d6a6b10185f3aee28acc1051" |
Patrick Williams | 975a06f | 2022-10-21 14:42:47 -0500 | [diff] [blame] | 36 | SRCREV_protobuf = "6a59a2ad1f61d9696092f79b6d74368b4d7970a3" |
Patrick Williams | 864cc43 | 2023-02-09 14:54:44 -0600 | [diff] [blame] | 37 | SRCREV_libbase = "78f1c2f83e625bdf66d55b48bdb3a301c20d2fb3" |
| 38 | SRCREV_libcxx = "f8571eaba606bde2eb8cd34b30104ca33e7c207e" |
| 39 | SRCREV_libcxxabi = "8dd405113a4f3694e910b79785dd7fb7535a888a" |
| 40 | SRCREV_libunwind = "aabcd8753678f1536e15eb6385a948470debdae4" |
Patrick Williams | 975a06f | 2022-10-21 14:42:47 -0500 | [diff] [blame] | 41 | SRCREV_zlib = "5c85a2da4c13eda07f69d81a1579a5afddd35f59" |
Andrew Geissler | 5082cc7 | 2023-09-11 08:41:39 -0400 | [diff] [blame] | 42 | |
| 43 | SRCREV_FORMAT .="_bionic_core_lzma_libprocinfo_logging_unwinding_protobuf_libbase_libcxx_libcxxabi_libunwind_zlib" |
| 44 | |
Patrick Williams | 975a06f | 2022-10-21 14:42:47 -0500 | [diff] [blame] | 45 | SRC_URI[gn.sha256sum] = "f706aaa0676e3e22f5fc9ca482295d7caee8535d1869f99efa2358177b64f5cd" |
| 46 | |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 47 | require perfetto.inc |
| 48 | |
Patrick Williams | 975a06f | 2022-10-21 14:42:47 -0500 | [diff] [blame] | 49 | DEPENDS += " ninja-native" |
| 50 | |
| 51 | COMPATIBLE_HOST = "(i.86|x86_64|aarch64|arm).*-linux*" |
| 52 | |
Patrick Williams | 864cc43 | 2023-02-09 14:54:44 -0600 | [diff] [blame] | 53 | CCACHE_DISABLE = "1" |
| 54 | |
| 55 | # Some musl hacks gets through compiling it for musl |
| 56 | # Nullifying -DTEMP_FAILURE_RETRY might be grossest of them |
| 57 | TUNE_CCARGS:append:libc-musl = " -D_LIBCPP_HAS_MUSL_LIBC -Dgetprogname\(\)=program_invocation_name -DTEMP_FAILURE_RETRY=" |
Patrick Williams | 975a06f | 2022-10-21 14:42:47 -0500 | [diff] [blame] | 58 | FILES:${PN}:append = " \ |
| 59 | ${bindir}/tracebox \ |
| 60 | " |
| 61 | |
Patrick Williams | 975a06f | 2022-10-21 14:42:47 -0500 | [diff] [blame] | 62 | B = "${WORKDIR}/build" |
| 63 | |
| 64 | # Run the GN (Generate Ninja) script, and replace the compiler flags where applicable |
| 65 | do_configure () { |
| 66 | # Configuration needs to be done from the source directory |
| 67 | cd ${S} |
| 68 | # Rename a few build tools if they have not been renamed |
| 69 | cd buildtools |
| 70 | x="gn-linux64-1968-0725d782" |
| 71 | [ -f $x ] && mkdir linux64 && mv $x linux64/gn |
| 72 | chmod +x linux64/gn |
| 73 | cd .. |
| 74 | |
| 75 | CC_BIN=`echo $CC | awk '{print $1}'` |
| 76 | CXX_BIN=`echo $CXX | awk '{print $1}'` |
| 77 | STRIP_BIN=`echo $STRIP | awk '{print $1}'` |
| 78 | |
| 79 | ARGS="is_debug=false " # Tell gn to use release mode |
| 80 | |
| 81 | if [ -z `echo ${TOOLCHAIN} | grep clang` ]; then |
| 82 | ARGS=$ARGS" is_clang=false" |
| 83 | else |
| 84 | ARGS=$ARGS" is_clang=true" |
| 85 | fi |
| 86 | |
| 87 | # Architecture parameter accepted by Perfetto |
| 88 | arch=${TARGET_ARCH} |
| 89 | if [ $arch = "i686" ]; then |
| 90 | arch="x86" |
| 91 | elif [ $arch = "x86_64" ]; then |
| 92 | arch="x64" |
| 93 | elif [ $arch = "aarch64" ]; then |
| 94 | arch="arm64" |
| 95 | fi |
Patrick Williams | 975a06f | 2022-10-21 14:42:47 -0500 | [diff] [blame] | 96 | |
| 97 | ARGS=$ARGS" target_os=\"linux\"" |
| 98 | ARGS=$ARGS" target_cpu=\"$arch\"" |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 99 | ARGS=$ARGS" target_cc=\"$CC_BIN ${TUNE_CCARGS}\"" |
| 100 | ARGS=$ARGS" target_cxx=\"$CXX_BIN -std=c++11 ${TUNE_CCARGS}\"" |
Patrick Williams | 975a06f | 2022-10-21 14:42:47 -0500 | [diff] [blame] | 101 | ARGS=$ARGS" target_strip=\"$STRIP_BIN\"" # |
| 102 | ARGS=$ARGS" target_sysroot=\"${RECIPE_SYSROOT}\"" |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 103 | ARGS=$ARGS" target_linker=\"$CC_BIN ${TUNE_CCARGS} ${LDFLAGS}\"" |
Patrick Williams | 975a06f | 2022-10-21 14:42:47 -0500 | [diff] [blame] | 104 | ARGS=$ARGS" target_ar=\"$AR\"" |
| 105 | ARGS="'$ARGS'" |
| 106 | cmd="tools/gn gen --args=$ARGS ${B}" |
| 107 | |
| 108 | echo $cmd |
| 109 | # Use eval, not just call $cmd, due to escaping of single quotation marks |
| 110 | eval $cmd |
| 111 | |
| 112 | cd ${B} |
| 113 | # Eliminate a few incompatible build flags |
| 114 | REPLACES="s/-Wl,--icf=all//g" |
| 115 | REPLACES=$REPLACES";s/-Werror//g" |
Patrick Williams | 975a06f | 2022-10-21 14:42:47 -0500 | [diff] [blame] | 116 | REPLACES=$REPLACES";s/-fcolor-diagnostics//g" |
| 117 | REPLACES=$REPLACES";s/=format-security//g" |
| 118 | REPLACES=$REPLACES";s/-fdiagnostics-show-template-tree//g" |
| 119 | REPLACES=$REPLACES";s/-D_FORTIFY_SOURCE=2//g" |
| 120 | REPLACES=$REPLACES";s/-fuse-ld=\S*//g" |
| 121 | |
| 122 | find . -name "*.ninja" | xargs sed $REPLACES -i |
| 123 | |
| 124 | # If using the clang toolchain: use the clang host-side binaries built by Bitbake |
| 125 | if [ "${TOOLCHAIN}" = "clang" ]; then |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 126 | BB_CLANGXX="${BUILD_CXX} ${BUILD_LDFLAGS}" |
| 127 | BB_CLANG="${BUILD_CC}" |
Patrick Williams | 975a06f | 2022-10-21 14:42:47 -0500 | [diff] [blame] | 128 | BB_LLVM_OBJCOPY="${RECIPE_SYSROOT_NATIVE}/usr/bin/llvm-objcopy" |
| 129 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 130 | HOST_CLANGXX="${STAGING_DIR_NATIVE}/usr/bin/clang++ -stdlib=libc++ -rtlib=libgcc -unwindlib=libgcc" |
| 131 | HOST_CLANG="${STAGING_DIR_NATIVE}/usr/bin/clang" |
Patrick Williams | 975a06f | 2022-10-21 14:42:47 -0500 | [diff] [blame] | 132 | HOST_LLVM_OBJCOPY="${STAGING_DIR_NATIVE}/usr/bin/llvm-objcopy" |
| 133 | |
| 134 | cd gcc_like_host |
| 135 | REPLACES="s:\S*clang++ :$HOST_CLANGXX :g" |
| 136 | REPLACES=$REPLACES";s:\S*clang :$HOST_CLANG :g" |
| 137 | REPLACES=$REPLACES";s:\S*llvm-objcopy :$HOST_LLVM_OBJCOPY :g" |
| 138 | find . -name "*.ninja" | xargs sed "$REPLACES" -i |
| 139 | cd .. |
| 140 | fi |
| 141 | # Done processing the Ninja files |
Patrick Williams | 975a06f | 2022-10-21 14:42:47 -0500 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | # Perfetto generates a few different binaries, such as traced and traced_probes and perfetto. |
| 145 | # The "tracebox" is a busybox that combines the 3 above and provides a single stop for trace capture, so we only build "tracebox" here. |
| 146 | do_compile () { |
| 147 | cd ${B} |
| 148 | ninja -C . tracebox |
| 149 | } |
| 150 | |
| 151 | do_install () { |
| 152 | BIN_DIR=${D}${bindir} |
| 153 | |
| 154 | install -d -m0755 $BIN_DIR |
| 155 | install ${B}/tracebox $BIN_DIR/tracebox |
| 156 | } |