douzouchang7448 2019-05-15 15:43
浏览 60

如何在Travis-CI上将Linux的Go项目交叉编译到Windows

Because Travis-CI native windows support for Go seems to be lacking, I though about going this route.

How would I best do that?

  • 写回答

1条回答 默认 最新

  • duanke1286 2019-05-15 15:43
    关注

    This builds natively for Linux, natively for OSX, and cross compiles for windows, as part of the linux build:

    .travis.yml:

    language: go
    sudo: false
    
    matrix:
      include:
        - go: tip
          os: linux
          env: CROSS_COMPILE=true
        - go: tip
          os: osx
    
    before_install:
      - if [ "$CROSS_COMPILE" = "true" ]; then sudo apt update; fi
    
    install:
      - if [ "$CROSS_COMPILE" = "true" ]; then sudo apt install gcc-mingw-w64 libc6-dev-i386; fi
      - go get github.com/some/go-dependency
      - go get -t -v ./...
    
    script:
      - go build
      - go test
      - if [ "$TRAVIS_OS_NAME" = "linux" -a "$CROSS_COMPILE" = "true" ]; then env CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc go build -v; fi
    
    评论

报告相同问题?

悬赏问题

  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式