mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 15:07:28 -06:00
Build mo translation files when creating conan package
Added a build step which uses the Conan package gettext as a tool_requires to convert the po files to mo files and store these in the resources folder When on Windows the msys2 recipe is used to ensure that we have a bash environment to run gnu gettext Creating the mo files as part of the conan package will ensures that we no longer need to store them in the cura-binary-data and generate them manually. This should result in less risk of human error during the release cycle
This commit is contained in:
parent
1f5336805c
commit
96363c652a
1 changed files with 23 additions and 8 deletions
31
conanfile.py
31
conanfile.py
|
@ -4,7 +4,8 @@ from pathlib import Path
|
||||||
from jinja2 import Template
|
from jinja2 import Template
|
||||||
|
|
||||||
from conan import ConanFile
|
from conan import ConanFile
|
||||||
from conan.tools.files import copy, rmdir, save
|
from conan.tools.files import copy, rmdir, save, mkdir
|
||||||
|
from conan.tools.microsoft import unix_path
|
||||||
from conan.tools.env import VirtualRunEnv, Environment
|
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
|
||||||
|
@ -274,6 +275,11 @@ class CuraConan(ConanFile):
|
||||||
for req in self._um_data()["internal_requirements"]:
|
for req in self._um_data()["internal_requirements"]:
|
||||||
self.requires(req)
|
self.requires(req)
|
||||||
|
|
||||||
|
def build_requirements(self):
|
||||||
|
if self.settings_build.os == "Windows" and not self.conf.get("tools.microsoft.bash:path", default=False, check_type=bool):
|
||||||
|
self.tool_requires("msys2/cci.latest")
|
||||||
|
self.tool_requires("gettext/0.21")
|
||||||
|
|
||||||
def layout(self):
|
def layout(self):
|
||||||
self.folders.source = "."
|
self.folders.source = "."
|
||||||
self.folders.build = "venv"
|
self.folders.build = "venv"
|
||||||
|
@ -284,7 +290,15 @@ 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):
|
||||||
pass
|
if self.settings.os == "Windows":
|
||||||
|
self.win_bash = True # We need gettext, which requires the bash environment
|
||||||
|
|
||||||
|
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))
|
||||||
|
mkdir(self, str(unix_path(self, mo_file.parent)))
|
||||||
|
self.run(f"msgfmt {po_file} -o {mo_file} -f", env="conanbuild")
|
||||||
|
|
||||||
|
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")
|
||||||
|
@ -418,12 +432,13 @@ echo "CURA_VERSION_FULL={{ cura_version_full }}" >> ${{ env_prefix }}GITHUB_ENV
|
||||||
entitlements_file = entitlements_file if self.settings.os == "Macos" else "None")
|
entitlements_file = entitlements_file if self.settings.os == "Macos" else "None")
|
||||||
|
|
||||||
def package(self):
|
def package(self):
|
||||||
self.copy("cura_app.py", src = ".", dst = self.cpp.package.bindirs[0])
|
copy(self, "cura_app.py", src = self.source_path, dst = self.package_path.joinpath(self.cpp.package.bindirs[0]))
|
||||||
self.copy("*", src = "cura", dst = self.cpp.package.libdirs[0])
|
copy(self, "*", src = self.source_path.joinpath("cura"), dst = self.package_path.joinpath(self.cpp.package.libdirs[0]))
|
||||||
self.copy("*", src = "resources", dst = self.cpp.package.resdirs[0])
|
copy(self, "*", src = self.source_path.joinpath("resources"), dst = self.package_path.joinpath(self.cpp.package.resdirs[0]), excludes="*.po")
|
||||||
self.copy("*", src = "plugins", dst = self.cpp.package.resdirs[1])
|
copy(self, "*", src = self.build_path.joinpath("resources"), dst = self.package_path.joinpath(self.cpp.package.resdirs[0]))
|
||||||
self.copy("requirement*.txt", src = ".", dst = self.cpp.package.resdirs[-1])
|
copy(self, "*", src = self.source_path.joinpath("plugins"), dst = self.package_path.joinpath(self.cpp.package.resdirs[1]))
|
||||||
self.copy("*", src = "packaging", dst = self.cpp.package.resdirs[2])
|
copy(self, "requirement*.txt", src = self.source_path, dst = self.package_path.joinpath(self.cpp.package.resdirs[-1]))
|
||||||
|
copy(self, "*", src = self.source_path.joinpath("packaging"), dst = self.package_path.joinpath(self.cpp.package.resdirs[2]))
|
||||||
|
|
||||||
def package_info(self):
|
def package_info(self):
|
||||||
self.user_info.pip_requirements = "requirements.txt"
|
self.user_info.pip_requirements = "requirements.txt"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue