// SPDX-FileCopyrightText: 2026 Progmasoft // SPDX-License-Identifier: MIT using System; using System.Collections.Generic; using Progmasoft.Tazel.Dsl.Common; namespace Progmasoft.Tazel.Dsl.Build.Prelude; /// How zig optimizes, as its -O names it. public enum ZigOptimization { /// No optimization, every safety check. Debug, /// Optimized, with safety checks. ReleaseSafe, /// Optimized for speed, without safety checks. ReleaseFast, /// Optimized for size, without safety checks. ReleaseSmall, } /// A Zig module: a root file other Zig targets import by a name. public class ZigModuleSettings : TargetSettings { /// The root file of the module. public string RootSourceFile { get; init; } = ""; /// /// The files the root imports, for the cache; default: every .zig file beside the root file and below it. /// public Files Sources { get; init; } = Files.None; /// The modules this one imports: the name @import uses, and the label of a Zig module. public Dictionary ModuleImports { get; init; } = new(); /// How zig optimizes; default: Debug in a debug build, ReleaseSafe in a release build. public ZigOptimization? OptimizationMode { get; init; } } /// What every Zig target that zig compiles has. public abstract class ZigCompiledSettings : ZigModuleSettings { /// C and C++ files zig compiles into the target. public Files CSources { get; init; } = Files.None; /// Options for every file of . public IReadOnlyList CompilerOptions { get; init; } = []; /// Options for the .c files of . public IReadOnlyList CCompilerOptions { get; init; } = []; /// Options for the .cpp files of . public IReadOnlyList CppCompilerOptions { get; init; } = []; /// Options for zig itself, as written. public IReadOnlyList ZigCompilerOptions { get; init; } = []; /// Options for the linker. public IReadOnlyList LinkerOptions { get; init; } = []; /// Whether the C library is linked (-lc). public bool LinkCStandardLibrary { get; init; } /// Whether the code is position independent (-fPIC). public bool PositionIndependentCode { get; init; } /// Whether symbols are stripped (-fstrip). public bool StripSymbols { get; init; } /// Whether link-time optimization is on (-flto). public bool LinkTimeOptimization { get; init; } } /// A Zig static library. public sealed class ZigStaticLibrarySettings : ZigCompiledSettings { /// The C header zig emits (-femit-h); default: none. public string? EmitHeader { get; init; } } /// A Zig shared library. public sealed class ZigSharedLibrarySettings : ZigCompiledSettings { /// The version of the library; default: none. public Version? LibraryVersion { get; init; } /// The C header zig emits (-femit-h); default: none. public string? EmitHeader { get; init; } } /// A Zig executable. public class ZigExecutableSettings : ZigCompiledSettings, IRunSettings { /// public IReadOnlyList Arguments { get; init; } = []; /// public Files RuntimeData { get; init; } = Files.None; /// public Dictionary EnvironmentVariables { get; init; } = new(); } /// A Zig test, which zig test builds. public sealed class ZigTestSettings : ZigExecutableSettings, ITestSettings { /// Runs only the tests whose names hold this text (--test-filter). public string? TestFilter { get; init; } /// public IReadOnlyList InheritedEnvironmentVariables { get; init; } = []; /// public TestSize TestSize { get; init; } = TestSize.Medium; /// public TimeSpan? Timeout { get; init; } /// public bool Flaky { get; init; } /// public int ShardCount { get; init; } = 1; /// public bool RunLocally { get; init; } }