asticode / go-astilectron-bundler

Bundle your Astilectron app with ease
MIT License
129 stars 68 forks source link

Using xgo for cross compiling #18

Open vidmed opened 6 years ago

vidmed commented 6 years ago

This PR for https://github.com/asticode/go-astilectron-bundler/issues/17 To build your app using xgo you should add "xgo": { "enabled": true, "deps": ["https://gmplib.org/download/gmp/gmp-6.0.0a.tar.bz2"] } into your bundler.json

To install and/or update xgo, simply type: go get -u github.com/karalabe/xgo You can test whether xgo is functioning correctly by requesting it to cross compile itself and verifying that all cross compilations succeeded or not.

$ xgo github.com/karalabe/xgo
...

$ ls -al
-rwxr-xr-x  1 root     root      2792436 Sep 14 16:45 xgo-android-21-arm
-rwxr-xr-x  1 root     root      2353212 Sep 14 16:45 xgo-darwin-386
-rwxr-xr-x  1 root     root      2906128 Sep 14 16:45 xgo-darwin-amd64
-rwxr-xr-x  1 root     root      2388288 Sep 14 16:45 xgo-linux-386
-rwxr-xr-x  1 root     root      2960560 Sep 14 16:45 xgo-linux-amd64
-rwxr-xr-x  1 root     root      2437864 Sep 14 16:45 xgo-linux-arm
-rwxr-xr-x  1 root     root      2551808 Sep 14 16:45 xgo-windows-386.exe
-rwxr-xr-x  1 root     root      3130368 Sep 14 16:45 xgo-windows-amd64.exe
asticode commented 6 years ago

@vidmed I don't feel the way it's done right now would allow adding more build tools in the future. Here's what I have in mind:

That way, we'll be able to add more builder in the future.

And if someone wants to use xgo, he/she can use the following configuration:

{
  "builder": {
    "name": "xgo",
    "xgo": {
      "deps": ["https://gmplib.org/download/gmp/gmp-6.0.0a.tar.bz2"]
    }
  }
}

What do you think?

vidmed commented 6 years ago

Actually, I haven't even thought about extending builders. Your idea is quite reasonable. But! Your approach won't allow developers to extend builders via registering their own ones. So I'd like to have an opportunity to register builders using something like func RegisterBuilder(name sting, b Builder){ KnownBuilders[name] } But there is a problem. For custom builders there might be some custom configuration. For example as for xgo deps. And that is a bad idea to store xgo configuration in ConfigurationBuilder. We have to come up with storing custom config for builder in some way. Do you have any ideas? I hope I explained my thoughts clearly.

vidmed commented 6 years ago

We could store builder config like

type ConfigurationBuilder struct {
    Name string `json:"name"`
   Config map[string]interface{} `json:"config"`
}

And then in Cmd method parse config. Also this method have to return error if parsing or something else went wrong. What do you think?

asticode commented 6 years ago

Adding a RegisterBuilder method sounds like a good idea to me. Please store the builders in an unexported map protected by a mutex.

However, regarding the configuration, I would create the ConfigurationBuilder type like this:

type ConfigurationBuilder struct {
    Custom json.RawMessage `json:"custom"`
    Name string `json:"name"`
}

Then I would add a method ParseConfig(b json.RawMessage) error to the Builder interface. That way, one could implement such a method like this:

func ParseConfig(b json.RawMessage) error {
    var v myAwewomeStruct
    json.Unmarshal(b, &v)
}

What do you think?

asticode commented 6 years ago

@vidmed did you have time to work on this PR?

chinenual commented 4 years ago

Has there been any progress toward support for xgo other than this abandoned pull request? I've come upon a build issue that might be solved by a change to using xgo. I am trying to determine my options...

Thanks!

asticode commented 4 years ago

@chinenual there has been no progress toward supporting xgo apart from that PR.

I'd be happy to review it if you decide to pick it up.

chinenual commented 4 years ago

@asticode OK. I'm currently exploring a different fix (which avoids need for native code/xgo). But I may return to this and work on a PR.