diff options
| author | gingerBill <bill@gingerbill.org> | 2022-09-08 16:35:25 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-09-08 16:35:25 +0100 |
| commit | 81e3b64ecda857458b8e0762bdf6156cdaa1cb74 (patch) | |
| tree | 3571e769475762f406af73f4aa3d4585276d28a8 /src/build_settings.cpp | |
| parent | 39728b8bfbd15a82a3137b303bb58394342c2250 (diff) | |
Add `ODIN_BUILD_PROJECT_NAME` and `//+build-project-name`
This allows for condition inclusion of files, similar to `+build` or `ODIN_BUILD`, but relies on the directory name of the project to be the same as specified
Example:
odin build foo/bar/baz
ODIN_BUILD_PROJECT_NAME == "baz"
//+build_project_name baz
Diffstat (limited to 'src/build_settings.cpp')
| -rw-r--r-- | src/build_settings.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/build_settings.cpp b/src/build_settings.cpp index 998c40208..b877b8cb7 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -225,6 +225,7 @@ struct BuildContext { String ODIN_VENDOR; // compiler vendor String ODIN_VERSION; // compiler version String ODIN_ROOT; // Odin ROOT + String ODIN_BUILD_PROJECT_NAME; // Odin main/initial package's directory name bool ODIN_DEBUG; // Odin in debug mode bool ODIN_DISABLE_ASSERT; // Whether the default 'assert' et al is disabled in code or not bool ODIN_DEFAULT_TO_NIL_ALLOCATOR; // Whether the default allocator is a "nil" allocator or not (i.e. it does nothing) @@ -1537,6 +1538,12 @@ bool init_build_paths(String init_filename) { enable_target_feature({}, bc->target_features_string); } + { + String build_project_name = last_path_element(bc->build_paths[BuildPath_Main_Package].basename); + GB_ASSERT(build_project_name.len > 0); + bc->ODIN_BUILD_PROJECT_NAME = build_project_name; + } + return true; } |