aboutsummaryrefslogtreecommitdiffstats
path: root/meta-xilinx-standalone/classes/esw.bbclass
blob: 1f7e35f424cec9dc6b903544a1b21dcd510d1445 (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
inherit pkgconfig cmake

LICENSE = "Proprietary"
LICFILENAME = "license.txt"
LIC_FILES_CHKSUM = "file://${S}/${LICFILENAME};md5=39ab6ab638f4d1836ba994ec6852de94"

# We should move to an actual SRCREV eventually
include conf/xilinx/esw-srcrev.inc

SRCREV ?= "${AUTOREV}"
PV = "${XILINX_RELEASE_VERSION}+git${SRCPV}"
REPO ?= "git://github.com/xilinx/embeddedsw.git;protocol=https"
BRANCH ?= "master"
SRC_URI = "${REPO};branch=${BRANCH}"

SRCREV_FORMAT = "src_decouple"

S = "${WORKDIR}/git"
B = "${WORKDIR}/build"
OECMAKE_SOURCEPATH = "${S}/${ESW_COMPONENT_SRC}"

SPECFILE_PATH_arm = "${S}/scripts/specs/arm/Xilinx.spec"
SPECFILE_PATH_aarch64 = "${S}/scripts/specs/arm/Xilinx.spec"
SPECFILE_PATH_microblaze = "${S}/scripts/specs/microblaze/Xilinx.spec"

ESW_CFLAGS += "-specs=${SPECFILE_PATH}"

inherit ccmake

COMPATIBLE_HOST = ".*-elf"
COMPATIBLE_HOST_arm = "[^-]*-[^-]*-eabi"

DTBFILE ?= "${RECIPE_SYSROOT}/boot/devicetree/system-top.dtb"

def get_xlnx_cmake_machine(fam, d):
    cmake_machine = fam
    if (fam == 'zynqmp'):
        cmake_machine = 'ZynqMP'
    elif (fam == 'versal'):
        cmake_machine = 'Versal'
    elif (fam == 'zynq'):
        cmake_machine = 'Zynq'
    return cmake_machine

def get_xlnx_cmake_processor(tune, machine, d):
    cmake_processor = tune
    if tune.startswith('microblaze'):
        if (machine == 'microblaze-pmu'):
            cmake_processor = 'pmu_microblaze'
        elif (machine == 'microblaze-plm'):
            cmake_processor = 'plm_microblaze'
        else:
            cmake_processor = 'microblaze'
    elif (tune in [ 'cortexr5', 'cortexr5f' ]):
        cmake_processor = 'cortexr5'
    elif tune.startswith('cortexa9'):
        cmake_processor = 'cortexa9'
    elif (tune in [ 'cortexa53', 'cortexa72-cortexa53' ]):
        cmake_processor = 'cortexa53'
    elif tune == 'cortexa72':
        cmake_processor = 'cortexa72'
    return cmake_processor

XLNX_CMAKE_MACHINE = "${@get_xlnx_cmake_machine(d.getVar('SOC_FAMILY'), d)}"
XLNX_CMAKE_PROCESSOR = "${@get_xlnx_cmake_processor(d.getVar('DEFAULTTUNE'), d.getVar('MACHINE'), d)}"
XLNX_CMAKE_SYSTEM_NAME ?= "Generic"

cmake_do_generate_toolchain_file_append() {
    cat >> ${WORKDIR}/toolchain.cmake <<EOF
    include(CMakeForceCompiler)
    CMAKE_FORCE_C_COMPILER("${OECMAKE_C_COMPILER}" GNU)
    CMAKE_FORCE_CXX_COMPILER("${OECMAKE_CXX_COMPILER}" GNU)
    set( CMAKE_SYSTEM_PROCESSOR "${XLNX_CMAKE_PROCESSOR}" )
    set( CMAKE_MACHINE "${XLNX_CMAKE_MACHINE}" )
    # Will need this in the future to make cmake understand esw variables
    # set( CMAKE_SYSTEM_NAME `echo elf | sed -e 's/^./\u&/' -e 's/^\(Linux\).*/\1/'` )
    set( CMAKE_SYSTEM_NAME "${XLNX_CMAKE_SYSTEM_NAME}" )
EOF
}

do_install() {
    install -d ${D}${libdir}
    install -d ${D}${includedir}
    install -m 0755  ${B}/${ESW_COMPONENT_NAME} ${D}${libdir}
    install -m 0644  ${B}/include/*.h ${D}${includedir}
}

CFLAGS_append = " ${ESW_CFLAGS}"

# We need to find the license file, which vaires depending on the component
# recurse a maximum of x times, could be fancier but it gets complicated since
# we dont know for certain we are running devtool or just externalsrc
python(){
    import os.path
    if bb.data.inherits_class('externalsrc', d) and d.getVar('EXTERNALSRC'):
        externalsrc = d.getVar('EXTERNALSRC')
        lic_file = d.getVar('LIC_FILES_CHKSUM', False)
        licpath=externalsrc
        for i in range(5):
            if os.path.isfile(licpath + '/' + d.getVar('LICFILENAME',True)):
                lic_file = lic_file.replace('${S}',licpath)
                d.setVar('LIC_FILES_CHKSUM', lic_file)
                return
            licpath=os.path.dirname(licpath)
        bb.error("Couldn't find license file: %s, within directory %s or his parent directories" % (d.getVar('LICFILENAME',True), externalsrc))
}