From c99396d4a79e8873bcb4bbdc7b396d438808583c Mon Sep 17 00:00:00 2001 From: Raghunandan Netrapalli Madhusudhan <raghunandan.madhusudhan@in-tech.com> Date: Wed, 13 Sep 2023 09:38:28 +0200 Subject: [PATCH] recipes suitable for cross compilation --- .../conan/recipe/FMILibrary/all/conanfile.py | 2 +- .../all/patches/fmi-library-2.0.3-fixes.patch | 132 +++++++++--------- .../conan/recipe/MantleAPI/all/conanfile.py | 2 +- utils/ci/conan/recipe/Yase/all/conanfile.py | 4 +- .../all/conanfile.py | 33 +++-- .../recipe/openscenario_api/all/conanfile.py | 12 +- utils/ci/conan/recipe/units/all/conanfile.py | 2 +- 7 files changed, 97 insertions(+), 90 deletions(-) diff --git a/utils/ci/conan/recipe/FMILibrary/all/conanfile.py b/utils/ci/conan/recipe/FMILibrary/all/conanfile.py index a0466b5cb..f043ebcca 100644 --- a/utils/ci/conan/recipe/FMILibrary/all/conanfile.py +++ b/utils/ci/conan/recipe/FMILibrary/all/conanfile.py @@ -56,7 +56,7 @@ class FmiConan(ConanFile): def build(self): if self.settings.os == "Windows": - cmake = CMake(self, generator="MSYS Makefiles") + cmake = CMake(self) else: cmake = CMake(self) cmake.configure(source_folder=self.name, diff --git a/utils/ci/conan/recipe/FMILibrary/all/patches/fmi-library-2.0.3-fixes.patch b/utils/ci/conan/recipe/FMILibrary/all/patches/fmi-library-2.0.3-fixes.patch index 963a449c0..e9839c763 100644 --- a/utils/ci/conan/recipe/FMILibrary/all/patches/fmi-library-2.0.3-fixes.patch +++ b/utils/ci/conan/recipe/FMILibrary/all/patches/fmi-library-2.0.3-fixes.patch @@ -1,66 +1,66 @@ -diff --git a/src/Import/src/FMI1/fmi1_import_capi.c b/src/Import/src/FMI1/fmi1_import_capi.c -index 842c998..eeff2b5 100644 ---- a/src/Import/src/FMI1/fmi1_import_capi.c -+++ b/src/Import/src/FMI1/fmi1_import_capi.c -@@ -67,18 +67,8 @@ jm_status_enu_t fmi1_import_create_dllfmu(fmi1_import_t* fmu, fmi1_callback_func - return jm_status_error; - } - -- if(jm_portability_set_current_working_directory(dllDirPath) != jm_status_success) { -- jm_log_fatal(fmu->callbacks, module, "Could not change to the DLL directory %s", dllDirPath); -- if(ENOENT == errno) -- jm_log_fatal(fmu->callbacks, module, "The FMU contains no binary for this platform."); -- else -- jm_log_fatal(fmu->callbacks, module, "System error: %s", strerror(errno)); -- } -- else { - /* Allocate memory for the C-API struct */ - fmu -> capi = fmi1_capi_create_dllfmu(fmu->callbacks, dllFileName, modelIdentifier, callBackFunctions, standard); -- } -- - - /* Load the DLL handle */ - if (fmu -> capi) { -diff --git a/src/Import/src/FMI2/fmi2_import_capi.c b/src/Import/src/FMI2/fmi2_import_capi.c -index e794775..ffca14d 100644 ---- a/src/Import/src/FMI2/fmi2_import_capi.c -+++ b/src/Import/src/FMI2/fmi2_import_capi.c -@@ -88,18 +88,8 @@ jm_status_enu_t fmi2_import_create_dllfmu(fmi2_import_t* fmu, fmi2_fmu_kind_enu_ - callBackFunctions = &defaultCallbacks; - } - -- if(jm_portability_set_current_working_directory(dllDirPath) != jm_status_success) { -- jm_log_fatal(fmu->callbacks, module, "Could not change to the DLL directory %s", dllDirPath); -- if(ENOENT == errno) -- jm_log_fatal(fmu->callbacks, module, "The FMU contains no binary for this platform."); -- else -- jm_log_fatal(fmu->callbacks, module, "System error: %s", strerror(errno)); -- } -- else { - /* Allocate memory for the C-API struct */ - fmu -> capi = fmi2_capi_create_dllfmu(fmu->callbacks, dllFileName, modelIdentifier, callBackFunctions, fmuKind); -- } -- - - /* Load the DLL handle */ - if (fmu -> capi) { -diff --git a/src/Util/include/JM/jm_portability.h b/src/Util/include/JM/jm_portability.h -index 82e472a..605dff9 100644 ---- a/src/Util/include/JM/jm_portability.h -+++ b/src/Util/include/JM/jm_portability.h -@@ -65,6 +65,7 @@ jm_status_enu_t jm_portability_get_current_working_directory(char* buffer, size_ - jm_status_enu_t jm_portability_set_current_working_directory(const char* cwd); - - /** \brief Get system-wide temporary directory */ -+FMILIB_EXPORT - const char* jm_get_system_temp_dir(); - - /** -@@ -118,6 +119,7 @@ jm_status_enu_t jm_mkdir(jm_callbacks* cb, const char* dir); - /** - \brief Remove directory and all it contents. - */ -+FMILIB_EXPORT - jm_status_enu_t jm_rmdir(jm_callbacks* cb, const char* dir); - - /** +diff --git a/src/Import/src/FMI1/fmi1_import_capi.c b/src/Import/src/FMI1/fmi1_import_capi.c +index 842c998..eeff2b5 100644 +--- a/src/Import/src/FMI1/fmi1_import_capi.c ++++ b/src/Import/src/FMI1/fmi1_import_capi.c +@@ -67,18 +67,8 @@ jm_status_enu_t fmi1_import_create_dllfmu(fmi1_import_t* fmu, fmi1_callback_func + return jm_status_error; + } + +- if(jm_portability_set_current_working_directory(dllDirPath) != jm_status_success) { +- jm_log_fatal(fmu->callbacks, module, "Could not change to the DLL directory %s", dllDirPath); +- if(ENOENT == errno) +- jm_log_fatal(fmu->callbacks, module, "The FMU contains no binary for this platform."); +- else +- jm_log_fatal(fmu->callbacks, module, "System error: %s", strerror(errno)); +- } +- else { + /* Allocate memory for the C-API struct */ + fmu -> capi = fmi1_capi_create_dllfmu(fmu->callbacks, dllFileName, modelIdentifier, callBackFunctions, standard); +- } +- + + /* Load the DLL handle */ + if (fmu -> capi) { +diff --git a/src/Import/src/FMI2/fmi2_import_capi.c b/src/Import/src/FMI2/fmi2_import_capi.c +index e794775..ffca14d 100644 +--- a/src/Import/src/FMI2/fmi2_import_capi.c ++++ b/src/Import/src/FMI2/fmi2_import_capi.c +@@ -88,18 +88,8 @@ jm_status_enu_t fmi2_import_create_dllfmu(fmi2_import_t* fmu, fmi2_fmu_kind_enu_ + callBackFunctions = &defaultCallbacks; + } + +- if(jm_portability_set_current_working_directory(dllDirPath) != jm_status_success) { +- jm_log_fatal(fmu->callbacks, module, "Could not change to the DLL directory %s", dllDirPath); +- if(ENOENT == errno) +- jm_log_fatal(fmu->callbacks, module, "The FMU contains no binary for this platform."); +- else +- jm_log_fatal(fmu->callbacks, module, "System error: %s", strerror(errno)); +- } +- else { + /* Allocate memory for the C-API struct */ + fmu -> capi = fmi2_capi_create_dllfmu(fmu->callbacks, dllFileName, modelIdentifier, callBackFunctions, fmuKind); +- } +- + + /* Load the DLL handle */ + if (fmu -> capi) { +diff --git a/src/Util/include/JM/jm_portability.h b/src/Util/include/JM/jm_portability.h +index 82e472a..605dff9 100644 +--- a/src/Util/include/JM/jm_portability.h ++++ b/src/Util/include/JM/jm_portability.h +@@ -65,6 +65,7 @@ jm_status_enu_t jm_portability_get_current_working_directory(char* buffer, size_ + jm_status_enu_t jm_portability_set_current_working_directory(const char* cwd); + + /** \brief Get system-wide temporary directory */ ++FMILIB_EXPORT + const char* jm_get_system_temp_dir(); + + /** +@@ -118,6 +119,7 @@ jm_status_enu_t jm_mkdir(jm_callbacks* cb, const char* dir); + /** + \brief Remove directory and all it contents. + */ ++FMILIB_EXPORT + jm_status_enu_t jm_rmdir(jm_callbacks* cb, const char* dir); + + /** diff --git a/utils/ci/conan/recipe/MantleAPI/all/conanfile.py b/utils/ci/conan/recipe/MantleAPI/all/conanfile.py index f2fe2ad28..8126ce823 100644 --- a/utils/ci/conan/recipe/MantleAPI/all/conanfile.py +++ b/utils/ci/conan/recipe/MantleAPI/all/conanfile.py @@ -39,7 +39,7 @@ class MantleAPIConan(ConanFile): if self.settings.os == "Windows": del self.options.fPIC if not self.options.cmake_generator: - self.options.cmake_generator = self.env.get("CONAN_CMAKE_GENERATOR", "MSYS Makefiles") + self.options.cmake_generator = self.env.get("CONAN_CMAKE_GENERATOR", "Unix Makefiles") else: if not self.options.cmake_generator: self.options.cmake_generator = self.env.get("CONAN_CMAKE_GENERATOR", "Unix Makefiles") diff --git a/utils/ci/conan/recipe/Yase/all/conanfile.py b/utils/ci/conan/recipe/Yase/all/conanfile.py index a423e9e30..d37729b1d 100644 --- a/utils/ci/conan/recipe/Yase/all/conanfile.py +++ b/utils/ci/conan/recipe/Yase/all/conanfile.py @@ -51,7 +51,7 @@ class YaseConan(ConanFile): def build(self): if self.settings.os == "Windows": - cmake = CMake(self, generator="MSYS Makefiles") + cmake = CMake(self) cmake.configure(source_folder=self.name, defs={"Yase_BUILD_TESTS":False}) else: cmake = CMake(self) @@ -60,7 +60,7 @@ class YaseConan(ConanFile): def package(self): if self.settings.os == "Windows": - cmake = CMake(self, generator="MSYS Makefiles") + cmake = CMake(self) else: cmake = CMake(self) cmake.install() diff --git a/utils/ci/conan/recipe/open-simulation-interface/all/conanfile.py b/utils/ci/conan/recipe/open-simulation-interface/all/conanfile.py index 03a482e65..da7da59bc 100644 --- a/utils/ci/conan/recipe/open-simulation-interface/all/conanfile.py +++ b/utils/ci/conan/recipe/open-simulation-interface/all/conanfile.py @@ -47,14 +47,14 @@ class OpenSimulationInterfaceConan(ConanFile): return "build_subfolder" def requirements(self): - if self.settings.os == "Linux": - self.requires("protobuf/3.20.0@") - self.options["protobuf"].shared = True + # if self.settings.os == "Linux": + self.requires("protobuf/3.20.0@") + self.options["protobuf"].shared = True def build_requirements(self): if self.settings.os == "Windows": - self.requires("protobuf/3.20.0@") - self.options["protobuf"].shared = True + # self.requires("protobuf/3.20.0@") + # self.options["protobuf"].shared = True self.tool_requires("protobuf/3.20.0@") self.options["protobuf"].shared = True @@ -69,21 +69,28 @@ class OpenSimulationInterfaceConan(ConanFile): def build(self): if self.settings.os == "Windows": - cmake = CMake(self, generator="MSYS Makefiles") + PROTOBUF_PROTOC_EXECUTABLE = os.path.join(self.deps_cpp_info["protobuf"].bin_paths[0], "protoc") + PROTOBUF_LIBRARY = os.path.join(self.deps_cpp_info["protobuf"].lib_paths[0], "libprotobuf.dll.a") + print("protobuf_protoc_exec: ", PROTOBUF_PROTOC_EXECUTABLE) + print("PROTOBUF_LIBRARY: ", PROTOBUF_LIBRARY) + print("PROTOBUF_INCLUDE_DIR: ", self.deps_cpp_info["protobuf"].include_paths[0]) + cmake = CMake(self, generator="Unix Makefiles") cmake.configure(source_folder=self._repo_source, defs={"CMAKE_BUILD_TYPE":"Release", - "CMAKE_INSTALL_PREFIX":"osi3.5.0"}) + "PROTOBUF_INCLUDE_DIR":self.deps_cpp_info["protobuf"].include_paths[0], + "CMAKE_INSTALL_PREFIX":"osi3.5.0", + "PROTOBUF_LIBRARY":PROTOBUF_LIBRARY}) else: cmake = CMake(self) PROTOBUF_PROTOC_EXECUTABLE = os.path.join(self.deps_cpp_info["protobuf"].bin_paths[0], "protoc") PROTOBUF_LIBRARY = os.path.join(self.deps_cpp_info["protobuf"].lib_paths[0], "libprotobuf.so") cmake.configure(source_folder=self._repo_source, - defs={"CMAKE_GENERATOR_ARG":"Unix Makefiles", - "CMAKE_BUILD_TYPE":"Release", - "CMAKE_INSTALL_PREFIX":"osi3.5.0", - "PROTOBUF_INCLUDE_DIR":self.deps_cpp_info["protobuf"].include_paths[0], - "PROTOBUF_PROTOC_EXECUTABLE":PROTOBUF_PROTOC_EXECUTABLE, - "PROTOBUF_LIBRARY":PROTOBUF_LIBRARY}) + defs={"CMAKE_GENERATOR_ARG":"Unix Makefiles", + "CMAKE_BUILD_TYPE":"Release", + "CMAKE_INSTALL_PREFIX":"osi3.5.0", + "PROTOBUF_INCLUDE_DIR":self.deps_cpp_info["protobuf"].include_paths[0], + "PROTOBUF_PROTOC_EXECUTABLE":PROTOBUF_PROTOC_EXECUTABLE, + "PROTOBUF_LIBRARY":PROTOBUF_LIBRARY}) cmake.build() cmake.install() diff --git a/utils/ci/conan/recipe/openscenario_api/all/conanfile.py b/utils/ci/conan/recipe/openscenario_api/all/conanfile.py index 4a3e53105..cb9ba7454 100644 --- a/utils/ci/conan/recipe/openscenario_api/all/conanfile.py +++ b/utils/ci/conan/recipe/openscenario_api/all/conanfile.py @@ -49,10 +49,10 @@ class OpenScenarioApiConan(ConanFile): def _patch_sources(self): os.chdir(self.name) - if self.settings.os == "Windows": - os.system('git apply ../patches/v1.3.1.patch') - else: - os.system('git apply ../patches/rpath.patch') + # if self.settings.os == "Windows": + # os.system('git apply ../patches/v1.3.1.patch') + # else: + os.system('git apply ../patches/rpath.patch') def source(self): url, sha256 = self._get_url_sha() @@ -66,8 +66,8 @@ class OpenScenarioApiConan(ConanFile): def build(self): if self.settings.os == "Windows": os.chdir(os.path.join(self._repo_source, "cpp")) - os.system('cmake -Wno-dev --preset="MSYS-shared-release"') - os.system('cmake --build --preset="Build-MSYS-shared-release"') + os.system('cmake -G "Unix Makefiles" -Wno-dev ') + os.system('cmake --build .') else: os.chdir(self._artifact_path) os.system('chmod +x generateLinux.sh') diff --git a/utils/ci/conan/recipe/units/all/conanfile.py b/utils/ci/conan/recipe/units/all/conanfile.py index 5490b982d..c993dd917 100644 --- a/utils/ci/conan/recipe/units/all/conanfile.py +++ b/utils/ci/conan/recipe/units/all/conanfile.py @@ -39,7 +39,7 @@ class UnitsConan(ConanFile): del self.options.fPIC if not self.options.cmake_generator: self.options.cmake_generator = self.env.get( - "CONAN_CMAKE_GENERATOR", "MSYS Makefiles") + "CONAN_CMAKE_GENERATOR", "Unix Makefiles") else: if not self.options.cmake_generator: self.options.cmake_generator = self.env.get( -- GitLab