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
15681568 return Step.ObjCopy.create(b, source, options);
15691569}
15701570
1571///`dest_rel_path` is relative to install prefix path
1571/// `dest_rel_path` is relative to install prefix path
15721572pub fn addInstallFile(b: *Build, source: LazyPath, dest_rel_path: []const u8) *Step.InstallFile {
15731573 return b.addInstallFileWithDir(source, .prefix, dest_rel_path);
15741574}
15751575
1576///`dest_rel_path` is relative to bin path
1576/// `dest_rel_path` is relative to bin path
15771577pub fn addInstallBinFile(b: *Build, source: LazyPath, dest_rel_path: []const u8) *Step.InstallFile {
15781578 return b.addInstallFileWithDir(source, .bin, dest_rel_path);
15791579}
15801580
1581///`dest_rel_path` is relative to lib path
1581/// `dest_rel_path` is relative to lib path
15821582pub fn addInstallLibFile(b: *Build, source: LazyPath, dest_rel_path: []const u8) *Step.InstallFile {
15831583 return b.addInstallFileWithDir(source, .lib, dest_rel_path);
15841584}
15851585
1586/// `dest_rel_path` is relative to header path
15861587pub fn addInstallHeaderFile(b: *Build, source: LazyPath, dest_rel_path: []const u8) *Step.InstallFile {
15871588 return b.addInstallFileWithDir(source, .header, dest_rel_path);
15881589}
lib/std/Build/Step/Compile.zig+13-1
......@@ -446,6 +446,9 @@ pub fn create(owner: *std.Build, options: Options) *Compile {
446446 return self;
447447}
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.
449452pub fn installHeader(cs: *Compile, source: LazyPath, dest_rel_path: []const u8) void {
450453 const b = cs.step.owner;
451454 const installation: HeaderInstallation = .{ .file = .{
......@@ -457,7 +460,10 @@ pub fn installHeader(cs: *Compile, source: LazyPath, dest_rel_path: []const u8)
457460 installation.getSource().addStepDependencies(&cs.step);
458461}
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(
461467 cs: *Compile,
462468 source: LazyPath,
463469 dest_rel_path: []const u8,
......@@ -474,10 +480,16 @@ pub fn installHeaders(
474480 installation.getSource().addStepDependencies(&cs.step);
475481}
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.
477486pub fn installConfigHeader(cs: *Compile, config_header: *Step.ConfigHeader) void {
478487 cs.installHeader(config_header.getOutput(), config_header.include_path);
479488}
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.
481493pub fn installLibraryHeaders(cs: *Compile, lib: *Compile) void {
482494 assert(lib.kind == .lib);
483495 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
126126 return file.getPath();
127127}
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.
129132pub fn addCopyDirectory(
130133 wf: *WriteFile,
131134 source: std.Build.LazyPath,
test/standalone/install_headers/build.zig+1-1
......@@ -32,7 +32,7 @@ pub fn build(b: *std.Build) void {
3232 \\}
3333 ) });
3434
35 libfoo.installHeaders(.{ .path = "include" }, "foo", .{ .exclude_extensions = &.{".ignore_me.h"} });
35 libfoo.installHeadersDirectory(.{ .path = "include" }, "foo", .{ .exclude_extensions = &.{".ignore_me.h"} });
3636 libfoo.installHeader(b.addWriteFiles().add("d.h",
3737 \\#define FOO_D "D"
3838 \\