authorgravatar for carl@astholm.seCarl Åstholm <carl@astholm.se> 2024-03-10 12:17:33+01:00
committergravatar for carl@astholm.seCarl Åstholm <carl@astholm.se> 2024-04-07 15:34:47+02:00
logd99e44a157dee9204c38e66bf7eba00c051690ba
tree661fd3be7a71a67f47e0a99874ba827a107dd6c0
parent5af4e91e0036a5d83889d20ee1477a366c6c12ac

Document added/updated functions

Also renames `addHeaders` to `addHeadersDirectory` for clarity.

4 files changed, 21 insertions(+), 5 deletions(-)

lib/std/Build.zig+4-3
...@@ -1568,21 +1568,22 @@ pub fn addObjCopy(b: *Build, source: LazyPath, options: Step.ObjCopy.Options) *S...@@ -1568,21 +1568,22 @@ pub fn addObjCopy(b: *Build, source: LazyPath, options: Step.ObjCopy.Options) *S
1568 return Step.ObjCopy.create(b, source, options);1568 return Step.ObjCopy.create(b, source, options);
1569}1569}
15701570
1571///`dest_rel_path` is relative to install prefix path1571/// `dest_rel_path` is relative to install prefix path
1572pub fn addInstallFile(b: *Build, source: LazyPath, dest_rel_path: []const u8) *Step.InstallFile {1572pub fn addInstallFile(b: *Build, source: LazyPath, dest_rel_path: []const u8) *Step.InstallFile {
1573 return b.addInstallFileWithDir(source, .prefix, dest_rel_path);1573 return b.addInstallFileWithDir(source, .prefix, dest_rel_path);
1574}1574}
15751575
1576///`dest_rel_path` is relative to bin path1576/// `dest_rel_path` is relative to bin path
1577pub fn addInstallBinFile(b: *Build, source: LazyPath, dest_rel_path: []const u8) *Step.InstallFile {1577pub fn addInstallBinFile(b: *Build, source: LazyPath, dest_rel_path: []const u8) *Step.InstallFile {
1578 return b.addInstallFileWithDir(source, .bin, dest_rel_path);1578 return b.addInstallFileWithDir(source, .bin, dest_rel_path);
1579}1579}
15801580
1581///`dest_rel_path` is relative to lib path1581/// `dest_rel_path` is relative to lib path
1582pub fn addInstallLibFile(b: *Build, source: LazyPath, dest_rel_path: []const u8) *Step.InstallFile {1582pub fn addInstallLibFile(b: *Build, source: LazyPath, dest_rel_path: []const u8) *Step.InstallFile {
1583 return b.addInstallFileWithDir(source, .lib, dest_rel_path);1583 return b.addInstallFileWithDir(source, .lib, dest_rel_path);
1584}1584}
15851585
1586/// `dest_rel_path` is relative to header path
1586pub fn addInstallHeaderFile(b: *Build, source: LazyPath, dest_rel_path: []const u8) *Step.InstallFile {1587pub fn addInstallHeaderFile(b: *Build, source: LazyPath, dest_rel_path: []const u8) *Step.InstallFile {
1587 return b.addInstallFileWithDir(source, .header, dest_rel_path);1588 return b.addInstallFileWithDir(source, .header, dest_rel_path);
1588}1589}
lib/std/Build/Step/Compile.zig+13-1
...@@ -446,6 +446,9 @@ pub fn create(owner: *std.Build, options: Options) *Compile {...@@ -446,6 +446,9 @@ pub fn create(owner: *std.Build, options: Options) *Compile {
446 return self;446 return self;
447}447}
448448
449/// Marks the specified header for installation alongside this artifact.
450/// When a module links with this artifact, all headers marked for installation are added to that
451/// module's include search path.
449pub fn installHeader(cs: *Compile, source: LazyPath, dest_rel_path: []const u8) void {452pub fn installHeader(cs: *Compile, source: LazyPath, dest_rel_path: []const u8) void {
450 const b = cs.step.owner;453 const b = cs.step.owner;
451 const installation: HeaderInstallation = .{ .file = .{454 const installation: HeaderInstallation = .{ .file = .{
...@@ -457,7 +460,10 @@ pub fn installHeader(cs: *Compile, source: LazyPath, dest_rel_path: []const u8)...@@ -457,7 +460,10 @@ pub fn installHeader(cs: *Compile, source: LazyPath, dest_rel_path: []const u8)
457 installation.getSource().addStepDependencies(&cs.step);460 installation.getSource().addStepDependencies(&cs.step);
458}461}
459462
460pub fn installHeaders(463/// Marks headers from the specified directory for installation alongside this artifact.
464/// When a module links with this artifact, all headers marked for installation are added to that
465/// module's include search path.
466pub fn installHeadersDirectory(
461 cs: *Compile,467 cs: *Compile,
462 source: LazyPath,468 source: LazyPath,
463 dest_rel_path: []const u8,469 dest_rel_path: []const u8,
...@@ -474,10 +480,16 @@ pub fn installHeaders(...@@ -474,10 +480,16 @@ pub fn installHeaders(
474 installation.getSource().addStepDependencies(&cs.step);480 installation.getSource().addStepDependencies(&cs.step);
475}481}
476482
483/// Marks the specified config header for installation alongside this artifact.
484/// When a module links with this artifact, all headers marked for installation are added to that
485/// module's include search path.
477pub fn installConfigHeader(cs: *Compile, config_header: *Step.ConfigHeader) void {486pub fn installConfigHeader(cs: *Compile, config_header: *Step.ConfigHeader) void {
478 cs.installHeader(config_header.getOutput(), config_header.include_path);487 cs.installHeader(config_header.getOutput(), config_header.include_path);
479}488}
480489
490/// Forwards all headers marked for installation from `lib` to this artifact.
491/// When a module links with this artifact, all headers marked for installation are added to that
492/// module's include search path.
481pub fn installLibraryHeaders(cs: *Compile, lib: *Compile) void {493pub fn installLibraryHeaders(cs: *Compile, lib: *Compile) void {
482 assert(lib.kind == .lib);494 assert(lib.kind == .lib);
483 const b = cs.step.owner;495 const b = cs.step.owner;
lib/std/Build/Step/WriteFile.zig+3
...@@ -126,6 +126,9 @@ pub fn addCopyFile(wf: *WriteFile, source: std.Build.LazyPath, sub_path: []const...@@ -126,6 +126,9 @@ pub fn addCopyFile(wf: *WriteFile, source: std.Build.LazyPath, sub_path: []const
126 return file.getPath();126 return file.getPath();
127}127}
128128
129/// Copy files matching the specified exclude/include patterns to the specified subdirectory
130/// relative to this step's generated directory.
131/// The returned value is a lazy path to the generated subdirectory.
129pub fn addCopyDirectory(132pub fn addCopyDirectory(
130 wf: *WriteFile,133 wf: *WriteFile,
131 source: std.Build.LazyPath,134 source: std.Build.LazyPath,
test/standalone/install_headers/build.zig+1-1
...@@ -32,7 +32,7 @@ pub fn build(b: *std.Build) void {...@@ -32,7 +32,7 @@ pub fn build(b: *std.Build) void {
32 \\}32 \\}
33 ) });33 ) });
3434
35 libfoo.installHeaders(.{ .path = "include" }, "foo", .{ .exclude_extensions = &.{".ignore_me.h"} });35 libfoo.installHeadersDirectory(.{ .path = "include" }, "foo", .{ .exclude_extensions = &.{".ignore_me.h"} });
36 libfoo.installHeader(b.addWriteFiles().add("d.h",36 libfoo.installHeader(b.addWriteFiles().add("d.h",
37 \\#define FOO_D "D"37 \\#define FOO_D "D"
38 \\38 \\