From cf08ca836ac585e28c53fe63e5f15d280880e294 Mon Sep 17 00:00:00 2001 From: Sung Won Cho Date: Fri, 29 Apr 2022 20:31:38 +1000 Subject: [PATCH] Build CLI --- go.mod | 1 + go.sum | 2 ++ scripts/cli/build.sh | 20 ++++++++++++-------- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 0150d739..7a1b0135 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/PuerkitoBio/goquery v1.6.0 // indirect github.com/andybalholm/cascadia v1.2.0 // indirect github.com/aymerick/douceur v0.2.0 + github.com/crazy-max/xgo v0.14.1 // indirect github.com/dnote/actions v0.2.0 github.com/dnote/color v1.7.0 github.com/gobuffalo/packr/v2 v2.8.1 diff --git a/go.sum b/go.sum index 41625712..407d7929 100644 --- a/go.sum +++ b/go.sum @@ -72,6 +72,8 @@ github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfc github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/crazy-max/xgo v0.14.1 h1:f2VWvoxInGBhnfMhd0tF/plwSTUDSyCoCAJaYaGOWdA= +github.com/crazy-max/xgo v0.14.1/go.mod h1:m/aqfKaN/cYzfw+Pzk7Mk0tkmShg3/rCS4Zdhdugi4o= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/scripts/cli/build.sh b/scripts/cli/build.sh index ee010751..a4b61771 100755 --- a/scripts/cli/build.sh +++ b/scripts/cli/build.sh @@ -19,9 +19,13 @@ projectDir="$dir/../.." basedir="$projectDir/pkg/cli" outputDir="$projectDir/build/cli" -# xgo has issues when using modules -# https://github.com/karalabe/xgo/issues/176 -# bypass it by copying the project inside a GOPATH +echo "projectDir: $projectDir" +echo "basedir: $basedir" +echo "outputDir: $projectDir" + +xgo has issues when using modules +https://github.com/karalabe/xgo/issues/176 +bypass it by copying the project inside a GOPATH goPathBasedir="$GOPATH/src/github.com/dnote/dnote" command_exists () { @@ -41,7 +45,7 @@ if [[ $1 == v* ]]; then exit 1 fi -goVersion=1.13.x +goVersion=1.18.x get_binary_name() { platform=$1 @@ -77,10 +81,10 @@ build() { else xgo \ -go "$goVersion" \ - --targets="$platform/$arch" \ + -targets="$platform/$arch" \ -ldflags "$ldflags" \ - --tags "$tags" \ - --dest="$destDir" \ + -tags "$tags" \ + -dest="$destDir" \ -x \ -v \ "$goPathBasedir/pkg/cli" @@ -106,7 +110,7 @@ build() { if [ -z "$GOOS" ] && [ -z "$GOARCH" ]; then # fetch tool - go get -u github.com/dnote/xgo + # go get -u github.com/dnote/xgo rm -rf "$GOPATH/src/github.com/dnote/dnote" cp -R "$projectDir" "$goPathBasedir"