| ... | @@ -21,6 +21,7 @@ const Graph = @import("Maker/Graph.zig"); | ... | @@ -21,6 +21,7 @@ const Graph = @import("Maker/Graph.zig"); |
| 21 | const Step = @import("Maker/Step.zig"); | 21 | const Step = @import("Maker/Step.zig"); |
| 22 | const Watch = @import("Maker/Watch.zig"); | 22 | const Watch = @import("Maker/Watch.zig"); |
| 23 | const WebServer = @import("Maker/WebServer.zig"); | 23 | const WebServer = @import("Maker/WebServer.zig"); |
| | 24 | const ScannedConfig = @import("Maker/ScannedConfig.zig"); |
| 24 | | 25 | |
| 25 | pub const std_options: std.Options = .{ | 26 | pub const std_options: std.Options = .{ |
| 26 | .side_channels_mitigations = .none, | 27 | .side_channels_mitigations = .none, |
| ... | @@ -1667,205 +1668,3 @@ fn initStdoutWriter(io: Io) *Writer { | ... | @@ -1667,205 +1668,3 @@ fn initStdoutWriter(io: Io) *Writer { |
| 1667 | stdout_writer_allocation = Io.File.stdout().writerStreaming(io, &stdio_buffer_allocation); | 1668 | stdout_writer_allocation = Io.File.stdout().writerStreaming(io, &stdio_buffer_allocation); |
| 1668 | return &stdout_writer_allocation.interface; | 1669 | return &stdout_writer_allocation.interface; |
| 1669 | } | 1670 | } |
| 1670 | | | |
| 1671 | const ScannedConfig = struct { | | |
| 1672 | configuration: Configuration, | | |
| 1673 | top_level_steps: std.StringArrayHashMapUnmanaged(Configuration.Step.Index), | | |
| 1674 | | | |
| 1675 | fn print(sc: *const ScannedConfig, w: *Writer) Writer.Error!void { | | |
| 1676 | const c = &sc.configuration; | | |
| 1677 | var serializer: std.zon.Serializer = .{ .writer = w }; | | |
| 1678 | var s = try serializer.beginStruct(.{}); | | |
| 1679 | | | |
| 1680 | try s.field("default_step", @intFromEnum(c.default_step), .{}); | | |
| 1681 | { | | |
| 1682 | var ss = try s.beginStructField("top_level_steps", .{}); | | |
| 1683 | for (sc.top_level_steps.keys(), sc.top_level_steps.values()) |name, step| { | | |
| 1684 | try ss.field(name, @intFromEnum(step), .{}); | | |
| 1685 | } | | |
| 1686 | try ss.end(); | | |
| 1687 | } | | |
| 1688 | | | |
| 1689 | try s.end(); | | |
| 1690 | } | | |
| 1691 | | | |
| 1692 | fn printSteps(sc: *const ScannedConfig, graph: *Graph, w: *Writer) !void { | | |
| 1693 | const arena = graph.arena; | | |
| 1694 | const c = &sc.configuration; | | |
| 1695 | for (sc.top_level_steps.keys(), sc.top_level_steps.values()) |name, step_index| { | | |
| 1696 | const step = step_index.ptr(c); | | |
| 1697 | const decorated_name = if (step_index == c.default_step) | | |
| 1698 | try fmt.allocPrint(arena, "{s} (default)", .{name}) | | |
| 1699 | else | | |
| 1700 | name; | | |
| 1701 | const top_level = c.extraData(Configuration.Step.TopLevel, step.extra_index); | | |
| 1702 | const description = top_level.description.slice(c); | | |
| 1703 | try w.print(" {s:<28} {s}\n", .{ decorated_name, description }); | | |
| 1704 | } | | |
| 1705 | } | | |
| 1706 | | | |
| 1707 | fn printUsage(sc: *const ScannedConfig, graph: *Graph, w: *Writer) !void { | | |
| 1708 | const arena = graph.arena; | | |
| 1709 | | | |
| 1710 | try w.print( | | |
| 1711 | \\Usage: {s} build [steps] [options] | | |
| 1712 | \\ | | |
| 1713 | \\Steps: | | |
| 1714 | \\ | | |
| 1715 | , .{graph.zig_exe}); | | |
| 1716 | try printSteps(sc, graph, w); | | |
| 1717 | try w.writeAll( | | |
| 1718 | \\ | | |
| 1719 | \\Project-Specific Options: | | |
| 1720 | \\ | | |
| 1721 | ); | | |
| 1722 | | | |
| 1723 | const available_options = sc.configuration.available_options; | | |
| 1724 | if (available_options.len == 0) { | | |
| 1725 | try w.print(" (none)\n", .{}); | | |
| 1726 | } else { | | |
| 1727 | for (available_options) |option| { | | |
| 1728 | const name = option.name.slice(&sc.configuration); | | |
| 1729 | const description = option.description.slice(&sc.configuration); | | |
| 1730 | const help = try fmt.allocPrint(arena, " -D{s}=[{t}]", .{ name, option.type }); | | |
| 1731 | try w.print("{s:<30} {s}\n", .{ help, description }); | | |
| 1732 | if (option.enum_options.slice(&sc.configuration)) |enum_options| { | | |
| 1733 | const padding: [33]u8 = @splat(' '); | | |
| 1734 | try w.writeAll(padding ++ "Supported Values:\n"); | | |
| 1735 | for (enum_options) |enum_option_index| { | | |
| 1736 | const enum_option = enum_option_index.slice(&sc.configuration); | | |
| 1737 | try w.print(padding ++ " {s}\n", .{enum_option}); | | |
| 1738 | } | | |
| 1739 | } | | |
| 1740 | } | | |
| 1741 | } | | |
| 1742 | | | |
| 1743 | try w.writeAll( | | |
| 1744 | \\ | | |
| 1745 | \\System Integration Options: | | |
| 1746 | \\ --search-prefix [path] Add a path to look for binaries, libraries, headers | | |
| 1747 | \\ --sysroot [path] Set the system root directory (usually /) | | |
| 1748 | \\ --libc [file] Provide a file which specifies libc paths | | |
| 1749 | \\ | | |
| 1750 | \\ --system [pkgdir] Disable package fetching; enable all integrations | | |
| 1751 | \\ -fsys=[name] Enable a system integration | | |
| 1752 | \\ -fno-sys=[name] Disable a system integration | | |
| 1753 | \\ | | |
| 1754 | \\ -fdarling, -fno-darling Integration with system-installed Darling to | | |
| 1755 | \\ execute macOS programs on Linux hosts | | |
| 1756 | \\ (default: no) | | |
| 1757 | \\ -fqemu, -fno-qemu Integration with system-installed QEMU to execute | | |
| 1758 | \\ foreign-architecture programs on Linux hosts | | |
| 1759 | \\ (default: no) | | |
| 1760 | \\ --libc-runtimes [path] Enhances QEMU integration by providing dynamic libc | | |
| 1761 | \\ (e.g. glibc or musl) built for multiple foreign | | |
| 1762 | \\ architectures, allowing execution of non-native | | |
| 1763 | \\ programs that link with libc. | | |
| 1764 | \\ -frosetta, -fno-rosetta Rely on Rosetta to execute x86_64 programs on | | |
| 1765 | \\ ARM64 macOS hosts. (default: no) | | |
| 1766 | \\ -fwasmtime, -fno-wasmtime Integration with system-installed wasmtime to | | |
| 1767 | \\ execute WASI binaries. (default: no) | | |
| 1768 | \\ -fwine, -fno-wine Integration with system-installed Wine to execute | | |
| 1769 | \\ Windows programs on Linux hosts. (default: no) | | |
| 1770 | \\ | | |
| 1771 | \\ Available System Integrations: Enabled: | | |
| 1772 | \\ | | |
| 1773 | ); | | |
| 1774 | if (sc.configuration.system_integrations.len == 0) { | | |
| 1775 | try w.writeAll(" (none) -\n"); | | |
| 1776 | } else { | | |
| 1777 | for (sc.configuration.system_integrations) |system_integration| { | | |
| 1778 | const name = system_integration.name.slice(&sc.configuration); | | |
| 1779 | const status = switch (system_integration.status) { | | |
| 1780 | .disabled => "no", | | |
| 1781 | .enabled => "yes", | | |
| 1782 | }; | | |
| 1783 | try w.print(" {s:<43} {s}\n", .{ name, status }); | | |
| 1784 | } | | |
| 1785 | } | | |
| 1786 | | | |
| 1787 | try w.writeAll( | | |
| 1788 | \\ | | |
| 1789 | \\General Options: | | |
| 1790 | \\ -h, --help Print this help to stdout and exit | | |
| 1791 | \\ -l, --list-steps Print available steps to stdout and exit | | |
| 1792 | \\ | | |
| 1793 | \\ -p, --prefix [path] Where to install files (default: zig-out) | | |
| 1794 | \\ --prefix-lib-dir [path] Where to install libraries | | |
| 1795 | \\ --prefix-exe-dir [path] Where to install executables | | |
| 1796 | \\ --prefix-include-dir [path] Where to install C header files | | |
| 1797 | \\ --release[=mode] Request release mode, optionally specifying a | | |
| 1798 | \\ preferred optimization mode: fast, safe, small | | |
| 1799 | \\ | | |
| 1800 | \\ --verbose Print commands before executing them | | |
| 1801 | \\ --color [auto|off|on] Enable or disable colored error messages | | |
| 1802 | \\ --error-style [style] Control how build errors are printed | | |
| 1803 | \\ verbose (Default) Report errors with full context | | |
| 1804 | \\ minimal Report errors after summary, excluding context like command lines | | |
| 1805 | \\ verbose_clear Like 'verbose', but clear the terminal at the start of each update | | |
| 1806 | \\ minimal_clear Like 'minimal', but clear the terminal at the start of each update | | |
| 1807 | \\ --multiline-errors [style] Control how multi-line error messages are printed | | |
| 1808 | \\ indent (Default) Indent non-initial lines to align with initial line | | |
| 1809 | \\ newline Include a leading newline so that the error message is on its own lines | | |
| 1810 | \\ none Print as usual so the first line is misaligned | | |
| 1811 | \\ --summary [mode] Control the printing of the build summary | | |
| 1812 | \\ all Print the build summary in its entirety | | |
| 1813 | \\ new Omit cached steps | | |
| 1814 | \\ failures (Default if short-lived) Only print failed steps | | |
| 1815 | \\ line (Default if long-lived) Only print the single-line summary | | |
| 1816 | \\ none Do not print the build summary | | |
| 1817 | \\ -j<N> Limit concurrent jobs (default is to use all CPU cores) | | |
| 1818 | \\ --maxrss <bytes> Limit memory usage (default is to use available memory) | | |
| 1819 | \\ --skip-oom-steps Instead of failing, skip steps that would exceed --maxrss | | |
| 1820 | \\ --test-timeout <timeout> Limit execution time of unit tests, terminating if exceeded. | | |
| 1821 | \\ The timeout must include a unit: ns, us, ms, s, m, h | | |
| 1822 | \\ --watch Continuously rebuild when source files are modified | | |
| 1823 | \\ --debounce <ms> Delay before rebuilding after changed file detected | | |
| 1824 | \\ --webui[=ip] Enable the web interface on the given IP address | | |
| 1825 | \\ --fuzz[=limit] Continuously search for unit test failures with an optional | | |
| 1826 | \\ limit to the max number of iterations. The argument supports | | |
| 1827 | \\ an optional 'K', 'M', or 'G' suffix (e.g. '10K'). Implies | | |
| 1828 | \\ '--webui' when no limit is specified. | | |
| 1829 | \\ --time-report Force full rebuild and provide detailed information on | | |
| 1830 | \\ compilation time of Zig source code (implies '--webui') | | |
| 1831 | \\ -fincremental Enable incremental compilation | | |
| 1832 | \\ -fno-incremental Disable incremental compilation | | |
| 1833 | \\ | | |
| 1834 | \\Package Management Options: | | |
| 1835 | \\ --fetch[=mode] Fetch dependency tree (optionally choose laziness) and exit | | |
| 1836 | \\ needed (Default) Lazy dependencies are fetched as needed | | |
| 1837 | \\ all Lazy dependencies are always fetched | | |
| 1838 | \\ --fork=[path] Override one or more projects from dependency tree | | |
| 1839 | \\ | | |
| 1840 | \\Advanced Options: | | |
| 1841 | \\ -freference-trace[=num] How many lines of reference trace should be shown per compile error | | |
| 1842 | \\ -fno-reference-trace Disable reference trace | | |
| 1843 | \\ -fallow-so-scripts Allows .so files to be GNU ld scripts | | |
| 1844 | \\ -fno-allow-so-scripts (default) .so files must be ELF files | | |
| 1845 | \\ --error-limit [num] Set the maximum amount of distinct error values | | |
| 1846 | \\ --build-file [file] Override path to build.zig | | |
| 1847 | \\ --cache-dir [path] Override path to local Zig cache directory | | |
| 1848 | \\ --global-cache-dir [path] Override path to global Zig cache directory | | |
| 1849 | \\ --zig-lib-dir [arg] Override path to Zig lib directory | | |
| 1850 | \\ --build-runner [file] Override path to build runner | | |
| 1851 | \\ --seed [integer] For shuffling dependency traversal order (default: random) | | |
| 1852 | \\ --build-id[=style] At a minor link-time expense, embeds a build ID in binaries | | |
| 1853 | \\ fast 8-byte non-cryptographic hash (COFF, ELF, WASM) | | |
| 1854 | \\ sha1, tree 20-byte cryptographic hash (ELF, WASM) | | |
| 1855 | \\ md5 16-byte cryptographic hash (ELF) | | |
| 1856 | \\ uuid 16-byte random UUID (ELF, WASM) | | |
| 1857 | \\ 0x[hexstring] Constant ID, maximum 32 bytes (ELF, WASM) | | |
| 1858 | \\ none (default) No build ID | | |
| 1859 | \\ --debug-log [scope] Enable debugging the compiler | | |
| 1860 | \\ --debug-pkg-config Fail if unknown pkg-config flags encountered | | |
| 1861 | \\ --debug-rt Debug compiler runtime libraries | | |
| 1862 | \\ --verbose-link Enable compiler debug output for linking | | |
| 1863 | \\ --verbose-air Enable compiler debug output for Zig AIR | | |
| 1864 | \\ --verbose-llvm-ir Enable compiler debug output for LLVM IR | | |
| 1865 | \\ --verbose-cimport Enable compiler debug output for C imports | | |
| 1866 | \\ --verbose-cc Enable compiler debug output for C compilation | | |
| 1867 | \\ --verbose-llvm-cpu-features Enable compiler debug output for LLVM CPU features | | |
| 1868 | \\ | | |
| 1869 | ); | | |
| 1870 | } | | |
| 1871 | }; | | |