From d9d61ed5631cdbde26b62693f233c3473b3ae917 Mon Sep 17 00:00:00 2001
From: Andrew Kelley
Date: Wed, 3 Jan 2018 02:51:45 -0500
Subject: [PATCH 1/8] doc fixes
---
doc/langref.html.in | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/doc/langref.html.in b/doc/langref.html.in
index 84f03e8f84..2682156f5f 100644
--- a/doc/langref.html.in
+++ b/doc/langref.html.in
@@ -34,6 +34,7 @@
- Introduction
- Hello World
+ - Source Encoding
- Values
- Source encoding
+ Source Encoding
Zig source code is encoded in UTF-8. An invalid UTF-8 byte sequence results in a compile error.
Throughout all zig source code (including in comments), some codepoints are never allowed:
@EnumTagType(T: type) -> type
+ @TagType
+ @TagType(T: type) -> type
- Returns the integer type that is used to store the enumeration value.
+ For an enum, returns the integer type that is used to store the enumeration value.
+
+
+ For a union, returns the enum type that is used to store the tag value.
@errorName
@errorName(err: error) -> []u8
From c741d3f4b20d2c4e6972427a0499e0e8841ba6d5 Mon Sep 17 00:00:00 2001
From: Andrew Kelley
Date: Wed, 3 Jan 2018 03:15:06 -0500
Subject: [PATCH 2/8] add test for while respecting implicit comptime
---
test/cases/misc.zig | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/test/cases/misc.zig b/test/cases/misc.zig
index 5d2346507e..0f9201c8e6 100644
--- a/test/cases/misc.zig
+++ b/test/cases/misc.zig
@@ -571,3 +571,9 @@ fn testComptimeIfInsideRuntimeWhileWhichUnconditionallyBreaks(cond: bool) {
break;
}
}
+
+test "implicit comptime while" {
+ while (false) {
+ @compileError("bad");
+ }
+}
From 6281a511e130aeb4f7c777de9b90c60d7c8c6f34 Mon Sep 17 00:00:00 2001
From: Andrew Kelley
Date: Wed, 3 Jan 2018 03:27:48 -0500
Subject: [PATCH 3/8] add noInlineCall to docs
---
doc/langref.html.in | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/doc/langref.html.in b/doc/langref.html.in
index 2682156f5f..d33b143959 100644
--- a/doc/langref.html.in
+++ b/doc/langref.html.in
@@ -158,6 +158,7 @@
@minValue
@mod
@mulWithOverflow
+ @noInlineCall
@offsetOf
@OpaqueType
@panic
@@ -4481,6 +4482,10 @@ fn add(a: i32, b: i32) -> i32 { a + b }
Unlike a normal function call, however, @inlineCall guarantees that the call
will be inlined. If the call cannot be inlined, a compile error is emitted.
+ See also:
+
@intToPtr
@intToPtr(comptime DestType: type, int: usize) -> DestType
@@ -4574,6 +4579,25 @@ mem.set(u8, dest, c);
stores the overflowed bits in result and returns true.
If no overflow or underflow occurs, returns false.
+ @noInlineCall
+ @noInlineCall(function: var, args: ...) -> var
+
+ This calls a function, in the same way that invoking an expression with parentheses does:
+
+ const assert = @import("std").debug.assert;
+test "noinline function call" {
+ assert(@noInlineCall(add, 3, 9) == 12);
+}
+
+fn add(a: i32, b: i32) -> i32 { a + b }
+
+ Unlike a normal function call, however, @noInlineCall guarantees that the call
+ will not be inlined. If the call must be inlined, a compile error is emitted.
+
+ See also:
+
@offsetOf
@offsetOf(comptime T: type, comptime field_name: [] const u8) -> (number literal)
From 36ff26609b1d81a253053e7d7785392fae240dab Mon Sep 17 00:00:00 2001
From: Andrew Kelley
Date: Wed, 3 Jan 2018 04:55:16 -0500
Subject: [PATCH 4/8] fix self hosted compiler on windows
---
build.zig | 43 +++++++++++++++++++++++++++++++------------
src-self-hosted/c.zig | 1 +
src/config.h.in | 2 ++
src/link.cpp | 6 ++++--
src/main.cpp | 2 +-
std/buffer.zig | 9 +++++----
std/os/index.zig | 4 ++--
std/os/path.zig | 8 ++++++++
8 files changed, 54 insertions(+), 21 deletions(-)
diff --git a/build.zig b/build.zig
index 7c0570bf46..9727be0843 100644
--- a/build.zig
+++ b/build.zig
@@ -36,23 +36,33 @@ pub fn build(b: &Builder) {
if (findLLVM(b)) |llvm| {
// find the stage0 build artifacts because we're going to re-use config.h and zig_cpp library
const build_info = b.exec([][]const u8{b.zig_exe, "BUILD_INFO"});
- var build_info_it = mem.split(build_info, "\n");
- const cmake_binary_dir = ??build_info_it.next();
- const cxx_compiler = ??build_info_it.next();
+ var index: usize = 0;
+ const cmake_binary_dir = nextValue(&index, build_info);
+ const cxx_compiler = nextValue(&index, build_info);
+ const lld_include_dir = nextValue(&index, build_info);
+ const lld_libraries = nextValue(&index, build_info);
var exe = b.addExecutable("zig", "src-self-hosted/main.zig");
exe.setBuildMode(mode);
exe.addIncludeDir("src");
exe.addIncludeDir(cmake_binary_dir);
- addCppLib(b, exe, cmake_binary_dir, "libzig_cpp");
- addCppLib(b, exe, cmake_binary_dir, "libembedded_lld_elf");
- addCppLib(b, exe, cmake_binary_dir, "libembedded_lld_coff");
- addCppLib(b, exe, cmake_binary_dir, "libembedded_lld_lib");
+ addCppLib(b, exe, cmake_binary_dir, "zig_cpp");
+ if (lld_include_dir.len != 0) {
+ exe.addIncludeDir(lld_include_dir);
+ var it = mem.split(lld_libraries, ";");
+ while (it.next()) |lib| {
+ exe.addObjectFile(lib);
+ }
+ } else {
+ addCppLib(b, exe, cmake_binary_dir, "embedded_lld_elf");
+ addCppLib(b, exe, cmake_binary_dir, "embedded_lld_coff");
+ addCppLib(b, exe, cmake_binary_dir, "embedded_lld_lib");
+ }
dependOnLib(exe, llvm);
if (!exe.target.isWindows()) {
const libstdcxx_path_padded = b.exec([][]const u8{cxx_compiler, "-print-file-name=libstdc++.a"});
- const libstdcxx_path = ??mem.split(libstdcxx_path_padded, "\n").next();
+ const libstdcxx_path = ??mem.split(libstdcxx_path_padded, "\r\n").next();
exe.addObjectFile(libstdcxx_path);
exe.linkSystemLibrary("pthread");
@@ -114,8 +124,9 @@ fn dependOnLib(lib_exe_obj: &std.build.LibExeObjStep, dep: &const LibraryDep) {
}
fn addCppLib(b: &Builder, lib_exe_obj: &std.build.LibExeObjStep, cmake_binary_dir: []const u8, lib_name: []const u8) {
+ const lib_prefix = if (lib_exe_obj.target.isWindows()) "" else "lib";
lib_exe_obj.addObjectFile(%%os.path.join(b.allocator, cmake_binary_dir, "zig_cpp",
- b.fmt("{}{}", lib_name, lib_exe_obj.target.libFileExt())));
+ b.fmt("{}{}{}", lib_prefix, lib_name, lib_exe_obj.target.libFileExt())));
}
const LibraryDep = struct {
@@ -150,7 +161,7 @@ fn findLLVM(b: &Builder) -> ?LibraryDep {
.libdirs = ArrayList([]const u8).init(b.allocator),
};
{
- var it = mem.split(libs_output, " \n");
+ var it = mem.split(libs_output, " \r\n");
while (it.next()) |lib_arg| {
if (mem.startsWith(u8, lib_arg, "-l")) {
%%result.system_libs.append(lib_arg[2..]);
@@ -164,7 +175,7 @@ fn findLLVM(b: &Builder) -> ?LibraryDep {
}
}
{
- var it = mem.split(includes_output, " \n");
+ var it = mem.split(includes_output, " \r\n");
while (it.next()) |include_arg| {
if (mem.startsWith(u8, include_arg, "-I")) {
%%result.includes.append(include_arg[2..]);
@@ -174,7 +185,7 @@ fn findLLVM(b: &Builder) -> ?LibraryDep {
}
}
{
- var it = mem.split(libdir_output, " \n");
+ var it = mem.split(libdir_output, " \r\n");
while (it.next()) |libdir| {
if (mem.startsWith(u8, libdir, "-L")) {
%%result.libdirs.append(libdir[2..]);
@@ -310,3 +321,11 @@ pub fn installStdLib(b: &Builder) {
b.installFile(src_path, dest_path);
}
}
+
+fn nextValue(index: &usize, build_info: []const u8) -> []const u8 {
+ const start = *index;
+ while (build_info[*index] != '\n' and build_info[*index] != '\r') : (*index += 1) { }
+ const result = build_info[start..*index];
+ *index += 1;
+ return result;
+}
diff --git a/src-self-hosted/c.zig b/src-self-hosted/c.zig
index 9a4b56adea..08060fbe3a 100644
--- a/src-self-hosted/c.zig
+++ b/src-self-hosted/c.zig
@@ -1,4 +1,5 @@
pub use @cImport({
+ @cInclude("inttypes.h");
@cInclude("config.h");
@cInclude("zig_llvm.h");
});
diff --git a/src/config.h.in b/src/config.h.in
index 73e1de27c1..0712c008a6 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -27,5 +27,7 @@
// Used for communicating build information to self hosted build.
#define ZIG_CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@"
#define ZIG_CXX_COMPILER "@CMAKE_CXX_COMPILER@"
+#define ZIG_LLD_INCLUDE_PATH "@LLD_INCLUDE_DIRS@"
+#define ZIG_LLD_LIBRARIES "@LLD_LIBRARIES@"
#endif
diff --git a/src/link.cpp b/src/link.cpp
index f07364e5bc..13e61dd4e7 100644
--- a/src/link.cpp
+++ b/src/link.cpp
@@ -426,8 +426,7 @@ static void construct_linker_job_coff(LinkJob *lj) {
if (g->is_static) {
Buf *cmt_lib_name = buf_sprintf("libcmt%s.lib", d_str);
lj->args.append(buf_ptr(cmt_lib_name));
- }
- else {
+ } else {
Buf *msvcrt_lib_name = buf_sprintf("msvcrt%s.lib", d_str);
lj->args.append(buf_ptr(msvcrt_lib_name));
}
@@ -452,6 +451,9 @@ static void construct_linker_job_coff(LinkJob *lj) {
// }
//}
//lj->args.append(get_libc_static_file(g, "crtbegin.o"));
+
+ // msvcrt depends on kernel32
+ lj->args.append("kernel32.lib");
} else {
lj->args.append("-NODEFAULTLIB");
if (!is_library) {
diff --git a/src/main.cpp b/src/main.cpp
index 66ffbbde82..4c606c95be 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -267,7 +267,7 @@ static void add_package(CodeGen *g, CliPkg *cli_pkg, PackageTableEntry *pkg) {
int main(int argc, char **argv) {
if (argc == 2 && strcmp(argv[1], "BUILD_INFO") == 0) {
- printf("%s\n%s\n", ZIG_CMAKE_BINARY_DIR, ZIG_CXX_COMPILER);
+ printf("%s\n%s\n%s\n%s\n", ZIG_CMAKE_BINARY_DIR, ZIG_CXX_COMPILER, ZIG_LLD_INCLUDE_PATH, ZIG_LLD_LIBRARIES);
return 0;
}
diff --git a/std/buffer.zig b/std/buffer.zig
index 2bb395d0fb..69e5a6d673 100644
--- a/std/buffer.zig
+++ b/std/buffer.zig
@@ -112,11 +112,12 @@ pub const Buffer = struct {
// TODO: remove, use OutStream for this
pub fn appendByteNTimes(self: &Buffer, byte: u8, count: usize) -> %void {
var prev_size: usize = self.len();
- %return self.resize(prev_size + count);
+ const new_size = prev_size + count;
+ %return self.resize(new_size);
- var i: usize = 0;
- while (i < count) : (i += 1) {
- self.list.items[prev_size + i] = byte;
+ var i: usize = prev_size;
+ while (i < new_size) : (i += 1) {
+ self.list.items[i] = byte;
}
}
diff --git a/std/os/index.zig b/std/os/index.zig
index 0fd3f02e9a..e1b6a9dcce 100644
--- a/std/os/index.zig
+++ b/std/os/index.zig
@@ -851,7 +851,7 @@ pub fn makePath(allocator: &Allocator, full_path: []const u8) -> %void {
// march end_index backward until next path component
while (true) {
end_index -= 1;
- if (resolved_path[end_index] == '/')
+ if (os.path.isSep(resolved_path[end_index]))
break;
}
continue;
@@ -864,7 +864,7 @@ pub fn makePath(allocator: &Allocator, full_path: []const u8) -> %void {
// march end_index forward until next path component
while (true) {
end_index += 1;
- if (end_index == resolved_path.len or resolved_path[end_index] == '/')
+ if (end_index == resolved_path.len or os.path.isSep(resolved_path[end_index]))
break;
}
}
diff --git a/std/os/path.zig b/std/os/path.zig
index 9417cb4299..fda1f60811 100644
--- a/std/os/path.zig
+++ b/std/os/path.zig
@@ -22,6 +22,14 @@ pub const delimiter = if (is_windows) delimiter_windows else delimiter_posix;
const is_windows = builtin.os == builtin.Os.windows;
+pub fn isSep(byte: u8) -> bool {
+ if (is_windows) {
+ return byte == '/' or byte == '\\';
+ } else {
+ return byte == '/';
+ }
+}
+
/// Naively combines a series of paths with the native path seperator.
/// Allocates memory for the result, which must be freed by the caller.
pub fn join(allocator: &Allocator, paths: ...) -> %[]u8 {
From 5c988cc7222db9b1a943ba0dd40f7f6116813bcb Mon Sep 17 00:00:00 2001
From: Andrew Kelley
Date: Wed, 3 Jan 2018 14:16:20 -0500
Subject: [PATCH 5/8] readme: update macos installation instructions
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index 1ba90c004c..a05d8a1a71 100644
--- a/README.md
+++ b/README.md
@@ -154,6 +154,7 @@ make install
`ZIG_LIBC_LIB_DIR` and `ZIG_LIBC_STATIC_LIB_DIR` are unused.
```
+brew install cmake
brew install llvm@5
brew outdated llvm@5 || brew upgrade llvm@5
mkdir build
From 5b156031e92c66c1bea71d5eb6c337b23185d65d Mon Sep 17 00:00:00 2001
From: Andrew Kelley
Date: Wed, 3 Jan 2018 16:05:37 -0500
Subject: [PATCH 6/8] enum tag values are expressions so no parentheses needed
---
src/parser.cpp | 2 +-
test/cases/enum.zig | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/parser.cpp b/src/parser.cpp
index d069a23c5f..6ee3b877ad 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -2552,7 +2552,7 @@ static AstNode *ast_parse_container_decl(ParseContext *pc, size_t *token_index,
Token *eq_token = &pc->tokens->at(*token_index);
if (eq_token->id == TokenIdEq) {
*token_index += 1;
- field_node->data.struct_field.value = ast_parse_prefix_op_expr(pc, token_index, true);
+ field_node->data.struct_field.value = ast_parse_expression(pc, token_index, true);
}
Token *next_token = &pc->tokens->at(*token_index);
diff --git a/test/cases/enum.zig b/test/cases/enum.zig
index 26aa8fb589..6f0f1c4730 100644
--- a/test/cases/enum.zig
+++ b/test/cases/enum.zig
@@ -377,3 +377,13 @@ test "switch on enum with one member is comptime known" {
}
@compileError("analysis should not reach here");
}
+
+const EnumWithTagValues = enum(u4) {
+ A = 1 << 0,
+ B = 1 << 1,
+ C = 1 << 2,
+ D = 1 << 3,
+};
+test "enum with tag values don't require parens" {
+ assert(u4(EnumWithTagValues.C) == 0b0100);
+}
From a45db7e853c2aa04ff7a91dbda975f181aa467bd Mon Sep 17 00:00:00 2001
From: Andrew Kelley
Date: Wed, 3 Jan 2018 18:25:17 -0500
Subject: [PATCH 7/8] add building the self hosted compiler to the main test
suite
---
build.zig | 5 ++++-
src-self-hosted/main.zig | 5 +++++
src-self-hosted/tokenizer.zig | 15 +++++++++++++--
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/build.zig b/build.zig
index 9727be0843..3d54067186 100644
--- a/build.zig
+++ b/build.zig
@@ -33,6 +33,8 @@ pub fn build(b: &Builder) {
docs_step.dependOn(&docgen_cmd.step);
docs_step.dependOn(&docgen_home_cmd.step);
+ const test_step = b.step("test", "Run all the tests");
+
if (findLLVM(b)) |llvm| {
// find the stage0 build artifacts because we're going to re-use config.h and zig_cpp library
const build_info = b.exec([][]const u8{b.zig_exe, "BUILD_INFO"});
@@ -72,15 +74,16 @@ pub fn build(b: &Builder) {
b.default_step.dependOn(&exe.step);
b.default_step.dependOn(docs_step);
+ test_step.dependOn(&exe.step);
b.installArtifact(exe);
installStdLib(b);
+
}
const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter");
const with_lldb = b.option(bool, "with-lldb", "Run tests in LLDB to get a backtrace if one fails") ?? false;
- const test_step = b.step("test", "Run all the tests");
test_step.dependOn(docs_step);
diff --git a/src-self-hosted/main.zig b/src-self-hosted/main.zig
index ff8fb37b42..a737cd9503 100644
--- a/src-self-hosted/main.zig
+++ b/src-self-hosted/main.zig
@@ -626,3 +626,8 @@ fn findZigLibDir(allocator: &mem.Allocator) -> %[]u8 {
return error.FileNotFound;
}
+
+test "import tests" {
+ _ = @import("tokenizer.zig");
+ _ = @import("parser.zig");
+}
diff --git a/src-self-hosted/tokenizer.zig b/src-self-hosted/tokenizer.zig
index de2fbdc1ee..92312a063a 100644
--- a/src-self-hosted/tokenizer.zig
+++ b/src-self-hosted/tokenizer.zig
@@ -204,6 +204,7 @@ pub const Tokenizer = struct {
LineComment,
Zero,
IntegerLiteral,
+ IntegerLiteralWithRadix,
NumberDot,
FloatFraction,
FloatExponentUnsigned,
@@ -454,7 +455,7 @@ pub const Tokenizer = struct {
},
State.Zero => switch (c) {
'b', 'o', 'x' => {
- state = State.IntegerLiteral;
+ state = State.IntegerLiteralWithRadix;
},
else => {
// reinterpret as a normal number
@@ -469,6 +470,16 @@ pub const Tokenizer = struct {
'p', 'P', 'e', 'E' => {
state = State.FloatExponentUnsigned;
},
+ '0'...'9' => {},
+ else => break,
+ },
+ State.IntegerLiteralWithRadix => switch (c) {
+ '.' => {
+ state = State.NumberDot;
+ },
+ 'p', 'P' => {
+ state = State.FloatExponentUnsigned;
+ },
'0'...'9', 'a'...'f', 'A'...'F' => {},
else => break,
},
@@ -485,7 +496,7 @@ pub const Tokenizer = struct {
},
},
State.FloatFraction => switch (c) {
- 'p', 'P', 'e', 'E' => {
+ 'p', 'P' => {
state = State.FloatExponentUnsigned;
},
'0'...'9', 'a'...'f', 'A'...'F' => {},
From 5a800db48cde943a7fd80fdbfb42bc69a325ca76 Mon Sep 17 00:00:00 2001
From: Andrew Kelley
Date: Wed, 3 Jan 2018 19:39:04 -0500
Subject: [PATCH 8/8] build: std files and c header files are only specified
once
In the CMakeLists.txt file. And then we communicate the list
to the zig build.
---
CMakeLists.txt | 436 +++++++++++++++++++++++++-----------------------
build.zig | 136 ++-------------
src/config.h.in | 2 +
src/main.cpp | 8 +-
4 files changed, 250 insertions(+), 332 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c3a2d6bf7d..08c2cf4761 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -353,6 +353,223 @@ set(ZIG_CPP_SOURCES
"${CMAKE_SOURCE_DIR}/src/zig_llvm.cpp"
)
+set(ZIG_STD_FILES
+ "array_list.zig"
+ "base64.zig"
+ "buf_map.zig"
+ "buf_set.zig"
+ "buffer.zig"
+ "build.zig"
+ "c/darwin.zig"
+ "c/index.zig"
+ "c/linux.zig"
+ "c/windows.zig"
+ "cstr.zig"
+ "debug/failing_allocator.zig"
+ "debug/index.zig"
+ "dwarf.zig"
+ "elf.zig"
+ "empty.zig"
+ "endian.zig"
+ "fmt/errol/enum3.zig"
+ "fmt/errol/index.zig"
+ "fmt/errol/lookup.zig"
+ "fmt/index.zig"
+ "hash_map.zig"
+ "heap.zig"
+ "index.zig"
+ "io.zig"
+ "linked_list.zig"
+ "math/acos.zig"
+ "math/acosh.zig"
+ "math/asin.zig"
+ "math/asinh.zig"
+ "math/atan.zig"
+ "math/atan2.zig"
+ "math/atanh.zig"
+ "math/cbrt.zig"
+ "math/ceil.zig"
+ "math/copysign.zig"
+ "math/cos.zig"
+ "math/cosh.zig"
+ "math/exp.zig"
+ "math/exp2.zig"
+ "math/expm1.zig"
+ "math/expo2.zig"
+ "math/fabs.zig"
+ "math/floor.zig"
+ "math/fma.zig"
+ "math/frexp.zig"
+ "math/hypot.zig"
+ "math/ilogb.zig"
+ "math/index.zig"
+ "math/inf.zig"
+ "math/isfinite.zig"
+ "math/isinf.zig"
+ "math/isnan.zig"
+ "math/isnormal.zig"
+ "math/ln.zig"
+ "math/log.zig"
+ "math/log10.zig"
+ "math/log1p.zig"
+ "math/log2.zig"
+ "math/modf.zig"
+ "math/nan.zig"
+ "math/pow.zig"
+ "math/round.zig"
+ "math/scalbn.zig"
+ "math/signbit.zig"
+ "math/sin.zig"
+ "math/sinh.zig"
+ "math/sqrt.zig"
+ "math/tan.zig"
+ "math/tanh.zig"
+ "math/trunc.zig"
+ "mem.zig"
+ "net.zig"
+ "os/child_process.zig"
+ "os/darwin.zig"
+ "os/darwin_errno.zig"
+ "os/get_user_id.zig"
+ "os/index.zig"
+ "os/linux.zig"
+ "os/linux_errno.zig"
+ "os/linux_i386.zig"
+ "os/linux_x86_64.zig"
+ "os/path.zig"
+ "os/windows/error.zig"
+ "os/windows/index.zig"
+ "os/windows/util.zig"
+ "rand.zig"
+ "sort.zig"
+ "special/bootstrap.zig"
+ "special/bootstrap_lib.zig"
+ "special/build_file_template.zig"
+ "special/build_runner.zig"
+ "special/builtin.zig"
+ "special/compiler_rt/aulldiv.zig"
+ "special/compiler_rt/aullrem.zig"
+ "special/compiler_rt/comparetf2.zig"
+ "special/compiler_rt/fixuint.zig"
+ "special/compiler_rt/fixunsdfdi.zig"
+ "special/compiler_rt/fixunsdfsi.zig"
+ "special/compiler_rt/fixunsdfti.zig"
+ "special/compiler_rt/fixunssfdi.zig"
+ "special/compiler_rt/fixunssfsi.zig"
+ "special/compiler_rt/fixunssfti.zig"
+ "special/compiler_rt/fixunstfdi.zig"
+ "special/compiler_rt/fixunstfsi.zig"
+ "special/compiler_rt/fixunstfti.zig"
+ "special/compiler_rt/index.zig"
+ "special/compiler_rt/udivmod.zig"
+ "special/compiler_rt/udivmoddi4.zig"
+ "special/compiler_rt/udivmodti4.zig"
+ "special/compiler_rt/udivti3.zig"
+ "special/compiler_rt/umodti3.zig"
+ "special/panic.zig"
+ "special/test_runner.zig"
+ "unicode.zig"
+)
+
+set(ZIG_C_HEADER_FILES
+ "__clang_cuda_builtin_vars.h"
+ "__clang_cuda_cmath.h"
+ "__clang_cuda_complex_builtins.h"
+ "__clang_cuda_intrinsics.h"
+ "__clang_cuda_math_forward_declares.h"
+ "__clang_cuda_runtime_wrapper.h"
+ "__stddef_max_align_t.h"
+ "__wmmintrin_aes.h"
+ "__wmmintrin_pclmul.h"
+ "adxintrin.h"
+ "altivec.h"
+ "ammintrin.h"
+ "arm_acle.h"
+ "arm_neon.h"
+ "armintr.h"
+ "avx2intrin.h"
+ "avx512bwintrin.h"
+ "avx512cdintrin.h"
+ "avx512dqintrin.h"
+ "avx512erintrin.h"
+ "avx512fintrin.h"
+ "avx512ifmaintrin.h"
+ "avx512ifmavlintrin.h"
+ "avx512pfintrin.h"
+ "avx512vbmiintrin.h"
+ "avx512vbmivlintrin.h"
+ "avx512vlbwintrin.h"
+ "avx512vlcdintrin.h"
+ "avx512vldqintrin.h"
+ "avx512vlintrin.h"
+ "avx512vpopcntdqintrin.h"
+ "avxintrin.h"
+ "bmi2intrin.h"
+ "bmiintrin.h"
+ "clflushoptintrin.h"
+ "clzerointrin.h"
+ "cpuid.h"
+ "cuda_wrappers/algorithm"
+ "cuda_wrappers/complex"
+ "cuda_wrappers/new"
+ "emmintrin.h"
+ "f16cintrin.h"
+ "float.h"
+ "fma4intrin.h"
+ "fmaintrin.h"
+ "fxsrintrin.h"
+ "htmintrin.h"
+ "htmxlintrin.h"
+ "ia32intrin.h"
+ "immintrin.h"
+ "intrin.h"
+ "inttypes.h"
+ "iso646.h"
+ "limits.h"
+ "lwpintrin.h"
+ "lzcntintrin.h"
+ "mm3dnow.h"
+ "mm_malloc.h"
+ "mmintrin.h"
+ "module.modulemap"
+ "msa.h"
+ "mwaitxintrin.h"
+ "nmmintrin.h"
+ "opencl-c.h"
+ "pkuintrin.h"
+ "pmmintrin.h"
+ "popcntintrin.h"
+ "prfchwintrin.h"
+ "rdseedintrin.h"
+ "rtmintrin.h"
+ "s390intrin.h"
+ "shaintrin.h"
+ "smmintrin.h"
+ "stdalign.h"
+ "stdarg.h"
+ "stdatomic.h"
+ "stdbool.h"
+ "stddef.h"
+ "stdint.h"
+ "stdnoreturn.h"
+ "tbmintrin.h"
+ "tgmath.h"
+ "tmmintrin.h"
+ "unwind.h"
+ "vadefs.h"
+ "varargs.h"
+ "vecintrin.h"
+ "wmmintrin.h"
+ "x86intrin.h"
+ "xmmintrin.h"
+ "xopintrin.h"
+ "xsavecintrin.h"
+ "xsaveintrin.h"
+ "xsaveoptintrin.h"
+ "xsavesintrin.h"
+ "xtestintrin.h"
+)
+
set(ZIG_LIB_DIR "lib/zig")
set(C_HEADERS_DEST "${ZIG_LIB_DIR}/include")
set(ZIG_STD_DEST "${ZIG_LIB_DIR}/std")
@@ -420,215 +637,12 @@ endif()
install(TARGETS zig DESTINATION bin)
install(TARGETS zig_cpp DESTINATION "${ZIG_CPP_LIB_DIR}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/__clang_cuda_builtin_vars.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/__clang_cuda_cmath.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/__clang_cuda_complex_builtins.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/__clang_cuda_intrinsics.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/__clang_cuda_math_forward_declares.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/__clang_cuda_runtime_wrapper.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/__stddef_max_align_t.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/__wmmintrin_aes.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/__wmmintrin_pclmul.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/adxintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/altivec.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/ammintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/arm_acle.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/arm_neon.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/armintr.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/avx2intrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/avx512bwintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/avx512cdintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/avx512dqintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/avx512erintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/avx512fintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/avx512ifmaintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/avx512ifmavlintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/avx512pfintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/avx512vbmiintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/avx512vbmivlintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/avx512vlbwintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/avx512vlcdintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/avx512vldqintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/avx512vlintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/avx512vpopcntdqintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/avxintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/bmi2intrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/bmiintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/clflushoptintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/clzerointrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/cpuid.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/cuda_wrappers/algorithm" DESTINATION "${C_HEADERS_DEST}/cuda_wrappers")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/cuda_wrappers/complex" DESTINATION "${C_HEADERS_DEST}/cuda_wrappers")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/cuda_wrappers/new" DESTINATION "${C_HEADERS_DEST}/cuda_wrappers")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/emmintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/f16cintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/float.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/fma4intrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/fmaintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/fxsrintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/htmintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/htmxlintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/ia32intrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/immintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/intrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/inttypes.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/iso646.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/limits.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/lwpintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/lzcntintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/mm3dnow.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/mm_malloc.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/mmintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/module.modulemap" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/msa.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/mwaitxintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/nmmintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/opencl-c.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/pkuintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/pmmintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/popcntintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/prfchwintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/rdseedintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/rtmintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/s390intrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/shaintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/smmintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/stdalign.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/stdarg.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/stdatomic.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/stdbool.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/stddef.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/stdint.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/stdnoreturn.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/tbmintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/tgmath.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/tmmintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/unwind.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/vadefs.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/varargs.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/vecintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/wmmintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/x86intrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/xmmintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/xopintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/xsavecintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/xsaveintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/xsaveoptintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/xsavesintrin.h" DESTINATION "${C_HEADERS_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/c_headers/xtestintrin.h" DESTINATION "${C_HEADERS_DEST}")
+foreach(file ${ZIG_C_HEADER_FILES})
+ get_filename_component(file_dir "${C_HEADERS_DEST}/${file}" DIRECTORY)
+ install(FILES "${CMAKE_SOURCE_DIR}/c_headers/${file}" DESTINATION "${file_dir}")
+endforeach()
-install(FILES "${CMAKE_SOURCE_DIR}/std/array_list.zig" DESTINATION "${ZIG_STD_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/std/base64.zig" DESTINATION "${ZIG_STD_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/std/buf_map.zig" DESTINATION "${ZIG_STD_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/std/buf_set.zig" DESTINATION "${ZIG_STD_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/std/buffer.zig" DESTINATION "${ZIG_STD_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/std/build.zig" DESTINATION "${ZIG_STD_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/std/c/darwin.zig" DESTINATION "${ZIG_STD_DEST}/c")
-install(FILES "${CMAKE_SOURCE_DIR}/std/c/index.zig" DESTINATION "${ZIG_STD_DEST}/c")
-install(FILES "${CMAKE_SOURCE_DIR}/std/c/linux.zig" DESTINATION "${ZIG_STD_DEST}/c")
-install(FILES "${CMAKE_SOURCE_DIR}/std/c/windows.zig" DESTINATION "${ZIG_STD_DEST}/c")
-install(FILES "${CMAKE_SOURCE_DIR}/std/cstr.zig" DESTINATION "${ZIG_STD_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/std/debug/index.zig" DESTINATION "${ZIG_STD_DEST}/debug")
-install(FILES "${CMAKE_SOURCE_DIR}/std/debug/failing_allocator.zig" DESTINATION "${ZIG_STD_DEST}/debug")
-install(FILES "${CMAKE_SOURCE_DIR}/std/dwarf.zig" DESTINATION "${ZIG_STD_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/std/elf.zig" DESTINATION "${ZIG_STD_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/std/empty.zig" DESTINATION "${ZIG_STD_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/std/endian.zig" DESTINATION "${ZIG_STD_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/std/fmt/errol/enum3.zig" DESTINATION "${ZIG_STD_DEST}/fmt/errol")
-install(FILES "${CMAKE_SOURCE_DIR}/std/fmt/errol/index.zig" DESTINATION "${ZIG_STD_DEST}/fmt/errol")
-install(FILES "${CMAKE_SOURCE_DIR}/std/fmt/errol/lookup.zig" DESTINATION "${ZIG_STD_DEST}/fmt/errol")
-install(FILES "${CMAKE_SOURCE_DIR}/std/fmt/index.zig" DESTINATION "${ZIG_STD_DEST}/fmt")
-install(FILES "${CMAKE_SOURCE_DIR}/std/hash_map.zig" DESTINATION "${ZIG_STD_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/std/heap.zig" DESTINATION "${ZIG_STD_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/std/index.zig" DESTINATION "${ZIG_STD_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/std/io.zig" DESTINATION "${ZIG_STD_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/std/linked_list.zig" DESTINATION "${ZIG_STD_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/acos.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/acosh.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/asin.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/asinh.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/atan.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/atan2.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/atanh.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/cbrt.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/ceil.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/copysign.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/cos.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/cosh.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/exp.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/exp2.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/expm1.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/expo2.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/fabs.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/floor.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/fma.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/frexp.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/hypot.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/ilogb.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/index.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/inf.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/isfinite.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/isinf.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/isnan.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/isnormal.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/ln.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/log.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/log10.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/log1p.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/log2.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/modf.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/nan.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/pow.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/round.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/scalbn.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/signbit.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/sin.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/sinh.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/sqrt.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/tan.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/tanh.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/math/trunc.zig" DESTINATION "${ZIG_STD_DEST}/math")
-install(FILES "${CMAKE_SOURCE_DIR}/std/mem.zig" DESTINATION "${ZIG_STD_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/std/net.zig" DESTINATION "${ZIG_STD_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/std/os/child_process.zig" DESTINATION "${ZIG_STD_DEST}/os")
-install(FILES "${CMAKE_SOURCE_DIR}/std/os/darwin.zig" DESTINATION "${ZIG_STD_DEST}/os")
-install(FILES "${CMAKE_SOURCE_DIR}/std/os/darwin_errno.zig" DESTINATION "${ZIG_STD_DEST}/os")
-install(FILES "${CMAKE_SOURCE_DIR}/std/os/get_user_id.zig" DESTINATION "${ZIG_STD_DEST}/os")
-install(FILES "${CMAKE_SOURCE_DIR}/std/os/index.zig" DESTINATION "${ZIG_STD_DEST}/os")
-install(FILES "${CMAKE_SOURCE_DIR}/std/os/linux.zig" DESTINATION "${ZIG_STD_DEST}/os")
-install(FILES "${CMAKE_SOURCE_DIR}/std/os/linux_errno.zig" DESTINATION "${ZIG_STD_DEST}/os")
-install(FILES "${CMAKE_SOURCE_DIR}/std/os/linux_i386.zig" DESTINATION "${ZIG_STD_DEST}/os")
-install(FILES "${CMAKE_SOURCE_DIR}/std/os/linux_x86_64.zig" DESTINATION "${ZIG_STD_DEST}/os")
-install(FILES "${CMAKE_SOURCE_DIR}/std/os/path.zig" DESTINATION "${ZIG_STD_DEST}/os")
-install(FILES "${CMAKE_SOURCE_DIR}/std/os/windows/error.zig" DESTINATION "${ZIG_STD_DEST}/os/windows")
-install(FILES "${CMAKE_SOURCE_DIR}/std/os/windows/index.zig" DESTINATION "${ZIG_STD_DEST}/os/windows")
-install(FILES "${CMAKE_SOURCE_DIR}/std/os/windows/util.zig" DESTINATION "${ZIG_STD_DEST}/os/windows")
-install(FILES "${CMAKE_SOURCE_DIR}/std/rand.zig" DESTINATION "${ZIG_STD_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/std/sort.zig" DESTINATION "${ZIG_STD_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/std/unicode.zig" DESTINATION "${ZIG_STD_DEST}")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/bootstrap.zig" DESTINATION "${ZIG_STD_DEST}/special")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/bootstrap_lib.zig" DESTINATION "${ZIG_STD_DEST}/special")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/build_file_template.zig" DESTINATION "${ZIG_STD_DEST}/special")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/build_runner.zig" DESTINATION "${ZIG_STD_DEST}/special")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/builtin.zig" DESTINATION "${ZIG_STD_DEST}/special")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/aulldiv.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/aullrem.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/comparetf2.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/fixuint.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/fixunsdfdi.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/fixunsdfsi.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/fixunsdfti.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/fixunssfdi.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/fixunssfsi.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/fixunssfti.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/fixunstfdi.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/fixunstfsi.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/fixunstfti.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/index.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/udivmod.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/udivmoddi4.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/udivmodti4.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/udivti3.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/umodti3.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/panic.zig" DESTINATION "${ZIG_STD_DEST}/special")
-install(FILES "${CMAKE_SOURCE_DIR}/std/special/test_runner.zig" DESTINATION "${ZIG_STD_DEST}/special")
+foreach(file ${ZIG_STD_FILES})
+ get_filename_component(file_dir "${ZIG_STD_DEST}/${file}" DIRECTORY)
+ install(FILES "${CMAKE_SOURCE_DIR}/std/${file}" DESTINATION "${file_dir}")
+endforeach()
diff --git a/build.zig b/build.zig
index 3d54067186..679c88bb71 100644
--- a/build.zig
+++ b/build.zig
@@ -43,6 +43,8 @@ pub fn build(b: &Builder) {
const cxx_compiler = nextValue(&index, build_info);
const lld_include_dir = nextValue(&index, build_info);
const lld_libraries = nextValue(&index, build_info);
+ const std_files = nextValue(&index, build_info);
+ const c_header_files = nextValue(&index, build_info);
var exe = b.addExecutable("zig", "src-self-hosted/main.zig");
exe.setBuildMode(mode);
@@ -77,7 +79,8 @@ pub fn build(b: &Builder) {
test_step.dependOn(&exe.step);
b.installArtifact(exe);
- installStdLib(b);
+ installStdLib(b, std_files);
+ installCHeaders(b, c_header_files);
}
@@ -200,131 +203,24 @@ fn findLLVM(b: &Builder) -> ?LibraryDep {
return result;
}
-pub fn installStdLib(b: &Builder) {
- const stdlib_files = []const []const u8 {
- "array_list.zig",
- "base64.zig",
- "buf_map.zig",
- "buf_set.zig",
- "buffer.zig",
- "build.zig",
- "c/darwin.zig",
- "c/index.zig",
- "c/linux.zig",
- "c/windows.zig",
- "cstr.zig",
- "debug/failing_allocator.zig",
- "debug/index.zig",
- "dwarf.zig",
- "elf.zig",
- "empty.zig",
- "endian.zig",
- "fmt/errol/enum3.zig",
- "fmt/errol/index.zig",
- "fmt/errol/lookup.zig",
- "fmt/index.zig",
- "hash_map.zig",
- "heap.zig",
- "index.zig",
- "io.zig",
- "linked_list.zig",
- "math/acos.zig",
- "math/acosh.zig",
- "math/asin.zig",
- "math/asinh.zig",
- "math/atan.zig",
- "math/atan2.zig",
- "math/atanh.zig",
- "math/cbrt.zig",
- "math/ceil.zig",
- "math/copysign.zig",
- "math/cos.zig",
- "math/cosh.zig",
- "math/exp.zig",
- "math/exp2.zig",
- "math/expm1.zig",
- "math/expo2.zig",
- "math/fabs.zig",
- "math/floor.zig",
- "math/fma.zig",
- "math/frexp.zig",
- "math/hypot.zig",
- "math/ilogb.zig",
- "math/index.zig",
- "math/inf.zig",
- "math/isfinite.zig",
- "math/isinf.zig",
- "math/isnan.zig",
- "math/isnormal.zig",
- "math/ln.zig",
- "math/log.zig",
- "math/log10.zig",
- "math/log1p.zig",
- "math/log2.zig",
- "math/modf.zig",
- "math/nan.zig",
- "math/pow.zig",
- "math/round.zig",
- "math/scalbn.zig",
- "math/signbit.zig",
- "math/sin.zig",
- "math/sinh.zig",
- "math/sqrt.zig",
- "math/tan.zig",
- "math/tanh.zig",
- "math/trunc.zig",
- "mem.zig",
- "net.zig",
- "os/child_process.zig",
- "os/darwin.zig",
- "os/darwin_errno.zig",
- "os/get_user_id.zig",
- "os/index.zig",
- "os/linux.zig",
- "os/linux_errno.zig",
- "os/linux_i386.zig",
- "os/linux_x86_64.zig",
- "os/path.zig",
- "os/windows/error.zig",
- "os/windows/index.zig",
- "os/windows/util.zig",
- "rand.zig",
- "sort.zig",
- "unicode.zig",
- "special/bootstrap.zig",
- "special/bootstrap_lib.zig",
- "special/build_file_template.zig",
- "special/build_runner.zig",
- "special/builtin.zig",
- "special/compiler_rt/aulldiv.zig",
- "special/compiler_rt/aullrem.zig",
- "special/compiler_rt/comparetf2.zig",
- "special/compiler_rt/fixuint.zig",
- "special/compiler_rt/fixunsdfdi.zig",
- "special/compiler_rt/fixunsdfsi.zig",
- "special/compiler_rt/fixunsdfti.zig",
- "special/compiler_rt/fixunssfdi.zig",
- "special/compiler_rt/fixunssfsi.zig",
- "special/compiler_rt/fixunssfti.zig",
- "special/compiler_rt/fixunstfdi.zig",
- "special/compiler_rt/fixunstfsi.zig",
- "special/compiler_rt/fixunstfti.zig",
- "special/compiler_rt/index.zig",
- "special/compiler_rt/udivmod.zig",
- "special/compiler_rt/udivmoddi4.zig",
- "special/compiler_rt/udivmodti4.zig",
- "special/compiler_rt/udivti3.zig",
- "special/compiler_rt/umodti3.zig",
- "special/panic.zig",
- "special/test_runner.zig",
- };
- for (stdlib_files) |stdlib_file| {
+pub fn installStdLib(b: &Builder, stdlib_files: []const u8) {
+ var it = mem.split(stdlib_files, ";");
+ while (it.next()) |stdlib_file| {
const src_path = %%os.path.join(b.allocator, "std", stdlib_file);
const dest_path = %%os.path.join(b.allocator, "lib", "zig", "std", stdlib_file);
b.installFile(src_path, dest_path);
}
}
+pub fn installCHeaders(b: &Builder, c_header_files: []const u8) {
+ var it = mem.split(c_header_files, ";");
+ while (it.next()) |c_header_file| {
+ const src_path = %%os.path.join(b.allocator, "c_headers", c_header_file);
+ const dest_path = %%os.path.join(b.allocator, "lib", "zig", "include", c_header_file);
+ b.installFile(src_path, dest_path);
+ }
+}
+
fn nextValue(index: &usize, build_info: []const u8) -> []const u8 {
const start = *index;
while (build_info[*index] != '\n' and build_info[*index] != '\r') : (*index += 1) { }
diff --git a/src/config.h.in b/src/config.h.in
index 0712c008a6..4202e670ff 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -29,5 +29,7 @@
#define ZIG_CXX_COMPILER "@CMAKE_CXX_COMPILER@"
#define ZIG_LLD_INCLUDE_PATH "@LLD_INCLUDE_DIRS@"
#define ZIG_LLD_LIBRARIES "@LLD_LIBRARIES@"
+#define ZIG_STD_FILES "@ZIG_STD_FILES@"
+#define ZIG_C_HEADER_FILES "@ZIG_C_HEADER_FILES@"
#endif
diff --git a/src/main.cpp b/src/main.cpp
index 4c606c95be..a3ca1bc164 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -267,7 +267,13 @@ static void add_package(CodeGen *g, CliPkg *cli_pkg, PackageTableEntry *pkg) {
int main(int argc, char **argv) {
if (argc == 2 && strcmp(argv[1], "BUILD_INFO") == 0) {
- printf("%s\n%s\n%s\n%s\n", ZIG_CMAKE_BINARY_DIR, ZIG_CXX_COMPILER, ZIG_LLD_INCLUDE_PATH, ZIG_LLD_LIBRARIES);
+ printf("%s\n%s\n%s\n%s\n%s\n%s\n",
+ ZIG_CMAKE_BINARY_DIR,
+ ZIG_CXX_COMPILER,
+ ZIG_LLD_INCLUDE_PATH,
+ ZIG_LLD_LIBRARIES,
+ ZIG_STD_FILES,
+ ZIG_C_HEADER_FILES);
return 0;
}