aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build/Step/Compile.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-07-21 20:29:42 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-07-22 00:16:27 -0700
commit6e4fff6ba62ae3e61a948c98fa8fea7e35732cc0 (patch)
tree017722866adaf7405fd5a2cc72bc0380334de060 /lib/std/Build/Step/Compile.zig
parent1291f4aca46b2929d9ee9b265a2bfe5311e60861 (diff)
downloadzig-6e4fff6ba62ae3e61a948c98fa8fea7e35732cc0.tar.gz
zig-6e4fff6ba62ae3e61a948c98fa8fea7e35732cc0.zip
move installation logic to the build script where it belongs
* build.zig: introduce `-Dflat` option which makes the installation match what we want to ship for our download tarballs. This allows deleting a bunch of shell script logic from the CI. - for example it puts the executable directly in prefix/zig rather than prefix/bin/zig and it additionally includes prefix/LICENSE. * build.zig: by default also install std lib documentation to doc/std/ - this can be disabled by `-Dno-autodocs` similar to how there is already `-Dno-langref`. * build.zig: add `std-docs` and `langref` steps which build and install the std lib autodocs and langref to prefix/doc/std and prefix/doc/langref.html, respectively. * std.Build: implement proper handling of `-femit-docs` using the LazyPath system. This is a breaking change. - this is a partial implementation of #16351 * frontend: fixed the handling of Autodocs with regards to caching and putting the artifacts in the proper location to integrate with the build system. - closes #15864 * CI: delete the logic for autodocs since it is now handled by build.zig and is enabled by default. - in the future we should strive to have nearly all the CI shell script logic deleted in favor of `zig build` commands. * CI: pass `-DZIG_NO_LIB=ON`/`-Dno-lib` except for the one command where we want to actually generate the langref and autodocs. Generating the langref takes 14 minutes right now (why?!) so we don't want to do that more times than necessary. * Autodoc: fixed use of a global variable. It works fine as a local variable instead. - note that in the future we will want to make Autodoc run simultaneously using the job system, but for now the principle of YAGNI dictates that we don't have an init()/deinit() API and instead simply call the function that does the things. * Autodoc: only do it when there are no compile errors
Diffstat (limited to 'lib/std/Build/Step/Compile.zig')
-rw-r--r--lib/std/Build/Step/Compile.zig20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/std/Build/Step/Compile.zig b/lib/std/Build/Step/Compile.zig
index 22e88a0d71..7ff82e4b7b 100644
--- a/lib/std/Build/Step/Compile.zig
+++ b/lib/std/Build/Step/Compile.zig
@@ -49,7 +49,6 @@ verbose_cc: bool,
emit_analysis: EmitOption = .default,
emit_asm: EmitOption = .default,
emit_bin: EmitOption = .default,
-emit_docs: EmitOption = .default,
emit_implib: EmitOption = .default,
emit_llvm_bc: EmitOption = .default,
emit_llvm_ir: EmitOption = .default,
@@ -217,6 +216,7 @@ output_lib_path_source: GeneratedFile,
output_h_path_source: GeneratedFile,
output_pdb_path_source: GeneratedFile,
output_dirname_source: GeneratedFile,
+generated_docs: ?*GeneratedFile,
pub const CSourceFiles = struct {
files: []const []const u8,
@@ -433,7 +433,7 @@ pub fn create(owner: *std.Build, options: Options) *Compile {
}) catch @panic("OOM");
const self = owner.allocator.create(Compile) catch @panic("OOM");
- self.* = Compile{
+ self.* = .{
.strip = null,
.unwind_tables = null,
.verbose_link = false,
@@ -486,6 +486,7 @@ pub fn create(owner: *std.Build, options: Options) *Compile {
.output_h_path_source = GeneratedFile{ .step = &self.step },
.output_pdb_path_source = GeneratedFile{ .step = &self.step },
.output_dirname_source = GeneratedFile{ .step = &self.step },
+ .generated_docs = null,
.target_info = target_info,
@@ -1004,6 +1005,15 @@ pub fn getOutputPdbSource(self: *Compile) FileSource {
return .{ .generated = &self.output_pdb_path_source };
}
+pub fn getOutputDocs(self: *Compile) FileSource {
+ assert(self.generated_docs == null); // This function may only be called once.
+ const arena = self.step.owner.allocator;
+ const generated_file = arena.create(GeneratedFile) catch @panic("OOM");
+ generated_file.* = .{ .step = &self.step };
+ self.generated_docs = generated_file;
+ return .{ .generated = generated_file };
+}
+
pub fn addAssemblyFile(self: *Compile, path: []const u8) void {
const b = self.step.owner;
self.link_objects.append(.{
@@ -1509,7 +1519,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
if (self.emit_analysis.getArg(b, "emit-analysis")) |arg| try zig_args.append(arg);
if (self.emit_asm.getArg(b, "emit-asm")) |arg| try zig_args.append(arg);
if (self.emit_bin.getArg(b, "emit-bin")) |arg| try zig_args.append(arg);
- if (self.emit_docs.getArg(b, "emit-docs")) |arg| try zig_args.append(arg);
+ if (self.generated_docs != null) try zig_args.append("-femit-docs");
if (self.emit_implib.getArg(b, "emit-implib")) |arg| try zig_args.append(arg);
if (self.emit_llvm_bc.getArg(b, "emit-llvm-bc")) |arg| try zig_args.append(arg);
if (self.emit_llvm_ir.getArg(b, "emit-llvm-ir")) |arg| try zig_args.append(arg);
@@ -2022,6 +2032,10 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
&.{ output_dir, self.out_pdb_filename },
);
}
+
+ if (self.generated_docs) |generated_docs| {
+ generated_docs.path = b.pathJoin(&.{ output_dir, "docs" });
+ }
}
if (self.kind == .lib and self.linkage != null and self.linkage.? == .dynamic and