2024-07-09 12:19:01 +00:00
|
|
|
from conan import ConanFile
|
2024-08-08 08:37:22 +00:00
|
|
|
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout
|
|
|
|
import shutil
|
|
|
|
import os
|
2024-07-09 12:19:01 +00:00
|
|
|
|
|
|
|
class LightRecipe(ConanFile):
|
|
|
|
name = "light"
|
|
|
|
|
|
|
|
settings = "os", "compiler", "build_type", "arch"
|
|
|
|
generators = "CMakeDeps"
|
|
|
|
|
|
|
|
requires = [
|
|
|
|
"benchmark/1.8.4",
|
|
|
|
"gtest/1.14.0",
|
|
|
|
]
|
|
|
|
|
|
|
|
tool_requires = [
|
|
|
|
"cmake/3.30.0"
|
|
|
|
]
|
|
|
|
|
|
|
|
options = {
|
|
|
|
"enable_static_analysis": [True, False],
|
|
|
|
"enable_sanitizers": [True, False],
|
|
|
|
}
|
|
|
|
|
|
|
|
default_options = {
|
|
|
|
"enable_static_analysis": True,
|
|
|
|
"enable_sanitizers": False,
|
|
|
|
}
|
|
|
|
|
2024-08-08 08:37:22 +00:00
|
|
|
def layout(self):
|
|
|
|
cmake_layout(self)
|
|
|
|
|
2024-07-09 12:19:01 +00:00
|
|
|
def generate(self):
|
|
|
|
tc = CMakeToolchain(self)
|
|
|
|
|
|
|
|
tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True
|
|
|
|
tc.cache_variables["ENABLE_SANITIZERS"] = self.options.enable_sanitizers
|
|
|
|
tc.cache_variables["ENABLE_STATIC_ANALYSIS"] = self.options.enable_static_analysis
|
|
|
|
|
|
|
|
tc.generate()
|
2024-08-08 08:37:22 +00:00
|
|
|
|
|
|
|
def build(self):
|
|
|
|
cmake = CMake(self)
|
|
|
|
cmake.configure()
|
|
|
|
cmake.build()
|
|
|
|
self.copy_compile_commands()
|
|
|
|
|
|
|
|
def copy_compile_commands(self):
|
|
|
|
build_folder = self.build_folder
|
|
|
|
source_file = os.path.join(build_folder, "compile_commands.json")
|
|
|
|
destination_file = os.path.join(self.source_folder, "compile_commands.json")
|
|
|
|
|
|
|
|
if os.path.isfile(source_file):
|
|
|
|
shutil.copy(source_file, destination_file)
|
|
|
|
self.output.info(f"Copied compile_commands.json to {destination_file}")
|
|
|
|
else:
|
|
|
|
self.output.warn("compile_commands.json not found!")
|