Skip to content

Commit

Permalink
构建二进制
Browse files Browse the repository at this point in the history
  • Loading branch information
ying32 committed May 10, 2019
1 parent 592e2d0 commit 404c5fb
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 16 deletions.
1 change: 1 addition & 0 deletions build/build-darwin32-GUI.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ echo Compiling 32-bit rproxy GUI...

# 根据你的实际情况修改这里
export GOROOT=$HOME/godev/go
export GOPATH=$HOME/godev/gosrc
export PATH=$GOROOT/bin:$PATH

export GOARCH=386
Expand Down
1 change: 1 addition & 0 deletions build/build-darwin32.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ echo Compiling 32-bit rproxy...

# 根据你的实际情况修改这里
export GOROOT=$HOME/godev/go
export GOPATH=$HOME/godev/gosrc
export PATH=$GOROOT/bin:$PATH

export GOARCH=386
Expand Down
1 change: 1 addition & 0 deletions build/build-darwin64-GUI.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ echo Compiling 64-bit rproxy GUI...

# 根据你的实际情况修改这里
export GOROOT=$HOME/godev/go
export GOPATH=$HOME/godev/gosrc
export PATH=$GOROOT/bin:$PATH

export GOARCH=amd64
Expand Down
1 change: 1 addition & 0 deletions build/build-darwin64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ echo Compiling 64-bit rproxy...

# 根据你的实际情况修改这里
export GOROOT=$HOME/godev/go
export GOPATH=$HOME/godev/gosrc
export PATH=$GOROOT/bin:$PATH

export GOARCH=amd64
Expand Down
34 changes: 20 additions & 14 deletions build/rpbuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ func darwinPkg() {

fmt.Println("编译rproxy-darwin64")
if executeBash("build-darwin64.sh") == nil {
fmt.Println("打包rproxy-darwin")
createZipFile("rproxy-darwin.zip", false)
fmt.Println("打包rproxy-darwin64")
createZipFile("rproxy-darwin64.zip", false)
}
fmt.Println("------------------------------")

fmt.Println("编译rproxy-darwin32-GUI")
if executeBash("build-darwin32-GUI.sh") == nil {
fmt.Println("打包rproxy-darwin32-GUI")
createZipFile("rproxy-win32-GUI.zip", true)
createZipFile("rproxy-darwin32-GUI.zip", true, true)
}
fmt.Println("------------------------------")

Expand Down Expand Up @@ -125,7 +125,7 @@ func executeBash(fileName string) error {
return err
}

func createZipFile(zipFileName string, isGUI bool) error {
func createZipFile(zipFileName string, isGUI bool, isDarwin32 ...bool) error {
f, err := os.Create(zipFileName)
if err != nil {
return err
Expand Down Expand Up @@ -179,7 +179,11 @@ func createZipFile(zipFileName string, isGUI bool) error {
if isGUI {
fnSuffix = "_GUI"
}
compressFile("../rproxy"+fnSuffix+exeExt, "rproxy"+exeExt)

if len(isDarwin32) == 0 {
compressFile("../rproxy"+fnSuffix+exeExt, "rproxy"+exeExt)
}

// 复制动态链接库
if isGUI {
switch runtime.GOOS {
Expand All @@ -195,15 +199,16 @@ func createZipFile(zipFileName string, isGUI bool) error {
compressFile("/usr/lib/liblcl.so", "")
}
case "darwin":
if runtime.GOARCH == "386" {
// 产生一个app
pkgMacOSApp("../rproxy_GUI")
compressFile("./rproxy.app/Contents/PkgInfo", "rproxy.app/Contents/PkgInfo")
compressFile("./rproxy.app/Contents/Info.plist", "rproxy.app/Contents/Info.plist")
compressFile("./rproxy.app/Contents/Resources/rproxy.icns", "rproxy.app/Contents/Resources/rproxy.icns")
compressFile("./rproxy.app/Contents/MacOS/rproxy", "rproxy.app/Contents/MacOS/rproxy")
compressFile("./rproxy.app/Contents/MacOS/liblcl.dylib", "rproxy.app/Contents/MacOS/liblcl.dylib")
}

// 产生一个app
pkgMacOSApp("../rproxy_GUI")

compressFile("./rproxy.app/Contents/PkgInfo", "rproxy.app/Contents/PkgInfo")
compressFile("./rproxy.app/Contents/Info.plist", "rproxy.app/Contents/Info.plist")
compressFile("./rproxy.app/Contents/Resources/rproxy.icns", "rproxy.app/Contents/Resources/rproxy.icns")
compressFile("./rproxy.app/Contents/MacOS/rproxy", "rproxy.app/Contents/MacOS/rproxy")
compressFile("./rproxy.app/Contents/MacOS/liblcl.dylib", "rproxy.app/Contents/MacOS/liblcl.dylib")

}
}

Expand Down Expand Up @@ -348,6 +353,7 @@ func pkgMacOSApp(exeFileName string) error {
}

copyFile(exeFileName, execFile)
os.Chmod(execFile, 0755)

return nil
}
File renamed without changes.
Binary file modified imgs/rproxy.icns
Binary file not shown.
Binary file added imgs/rproxy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions main_gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ package main

import (
"github.com/ying32/govcl/vcl"
"github.com/ying32/govcl/vcl/exts/tools"
//"github.com/ying32/govcl/vcl/exts/tools"
)

// GUI模式下暂时只能是客户端,服务端依然使用命令行。
// 另外如果更新了MainForm.go或者MainFormImpl.go需要在前面补充自定义标题 // +build gui
func main() {
tools.RunWithMacOSApp()
//tools.RunWithMacOSApp()
vcl.Application.SetFormScaled(true)
vcl.Application.Initialize()
vcl.Application.SetMainFormOnTaskBar(true)
Expand Down

0 comments on commit 404c5fb

Please sign in to comment.