Skip to content

Commit 77093ee

Browse files
committed
use cpu baseline
1 parent 5a18c84 commit 77093ee

4 files changed

Lines changed: 13 additions & 47 deletions

File tree

.github/build-release.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ targets=(
2525
# "aarch64-macos"
2626
"x86_64-macos"
2727
"x86_64-windows"
28+
"aarch64-windows"
2829
)
2930

3031
export BUILD_DATE=$(date +'%Y-%m-%dT%H:%M:%S%z')
@@ -36,8 +37,9 @@ for target in "${targets[@]}"; do
3637
dst_dir=zig-out/${filename}
3738

3839
# 1. Build
40+
# baseline is required, see https://github.com/jiacai2050/zigcli/issues/43
3941
zig build -Doptimize=ReleaseSafe -Dtarget="${target}" -p ${dst_dir} \
40-
-Dvendor-libcurl=true -Dgit_commit=${GIT_COMMIT} -Dbuild_date=${BUILD_DATE}
42+
-Dcpu=baseline -Dgit_commit=${GIT_COMMIT} -Dbuild_date=${BUILD_DATE}
4143

4244
# 2. Prepare files
4345
rm -f ${dst_dir}/bin/*demo

.github/workflows/CI.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ jobs:
4343
zig.exe fmt --check .
4444
zig.exe build test
4545
zig.exe build
46-
- name: deps(ubuntu)
47-
if: matrix.os == 'ubuntu-latest'
48-
run: |
49-
sudo apt update && sudo apt-get install -y libcurl4-openssl-dev
5046
- name: fmt and test(unix)
5147
if: matrix.os != 'windows-latest'
5248
run: |
@@ -72,10 +68,6 @@ jobs:
7268
- uses: mlugg/setup-zig@v1
7369
with:
7470
version: 0.14.0
75-
- name: deps(ubuntu)
76-
if: matrix.os == 'ubuntu-latest'
77-
run: |
78-
sudo apt update && sudo apt-get install -y libcurl4-openssl-dev
7971
- name: Build
8072
run: |
81-
zig build -Dtarget=${{ matrix.targets }} -Dskip-zigfetch=true
73+
zig build -Dtarget=${{ matrix.targets }}

.github/workflows/release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ jobs:
5151
- name: Build(Ubuntu)
5252
if: matrix.os == 'ubuntu-latest'
5353
run: |
54-
sudo apt update && sudo apt-get install -y libcurl4-openssl-dev
5554
bash .github/build-release.sh
5655
- name: Build(MacOS)
5756
if: matrix.os == 'macos-latest'

build.zig

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ const macos_private_framework = "/Applications/Xcode.app/Contents/Developer/Plat
66
pub fn build(b: *Build) !void {
77
const optimize = b.standardOptimizeOption(.{});
88
const target = b.standardTargetOptions(.{});
9-
const skip_zigfetch = b.option(bool, "skip-zigfetch", "Skip zig fetch") orelse false;
10-
const vendor_libcurl = b.option(bool, "vendor-libcurl", "Static link libcurl") orelse false;
119
var all_tests = std.ArrayList(*Build.Step).init(b.allocator);
1210

1311
try addModules(b, target, optimize, &all_tests);
14-
try buildBinaries(b, optimize, target, &all_tests, skip_zigfetch, vendor_libcurl);
12+
try buildBinaries(b, optimize, target, &all_tests);
1513
try buildExamples(b, optimize, target, &all_tests);
1614

1715
const test_all_step = b.step("test", "Run all tests");
@@ -102,7 +100,7 @@ fn buildExamples(
102100
"simargs-demo",
103101
"pretty-table-demo",
104102
}) |name| {
105-
try buildBinary(b, .{ .ex = name }, optimize, target, all_tests, false, false);
103+
try buildBinary(b, .{ .ex = name }, optimize, target, all_tests);
106104
}
107105
}
108106

@@ -111,8 +109,6 @@ fn buildBinaries(
111109
optimize: std.builtin.Mode,
112110
target: std.Build.ResolvedTarget,
113111
all_tests: *std.ArrayList(*Build.Step),
114-
skip_zigfetch: bool,
115-
vendor_libcurl: bool,
116112
) !void {
117113
inline for (.{
118114
"zigfetch",
@@ -132,8 +128,6 @@ fn buildBinaries(
132128
optimize,
133129
target,
134130
all_tests,
135-
skip_zigfetch,
136-
vendor_libcurl,
137131
);
138132
}
139133

@@ -147,16 +141,12 @@ fn buildBinary(
147141
optimize: std.builtin.Mode,
148142
target: std.Build.ResolvedTarget,
149143
all_tests: *std.ArrayList(*Build.Step),
150-
skip_zigfetch: bool,
151-
vendor_libcurl: bool,
152144
) !void {
153145
if (makeCompileStep(
154146
b,
155147
source,
156148
optimize,
157149
target,
158-
skip_zigfetch,
159-
vendor_libcurl,
160150
)) |exe| {
161151
var deps = b.modules.iterator();
162152
while (deps.next()) |dep| {
@@ -200,8 +190,6 @@ fn makeCompileStep(
200190
comptime source: Source,
201191
optimize: std.builtin.Mode,
202192
target: std.Build.ResolvedTarget,
203-
skip_zigfetch: bool,
204-
vendor_libcurl: bool,
205193
) ?*Build.Step.Compile {
206194
const name = comptime source.name();
207195
const path = comptime source.path();
@@ -236,28 +224,13 @@ fn makeCompileStep(
236224
}
237225
exe.linkLibC();
238226
} else if (std.mem.eql(u8, name, "zigfetch")) {
239-
if (skip_zigfetch) {
240-
return null;
241-
}
242-
const host_os = @import("builtin").os.tag;
243-
const build_os = target.result.os.tag;
244-
if (host_os != build_os) { // don't support cross compile
245-
return null;
246-
}
247-
if (host_os == .linux or host_os == .macos) {
248-
const dep_curl = b.dependency("curl", .{
249-
.link_vendor = vendor_libcurl,
250-
.target = target,
251-
.optimize = optimize,
252-
});
253-
if (!vendor_libcurl) {
254-
exe.linkSystemLibrary("curl");
255-
}
256-
exe.root_module.addImport("curl", dep_curl.module("curl"));
257-
exe.linkLibC();
258-
} else {
259-
return null;
260-
}
227+
const dep_curl = b.dependency("curl", .{
228+
.link_vendor = true,
229+
.target = target,
230+
.optimize = optimize,
231+
});
232+
exe.root_module.addImport("curl", dep_curl.module("curl"));
233+
exe.linkLibC();
261234
} else if (std.mem.eql(u8, name, "pidof")) {
262235
// only build for macOS
263236
if (is_darwin) {

0 commit comments

Comments
 (0)