aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-devtools/perfetto/perfetto.bb
blob: d1980a00975b4bd89fc4a1141c36f518cc1c9f3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
LICENSE = "Apache-2.0 & BSD-3-Clause & MIT & Zlib"

LIC_FILES_CHKSUM = "file://LICENSE;md5=f87516e0b698007e9e75a1fe1012b390 \
                    file://buildtools/libcxx/LICENSE.TXT;md5=55d89dd7eec8d3b4204b680e27da3953 \
                    file://buildtools/libcxx/utils/google-benchmark/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57 \
                    file://buildtools/libcxxabi/LICENSE.TXT;md5=7b9334635b542c56868400a46b272b1e \
                    file://buildtools/libunwind/LICENSE.TXT;md5=f66970035d12f196030658b11725e1a1 \
                    file://buildtools/protobuf/LICENSE;md5=37b5762e07f0af8c74ce80a8bda4266b \
                    file://buildtools/zlib/LICENSE;md5=f09575dbfb09420642318b413159496f \
                    file://debian/copyright;md5=4e08364c82141f181de69d0a2b89d612 \
                    file://python/LICENSE;md5=c602a632c34ade9c78a976734077bce7"

SRC_URI:append = " \
           git://github.com/protocolbuffers/protobuf.git;branch=3.9.x;protocol=https;destsuffix=git/buildtools/protobuf;name=protobuf \
           git://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx.git;protocol=https;destsuffix=git/buildtools/libcxx;branch=main;name=libcxx \
           git://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git;protocol=https;destsuffix=git/buildtools/libcxxabi;branch=main;name=libcxxabi \
           git://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git;protocol=https;destsuffix=git/buildtools/libunwind;branch=main;name=libunwind \
           git://android.googlesource.com/platform/external/zlib.git;branch=master;protocol=https;destsuffix=git/buildtools/zlib;name=zlib \
           https://storage.googleapis.com/perfetto/gn-linux64-1968-0725d782;subdir=git/buildtools/;name=gn \
           file://0001-Remove-check_build_deps-build-steps.patch "

SRCREV_protobuf = "6a59a2ad1f61d9696092f79b6d74368b4d7970a3"
SRCREV_libcxx = "d9040c75cfea5928c804ab7c235fed06a63f743a"
SRCREV_libcxxabi = "196ba1aaa8ac285d94f4ea8d9836390a45360533"
SRCREV_libunwind = "d999d54f4bca789543a2eb6c995af2d9b5a1f3ed"
SRCREV_zlib = "5c85a2da4c13eda07f69d81a1579a5afddd35f59"
SRC_URI[gn.sha256sum] = "f706aaa0676e3e22f5fc9ca482295d7caee8535d1869f99efa2358177b64f5cd"

require perfetto.inc

DEPENDS += " ninja-native"

COMPATIBLE_HOST = "(i.86|x86_64|aarch64|arm).*-linux*"

FILES:${PN}:append = " \
  ${bindir}/tracebox \
  "

B = "${WORKDIR}/build"

