-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build: End of the easily mistaken 'Makefile' #4395
Conversation
感谢!-buildvcs=false 这个放哪里比较合适,还有 -ldflags 能加等号吗 |
可以,不过很少见,多出现在环境上面不加等号可能会有奇怪问题的时候
现在看看放在 -trimpath 前后或者 -v 前面都可以 |
-buildvcs=false 放在 -trimpath 和 -ldflags 中间比较好,ldflags 太长的话后面的东西太容易忽略了 |
我也是这么想的 Win7 的 buildvcs 忘改位置了 Build Xray... 改为 Building 比较好 |
如果没有其它改动大概就可以合入了 :) go-win7 已经发了 1.24 的包,设置为了 pre-release 避免被 release-win7 自动下载(latest 为 1.23.6) 目前 1.24 仍可以用交叉编译的方式编译 Windows ARM32 的二进制,但是不知道能不能正常使用(没有设备),可能在某个时间点会被 Go 移除支持 (影响 WinRT、Win10 的 ARM32 版本,Windows ARM64 版本不受影响) |
因为之前所用的 makefile 自带被误会光环以至于出了一些问题(版本空包及被不明所以修改),现在如 #4384 (comment) 所言,将自动构建用的编译整合回回 Actions。(兜兜转转又回来了)
现在 reproducible 需要 Go 版本一致、源代码没有缺损、Go 相关的环境变量一致(
GOOS
、GOARCH
以及GOARCH
相关的变量)、没有开启 CGO(CGO_ENABLED=0
),且:git describe --always --dirty
获取COMMID
.git
损坏的情况下,需要将COMMID
手动设置为对应的 commit ID${COMMID}
)然后执行:
go build -o xray -trimpath -buildvcs=false -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
go build -o xray.exe -trimpath -buildvcs=false -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
(用于编译 Windows 版本)如果不需要设置
COMMID
,则使用以下命令编译,编译后二进制显示版本时原来为 commit ID 的区域则由Custom
代替。go build -o xray -trimpath -buildvcs=false -ldflags="-s -w -buildid=" -v ./main
go build -o xray.exe -trimpath -buildvcs=false -ldflags="-s -w -buildid=" -v ./main
(用于编译 Windows 版本)另外现在根据 #4384 (comment) ,不再提供 wxray.exe,而是在向 Windows 提供的版本中附带 xray_no_window.vbs (#28 (comment)) 及 xray_no_window.ps1 (#28 (comment)) 代替。如果仍在自行编译时需要完全无窗口无 conhost.exe 的版本,请用以下命令(
GOOS=windows
):go build -o wxray.exe -trimpath -buildvcs=false -ldflags="-H windowsgui -X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
(已设置COMMID
)go build -o wxray.exe -trimpath -buildvcs=false -ldflags="-H windowsgui -s -w -buildid=" -v ./main
(不需要COMMID
)如果需要修改 xray_no_window 中的运行参数:
-config config.json
部分-ArgumentList "-config ./config.json"
中引号内的部分。另外使用 ps1 应如此执行:powershell.exe -ExecutionPolicy Bypass -File "<path-to-the script>\xray_no_window.ps1"
另外:如果仍需要提供 makefile 或者 shell script 编译,这些内容仅会提供最低支持,因为核心编译命令只有一行,其余大部分是下载依赖及分包之类的内容。