Эх сурвалжийг харах

Fix newest ls-std recipe for Conan 2.x.x usage

Patrick-Christopher Mattulat 3 сар өмнө
parent
commit
2047a2584f

+ 33 - 16
recipes/ls-std/2024-1-0-1/conanfile.py

@@ -1,4 +1,8 @@
-from conans import ConanFile, CMake
+from conan import ConanFile
+from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps
+
+import shutil
+import os
 
 
 class LsStdConan(ConanFile):
@@ -11,34 +15,47 @@ class LsStdConan(ConanFile):
     settings = "os", "compiler", "build_type", "arch"
     options = {"shared": [True, False]}
     default_options = {"shared": False}
-    generators = "cmake"
 
     def source(self):
         self.run("git clone https://vcs.lynarstudios.de/public/ls-standard-library.git --branch v" + self.version +
-                 " --single-branch")
+                 " --single-branch .")
+        self.run("pwd")
+        self.run("ls -la $pwd")
+
+    def layout(self):
+        self.folders.source = "ls-standard-library"
+        self.folders.build = "build"
+        self.folders.generators = "build/generators"
 
     def build(self):
-        cmake = self.__configure_cmake()
+        cmake = CMake(self)
+        cmake.configure()
         cmake.build()
 
     def package(self):
-        self.copy("*.hpp", dst="include", src="ls-standard-library/include")
-        self.copy("*.lib", dst="lib", keep_path=False)
-        self.copy("*.a", dst="lib", keep_path=False)
-        self.copy("*.so", dst="lib", keep_path=False)
-        self.copy("*.dll", dst="lib", keep_path=False)
-        self.copy("*.dylib", dst="lib", keep_path=False)
+        include_src = os.path.join(self.source_folder, "include")
+        include_dst = os.path.join(self.package_folder, "include")
+        shutil.copytree(include_src, include_dst, dirs_exist_ok=True)
+
+        build_lib_src = os.path.join(self.build_folder)
+        lib_dst = os.path.join(self.package_folder, "lib")
+        os.makedirs(lib_dst, exist_ok=True)
+
+        for file in os.listdir(build_lib_src):
+            if file.endswith((".a", ".so", ".dll", ".lib", ".dylib")):
+                shutil.copy(os.path.join(build_lib_src, file), lib_dst)
 
     def package_info(self):
         self.cpp_info.libs = ["ls-std-boxing", "ls-std-core", "ls-std-encoding", "ls-std-event", "ls-std-io", "ls-std-logic", "ls-std-time"]
 
-    def __configure_cmake(self):
-        cmake = CMake(self)
+    def generate(self):
+        tool_chain = CMakeToolchain(self)
 
         if self.options.shared:
-            cmake.definitions['LS_STD_BUILD_STATIC'] = "OFF"
-            cmake.definitions['LS_STD_BUILD_SHARED'] = "ON"
+            tool_chain.variables['LS_STD_BUILD_STATIC'] = "OFF"
+            tool_chain.variables['LS_STD_BUILD_SHARED'] = "ON"
 
-        cmake.configure(source_folder="ls-standard-library")
+        tool_chain.generate()
 
-        return cmake
+        deps = CMakeDeps(self)
+        deps.generate()