Skip to content

Commit d1f4c6a

Browse files
move generate() method to the app recipe
1 parent 9f9f7d2 commit d1f4c6a

File tree

2 files changed

+3
-50
lines changed

2 files changed

+3
-50
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

conanfile.py

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
from conan import ConanFile
22
from conan.errors import ConanInvalidConfiguration
33
from conan.tools.apple import is_apple_os
4-
from conan.tools.cmake import CMakeToolchain
5-
from conan.tools.files import save
64
from conan.tools.microsoft import is_msvc
75

8-
from glob import glob
9-
import os
6+
from os import getenv
107

118
required_conan_version = ">=2.13.0"
129

1310
class VCMI(ConanFile):
1411
settings = "os", "compiler", "build_type", "arch"
15-
generators = "CMakeDeps"
1612

1713
_libRequires = [
1814
"minizip/[^1.2.12]",
@@ -49,7 +45,7 @@ def config_options(self):
4945
self.options["sdl_ttf"].shared = isSdlShared
5046

5147
if self.settings.os == "Android":
52-
self.options["qt"].android_sdk = os.getenv("ANDROID_HOME")
48+
self.options["qt"].android_sdk = getenv("ANDROID_HOME")
5349

5450
if self.settings.os != "Windows":
5551
del self.options.target_pre_windows10
@@ -110,47 +106,3 @@ def validate(self):
110106
raise ConanInvalidConfiguration("qt:qtandroidextras option for Android must be set to True")
111107
if not is_apple_os(self) and qtDep.options.openssl != True:
112108
raise ConanInvalidConfiguration("qt:openssl option for non-Apple OS must be set to True, otherwise mods can't be downloaded")
113-
114-
def _pathForCmake(self, path) -> str:
115-
# CMake doesn't like \ in strings
116-
return path.replace(os.path.sep, os.path.altsep) if os.path.altsep else path
117-
118-
def _generateRuntimeLibsFile(self) -> str:
119-
# create file with list of libs to copy to the package for distribution
120-
runtimeLibsFile = self._pathForCmake(os.path.join(self.build_folder, "_runtime_libs.txt"))
121-
122-
runtimeLibExtension = {
123-
"Android": "so",
124-
"iOS": "dylib",
125-
"Macos": "dylib",
126-
"Windows": "dll",
127-
}.get(str(self.settings.os))
128-
129-
runtimeLibs = []
130-
for _, dep in self.dependencies.host.items():
131-
# Qt libs are copied using *deployqt
132-
if dep.ref.name == "qt":
133-
continue
134-
135-
runtimeLibDir = ''
136-
if self.settings.os == "Windows":
137-
if len(dep.cpp_info.bindirs) > 0:
138-
runtimeLibDir = dep.cpp_info.bindir
139-
elif len(dep.cpp_info.libdirs) > 0:
140-
runtimeLibDir = dep.cpp_info.libdir
141-
if len(runtimeLibDir) > 0:
142-
runtimeLibs += glob(os.path.join(runtimeLibDir, f"*.{runtimeLibExtension}"))
143-
save(self, runtimeLibsFile, "\n".join(runtimeLibs))
144-
145-
return runtimeLibsFile
146-
147-
def generate(self):
148-
tc = CMakeToolchain(self)
149-
tc.variables["USING_CONAN"] = True
150-
tc.variables["CONAN_RUNTIME_LIBS_FILE"] = self._generateRuntimeLibsFile()
151-
if self.settings.os == "Android":
152-
tc.variables["CMAKE_ANDROID_API"] = str(self.settings.os.api_level)
153-
tc.variables["SDL_JAVA_SRC_DIR"] = os.path.join(self.dependencies.host["sdl"].package_folder, "share", "java", "SDL2")
154-
elif self.settings.os == "Windows":
155-
tc.variables["CONAN_RUNENV_SCRIPT"] = self._pathForCmake(os.path.join(self.build_folder, "conanrun.bat"))
156-
tc.generate()

0 commit comments

Comments
 (0)