# Run the GN (Generate Ninja) script, and replace the compiler flags where applicable
do_configure () {
    # Configuration needs to be done from the source directory
    cd ${S}
    # Rename a few build tools if they have not been renamed
    cd buildtools
    x="gn-linux64-1968-0725d782"
    [ -f $x ] && mkdir linux64 && mv $x linux64/gn
    chmod +x linux64/gn
    cd ..

    CC_BIN=`echo $CC | awk '{print $1}'`
    CXX_BIN=`echo $CXX | awk '{print $1}'`
    STRIP_BIN=`echo $STRIP | awk '{print $1}'`

    ARGS="is_debug=false "  # Tell gn to use release mode

    if [ -z `echo ${TOOLCHAIN} | grep clang` ]; then
        ARGS=$ARGS" is_clang=false"
    else
        ARGS=$ARGS" is_clang=true"
    fi
    
    # Architecture parameter accepted by Perfetto
    arch=${TARGET_ARCH}
    if [ $arch = "i686" ]; then
        arch="x86"
    elif [ $arch = "x86_64" ]; then
        arch="x64"
    elif [ $arch = "aarch64" ]; then
        arch="arm64"
    fi

    ARGS=$ARGS" target_os=\"linux\""
    ARGS=$ARGS" target_cpu=\"$arch\""
    ARGS=$ARGS" target_cc=\"$CC_BIN ${TUNE_CCARGS}\""
    ARGS=$ARGS" target_cxx=\"$CXX_BIN -std=c++11 ${TUNE_CCARGS}\""
    ARGS=$ARGS" target_strip=\"$STRIP_BIN\"" #
    ARGS=$ARGS" target_sysroot=\"${RECIPE_SYSROOT}\""
    ARGS=$ARGS" target_linker=\"$CC_BIN ${TUNE_CCARGS} ${LDFLAGS}\""
    ARGS=$ARGS" target_ar=\"$AR\""
    ARGS="'$ARGS'"
    cmd="tools/gn gen --args=$ARGS ${B}"

    echo $cmd
    # Use eval, not just call $cmd, due to escaping of single quotation marks
    eval $cmd

    cd ${B}
    # Eliminate a few incompatible build flags
    REPLACES="s/-Wl,--icf=all//g"
    REPLACES=$REPLACES";s/-Werror//g"
    REPLACES=$REPLACES";s/-fcolor-diagnostics//g"
    REPLACES=$REPLACES";s/=format-security//g"
    REPLACES=$REPLACES";s/-fdiagnostics-show-template-tree//g"
    REPLACES=$REPLACES";s/-D_FORTIFY_SOURCE=2//g"
    REPLACES=$REPLACES";s/-fuse-ld=\S*//g"

    find . -name "*.ninja" | xargs sed $REPLACES -i

    # If using the clang toolchain: use the clang host-side binaries built by Bitbake
    if [ "${TOOLCHAIN}" = "clang" ]; then
        BB_CLANGXX="${BUILD_CXX} ${BUILD_LDFLAGS}"
        BB_CLANG="${BUILD_CC}"
        BB_LLVM_OBJCOPY="${RECIPE_SYSROOT_NATIVE}/usr/bin/llvm-objcopy"
        
        HOST_CLANGXX="${STAGING_DIR_NATIVE}/usr/bin/clang++ -stdlib=libc++ -rtlib=libgcc -unwindlib=libgcc"
        HOST_CLANG="${STAGING_DIR_NATIVE}/usr/bin/clang"
        HOST_LLVM_OBJCOPY="${STAGING_DIR_NATIVE}/usr/bin/llvm-objcopy"

        cd gcc_like_host
        REPLACES="s:\S*clang++ :$HOST_CLANGXX :g"
        REPLACES=$REPLACES";s:\S*clang :$HOST_CLANG :g"
        REPLACES=$REPLACES";s:\S*llvm-objcopy :$HOST_LLVM_OBJCOPY :g"
        find . -name "*.ninja" | xargs sed "$REPLACES" -i
        cd ..
    fi
    # Done processing the Ninja files

    # Workaround for the functions not supported by musl
    if [ "${TCLIBC}" = "musl" ]; then
        sed -e 's/strtoll_l(__a, \&__p2, __base, _LIBCPP_GET_C_LOCALE)/strtoll(__a, \&__p2, __base)/g' \
            -e 's/strtoull_l(__a, \&__p2, __base, _LIBCPP_GET_C_LOCALE)/strtoull(__a, \&__p2, __base)/g' \
            ${S}/buildtools/libcxx/include/locale -i
    fi
}

# Perfetto generates a few different binaries, such as traced and traced_probes and perfetto.
# The "tracebox" is a busybox that combines the 3 above and provides a single stop for trace capture, so we only build "tracebox" here.
do_compile () {
    cd ${B}
    ninja -C . tracebox
}

