Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build packages for distribution using xgo #32

Merged
merged 2 commits into from
Aug 30, 2020
Merged

Build packages for distribution using xgo #32

merged 2 commits into from
Aug 30, 2020

Conversation

aotimme
Copy link
Owner

@aotimme aotimme commented Aug 29, 2020

This follows a suggestion from @flowrean in #18 to use xgo for cross-compiling the gocsv binary for distribution.

In general this works well and should allow the sql subcommand (which depends on the go-sqlite3 package) to work on other platforms and architectures. It also provides more platforms and architectures than the whitelisted set previously provided.

I have only tested the Mac binary (darwin and amd64) on my local machine and the Linux binary (linux and amd64) on the alpine:3.12.0 and ubuntu:12.04 Docker images.

On my Mac, everything works with the xgo compiled version of gocsv.

With Linux, all subcommands now work on the ubuntu image, including sql which previously did not work. However, there is a regression in that the xgo-built gocsv does not work at all on alpine, whereas previously all subcommands except the sql subcommand worked.

The issue I ran into with alpine was (after docker cp-ing a CSV and the cross-compiled gocsv binary into an interactive terminal in the alpine container):

/ # ./gocsv view tmp.csv
/bin/sh: ./gocsv: not found

This may be a duplicate of karalabe/xgo#183 (i.e. xgo may not support alpine). Regardless, I'm not too worried about it. I doubt people will be using gocsv in a container based on alpine, and if they are they can compile it themselves IMO.

I have not tested the Windows binaries, which would be helpful to determine if this can close the issue #18.

Here are the zip files that it now creates via xgo, which I'm fine with publishing in the release(s):

$ ls dist
gocsv-android-16-386.zip
gocsv-android-16-aar.zip
gocsv-android-16-arm.zip
gocsv-darwin-10.6-386.zip
gocsv-darwin-10.6-amd64.zip
gocsv-ios-5.0-arm64.zip
gocsv-ios-5.0-armv7.zip
gocsv-ios-5.0-framework.zip
gocsv-linux-386.zip
gocsv-linux-amd64.zip
gocsv-linux-arm-5.zip
gocsv-linux-arm-6.zip
gocsv-linux-arm-7.zip
gocsv-linux-arm64.zip
gocsv-linux-mips.zip
gocsv-linux-mips64.zip
gocsv-linux-mips64le.zip
gocsv-linux-mipsle.zip
gocsv-windows-4.0-386.zip
gocsv-windows-4.0-amd64.zip

@flowrean
Copy link
Contributor

flowrean commented Aug 30, 2020

Hi @aotimme, this looks really nice!
I have tested on Windows and the SQL subcommand works well there. (There was another unrelated issue I discovered doing this, see #34 for a pull request that should solve it.)
Two remarks:

  • Docker is now required for building. Not a problem for me.
  • The ZIP files have slightly different names, e.g. gocsv-darwin-amd64.zip is now called gocsv-darwin-10.6-amd64.zip. I don't know if this is an issue, but if we continue, the macOS install script should be updated (as well as the filenames in the installation part of the README for macOS and Windows).

@aotimme
Copy link
Owner Author

aotimme commented Aug 30, 2020

Good point re Docker. I just updated DEV.md to make a note of that (and needing to go get github.com/karalabe/xgo). I'm okay with it as well, especially because you can still build a binary for yourself without Docker via make which uses the usual go build.

Also good catch re the installation script. I'm fine with the name change (gocsv-darwin-amd64.zip to gocsv-darwin-10.6-amd64.zip). Now that we are using xgo to cross-compile, I'd like to delegate the naming scheme for the cross-compiled binaries to xgo.

I'll merge with the small changes now and then re-do the build and upload the full set of ZIP files.

@aotimme aotimme merged commit 7f81620 into master Aug 30, 2020
@aotimme aotimme deleted the xgo-compile branch September 4, 2020 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants