-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
91 lines (80 loc) · 2.57 KB
/
Copy pathbuild.zig
File metadata and controls
91 lines (80 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const std = @import("std");
pub fn build(b: *std.Build) void {
const llvm_project_dir = b.option(
[]const u8,
"llvm-project-dir",
"Path to OpenHarmony third_party_llvm-project checkout",
) orelse getEnv(b, "LLVM_PROJECT_DIR") orelse "vendor/third_party_llvm-project";
const sysroot = b.option(
[]const u8,
"sysroot",
"Path to OHOS native sysroot. If omitted, OHOS_NDK_HOME/OHOS_SDK_HOME is used.",
);
const targets = b.option(
[]const u8,
"targets",
"Comma or space separated OHOS target triples",
) orelse "aarch64-linux-ohos arm-linux-ohoseabi x86_64-linux-ohos";
const llvm_project_ref = b.option(
[]const u8,
"llvm-project-ref",
"OpenHarmony third_party_llvm-project branch, tag, or commit used for archive prefix",
) orelse getEnv(b, "LLVM_PROJECT_REF");
const out_dir = b.option(
[]const u8,
"out-dir",
"Output directory for libatomic artifacts",
) orelse "zig-out";
const profiles = b.option(
[]const u8,
"profiles",
"Comma or space separated profiles to package: debug release",
) orelse "debug release";
const release_optimize = b.option(
std.builtin.OptimizeMode,
"release-optimize",
"Optimize mode for the release profile",
) orelse b.option(
std.builtin.OptimizeMode,
"optimize",
"Alias for -Drelease-optimize",
) orelse .ReleaseSmall;
const archive = b.option(
[]const u8,
"archive",
"Output .tar.gz archive path",
);
const build_cmd = b.addSystemCommand(&.{
"bash",
b.pathFromRoot("scripts/build-libatomic.sh"),
});
build_cmd.addArgs(&.{
"--zig",
b.graph.zig_exe,
"--llvm-project-dir",
llvm_project_dir,
"--targets",
targets,
"--out-dir",
out_dir,
"--profiles",
profiles,
"--release-optimize",
@tagName(release_optimize),
});
if (llvm_project_ref) |value| {
build_cmd.addArgs(&.{ "--llvm-project-ref", value });
}
if (sysroot) |value| {
build_cmd.addArgs(&.{ "--sysroot", value });
}
if (archive) |value| {
build_cmd.addArgs(&.{ "--archive", value });
}
const libatomic_step = b.step("libatomic", "Build and package OHOS libatomic artifacts");
libatomic_step.dependOn(&build_cmd.step);
b.default_step.dependOn(&build_cmd.step);
}
fn getEnv(b: *std.Build, name: []const u8) ?[]const u8 {
return b.graph.environ_map.get(name);
}