do_install () {
    BIN_DIR=${D}${bindir}

    install -d -m0755 $BIN_DIR
    install ${B}/tracebox $BIN_DIR/tracebox
}
an class="p">) #make it overridable for platforms with FPU, like ep93xx or i.mx31 TARGET_FPU_arm ?= "soft" TARGET_FPU_armeb ?= "soft" TARGET_FPU_ixp4xx ?= "soft" TARGET_FPU_ppc405 ?= "soft" TARGET_FPU_armv6 ?= "hard" TARGET_FPU_armv6-novfp ?= "soft" TARGET_FPU_armv7a ?= "hard" TARGET_FPU_ppc603e ?= "hard" # webkit-gtk and cairo have alignment issues with double instructions on armv5 so # disable them here TARGET_CC_ARCH_pn-webkit-gtk_armv5te = "-march=armv4t" TARGET_CC_ARCH_pn-cairo_armv5te = "-march=armv4t" #Set the right arch for the feeds #Alphabetically sorted FEED_ARCH ?= "${BASE_PACKAGE_ARCH}" #blackfin machines FEED_ARCH_bfin = "blackfin" #Name the generated images in a sane way IMAGE_NAME = "${DISTRO_NAME}-${IMAGE_BASENAME}-${LIBC}-${ANGSTROM_PKG_FORMAT}-${DISTRO_VERSION}-${MACHINE}" DEPLOY_DIR_IMAGE = "${DEPLOY_DIR}/images/${MACHINE}" # Angstrom *always* has some form of release config, so error out if someone thinks he knows better DISTRO_CHECK := "${@bb.data.getVar("DISTRO_VERSION",d,1) or bb.fatal('Remove this line or set a dummy DISTRO_VERSION if you really want to build an unversioned distro')}" # Configuration for tinderbox, so people only need: # INHERIT += "tinderclient" # in their local.conf #Name of the client TINDER_MACHINE = "${MACHINE}-${LIBC}-build-image" # Which lof file to write to, which tree to report to TINDER_LOG = "${TMPDIR}/tinder.log" TINDER_TREE = "Angstrom" # HTTP posting TINDER_HOST ?= "ewi546.ewi.utwente.nl" TINDER_URL ?= "/tinderbox" # Which branch do we build TINDER_BRANCH = "org.openembedded.dev" ## Clobbing ## 0 for rebuilding everything from scratch ## 1 for incremental builds TINDER_CLOBBER = "1" ## Do a report at all TINDER_REPORT = "1" # Configuration for seppuku autobuilder, people only need to put: # INHERIT += "seppuku oestats-client" # SEPPUKU_USER = "your_bugzilla@user.id" # SEPPUKU_PASS = "your_bugzilla_password" # OESTATS_BUILDER = "your_name" # in their local.conf # seppuku bbclass SEPPUKU_LOGIN = "http://bugs.openembedded.net/query.cgi?" SEPPUKU_QUERY = "http://bugs.openembedded.net/buglist.cgi?" SEPPUKU_NEWREPORT = "http://bugs.openembedded.net/post_bug.cgi?bug_file_loc=http%3A%2F%2F&version=Angstrom%20unstable&priority=P2&bug_severity=normal&op_sys=Linux&rep_platform=Other&" SEPPUKU_ADDCOMMENT = "http://bugs.openembedded.net/process_bug.cgi?bug_file_loc=http%3A%2F%2F&version=Angstrom&priority=P2&bug_severity=normal&op_sys=Linux&rep_platform=Other&" SEPPUKU_ATTACHMENT = "http://bugs.openembedded.net/attachment.cgi?" SEPPUKU_AUTOBUILD = "1" SEPPUKU_PRODUCT = "Openembedded" SEPPUKU_COMPONENT = "org.openembedded.dev" OESTATS_SERVER ?= "tinderbox.openembedded.org" # We want images supporting the following features (for task-base) DISTRO_FEATURES = "nfs smbfs wifi ppp alsa bluetooth ext2 vfat irda pcmcia usbgadget usbhost pci pam" # Use-like features DISTRO_FEATURES += "tk"