bashful icon indicating copy to clipboard operation
bashful copied to clipboard

Cross compiling

Open vkuznecovas opened this issue 7 years ago • 6 comments

I have not managed to cross compile the bundle to a linux native from a macOS. Am I missing something? Is there a way to do it currently?

vkuznecovas avatar Jan 31 '18 08:01 vkuznecovas

Currently no, if you make a bundle from Linux it will only run in Linux (same for Mac). I could look into combining both Mac and Linux binaries into the bundle. There is another issue open on packaging this for multiple OSs, once I get that release process down this will easily be achievable.

For the meantime I've updated the readme noting some of these caveats.

wagoodman avatar Jan 31 '18 12:01 wagoodman

Is this fixed now with goreleaser? See https://github.com/wagoodman/bashful/releases for all the releases.

amir20 avatar Feb 02 '18 17:02 amir20

Needs a few more steps. When creating a bundle, a copy of bashful gets included in the binary generated. This means that if you bundle on Linux and run the bundle on Mac, it will fail since the bashful copy included was built for Linux.

Simple fix would be to include both binaries in the bundle, which needs some thought. But that's gonna inflate the binary size by a factor of 2... Not really desirable. The last option is to make an os specific binary, which is fine, just boring :) .

wagoodman avatar Feb 02 '18 17:02 wagoodman

I didn't even know it's possible to include two binaries with different targeted OS's in one bundle.

amir20 avatar Feb 02 '18 19:02 amir20

thats because I'm cheating: https://github.com/wagoodman/bashful/blob/master/main.go#L147

A 'bundle' in this case is just a shell script with a tar concatenated with it. The tar has bashful and other used files. The bash script knows how to separate itself from the tar, untar the tar, and run bashful. Kinda a weird solution but ends up being a powerfully simple way to 'just get a single "executable" ' from a collection of scripts.

The fix here would be to update this self-extracting bash script to be platform aware and use the right copy of bashful in the process.

wagoodman avatar Feb 02 '18 19:02 wagoodman

That’s pretty cool. I didn’t know that’s possible. In the past, I have just used go releaser to create one file per distro. The only down side was a more complicated read me file for installing. Are there any other advantages to bundling everything in one tar?

amir20 avatar Feb 03 '18 00:02 amir20