| author | |
| committer | |
| log | e8f28cda9edb06a5f2189ca5e8928df52ddea20d |
| tree | 2b243731106c292b737319edaa0d719682a47eaf |
| parent | c947e79d73d3ec7a7a7c4640f001b34f63d36d89 |
Windows does not support RPATH and only searches for DLLs in a small
number of predetermined paths by default, with one of them being the
directory from which the application loaded.
Installing both executables and DLLs to `bin/` by default helps ensure
that the executable can find any DLL artifacts it has linked to.
DLL import libraries are still installed to `lib/`.
These defaults match CMake's behavior.2 files changed, 9 insertions(+), 8 deletions(-)
lib/std/Build/Step/Compile.zig+5-1| ... | @@ -614,6 +614,10 @@ pub fn isStaticLibrary(self: *const Compile) bool { | ... | @@ -614,6 +614,10 @@ pub fn isStaticLibrary(self: *const Compile) bool { |
| 614 | return self.kind == .lib and self.linkage != .dynamic; | 614 | return self.kind == .lib and self.linkage != .dynamic; |
| 615 | } | 615 | } |
| 616 | 616 | ||
| 617 | pub fn isDll(self: *Compile) bool { | ||
| 618 | return self.isDynamicLibrary() and self.rootModuleTarget().os.tag == .windows; | ||
| 619 | } | ||
| 620 | |||
| 617 | pub fn producesPdbFile(self: *Compile) bool { | 621 | pub fn producesPdbFile(self: *Compile) bool { |
| 618 | const target = self.rootModuleTarget(); | 622 | const target = self.rootModuleTarget(); |
| 619 | // TODO: Is this right? Isn't PDB for *any* PE/COFF file? | 623 | // TODO: Is this right? Isn't PDB for *any* PE/COFF file? |
| ... | @@ -632,7 +636,7 @@ pub fn producesPdbFile(self: *Compile) bool { | ... | @@ -632,7 +636,7 @@ pub fn producesPdbFile(self: *Compile) bool { |
| 632 | } | 636 | } |
| 633 | 637 | ||
| 634 | pub fn producesImplib(self: *Compile) bool { | 638 | pub fn producesImplib(self: *Compile) bool { |
| 635 | return self.isDynamicLibrary() and self.rootModuleTarget().os.tag == .windows; | 639 | return self.isDll(); |
| 636 | } | 640 | } |
| 637 | 641 | ||
| 638 | pub fn linkLibC(self: *Compile) void { | 642 | pub fn linkLibC(self: *Compile) void { |
lib/std/Build/Step/InstallArtifact.zig+4-7| ... | @@ -57,8 +57,8 @@ pub fn create(owner: *std.Build, artifact: *Step.Compile, options: Options) *Ins | ... | @@ -57,8 +57,8 @@ pub fn create(owner: *std.Build, artifact: *Step.Compile, options: Options) *Ins |
| 57 | .disabled => null, | 57 | .disabled => null, |
| 58 | .default => switch (artifact.kind) { | 58 | .default => switch (artifact.kind) { |
| 59 | .obj => @panic("object files have no standard installation procedure"), | 59 | .obj => @panic("object files have no standard installation procedure"), |
| 60 | .exe, .@"test" => InstallDir{ .bin = {} }, | 60 | .exe, .@"test" => .bin, |
| 61 | .lib => InstallDir{ .lib = {} }, | 61 | .lib => if (artifact.isDll()) .bin else .lib, |
| 62 | }, | 62 | }, |
| 63 | .override => |o| o, | 63 | .override => |o| o, |
| 64 | }; | 64 | }; |
| ... | @@ -77,15 +77,12 @@ pub fn create(owner: *std.Build, artifact: *Step.Compile, options: Options) *Ins | ... | @@ -77,15 +77,12 @@ pub fn create(owner: *std.Build, artifact: *Step.Compile, options: Options) *Ins |
| 77 | }, | 77 | }, |
| 78 | .h_dir = switch (options.h_dir) { | 78 | .h_dir = switch (options.h_dir) { |
| 79 | .disabled => null, | 79 | .disabled => null, |
| 80 | .default => switch (artifact.kind) { | 80 | .default => if (artifact.kind == .lib) .header else null, |
| 81 | .lib => .header, | ||
| 82 | else => null, | ||
| 83 | }, | ||
| 84 | .override => |o| o, | 81 | .override => |o| o, |
| 85 | }, | 82 | }, |
| 86 | .implib_dir = switch (options.implib_dir) { | 83 | .implib_dir = switch (options.implib_dir) { |
| 87 | .disabled => null, | 84 | .disabled => null, |
| 88 | .default => if (artifact.producesImplib()) dest_dir else null, | 85 | .default => if (artifact.producesImplib()) .lib else null, |
| 89 | .override => |o| o, | 86 | .override => |o| o, |
| 90 | }, | 87 | }, |
| 91 | 88 |