xref: /OK3568_Linux_fs/yocto/meta-clang/recipes-devtools/clang/llvm-project-source.inc (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyundeltask do_configure
2*4882a593Smuzhiyundeltask do_compile
3*4882a593Smuzhiyundeltask do_install
4*4882a593Smuzhiyundeltask do_populate_sysroot
5*4882a593Smuzhiyundeltask do_populate_lic
6*4882a593SmuzhiyunRM_WORK_EXCLUDE += "${PN}"
7*4882a593Smuzhiyun
8*4882a593Smuzhiyuninherit nopackages
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunPN = "llvm-project-source-${PV}"
11*4882a593SmuzhiyunWORKDIR = "${TMPDIR}/work-shared/llvm-project-source-${PV}-${PR}"
12*4882a593SmuzhiyunSSTATE_SWSPEC = "sstate:llvm-project-source::${PV}:${PR}::${SSTATE_VERSION}:"
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunSTAMP = "${STAMPS_DIR}/work-shared/llvm-project-source-${PV}-${PR}"
15*4882a593SmuzhiyunSTAMPCLEAN = "${STAMPS_DIR}/work-shared/llvm-project-source-${PV}-*"
16*4882a593Smuzhiyun
17*4882a593SmuzhiyunINHIBIT_DEFAULT_DEPS = "1"
18*4882a593SmuzhiyunDEPENDS = ""
19*4882a593SmuzhiyunPACKAGES = ""
20*4882a593SmuzhiyunTARGET_ARCH = "allarch"
21*4882a593SmuzhiyunTARGET_AS_ARCH = "none"
22*4882a593SmuzhiyunTARGET_CC_ARCH = "none"
23*4882a593SmuzhiyunTARGET_LD_ARCH = "none"
24*4882a593SmuzhiyunTARGET_OS = "linux"
25*4882a593Smuzhiyunbaselib = "lib"
26*4882a593SmuzhiyunPACKAGE_ARCH = "all"
27*4882a593Smuzhiyun
28*4882a593Smuzhiyun# space separated list of additional distro vendor values we want to support e.g.
29*4882a593Smuzhiyun# "yoe webos" or "-yoe -webos" '-' is optional
30*4882a593SmuzhiyunCLANG_EXTRA_OE_VENDORS ?= "${TARGET_VENDOR} ${SDK_VENDOR}"
31*4882a593Smuzhiyun# Extra OE DISTRO that want to support as build host. space separated list of additional distro.
32*4882a593Smuzhiyun# ":" separated the ID in "/etc/os-release" and the triple for finding gcc on this OE DISTRO.
33*4882a593Smuzhiyun# eg: "poky:poky wrlinux:wrs"
34*4882a593SmuzhiyunCLANG_EXTRA_OE_DISTRO ?= "poky:poky"
35*4882a593Smuzhiyun# Match with MULTILIB_GLOBAL_VARIANTS
36*4882a593SmuzhiyunMULTILIB_VARIANTS = "lib32 lib64 libx32"
37*4882a593Smuzhiyunpython add_distro_vendor() {
38*4882a593Smuzhiyun    import subprocess
39*4882a593Smuzhiyun    case = ""
40*4882a593Smuzhiyun    triple = ""
41*4882a593Smuzhiyun    vendors = d.getVar('CLANG_EXTRA_OE_VENDORS')
42*4882a593Smuzhiyun    multilib_variants = (d.getVar("MULTILIB_VARIANTS") or "").split()
43*4882a593Smuzhiyun    vendors_to_add = []
44*4882a593Smuzhiyun    for vendor in vendors.split():
45*4882a593Smuzhiyun        # convert -yoe into yoe
46*4882a593Smuzhiyun        vendor = vendor.lstrip('-')
47*4882a593Smuzhiyun        # generate possible multilib vendor names for yoe
48*4882a593Smuzhiyun        # such as yoemllib32
49*4882a593Smuzhiyun        vendors_to_add.extend([vendor + 'ml' + variant for variant in multilib_variants])
50*4882a593Smuzhiyun        # skip oe since already part of the cpp file
51*4882a593Smuzhiyun        if vendor != "oe":
52*4882a593Smuzhiyun            vendors_to_add.append(vendor)
53*4882a593Smuzhiyun
54*4882a593Smuzhiyun    for vendor_to_add in vendors_to_add:
55*4882a593Smuzhiyun        case += '\\n    .Case("' + vendor_to_add + '", Triple::OpenEmbedded)'
56*4882a593Smuzhiyun        triple += ' "x86_64-' + vendor_to_add + '-linux",'
57*4882a593Smuzhiyun
58*4882a593Smuzhiyun    bb.note("Adding support following TARGET_VENDOR values")
59*4882a593Smuzhiyun    bb.note(str(vendors_to_add))
60*4882a593Smuzhiyun    bb.note("in llvm/lib/Support/Triple.cpp and ${S}/clang/lib/Driver/ToolChains/Gnu.cpp")
61*4882a593Smuzhiyun    cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_VENDORS_TRIPLES#%s#g' ${S}/clang/lib/Driver/ToolChains/Gnu.cpp" % (triple))
62*4882a593Smuzhiyun    subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
63*4882a593Smuzhiyun    cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_VENDORS_CASES#%s#g' -i ${S}/llvm/lib/Support/Triple.cpp" % (case))
64*4882a593Smuzhiyun    subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun
67*4882a593Smuzhiyun    case = ""
68*4882a593Smuzhiyun    triple = ""
69*4882a593Smuzhiyun    name = ""
70*4882a593Smuzhiyun    check = ""
71*4882a593Smuzhiyun    oe_names = ""
72*4882a593Smuzhiyun    distros = d.getVar('CLANG_EXTRA_OE_DISTRO')
73*4882a593Smuzhiyun    for distro in distros.split():
74*4882a593Smuzhiyun        distro_id = distro.split(":")[0].replace('-','_')
75*4882a593Smuzhiyun        distro_triple = distro.split(":")[1]
76*4882a593Smuzhiyun        case += '\\n    .Case("' + distro_id + '", Distro::' + distro_id.upper() + ')'
77*4882a593Smuzhiyun        triple += '\\n   if (Distro.Is' + distro_id.upper() + '())\\n     return "x86_64-' + distro_triple + '-linux",'
78*4882a593Smuzhiyun        name += '\\n    '+ distro_id.upper() + ','
79*4882a593Smuzhiyun        check += '\\nbool Is' + distro_id.upper() + '() const { return DistroVal == ' + distro_id.upper() + '; }'
80*4882a593Smuzhiyun        oe_names +=  distro_id.upper() + ' ||'
81*4882a593Smuzhiyun
82*4882a593Smuzhiyun    check += '\\nbool IsOpenEmbedded() const { return DistroVal == ' + oe_names[0:-3] + '; }'
83*4882a593Smuzhiyun
84*4882a593Smuzhiyun    cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_DISTRO_NAME#%s#g' ${S}/clang/include/clang/Driver/Distro.h" % (name))
85*4882a593Smuzhiyun    subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
86*4882a593Smuzhiyun    cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_DISTRO_CHECK#%s#g' ${S}/clang/include/clang/Driver/Distro.h" % (check))
87*4882a593Smuzhiyun    subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
88*4882a593Smuzhiyun    cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_DISTRO_TRIPLES#%s#g' ${S}/clang/lib/Driver/ToolChains/Linux.cpp" % (triple))
89*4882a593Smuzhiyun    subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
90*4882a593Smuzhiyun    cmd = d.expand("sed -i 's#//CLANG_EXTRA_OE_DISTRO_CASES#%s#g' -i ${S}/clang/lib/Driver/Distro.cpp" % (case))
91*4882a593Smuzhiyun    subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
92*4882a593Smuzhiyun}
93*4882a593Smuzhiyun
94*4882a593Smuzhiyundo_patch[postfuncs] += "add_distro_vendor"
95*4882a593Smuzhiyundo_create_spdx[depends] += "${PN}:do_patch"
96*4882a593Smuzhiyun
97