Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ on:
branches:
- libhal

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
package_and_upload_all_check:
uses: libhal/ci/.github/workflows/package_and_upload_all.yml@5.x.y
with:
modules_support_needed: true
extra_conan_arguments: -o "*:cxx_modules=True" -o "*:freestanding=True" -o "*:contracts=none" -o "*:import_std=False" -o "*:enable_rtti=False"
secrets: inherit
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ check_cache_var_values(MP_UNITS_DEV_TIME_TRACE NONE ALL MODULES HEADERS)
message(STATUS "MP_UNITS_DEV_IWYU: ${MP_UNITS_DEV_IWYU}")
message(STATUS "MP_UNITS_DEV_CLANG_TIDY: ${MP_UNITS_DEV_CLANG_TIDY}")
message(STATUS "MP_UNITS_DEV_TIME_TRACE: ${MP_UNITS_DEV_TIME_TRACE}")
message(STATUS "MP_UNITS_RTTI: ${MP_UNITS_RTTI}")

# make sure that the file is being used as an entry point
include(modern_project_structure)
Expand Down
35 changes: 25 additions & 10 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class MPUnitsConan(ConanFile):
"no_crtp": [True, False],
"contracts": ["none", "gsl-lite", "ms-gsl"],
"freestanding": [True, False],
"enable_rtti": [True, False],
}
default_options = {
# "cxx_modules" default set in config_options()
Expand All @@ -70,6 +71,7 @@ class MPUnitsConan(ConanFile):
"import_std": False, # still experimental in CMake
"contracts": "gsl-lite",
"freestanding": False,
"enable_rtti": True,
}
implements = ["auto_header_only"]
exports = "LICENSE.md"
Expand All @@ -82,6 +84,7 @@ class MPUnitsConan(ConanFile):
"CMakeLists.txt",
)
no_copy_source = True
user = "libhal"

@property
def _feature_compatibility(self):
Expand Down Expand Up @@ -181,7 +184,8 @@ def _run_clang_tidy(self):
return bool(self.conf.get("user.mp-units.analyze:clang-tidy", default=False))

def set_version(self):
content = load(self, os.path.join(self.recipe_folder, "src/CMakeLists.txt"))
content = load(self, os.path.join(
self.recipe_folder, "src/CMakeLists.txt"))
version = re.search(
r"project\([^\)]+VERSION (\d+\.\d+\.\d+)[^\)]*\)", content
).group(1)
Expand Down Expand Up @@ -282,7 +286,10 @@ def generate(self):
else:
tc.cache_variables["MP_UNITS_API_STD_FORMAT"] = opt.std_format
tc.cache_variables["MP_UNITS_API_NO_CRTP"] = opt.no_crtp
tc.cache_variables["MP_UNITS_API_CONTRACTS"] = str(opt.contracts).upper()
tc.cache_variables["MP_UNITS_API_CONTRACTS"] = str(
opt.contracts).upper()

tc.cache_variables["MP_UNITS_RTTI"] = opt.enable_rtti

tc.generate()
deps = CMakeDeps(self)
Expand Down Expand Up @@ -329,36 +336,43 @@ def package_info(self):
"MP_UNITS_API_CONTRACTS=0"
)
elif self.options.contracts == "gsl-lite":
self.cpp_info.components["core"].requires.append("gsl-lite::gsl-lite")
self.cpp_info.components["core"].requires.append(
"gsl-lite::gsl-lite")
self.cpp_info.components["core"].defines.append(
"MP_UNITS_API_CONTRACTS=2"
)
elif self.options.contracts == "ms-gsl":
self.cpp_info.components["core"].requires.append("ms-gsl::ms-gsl")
self.cpp_info.components["core"].requires.append(
"ms-gsl::ms-gsl")
self.cpp_info.components["core"].defines.append(
"MP_UNITS_API_CONTRACTS=3"
)

# handle API options
self.cpp_info.components["core"].defines.append(
"MP_UNITS_API_NO_CRTP=" + str(int(self.options.no_crtp == True))
"MP_UNITS_API_NO_CRTP=" +
str(int(self.options.no_crtp == True))
)

# handle hosted configuration
if self.options.freestanding:
self.cpp_info.components["core"].defines.append("MP_UNITS_HOSTED=0")
self.cpp_info.components["core"].defines.append(
"MP_UNITS_HOSTED=0")
else:
self.cpp_info.components["core"].defines.append("MP_UNITS_HOSTED=1")
self.cpp_info.components["core"].defines.append(
"MP_UNITS_HOSTED=1")
if not self.options.std_format:
self.cpp_info.components["core"].requires.append("fmt::fmt")
self.cpp_info.components["core"].requires.append(
"fmt::fmt")
self.cpp_info.components["core"].defines.append(
"MP_UNITS_API_STD_FORMAT="
+ str(int(self.options.std_format == True))
)

# handle import std
if self.options.import_std:
self.cpp_info.components["core"].defines.append("MP_UNITS_IMPORT_STD")
self.cpp_info.components["core"].defines.append(
"MP_UNITS_IMPORT_STD")
if compiler == "clang" and Version(compiler.version) < 19:
self.cpp_info.components["core"].cxxflags.append(
"-Wno-deprecated-declarations"
Expand All @@ -375,4 +389,5 @@ def package_info(self):
and Version(compiler.version).major == 20
and Version(compiler.version).minor == 1
):
self.cpp_info.components["core"].cxxflags.append("-Wno-unused-result")
self.cpp_info.components["core"].cxxflags.append(
"-Wno-unused-result")
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ message(STATUS "MP_UNITS_API_NO_CRTP: ${MP_UNITS_API_NO_CRTP}")
message(STATUS "MP_UNITS_API_THROWING_CONSTRAINTS: ${MP_UNITS_API_THROWING_CONSTRAINTS}")
message(STATUS "MP_UNITS_API_FREESTANDING: ${MP_UNITS_API_FREESTANDING}")
message(STATUS "MP_UNITS_API_CONTRACTS: ${MP_UNITS_API_CONTRACTS}")
message(STATUS "MP_UNITS_RTTI: ${MP_UNITS_RTTI}")

# validate options
if(MP_UNITS_API_FREESTANDING AND NOT MP_UNITS_API_CONTRACTS STREQUAL "NONE")
Expand Down
7 changes: 7 additions & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,10 @@ if(MP_UNITS_DEV_TIME_TRACE STREQUAL "ALL")
elseif(MP_UNITS_DEV_TIME_TRACE STREQUAL "MODULES")
target_compile_options(mp-units-core PRIVATE "-ftime-trace")
endif()

# RTTI enable
if(MP_UNITS_RTTI)
target_compile_options(mp-units-core ${MP_UNITS_TARGET_SCOPE} "-frtti")
else()
target_compile_options(mp-units-core ${MP_UNITS_TARGET_SCOPE} "-fno-rtti")
endif()