4#include "../Containers/Array.h"
5#include "../Containers/VectorSet.h"
6#include "../Foundation/Result.h"
7#include "../Foundation/TaggedUnion.h"
8#include "../Strings/String.h"
9#include "Internal/TaggedMap.h"
39 case Unknown:
return "unknown";
40 case Windows:
return "windows";
41 case Apple:
return "apple";
42 case Linux:
return "linux";
43 case Wasm:
return "wasm";
45 Assert::unreachable();
66 case Any:
return "Any";
67 case Intel32:
return "Intel32";
68 case Intel64:
return "Intel64";
69 case Arm64:
return "Arm64";
70 case Wasm:
return "Wasm";
72 Assert::unreachable();
92 case XCode:
return "XCode";
95 case Make:
return "Make";
97 Assert::unreachable();
115 case Debug:
return "Debug"_a8;
116 case Release:
return "Release"_a8;
118 Assert::unreachable();
149 case includePaths:
return {
"includePaths",
"Include paths"};
152 case enableASAN:
return {
"enableASAN",
"Address Sanitizer"};
153 case enableRTTI:
return {
"enableRTTI",
"Runtime Type Identification"};
155 case enableStdCpp:
return {
"enableStdCpp",
"C++ Standard Library"};
156 case enableCoverage:
return {
"enableCoverage",
"Code coverage instrumentation"};
158 Assert::unreachable();
160 template <Type E,
typename T>
164 Tag<preprocessorDefines, Vector<String>>,
165 Tag<optimizationLevel, Optimization::Type>,
166 Tag<enableASAN, bool>,
167 Tag<enableRTTI, bool>,
168 Tag<enableExceptions, bool>,
169 Tag<enableCoverage, bool>,
170 Tag<enableStdCpp, bool>>;
181 return getOrCreate<Compile::includePaths>()->append(includes);
187 return getOrCreate<Compile::preprocessorDefines>()->append(defines);
222 Assert::unreachable();
224 template <Type E,
typename T>
228 Tag<linkFrameworksAny, Vector<String>>,
229 Tag<linkFrameworksMacOS, Vector<String>>,
230 Tag<linkFrameworksIOS, Vector<String>>,
231 Tag<linkLibraries, Vector<String>>,
232 Tag<guiApplication, bool>,
233 Tag<enableLTO, bool>,
234 Tag<enableASAN, bool>,
235 Tag<enableStdCpp, bool>
241enum class PlatformApple
248struct LinkFlags :
public TaggedMap<Link::Type, Link::Union>
253 return getOrCreate<Link::libraryPaths>()->append(libraries);
261 case PlatformApple::macOS:
return getOrCreate<Link::linkFrameworksMacOS>()->append(frameworks);
262 case PlatformApple::iOS:
return getOrCreate<Link::linkFrameworksIOS>()->append(frameworks);
263 default:
return getOrCreate<Link::linkFrameworksAny>()->append(frameworks);
270 return getOrCreate<Link::linkLibraries>()->append(libraries);
304 Assert::unreachable();
310 [[nodiscard]]
static constexpr StringView getStandardBuildDirectory()
312 return "$(TARGET_OS)-$(TARGET_ARCHITECTURES)-$(BUILD_SYSTEM)-$(COMPILER)-$(CONFIGURATION)";
348 Assert::unreachable();
368 bool operator==(
const File& other)
const
439 String intermediatesDirectory;
441 String packagesCacheDirectory;
442 String packagesInstallDirectory;
481 [[nodiscard]]
Result validate();
482 [[nodiscard]]
Result build();
509 Type action = Configure;
Build Architecture (Processor / Instruction set)
Definition: Build.h:51
static constexpr StringView toString(Type type)
Get StringView from Architecture::Type.
Definition: Build.h:62
Two StringViews representing name and description.
Definition: Build.h:139
Map of SC::Build::Compile flags (include paths, preprocessor defines etc.)
Definition: Build.h:177
bool addDefines(Span< const StringView > defines)
Add define to preprocessor definitions.
Definition: Build.h:185
bool addIncludes(Span< const StringView > includes)
Add paths to includes search paths list.
Definition: Build.h:179
Compilation switches (include paths, preprocessor defines, etc.)
Definition: Build.h:124
static constexpr NameDescription typeToString(Type type)
Get name and description from Compile::Type.
Definition: Build.h:145
Type
Definition: Build.h:126
@ enableRTTI
Runtime Type Identification.
Definition: Build.h:131
@ enableStdCpp
C++ Standard Library.
Definition: Build.h:133
@ enableExceptions
C++ Exceptions.
Definition: Build.h:132
@ preprocessorDefines
Preprocessor defines.
Definition: Build.h:128
@ enableASAN
Address Sanitizer.
Definition: Build.h:130
@ includePaths
Include paths.
Definition: Build.h:127
@ enableCoverage
Enables code coverage instrumentation.
Definition: Build.h:134
@ optimizationLevel
Optimization Level (debug / release)
Definition: Build.h:129
Visual Studio platform toolset.
Definition: Build.h:288
Groups SC::Build::CompileFlags and SC::Build::LinkFlags for a given SC::Build::Architecture.
Definition: Build.h:276
Preset preset
Build preset applied to this configuration.
Definition: Build.h:322
String intermediatesPath
Obj path. If relative, it's appended to _Intermediates relative to .
Definition: Build.h:317
String outputPath
Exe path. If relative, it's appended to _Outputs relative to .
Definition: Build.h:316
bool applyPreset(Preset newPreset, const Parameters ¶meters)
Set compile flags depending on the given Preset.
CompileFlags compile
Configuration compile flags.
Definition: Build.h:319
String name
Configuration name.
Definition: Build.h:315
static constexpr StringView PresetToString(Preset preset)
Convert Preset to StringView.
Definition: Build.h:295
LinkFlags link
Configuration link flags.
Definition: Build.h:320
Architecture::Type architecture
Restrict this configuration to a specific architecture.
Definition: Build.h:323
Preset
A pre-made preset with pre-configured set of options.
Definition: Build.h:279
@ None
Custom configuration.
@ Debug
Debug configuration.
@ Release
Release configuration.
@ DebugCoverage
Debug coverage configuration.
VisualStudio visualStudio
Customize VisualStudio platformToolset.
Definition: Build.h:292
Caches file paths by pre-resolving directory filter search masks.
Definition: Build.h:475
Top level build description holding all Workspace objects.
Definition: Build.h:464
Result configure(StringView projectName, const Parameters ¶meters) const
Generates projects for all workspaces, with specified parameters at given root path.
Vector< Workspace > workspaces
Workspaces to be generated.
Definition: Build.h:465
Build system generator (Xcode / Visual Studio)
Definition: Build.h:78
static constexpr StringView toString(Type type)
Get StringView from Generator::Type.
Definition: Build.h:88
Type
Definition: Build.h:80
@ Make
Generate posix makefiles.
Definition: Build.h:84
@ VisualStudio2022
Generate projects for Visual Studio 2022.
Definition: Build.h:82
@ VisualStudio2019
Generate projects for Visual Studio 2019.
Definition: Build.h:83
@ XCode
Generate projects for XCode (Version 14+)
Definition: Build.h:81
Map of SC::Build::Link flags (library paths, LTO switch etc.)
Definition: Build.h:249
bool addFrameworks(Span< const StringView > frameworks, PlatformApple appleOS=PlatformApple::Any)
Add framework to list of frameworks to link.
Definition: Build.h:257
bool addLibraries(Span< const StringView > libraries)
Add more libraries to list of libraries to link.
Definition: Build.h:268
bool addSearchPath(Span< const StringView > libraries)
Add the given paths to the library search paths list.
Definition: Build.h:251
Linking switches (library paths, LTO etc.)
Definition: Build.h:193
Type
Definition: Build.h:195
@ libraryPaths
Library paths.
Definition: Build.h:196
@ enableStdCpp
C++ Standard Library.
Definition: Build.h:204
@ enableASAN
Address Sanitizer.
Definition: Build.h:203
@ linkLibraries
Libraries to link.
Definition: Build.h:200
@ linkFrameworksIOS
Frameworks to link on iOS.
Definition: Build.h:199
@ linkFrameworksAny
Frameworks to link on any Apple Platform.
Definition: Build.h:197
@ guiApplication
gui application
Definition: Build.h:201
@ enableLTO
Link Time Optimization.
Definition: Build.h:202
@ linkFrameworksMacOS
Frameworks to link on macOS.
Definition: Build.h:198
static constexpr StringView typeToString(Type type)
Get StringView describing Link::Type.
Definition: Build.h:208
Optimization level (Debug / Release)
Definition: Build.h:103
static constexpr StringView toString(Type type)
Get StringView from Optimization::Type.
Definition: Build.h:111
Type
Definition: Build.h:105
@ Debug
Optimizations set to debug.
Definition: Build.h:106
@ Release
Optimizations set to release.
Definition: Build.h:107
Describes a specific set of platforms, architectures and build generators to generate projects for.
Definition: Build.h:448
Platform::Type platform
Platform to generate.
Definition: Build.h:449
Generator::Type generator
Build system types to generate.
Definition: Build.h:451
Architecture::Type architecture
Architecture to generate.
Definition: Build.h:450
Project list of files.
Definition: Build.h:357
Operation
Indicates if this is an additive or subtractive files operation.
Definition: Build.h:360
@ Remove
Remove files.
Definition: Build.h:362
@ Add
Add files.
Definition: Build.h:361
Operation operation
Operation type (add or remove files)
Definition: Build.h:364
String mask
Mask suffix (can contain *)
Definition: Build.h:366
String base
Base path (not containing *)
Definition: Build.h:365
Groups multiple Configuration and source files with their compile and link flags.
Definition: Build.h:354
const Configuration * getConfiguration(StringView configurationName) const
Get Configuration with the matching configurationName
Configuration * getConfiguration(StringView configurationName)
Get Configuration with the matching configurationName
TargetType::Type targetType
Type of build artifact.
Definition: Build.h:378
Result validate() const
Validates this project for it to contain a valid combination of flags.
String rootDirectory
Project root directory.
Definition: Build.h:381
String targetName
Project target name.
Definition: Build.h:382
CompileFlags compile
Shared CompileFlags for all files in the project.
Definition: Build.h:386
bool addDirectory(StringView subdirectory, StringView filter)
Add all files from specific subdirectory (relative to project root) matching given filter.
bool setRootDirectory(StringView file)
Set root directory for this project (all relative paths will be relative to this one)
Vector< Configuration > configurations
Build configurations created inside the project.
Definition: Build.h:389
bool removeFiles(StringView subdirectory, StringView filter)
Remove files matching the given filter.
LinkFlags link
Shared LinkFlags for all files in the project.
Definition: Build.h:387
String name
Project name.
Definition: Build.h:380
bool addPresetConfiguration(Configuration::Preset preset, const Parameters ¶meters, StringView configurationName=StringView())
Add a configuration with a given name, started by cloning options of a specific Preset.
String iconPath
Icon location.
Definition: Build.h:383
Vector< File > files
Files that belong to the project.
Definition: Build.h:385
bool addFile(StringView singleFile)
Add a single file to the project.
Type of target artifact to build (executable, library)
Definition: Build.h:330
static constexpr StringView typeToString(Type type)
Convert TargetType to StringView.
Definition: Build.h:340
Type
Type of artifact.
Definition: Build.h:333
@ StaticLibrary
Create static library.
Definition: Build.h:336
@ Executable
Create executable program.
Definition: Build.h:334
@ DynamicLibrary
Create dynamic library.
Definition: Build.h:335
Groups multiple Project together with shared compile and link flags.
Definition: Build.h:423
String name
Workspace name.
Definition: Build.h:427
LinkFlags link
Global workspace link flags for all projects.
Definition: Build.h:430
Vector< Project > projects
List of projects in this workspace.
Definition: Build.h:428
CompileFlags compile
Global workspace compile flags for all projects.
Definition: Build.h:429
Result validate() const
Validates all projects in this workspace.
An ascii string used as boolean result. SC_TRY macro forwards errors to caller.
Definition: Result.h:11
View over a contiguous sequence of items (pointer + size in elements).
Definition: Span.h:20
A non-modifiable owning string with associated encoding.
Definition: String.h:30
Non-owning view over a range of characters with UTF Encoding.
Definition: StringView.h:47
Associate a Type to an Enum, as required by TaggedUnion.
Definition: TaggedUnion.h:24
Type safe union with an enum type, where each type has an associated enum value.
Definition: TaggedUnion.h:38
Represents a variadic template type list.
Definition: TypeList.h:19
A contiguous sequence of heap allocated elements.
Definition: Vector.h:51
A map holding VectorMapItem key-value pairs in an unsorted Vector.
Definition: VectorMap.h:33
A set built on an unsorted Vector, ensuring no item duplication.
Definition: VectorSet.h:20