diff --git a/main/BUILD b/main/BUILD new file mode 100644 index 000000000..cdcbd0c1f --- /dev/null +++ b/main/BUILD @@ -0,0 +1,8 @@ +load("@v2ray_ext//bazel:build.bzl", "foreign_go_binary") +load("@v2ray_ext//bazel:gpg.bzl", "gpg_sign") +load("@v2ray_ext//bazel:matrix.bzl", "SUPPORTED_MATRIX") +load("//main:targets.bzl", "gen_targets") + +package(default_visibility=["//visibility:public"]) + +gen_targets(SUPPORTED_MATRIX) diff --git a/main/targets.bzl b/main/targets.bzl new file mode 100644 index 000000000..cd15666b5 --- /dev/null +++ b/main/targets.bzl @@ -0,0 +1,69 @@ +load("@v2ray_ext//bazel:build.bzl", "foreign_go_binary") +load("@v2ray_ext//bazel:gpg.bzl", "gpg_sign") + +def gen_targets(matrix): + pkg = "v2ray.com/core/main" + output = "v2ray" + + for (os, arch) in matrix: + bin_name = "v2ray_" + os + "_" + arch + foreign_go_binary( + name = bin_name, + pkg = pkg, + output = output, + os = os, + arch = arch, + ) + + gpg_sign( + name = bin_name + "_sig", + base = ":" + bin_name, + ) + + if os in ["windows"]: + bin_name = "v2ray_" + os + "_" + arch + "_nowindow" + foreign_go_binary( + name = bin_name, + pkg = pkg, + output = "w" + output, + os = os, + arch = arch, + ld = "-H windowsgui", + ) + + gpg_sign( + name = bin_name + "_sig", + base = ":" + bin_name, + ) + + if arch in ["mips", "mipsle"]: + bin_name = "v2ray_" + os + "_" + arch + "_softfloat" + foreign_go_binary( + name = bin_name, + pkg = pkg, + output = output+"_softfloat", + os = os, + arch = arch, + mips = "softfloat", + ) + + gpg_sign( + name = bin_name + "_sig", + base = ":" + bin_name, + ) + + if arch in ["arm"]: + bin_name = "v2ray_" + os + "_" + arch + "_armv7" + foreign_go_binary( + name = bin_name, + pkg = pkg, + output = output+"_armv7", + os = os, + arch = arch, + arm = "7", + ) + + gpg_sign( + name = bin_name + "_sig", + base = ":" + bin_name, + ) diff --git a/release/BUILD b/release/BUILD index 86b661dbe..a9a3a075c 100644 --- a/release/BUILD +++ b/release/BUILD @@ -1,21 +1,6 @@ package(default_visibility=["//visibility:public"]) -load("@v2ray_ext//bazel:build.bzl", "foreign_go_binary") load("@v2ray_ext//bazel:zip.bzl", "pkg_zip") -load("@v2ray_ext//bazel:gpg.bzl", "gpg_sign") - -foreign_go_binary( - name = "v2ray_linux_amd64", - pkg = "v2ray.com/core/main", - output = "v2ray", - os = "linux", - arch = "amd64", -) - -gpg_sign( - name = "v2ray_linux_amd64_sig", - base = ":v2ray_linux_amd64", -) filegroup( name = "config_json", @@ -42,11 +27,57 @@ filegroup( srcs = ["config/geoip.dat", "config/geosite.dat"], ) +pkg_zip( + name = "v2ray_darwin_amd64_package", + srcs = [ + "//main:v2ray_darwin_amd64", + "//main:v2ray_darwin_amd64_sig", + "@v2ray_ext//tools/control/main:v2ctl_darwin_amd64", + "@v2ray_ext//tools/control/main:v2ctl_darwin_amd64_sig", + ":config_json", + ":doc", + ":geodata", + ], + out = "v2ray-macos-64.zip", +) + +pkg_zip( + name = "v2ray_windows_amd64_package", + srcs = [ + "//main:v2ray_windows_amd64", + "//main:v2ray_lwindows_amd64_sig", + "//main:v2ray_windows_amd64_nowindow", + "//main:v2ray_lwindows_amd64_nowindow_sig", + "@v2ray_ext//tools/control/main:v2ctl_windows_amd64", + "@v2ray_ext//tools/control/main:v2ctl_windows_amd64_sig", + ":config_json", + ":doc", + ":geodata", + ], + out = "v2ray-windows-64.zip", +) + +pkg_zip( + name = "v2ray_windows_x86_package", + srcs = [ + "//main:v2ray_windows_x86", + "//main:v2ray_windows_x86_sig", + "//main:v2ray_windows_x86_nowindow", + "//main:v2ray_windows_x86_nowindow_sig", + "@v2ray_ext//tools/control/main:v2ctl_windows_x86", + "@v2ray_ext//tools/control/main:v2ctl_windows_x86_sig", + ":config_json", + ":doc", + ":geodata", + ], + out = "v2ray-windows-32.zip", +) + pkg_zip( name = "v2ray_linux_amd64_package", srcs = [ - ":v2ray_linux_amd64", - ":v2ray_linux_amd64_sig", + "//main:v2ray_linux_amd64", + "//main:v2ray_linux_amd64_sig", "@v2ray_ext//tools/control/main:v2ctl_linux_amd64", "@v2ray_ext//tools/control/main:v2ctl_linux_amd64_sig", ":config_all", @@ -56,3 +87,18 @@ pkg_zip( ], out = "v2ray-linux-64.zip", ) + +pkg_zip( + name = "v2ray_linux_x86_package", + srcs = [ + "//main:v2ray_linux_x86", + "//main:v2ray_linux_x86_sig", + "@v2ray_ext//tools/control/main:v2ctl_linux_x86", + "@v2ray_ext//tools/control/main:v2ctl_linux_x86_sig", + ":config_all", + ":systemd", + ":doc", + ":geodata", + ], + out = "v2ray-linux-32.zip", +)