Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在yocto配方中管理golang项目的外部依赖关系_Go_Dependency Management_Yocto_Recipe - Fatal编程技术网

如何在yocto配方中管理golang项目的外部依赖关系

如何在yocto配方中管理golang项目的外部依赖关系,go,dependency-management,yocto,recipe,Go,Dependency Management,Yocto,Recipe,我想用Yocto2.4.1为交叉编译的golang应用程序编写一个yocto配方,但我无法让外部依赖项正常工作。 有人能帮我吗 current RECIPE_FILE: hello-world_%.bb LICENSE = "CLOSED" LIC_FILES_CHKSUM = "" DESCRIPTION = "Hello world test with golang." inherit go COMPATIBLE_MACHINE = "(<machine>)" DEPENDS

我想用Yocto2.4.1为交叉编译的golang应用程序编写一个yocto配方,但我无法让外部依赖项正常工作。 有人能帮我吗

current RECIPE_FILE: hello-world_%.bb
LICENSE = "CLOSED"
LIC_FILES_CHKSUM = ""
DESCRIPTION = "Hello world test with golang."

inherit go

COMPATIBLE_MACHINE = "(<machine>)"
DEPENDS = "go-cross-${TARGET_ARCH}"
GO_IMPORT = "hello-world"
SRC_URI = "<git_url>/${GO_IMPORT}.git;branch=${SRCBRANCH};tag=${PV}" 
SRCBRANCH = "master"
PV = "0.01"
S = "${WORKDIR}/git"

do_compile() {
  export GOPATH="${WORKDIR}/build"
  export GOARCH="<machine_arch>"
  export GOOS="linux"
  export CGO_ENABLED="0"
  go build src/${GO_IMPORT}/hello-world.go
}

 do_install() {
   install -d "${D}/${bindir}"
   install -m 0755 "${WORKDIR}/build/hello-world" "${D}/${bindir}/hello-world"
 }

RDEPENDS_${PN}-dev += "bash"
有人知道这个用例的解决方案吗

或者有人知道“go dep”如何处理这个问题吗


致以最诚挚的问候

我相信只有两种依赖关系
1.主机依赖项(应用程序在yocto中编译时的依赖项)
在yocto配方(.bb文件)中保留
DEPENDS=“some lib”

  • 目标依赖项(应用程序在板上运行时的依赖项)
    您的yocto配方
    RDEPENDS=“some lib”
  • 你好,bb

    DESCRIPTION =  
    LIC =  
    SRC_URI =  
    DEPENDS ="sqlite3"   
    inherit autools
    

    我用go dep来代替dep,下面是一个例子。最麻烦的是关于代理的问题,这在配方中也得到了解决:

    inherit go
    
    LICENSE = "CLOSED"
    LIC_FILES_CHKSUM = ""
    DESCRIPTION = "Hello world test with golang."
    
    COMPATIBLE_MACHINE = "(<machine>)"
    DEPENDS += "go-dep-native"
    GO_LINKSHARED = ""
    
    GO_IMPORT = "<git_url>/hello-world.git"
    SRC_URI = "<git_url>/${GO_IMPORT}.git;branch=${SRCBRANCH};tag=${PV}" 
    SRCBRANCH = "master"
    
    do_compile() {
        export SSH_AUTH_SOCK="${SSH_AUTH_SOCK}"
        export HTTP_PROXY="${HTTP_PROXY}"
        ( cd ${WORKDIR}/build/src/${GO_IMPORT} && dep ensure -v )
    }
    
    do_compile[vardepsexclude] += "SSH_AUTH_SOCK HTTP_PROXY"
    
    do_install() {
        install -d "${D}/${bindir}"
        install -m 0755 "${WORKDIR}/bin/<arch>/hello-world" "${D}/${bindir}/hello-world"
    }
    
    继承go
    LICENSE=“已关闭”
    LIC_FILES_CHKSUM=“”
    DESCRIPTION=“你好,与golang进行世界测试。”
    COMPATIBLE_MACHINE=“()”
    取决于+=“转到本机dep”
    GO_LINKSHARED=“”
    GO_IMPORT=“/hello world.git”
    SRC_URI=“/${GO_IMPORT}.git;branch=${SRCBRANCH};tag=${PV}”
    SRCBRANCH=“master”
    你要编译吗{
    export SSH\u AUTH\u SOCK=“${SSH\u AUTH\u SOCK}”
    export HTTP_PROXY=“${HTTP_PROXY}”
    (cd${WORKDIR}/build/src/${GO_IMPORT}&&dep sure-v)
    }
    do_compile[vardepseclude]+=“SSH_AUTH_SOCK HTTP_PROXY”
    安装吗{
    安装-d“${d}/${bindir}”
    安装-m 0755“${WORKDIR}/bin//hello world”“${D}/${bindir}/hello world”
    }
    
    您可以使用
    SRC\u URI
    添加外部go依赖项:

    SRC_URI = "\
               <git_url>/${GO_IMPORT}.git;branch=${SRCBRANCH};tag=${PV} \
               git://github.com/golang/protobuf/ptypes;protocol=https;name=ptype;destsuffix=${PN}-${PV}/src/github.com/golang/protobuf/ptypes \
    "
    
    SRCREV_ptype = "v0.1.0" <-- whatever revision you need (branch, tag, sha)
    
    
    SRC_URI=”\
    /${GO_IMPORT}.git;branch=${SRCBRANCH};tag=${PV}\
    git://github.com/golang/protobuf/ptypes;protocol=https;name=ptype;destsuffix=${PN}-${PV}/src/github.com/golang/protobuf/ptypes\
    "
    
    SRCREV_ptype=“v0.1.0”相关:感谢您的回复,但我认为go依赖项在那里无法处理。
    SRC_URI = "\
               <git_url>/${GO_IMPORT}.git;branch=${SRCBRANCH};tag=${PV} \
               git://github.com/golang/protobuf/ptypes;protocol=https;name=ptype;destsuffix=${PN}-${PV}/src/github.com/golang/protobuf/ptypes \
    "
    
    SRCREV_ptype = "v0.1.0" <-- whatever revision you need (branch, tag, sha)