// SPDX-FileCopyrightText: 2026 Progmasoft // SPDX-License-Identifier: MIT using System.Runtime.CompilerServices; using Progmasoft.Tazel.Dsl.Common; namespace Progmasoft.Tazel.Dsl.Build.Prelude; /// C and C++ targets; the language of each file comes from its extension. public static class CC { /// Declares a static library. public static Target StaticLibrary( string name, CCStaticLibrarySettings settings, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) => Declarations.Declare(Family.CC, TargetKind.StaticLibrary, name, settings, file, line); /// Declares a shared library. public static Target SharedLibrary( string name, CCSharedLibrarySettings settings, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) => Declarations.Declare(Family.CC, TargetKind.SharedLibrary, name, settings, file, line); /// Declares an executable. public static Target Executable( string name, CCExecutableSettings settings, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) => Declarations.Declare(Family.CC, TargetKind.Executable, name, settings, file, line); /// Declares a test. public static Target Test( string name, CCTestSettings settings, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) => Declarations.Declare(Family.CC, TargetKind.Test, name, settings, file, line); /// Turns a toolchain feature on for a target. public static FeatureToggle Enable(string name) => new(name, true); /// Turns a toolchain feature off for a target. public static FeatureToggle Disable(string name) => new(name, false); } /// Objective-C and Objective-C++ targets, with C and C++ files beside them. public static class ObjectiveC { /// Declares a static library. public static Target StaticLibrary( string name, ObjectiveCStaticLibrarySettings settings, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) => Declarations.Declare(Family.ObjectiveC, TargetKind.StaticLibrary, name, settings, file, line); /// Declares a shared library. public static Target SharedLibrary( string name, ObjectiveCSharedLibrarySettings settings, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) => Declarations.Declare(Family.ObjectiveC, TargetKind.SharedLibrary, name, settings, file, line); /// Declares an executable. public static Target Executable( string name, ObjectiveCExecutableSettings settings, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) => Declarations.Declare(Family.ObjectiveC, TargetKind.Executable, name, settings, file, line); /// Declares a test. public static Target Test( string name, ObjectiveCTestSettings settings, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) => Declarations.Declare(Family.ObjectiveC, TargetKind.Test, name, settings, file, line); /// Turns a toolchain feature on for a target. public static FeatureToggle Enable(string name) => new(name, true); /// Turns a toolchain feature off for a target. public static FeatureToggle Disable(string name) => new(name, false); } /// Zig targets. public static class Zig { /// Declares a module, which other Zig targets import. public static Target Module( string name, ZigModuleSettings settings, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) => Declarations.Declare(Family.Zig, TargetKind.Module, name, settings, file, line); /// Declares a static library. public static Target StaticLibrary( string name, ZigStaticLibrarySettings settings, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) => Declarations.Declare(Family.Zig, TargetKind.StaticLibrary, name, settings, file, line); /// Declares a shared library. public static Target SharedLibrary( string name, ZigSharedLibrarySettings settings, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) => Declarations.Declare(Family.Zig, TargetKind.SharedLibrary, name, settings, file, line); /// Declares an executable. public static Target Executable( string name, ZigExecutableSettings settings, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) => Declarations.Declare(Family.Zig, TargetKind.Executable, name, settings, file, line); /// Declares a test, which zig test builds. public static Target Test( string name, ZigTestSettings settings, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) => Declarations.Declare(Family.Zig, TargetKind.Test, name, settings, file, line); } /// What a project file can ask about the build it is part of. public sealed class BuildContext { internal BuildContext(BuildMode mode, Platform platform) { Mode = mode; Platform = platform; } /// Whether the build is a debug or a release build. public BuildMode Mode { get; } /// The platform the command builds for. public Platform Platform { get; } /// The operating system of . public OS OS => Platform.GetOS(); /// The architecture of . public Arch Arch => Platform.GetArch(); } /// What a BUILD.csx sees beyond its imports. public sealed class BuildGlobals { internal BuildGlobals(BuildContext build) => Build = build; /// The build this file is part of. public BuildContext Build { get; } }