Set the CuraVersion with the conan options

Contributes to CURA-9365
This commit is contained in:
j.spijker@ultimaker.com 2022-06-12 19:09:22 +02:00 committed by Jelle Spijker
parent e1c384cd92
commit 5d740d7368
2 changed files with 57 additions and 3 deletions

View file

@ -1,7 +1,10 @@
import os
from pathlib import Path
from platform import python_version
from jinja2 import Template
from conan import ConanFile
from conans import tools
from conan.errors import ConanInvalidConfiguration
@ -26,14 +29,18 @@ class CuraConan(ConanFile):
"enterprise": [True, False],
"staging": [True, False],
"external_engine": [True, False],
"devtools": [True, False]
"devtools": [True, False],
"cloud_api_version": "ANY",
"display_name": "ANY"
}
default_options = {
"python_version": "system",
"enterprise": False,
"staging": False,
"external_engine": False,
"devtools": False
"devtools": False,
"cloud_api_version": "1",
"display_name": "Ultimaker Cura"
}
scm = {
"type": "git",
@ -42,6 +49,26 @@ class CuraConan(ConanFile):
"revision": "auto"
}
def set_version(self):
if not self.version and "CURA_VERSION" in os.environ:
self.version = os.environ["CURA_VERSION"]
@property
def _cloud_api_root(self):
return "https://api-staging.ultimaker.com" if self.options.staging else "https://api.ultimaker.com"
@property
def _cloud_account_api_root(self):
return "https://account-staging.ultimaker.com" if self.options.staging else "https://account.ultimaker.com"
@property
def _marketplace_root(self):
return "https://marketplace-staging.ultimaker.com" if self.options.staging else "https://marketplace.ultimaker.com"
@property
def _digital_factory_url(self):
return "https://digitalfactory-staging.ultimaker.com" if self.options.staging else "https://digitalfactory.ultimaker.com"
@property
def requirements_txts(self):
if self.options.devtools:
@ -67,7 +94,21 @@ class CuraConan(ConanFile):
self.requires("pynest2d/latest@ultimaker/cura-9365") # FIXME: change to ultimaker/stable once the pynest2d PR for CURA-9365 has been merged
def generate(self):
pass
with open(Path(self.source_folder, "cura", "CuraVersion.py.jinja"), "r") as f:
cura_version_py = Template(f.read())
with open(Path(self.source_folder, "cura", "CuraVersion.py"), "w") as f:
f.write(cura_version_py.render(
cura_app_name = self.name,
cura_app_display_name = self.options.display_name,
cura_version = self.version if self.version else "master",
cura_build_type = "Enterprise" if self.options.enterprise else "",
cura_debug_mode = self.settings.build_type != "Release",
cura_cloud_api_root = self._cloud_api_root,
cura_cloud_api_version = self.options.cloud_api_version,
cura_cloud_account_api_root = self._cloud_account_api_root,
cura_marketplace_root = self._marketplace_root,
cura_digital_factory_url = self._digital_factory_url))
def layout(self):
self.folders.source = "."