-
Notifications
You must be signed in to change notification settings - Fork 69
Using xgo for cross compiling #18
base: master
Are you sure you want to change the base?
Conversation
|
@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:
type ConfigurationBuilder struct {
Name string `json:"name"`
XGO ConfigurationXGO `json:"xgo"`
}
type ConfigurationXGO struct {
Deps []string `json:"deps"`
}
type builder interface {
Cmd(os, arch string, l ldflags) *exec.Cmd
Finish() error
}Basically, in the case of return exec.Command("xgo", "--deps", strings.Join(b.xgo.Deps, " "), "--targets", e.OS+"/"+e.Arch, "--dest", environmentPath, "--out", binaryName, "-ldflags", l.string(), b.pathInput)And the astilog.Debug("Searching for binary produced by xgo")
// Search for file binary
// xgo names output files by himself. The only option we can set is prefix. So we must find file with such prefix
var files []os.FileInfo
files, err = ioutil.ReadDir(environmentPath)
if err != nil {
err = errors.Wrapf(err, "unable to find binary: %s", binaryName)
return
}
for _, f := range files {
if strings.HasPrefix(f.Name(), binaryName) {
binaryPath = filepath.Join(environmentPath, f.Name())
astilog.Debugf("Found binary produced by xgo - %s", binaryPath)
break
}
}
That way, we'll be able to add more builder in the future. And if someone wants to use {
"builder": {
"name": "xgo",
"xgo": {
"deps": ["https://gmplib.org/download/gmp/gmp-6.0.0a.tar.bz2"]
}
}
}What do you think? |
|
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 |
|
We could store builder config like And then in |
|
Adding a However, regarding the configuration, I would create the type ConfigurationBuilder struct {
Custom json.RawMessage `json:"custom"`
Name string `json:"name"`
}Then I would add a method func ParseConfig(b json.RawMessage) error {
var v myAwewomeStruct
json.Unmarshal(b, &v)
}What do you think? |
|
@vidmed did you have time to work on this PR? |
|
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! |
|
@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. |
|
@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. |
This PR for #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.jsonTo install and/or update xgo, simply type:
go get -u github.com/karalabe/xgoYou can test whether xgo is functioning correctly by requesting it to cross compile itself and verifying that all cross compilations succeeded or not.