Skip to content

Commit

Permalink
build: obtain zigcpp library prefix/suffix from cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk committed Dec 7, 2022
1 parent eb4337f commit 9627018
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
18 changes: 17 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,11 @@ fn addCmakeCfgOptionsToExe(
exe.addObjectFile(fs.path.join(b.allocator, &[_][]const u8{
cfg.cmake_binary_dir,
"zigcpp",
b.fmt("{s}{s}{s}", .{ exe.target.libPrefix(), "zigcpp", exe.target.staticLibSuffix() }),
b.fmt("{s}{s}{s}", .{
cfg.cmake_static_library_prefix,
"zigcpp",
cfg.cmake_static_library_suffix,
}),
}) catch unreachable);
assert(cfg.lld_include_dir.len != 0);
exe.addIncludePath(cfg.lld_include_dir);
Expand Down Expand Up @@ -669,6 +673,8 @@ const CMakeConfig = struct {
llvm_linkage: std.build.LibExeObjStep.Linkage,
cmake_binary_dir: []const u8,
cmake_prefix_path: []const u8,
cmake_static_library_prefix: []const u8,
cmake_static_library_suffix: []const u8,
cxx_compiler: []const u8,
lld_include_dir: []const u8,
lld_libraries: []const u8,
Expand Down Expand Up @@ -732,6 +738,8 @@ fn parseConfigH(b: *Builder, config_h_text: []const u8) ?CMakeConfig {
.llvm_linkage = undefined,
.cmake_binary_dir = undefined,
.cmake_prefix_path = undefined,
.cmake_static_library_prefix = undefined,
.cmake_static_library_suffix = undefined,
.cxx_compiler = undefined,
.lld_include_dir = undefined,
.lld_libraries = undefined,
Expand All @@ -751,6 +759,14 @@ fn parseConfigH(b: *Builder, config_h_text: []const u8) ?CMakeConfig {
.prefix = "#define ZIG_CMAKE_PREFIX_PATH ",
.field = "cmake_prefix_path",
},
.{
.prefix = "#define ZIG_CMAKE_STATIC_LIBRARY_PREFIX ",
.field = "cmake_static_library_prefix",
},
.{
.prefix = "#define ZIG_CMAKE_STATIC_LIBRARY_SUFFIX ",
.field = "cmake_static_library_suffix",
},
.{
.prefix = "#define ZIG_CXX_COMPILER ",
.field = "cxx_compiler",
Expand Down
10 changes: 6 additions & 4 deletions stage1/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@
#define ZIG_VERSION_STRING "@ZIG_VERSION@"

// Used by build.zig for communicating build information to self hosted build.
#define ZIG_CLANG_LIBRARIES "@CLANG_LIBRARIES@"
#define ZIG_CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@"
#define ZIG_LLVM_LINK_MODE "@LLVM_LINK_MODE@"
#define ZIG_CMAKE_PREFIX_PATH "@ZIG_CMAKE_PREFIX_PATH@"
#define ZIG_CMAKE_STATIC_LIBRARY_PREFIX "@CMAKE_STATIC_LIBRARY_PREFIX@"
#define ZIG_CMAKE_STATIC_LIBRARY_SUFFIX "@CMAKE_STATIC_LIBRARY_SUFFIX@"
#define ZIG_CXX_COMPILER "@CMAKE_CXX_COMPILER@"
#define ZIG_DIA_GUIDS_LIB "@ZIG_DIA_GUIDS_LIB_ESCAPED@"
#define ZIG_LLD_INCLUDE_PATH "@LLD_INCLUDE_DIRS@"
#define ZIG_LLD_LIBRARIES "@LLD_LIBRARIES@"
#define ZIG_CLANG_LIBRARIES "@CLANG_LIBRARIES@"
#define ZIG_LLVM_INCLUDE_PATH "@LLVM_INCLUDE_DIRS@"
#define ZIG_LLVM_LIB_PATH "@LLVM_LIBDIRS@"
#define ZIG_LLVM_LIBRARIES "@LLVM_LIBRARIES@"
#define ZIG_DIA_GUIDS_LIB "@ZIG_DIA_GUIDS_LIB_ESCAPED@"
#define ZIG_LLVM_LIB_PATH "@LLVM_LIBDIRS@"
#define ZIG_LLVM_LINK_MODE "@LLVM_LINK_MODE@"

#endif

0 comments on commit 9627018

Please sign in to comment.