简体   繁体   中英

How to build Go + C code in Yocto, fetching the source code from files in the recipe

I'm having issues building Go + C code inside of Yocto. I'm using Yocto gatesgarth, and the only way I can get it to work is by following the examples where they use git.

I do not want to use git for the fetching, just copy the files and build them. This is to allow me to try out changes, and also avoid dealing with source control revision.

How would you go about doing that? Thanks!

Edit: I posted a solution bellow, I hope this will be useful.

I could not get it to work without overloading do_compile() and do_install(), but here it is.

DESCRIPTION = "The application code"
LICENSE = "CLOSED"
LIC_FILES_CHKSUM=""

SRC_URI = "file://build/streamerapp.go file://build/gstreamer_pipelines.c file://build/gstreamer_pipelines.h"

GO_IMPORT = "streamerapp"
GO_LINKSHARED = ""
PTEST_ENABLED="0"
export GO111MODULE="auto"
CGO_ENABLED = "1"

inherit go

do_compile() {
    cd ${WORKDIR}/build
    export TMPDIR="${GOTMPDIR}"
    ${GO} build ${GO_LINKSHARED} ${GOBUILDFLAGS} -o streamerapp
    cd ${OLDPWD}
}

do_install() {
    cd ${WORKDIR}/build
    #install -m <permisions> SRC DEST
    mkdir -p ${D}${bindir}
    install -m 0755 ./streamerapp ${D}${bindir}
    cd ${OLDPWD}
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM