From 81e3b64ecda857458b8e0762bdf6156cdaa1cb74 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 8 Sep 2022 16:35:25 +0100 Subject: 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 --- src/build_settings.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/build_settings.cpp') 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; } -- cgit v1.2.3