Only translate when option devtools is set

This commit is contained in:
Jelle Spijker 2022-11-03 07:18:26 +01:00 committed by jspijker
parent 6deb1d8968
commit 50fad9caf4

View file

@ -10,7 +10,7 @@ from conan.tools.env import VirtualRunEnv, Environment
from conan.tools.scm import Version from conan.tools.scm import Version
from conan.errors import ConanInvalidConfiguration, ConanException from conan.errors import ConanInvalidConfiguration, ConanException
required_conan_version = ">=1.50.0" required_conan_version = ">=1.52.0"
class CuraConan(ConanFile): class CuraConan(ConanFile):
@ -276,8 +276,10 @@ class CuraConan(ConanFile):
self.requires(req) self.requires(req)
def build_requirements(self): def build_requirements(self):
if self.settings_build.os != "Windows" or self.conf.get("tools.microsoft.bash:path", check_type = str): if self.options.devtools:
self.tool_requires("gettext/0.21") if self.settings.os != "Windows" or self.conf.get("tools.microsoft.bash:path", check_type = str):
# FIXME: once m4, autoconf, automake are Conan V2 ready use self.win_bash and add gettext as base tool_requirement
self.tool_requires("gettext/0.21", force_host_context=True)
def layout(self): def layout(self):
self.folders.source = "." self.folders.source = "."
@ -289,13 +291,14 @@ class CuraConan(ConanFile):
self.cpp.package.resdirs = ["resources", "plugins", "packaging", "pip_requirements"] # pip_requirements should be the last item in the list self.cpp.package.resdirs = ["resources", "plugins", "packaging", "pip_requirements"] # pip_requirements should be the last item in the list
def build(self): def build(self):
if self.settings_build.os != "Windows" or self.conf.get("tools.microsoft.bash:path", check_type = str): if self.options.devtools:
if self.settings.os != "Windows" or self.conf.get("tools.microsoft.bash:path", check_type = str):
# FIXME: once m4, autoconf, automake are Conan V2 ready use self.win_bash and add gettext as base tool_requirement
cpp_info = self.dependencies["gettext"].cpp_info
for po_file in self.source_path.joinpath("resources", "i18n").glob("**/*.po"): for po_file in self.source_path.joinpath("resources", "i18n").glob("**/*.po"):
mo_file = self.build_path.joinpath(po_file.with_suffix('.mo').relative_to(self.source_path)) mo_file = self.build_path.joinpath(po_file.with_suffix('.mo').relative_to(self.source_path))
mkdir(self, str(unix_path(self, mo_file.parent))) mkdir(self, str(unix_path(self, mo_file.parent)))
self.run(f"msgfmt {po_file} -o {mo_file} -f", env="conanbuild", run_environment=True) self.run(f"{cpp_info.bindirs[0]}/msgfmt {po_file} -o {mo_file} -f", env="conanbuild", ignore_errors=True)
# FIXME: once m4, autoconf, automake are Conan V2 ready self.win_bash = None
def generate(self): def generate(self):
cura_run_envvars = self._cura_run_env.vars(self, scope = "run") cura_run_envvars = self._cura_run_env.vars(self, scope = "run")
@ -315,12 +318,14 @@ class CuraConan(ConanFile):
entitlements_file = entitlements_file if self.settings.os == "Macos" else "None") entitlements_file = entitlements_file if self.settings.os == "Macos" else "None")
# Update the po files # Update the po files
if self.settings_build.os != "Windows" or self.conf.get("tools.microsoft.bash:path", check_type = str): if self.settings.os != "Windows" or self.conf.get("tools.microsoft.bash:path", check_type = str):
# FIXME: once m4, autoconf, automake are Conan V2 ready use self.win_bash and add gettext as base tool_requirement
cpp_info = self.dependencies["gettext"].cpp_info
for po_file in self.source_path.joinpath("resources", "i18n").glob("**/*.po"): for po_file in self.source_path.joinpath("resources", "i18n").glob("**/*.po"):
pot_file = self.source_path.joinpath("resources", "i18n", po_file.with_suffix('.pot').name) pot_file = self.source_path.joinpath("resources", "i18n", po_file.with_suffix('.pot').name)
mkdir(self, str(unix_path(self, pot_file.parent))) mkdir(self, str(unix_path(self, pot_file.parent)))
self.run(f"msgmerge --no-wrap --no-fuzzy-matching -width=140 -o {po_file} {po_file} {pot_file}", env = "conanbuild", run_environment=True) self.run(f"{cpp_info.bindirs[0]}/msgmerge --no-wrap --no-fuzzy-matching -width=140 -o {po_file} {po_file} {pot_file}",
env = "conanbuild", ignore_errors = True)
def imports(self): def imports(self):
self.copy("CuraEngine.exe", root_package = "curaengine", src = "@bindirs", dst = "", keep_path = False) self.copy("CuraEngine.exe", root_package = "curaengine", src = "@bindirs", dst = "", keep_path = False)