Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cura 10951 gh build curapackage #49

Merged
merged 7 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/requirements-conan-package.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
conan
conan>=1.56.0,<2.0.0
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ jobs:
run: |
. ./activate_github_actions_runenv.sh
. ./activate_github_actions_buildenv.sh
working-directory: build/generators/
working-directory: build/Release/generators/

- name: Build Unit Test
run: |
Expand Down
20 changes: 0 additions & 20 deletions conandata.yml

This file was deleted.

98 changes: 67 additions & 31 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
from os import path


from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout
from conan.tools.files import AutoPackager
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import AutoPackager, copy
from conan.tools.build import check_min_cppstd
from conan import ConanFile
from conan.tools.microsoft import check_min_vs, is_msvc, is_msvc_static_runtime
from conan.tools.scm import Version

required_conan_version = ">=1.50.0"

required_conan_version = ">=1.56.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... same as the other comments about this. I should be adding easter eggs to these. 🥇 🥚



class SavitarConan(ConanFile):
Expand All @@ -18,9 +26,6 @@ class SavitarConan(ConanFile):
exports = "LICENSE*"
generators = "CMakeDeps", "VirtualBuildEnv", "VirtualRunEnv"

python_requires = "umbase/[>=0.1.7]@ultimaker/stable"
python_requires_extend = "umbase.UMBaseConanfile"

options = {
"shared": [True, False],
"fPIC": [True, False],
Expand All @@ -31,55 +36,86 @@ class SavitarConan(ConanFile):
"fPIC": True,
"enable_testing": False
}
scm = {
"type": "git",
"subfolder": ".",
"url": "auto",
"revision": "auto"
}

def set_version(self):
if self.version is None:
self.version = self._umdefault_version()
self.version = "5.3.0-alpha"

def build_requirements(self):
if self.options.enable_testing:
for req in self._um_data()["build_requirements_testing"]:
self.test_requires(req)

@property
def _min_cppstd(self):
return 17

@property
def _compilers_minimum_version(self):
return {
"gcc": "9",
"clang": "9",
"apple-clang": "9",
"msvc": "192",
"visual_studio": "14",
}

def export_sources(self):
copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder)
copy(self, "*", path.join(self.recipe_folder, "src"), path.join(self.export_sources_folder, "src"))
copy(self, "*", path.join(self.recipe_folder, "include"), path.join(self.export_sources_folder, "include"))
copy(self, "*", path.join(self.recipe_folder, "tests"), path.join(self.export_sources_folder, "tests"))

def layout(self):
cmake_layout(self)
self.cpp.package.libs = ["Savitar"]

if self.settings.get_safe("build_type", "Release") == "Debug":
self.cpp.package.defines = ["SAVITAR_DEBUG"]

def requirements(self):
self.requires("standardprojectsettings/[>=0.1.0]@ultimaker/stable")
for req in self._um_data()["requirements"]:
self.requires(req)
self.requires("pugixml/1.12.1", transitive_headers=True)

def validate(self):
if self.settings.compiler.cppstd:
check_min_cppstd(self, self._min_cppstd)
check_min_vs(self, 192) # TODO: remove in Conan 2.0
if not is_msvc(self):
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
)

def build_requirements(self):
self.test_requires("standardprojectsettings/[>=0.1.0]@ultimaker/stable")
if self.options.enable_testing:
self.test_requires("gtest/1.12.1")

def config_options(self):
if self.options.shared and self.settings.compiler == "Visual Studio":
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
self.options["pugixml"].shared = self.options.shared

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, 17)
if self.options.shared:
self.options.rm_safe("fPIC")

def generate(self):
tc = CMakeToolchain(self)
if is_msvc(self):
tc.variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self)
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW"
tc.variables["ENABLE_TESTING"] = self.options.enable_testing
tc.generate()

def layout(self):
cmake_layout(self)
self.cpp.package.libs = ["Savitar"]
tc = CMakeDeps(self)
tc.generate()

if self.settings.build_type == "Debug":
self.cpp.package.defines = ["SAVITAR_DEBUG"]
tc = VirtualBuildEnv(self)
tc.generate(scope="build")

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
copy(self, pattern="LICENSE*", dst="licenses", src=self.source_folder)
packager = AutoPackager(self)
packager.run()
21 changes: 12 additions & 9 deletions test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake
from conan.tools.env import VirtualRunEnv
from conans import tools
from conan.tools.files import copy


class SavitarTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "VirtualRunEnv"
test_type = "explicit"

def requirements(self):
self.requires(self.tested_reference_str)

def generate(self):
cmake = CMakeDeps(self)
Expand All @@ -15,23 +20,21 @@ def generate(self):
venv = VirtualRunEnv(self)
venv.generate()

tc = CMakeToolchain(self, generator = "Ninja")
if self.settings.compiler == "Visual Studio":
tc.blocks["generic_system"].values["generator_platform"] = None
tc.blocks["generic_system"].values["toolset"] = None
tc = CMakeToolchain(self)
tc.generate()

for dep in self.dependencies.values():
for bin_dir in dep.cpp_info.bindirs:
copy(self, "*.dll", src = bin_dir, dst = self.build_folder)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def imports(self):
if self.settings.os == "Windows" and not tools.cross_building(self, skip_x64_x86 = True):
self.copy("*.dll", dst=".", src="@bindirs")

def test(self):
if not tools.cross_building(self):
if can_run(self):
ext = ".exe" if self.settings.os == "Windows" else ""
prefix_path = "" if self.settings.os == "Windows" else "./"
self.run(f"{prefix_path}test{ext}", env = "conanrun")
2 changes: 1 addition & 1 deletion tests/namespaces.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>

Check failure on line 1 in tests/namespaces.xml

View workflow job for this annotation

GitHub Actions / testing

Error processing result file: Invalid format.

Check failure on line 1 in tests/namespaces.xml

View workflow job for this annotation

GitHub Actions / testing

Error processing result file: Invalid format.
<main unit="millimeter" xmlns="http://schemas.microsoft.com/3dmanufacturing/core/2015/02" xml:lang="en-US">

<simple xmlns:a="_a_"/>
Expand Down
2 changes: 1 addition & 1 deletion tests/problem_model.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>

Check failure on line 1 in tests/problem_model.xml

View workflow job for this annotation

GitHub Actions / testing

Error processing result file: Invalid format.

Check failure on line 1 in tests/problem_model.xml

View workflow job for this annotation

GitHub Actions / testing

Error processing result file: Invalid format.
<model unit="millimeter" xmlns="http://schemas.microsoft.com/3dmanufacturing/core/2015/02" xml:lang="en-US">
<!-- this file uses Dutch style commas for the decimal-indicator, instead of international/US points -->
<!-- this should either be read or fail fast, but should definitely not just silently ignore the part after the comma-->
Expand Down
2 changes: 1 addition & 1 deletion tests/test_model.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>

Check failure on line 1 in tests/test_model.xml

View workflow job for this annotation

GitHub Actions / testing

Error processing result file: Invalid format.

Check failure on line 1 in tests/test_model.xml

View workflow job for this annotation

GitHub Actions / testing

Error processing result file: Invalid format.
<model unit="millimeter" xmlns="http://schemas.microsoft.com/3dmanufacturing/core/2015/02" xml:lang="en-US">
<resources>
<object id="1" name="test_object" type="model">
Expand Down
Loading