dsnd7200 2018-03-23 17:08
浏览 149

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

I want to write a yocto recipe for a cross-compiled golang application with Yocto 2.4.1 but I cannot get external dependencies to work. Can anyone help me?

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"

This recipe works fine for internal dependencies only. But how do I integrate external dependencies like "github.com/golang/protobuf/ptypes"?

PROJECT_FILE: hello-world.go

package main

import (
    "fmt"
    "github.com/golang/protobuf/ptypes"
)

func main() {
    timestamp := ptypes.TimestampNow()
    fmt.Println(timestamp)
}

Does anyone knows a solution for this use case?

Or does anyone know how "go-dep" could handle this?

Best regards

  • 写回答

2条回答 默认 最新

  • doulu8446 2018-03-28 05:40
    关注

    I believe there is only two types of dependencies
    1. host dependencies (dependencies when the app compiling time in yocto)
    in yocto recipe(.bb file) keep DEPENDS = "some lib"

    1. target dependencies (dependencies when the app running time on board)
      your yocto recipe RDEPENDS = "some lib"

    hello.bb

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

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料