Being able to run custom `go build` command #28

Closed
jingweno opened this Issue Dec 2, 2013 · 7 comments

Comments

Projects
None yet
3 participants
@jingweno

jingweno commented Dec 2, 2013

I'm using godep to manage dependency. But it requires me to run godep go build to build with my dependencies managed. I'm wondering if it makes sense to being able to run that as part of the goxc build.

Thanks,
Owen

@laher

This comment has been minimized.

Show comment
Hide comment
@laher

laher Dec 3, 2013

Owner

Hi Jingweno, that sounds do-able, I guess I could make a PrependGoCommand setting, but i'm just looking at the source code and so far it looks like godep is simply prepending a 'Godeps/_workspace' dir to the GOPATH variable.

So, I'm wondering if it's enough to do that instead. What do you think?

goxc already allows you to set env variables, as follows (on Unix):
goxc -env GOPATH=Godeps/_workspace:$GOPATH

If you wanted to store this setting for future invocations, I would use -wlc rather than -wc, because the variable gets expanded to a host-specific GOPATH string.
goxc -wlc -env GOPATH=Godeps/_workspace:$GOPATH

What do you think? Does it work for you? Is this sufficient?
Cheers

Owner

laher commented Dec 3, 2013

Hi Jingweno, that sounds do-able, I guess I could make a PrependGoCommand setting, but i'm just looking at the source code and so far it looks like godep is simply prepending a 'Godeps/_workspace' dir to the GOPATH variable.

So, I'm wondering if it's enough to do that instead. What do you think?

goxc already allows you to set env variables, as follows (on Unix):
goxc -env GOPATH=Godeps/_workspace:$GOPATH

If you wanted to store this setting for future invocations, I would use -wlc rather than -wc, because the variable gets expanded to a host-specific GOPATH string.
goxc -wlc -env GOPATH=Godeps/_workspace:$GOPATH

What do you think? Does it work for you? Is this sufficient?
Cheers

@jingweno

This comment has been minimized.

Show comment
Hide comment
@jingweno

jingweno Dec 18, 2013

Sorry for the late reply. The approach on appending the godep to GOPATH works. But I found that using json setting doesn't work. I ended up setting GOPATH through env var directly.

Sorry for the late reply. The approach on appending the godep to GOPATH works. But I found that using json setting doesn't work. I ended up setting GOPATH through env var directly.

@laher

This comment has been minimized.

Show comment
Hide comment
@laher

laher Dec 19, 2013

Owner

OK. Maybe a good compromise would be to make each Env variable into a text/template template, that way you could have cross-platform Separators, PathSeparators, and other env variables.

e.g.

 "GOPATH=.{{.FS}}Godeps{{.FS}}_workspace{{.PS}}{{.Env.GOPATH}}"

I'll work on it & let you know .. I think the Env json setting is pretty hopeless without it.

Owner

laher commented Dec 19, 2013

OK. Maybe a good compromise would be to make each Env variable into a text/template template, that way you could have cross-platform Separators, PathSeparators, and other env variables.

e.g.

 "GOPATH=.{{.FS}}Godeps{{.FS}}_workspace{{.PS}}{{.Env.GOPATH}}"

I'll work on it & let you know .. I think the Env json setting is pretty hopeless without it.

@laher

This comment has been minimized.

Show comment
Hide comment
@laher

laher Dec 21, 2013

Owner

Hi Owen, I've implemented the text/template support.

Here's an example, as used in my own .goxc.json file:

     "Env": [
            "GOPATH=Godeps{{.PLS}}{{.Env.GOPATH}}"
    ]

I figured this format would enable to support all platforms and would help prevent platform-specific values from creeping in via -env commandline flags.

The only variables available initially are .PLS (PathListSeparator), .PS (PathSeparator), and .Env.* (all the environment variables in the current environment).

Please get latest and let me know if it's any use to you, or not.

Rgds,

Owner

laher commented Dec 21, 2013

Hi Owen, I've implemented the text/template support.

Here's an example, as used in my own .goxc.json file:

     "Env": [
            "GOPATH=Godeps{{.PLS}}{{.Env.GOPATH}}"
    ]

I figured this format would enable to support all platforms and would help prevent platform-specific values from creeping in via -env commandline flags.

The only variables available initially are .PLS (PathListSeparator), .PS (PathSeparator), and .Env.* (all the environment variables in the current environment).

Please get latest and let me know if it's any use to you, or not.

Rgds,

@laher

This comment has been minimized.

Show comment
Hide comment
@laher

laher Dec 21, 2013

Owner

Oh I just realised that the example should include the _workspace folder, i.e.

    "Env": [
        "GOPATH=Godeps{{.PS}}_workspace{{.PLS}}{{.Env.GOPATH}}"
    ]
Owner

laher commented Dec 21, 2013

Oh I just realised that the example should include the _workspace folder, i.e.

    "Env": [
        "GOPATH=Godeps{{.PS}}_workspace{{.PLS}}{{.Env.GOPATH}}"
    ]
@brycekahle

This comment has been minimized.

Show comment
Hide comment
@brycekahle

brycekahle Sep 12, 2014

This ended up working for me

"Env": [
        "GOPATH={{.Env.PWD}}{{.PS}}Godeps{{.PS}}_workspace{{.PLS}}{{.Env.GOPATH}}"
    ]

This ended up working for me

"Env": [
        "GOPATH={{.Env.PWD}}{{.PS}}Godeps{{.PS}}_workspace{{.PLS}}{{.Env.GOPATH}}"
    ]
@laher

This comment has been minimized.

Show comment
Hide comment
@laher

laher Feb 1, 2015

Owner

Closing after long time without response from reporter.

Owner

laher commented Feb 1, 2015

Closing after long time without response from reporter.

@laher laher closed this Feb 1, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment