mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
Allow build.zig scripts to define module definition files (.def) when building win32 dlls.
This commit is contained in:
@@ -79,6 +79,10 @@ rc_includes: std.zig.RcIncludes = .any,
|
||||
/// Set via options; intended to be read-only after that.
|
||||
win32_manifest: ?LazyPath = null,
|
||||
|
||||
/// (Windows) .def file to embed in the compilation (dll)
|
||||
/// Set via options; intended to be read-only after that.
|
||||
win32_module_definition: ?LazyPath = null,
|
||||
|
||||
installed_path: ?[]const u8,
|
||||
|
||||
/// Base address for an executable image.
|
||||
@@ -284,6 +288,8 @@ pub const Options = struct {
|
||||
/// Can be set regardless of target. The `.manifest` file will be ignored
|
||||
/// if the target object format does not support embedded manifests.
|
||||
win32_manifest: ?LazyPath = null,
|
||||
/// Win32 module definition file.
|
||||
win32_module_definition: ?LazyPath = null,
|
||||
};
|
||||
|
||||
pub const Kind = enum {
|
||||
@@ -467,6 +473,13 @@ pub fn create(owner: *std.Build, options: Options) *Compile {
|
||||
compile.win32_manifest = lp.dupe(compile.step.owner);
|
||||
lp.addStepDependencies(&compile.step);
|
||||
}
|
||||
if (compile.kind == .lib and compile.linkage != null and compile.linkage.? == .dynamic) {
|
||||
// Building a Win32 DLL, check for win32 .def file.
|
||||
if (options.win32_module_definition) |lp| {
|
||||
compile.win32_module_definition = lp.dupe(compile.step.owner);
|
||||
lp.addStepDependencies(&compile.step);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (compile.kind == .lib) {
|
||||
@@ -1332,6 +1345,10 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
|
||||
try zig_args.append(manifest_file.getPath2(b, step));
|
||||
}
|
||||
|
||||
if (compile.win32_module_definition) |module_file| {
|
||||
try zig_args.append(module_file.getPath2(b, step));
|
||||
}
|
||||
|
||||
if (compile.image_base) |image_base| {
|
||||
try zig_args.append("--image-base");
|
||||
try zig_args.append(b.fmt("0x{x}", .{image_base}));
|
||||
|
||||
Reference in New Issue
Block a user