diff --git a/.drone.yml b/.drone.yml index e588e71..77e5a2f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -32,11 +32,10 @@ steps: - cp ./tools/conan/profiles/linux_clang_amd64 $(conan profile path default) - conan remote add light https://artifactory.light7734.com/artifactory/api/conan/conan - - conan install . --output-folder=build -r light --build=missing + - conan install . -r light --build=missing + - conan build . - - cmake -Bbuild -DCMAKE_TOOLCHAIN_FILE=./build/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release - - cmake --build ./build/ - - ./build/modules/light/light + - build/Release/modules/light --- kind: pipeline @@ -73,11 +72,10 @@ steps: - cp ./tools/conan/profiles/linux_gcc_amd64 $(conan profile path default) - conan remote add light https://artifactory.light7734.com/artifactory/api/conan/conan - - conan install . --output-folder=build -r light --build=missing + - conan install . -r light --build=missing + - conan build . - - cmake -Bbuild -DCMAKE_TOOLCHAIN_FILE=./build/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release - - cmake --build ./build/ - - ./build/modules/light/light + - build/Release/modules/light --- kind: pipeline diff --git a/conanfile.py b/conanfile.py index ec68f06..56eb828 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,5 +1,7 @@ from conan import ConanFile -from conan.tools.cmake import CMakeToolchain +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout +import shutil +import os class LightRecipe(ConanFile): name = "light" @@ -26,6 +28,9 @@ class LightRecipe(ConanFile): "enable_sanitizers": False, } + def layout(self): + cmake_layout(self) + def generate(self): tc = CMakeToolchain(self) @@ -34,3 +39,20 @@ class LightRecipe(ConanFile): tc.cache_variables["ENABLE_STATIC_ANALYSIS"] = self.options.enable_static_analysis tc.generate() + + 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!")