asticode / go-astilectron-bundler

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

ldflags parameters not work in package out of GOPATH #29

Closed Grayon closed 6 years ago

Grayon commented 6 years ago

b.pathBuild is empty when package not in GOPATH ldflags seems not work, AppName and BuiltAt value not set. I set b.pathBuild = "." to fix this

I'm using macOS and go1.10.3

asticode commented 6 years ago

@Grayon could you paste the logs when you execute the bundler with the -v flag? I want to see what's executed exactly.

Grayon commented 6 years ago

DEBU[0000] Creating /Users/gonner/Documents/workspace/Project-PC/output DEBU[0000] Bundling for environment darwin/amd64
DEBU[0000] Binding data
DEBU[0000] Removing /var/folders/98/3d_qcs593c3c0zxdm0t6b5xm0000gn/T/astibundler/bind DEBU[0000] Creating /var/folders/98/3d_qcs593c3c0zxdm0t6b5xm0000gn/T/astibundler/bind DEBU[0000] Creating /var/folders/98/3d_qcs593c3c0zxdm0t6b5xm0000gn/T/astibundler/bind/vendor_astilectron_bundler DEBU[0000] Creating /var/folders/98/3d_qcs593c3c0zxdm0t6b5xm0000gn/T/astibundler/cache DEBU[0000] /var/folders/98/3d_qcs593c3c0zxdm0t6b5xm0000gn/T/astibundler/cache/astilectron-0.24.0.zip already exists, skipping download of https://github.com/asticode/astilectron/archive/v0.24.0.zip DEBU[0000] Copying /var/folders/98/3d_qcs593c3c0zxdm0t6b5xm0000gn/T/astibundler/cache/astilectron-0.24.0.zip to /var/folders/98/3d_qcs593c3c0zxdm0t6b5xm0000gn/T/astibundler/bind/vendor_astilectron_bundler/astilectron.zip DEBU[0000] /var/folders/98/3d_qcs593c3c0zxdm0t6b5xm0000gn/T/astibundler/cache/electron-darwin-amd64-1.8.1.zip already exists, skipping download of https://github.com/electron/electron/releases/download/v1.8.1/electron-v1.8.1-darwin-x64.zip DEBU[0000] Copying /var/folders/98/3d_qcs593c3c0zxdm0t6b5xm0000gn/T/astibundler/cache/electron-darwin-amd64-1.8.1.zip to /var/folders/98/3d_qcs593c3c0zxdm0t6b5xm0000gn/T/astibundler/bind/vendor_astilectron_bundler/electron.zip DEBU[0000] Creating /var/folders/98/3d_qcs593c3c0zxdm0t6b5xm0000gn/T/astibundler/bind/resources DEBU[0000] Copying /Users/gonner/Documents/workspace/Project-PC/resources to /var/folders/98/3d_qcs593c3c0zxdm0t6b5xm0000gn/T/astibundler/bind/resources DEBU[0000] Generating /Users/gonner/Documents/workspace/Project-PC/bind_darwin_amd64.go DEBU[0002] Removing /Users/gonner/Documents/workspace/Project-PC/output/darwin-amd64 DEBU[0002] Creating /Users/gonner/Documents/workspace/Project-PC/output/darwin-amd64 DEBU[0002] Building for os darwin and arch amd64
DEBU[0002] Executing go build -ldflags -s -X "main.AppName=Project" -X "main.BuiltAt=2018-07-27 17:41:08.789166528 +0800 CST m=+2.012625758" -o /Users/gonner/Documents/workspace/Project-PC/output/darwin-amd64/binary
DEBU[0008] Creating /Users/gonner/Documents/workspace/Project-PC/output/darwin-amd64/Project.app/Contents/MacOS DEBU[0008] Moving /Users/gonner/Documents/workspace/Project-PC/output/darwin-amd64/binary to /Users/gonner/Documents/workspace/Project-PC/output/darwin-amd64/Project.app/Contents/MacOS/Project DEBU[0008] Chmoding /Users/gonner/Documents/workspace/Project-PC/output/darwin-amd64/Project.app/Contents/MacOS/Project DEBU[0008] Creating /Users/gonner/Documents/workspace/Project-PC/output/darwin-amd64/Project.app/Contents/Resources DEBU[0008] Copying /Users/gonner/Documents/workspace/Project-PC/resources/icon.icns to /Users/gonner/Documents/workspace/Project-PC/output/darwin-amd64/Project.app/Contents/Resources/Project.icns DEBU[0008] Adding Info.plist to /Users/gonner/Documents/workspace/Project-PC/output/darwin-amd64/Project.app/Contents/Info.plist

go build -ldflags '-s -X "main.AppName=Project" -X "main.BuiltAt=2018-07-27 17:41:08.789166528 +0800 CST m=+2.012625758"' -o /Users/gonner/Documents/workspace/Project-PC/output/darwin-amd64/binary

this line works fine on command line

asticode commented 6 years ago

@Grayon I don't see any problem in the logs. What's your problem again ?

Grayon commented 6 years ago
var (
    AppName string
    BuiltAt string
)

These two variables are empty.

asticode commented 6 years ago

@Grayon I have pushed a fix in master. You can pull the changes and run make again.

Does that fix your issue?

One additional question though : how do you manage to build in GO without a GOPATH?

Grayon commented 6 years ago

my GOPATH is /Users/gonner/go and my project is in /Users/gonner/Documents/workspace/Project-PC I just use go build to build it.

And YES that fix my problem.

asticode commented 6 years ago

Cheers