Files
deskflow/scripts/package.py
Nick Bolton 4690b61551 Simplify compile options and use comprehensive edition logic (#7365)
* Simplify options

* Use more sensible edition logic

* Use set instead of option for string

* Improve macro for product name

* Add tests launch config

* Restore unregistered state

* Reorganize cases for title and improve function name

* Code coverage on by default

* Fixed copyright

* Improve code coverage and test readability

* Separate build-all and build-coverage

* Back out coverage on by default

* Fixed bad var in cmake

* More verbose logging for coverage

* Restore tasks

* Restore preLaunchTask

* Use default comparitor

* Move temp files to temp dir

* Add tasks for tests

* Support for wstring

* Upgrade sonar-scanner to 6 on Debian 12

* Use modern pip install

* Install python for sonarcloud

* Use Ubuntu and install deps

* Fixed sonar-scanner URL

* Fix exported dir

* Persist build dir

* Don't use venv for pip install gcovr

* Fixed another path

* Update actions/checkout to v4 for SonarCloud analysis workflow

* Add coverage task

* Improve coverage for SerialKeyEdition.cpp

* Enable licensing for builds

* Fixed invalid macro names, missing arguments, etc

* Fixed more copyright

* Fixed incorrect use of "enterprise"

* Fixed incorrect use of "business"

* Experiment with environment

* Make package prefix variable

* Add environment matrix to all OS

* Improve job names

* Make job names easier to read

* Roll back environment matrix (too much noise)

* Fixed: default should override required

* Refactor CI with vars

* Fixed arg for env.get_env
2024-07-04 10:14:54 +01:00

80 lines
2.1 KiB
Python
Executable File

#!/usr/bin/env python3
import platform
import lib.env as env
env_file = ".env"
default_package_prefix = "synergy"
def main():
# important: load venv before loading modules that install deps.
env.ensure_in_venv(__file__)
from dotenv import load_dotenv # type: ignore
load_dotenv(dotenv_path=env_file)
version = env.get_app_version()
filename_base = get_filename_base(version)
print(f"Package filename base: {filename_base}")
if env.is_windows():
windows_package(filename_base)
elif env.is_mac():
mac_package(filename_base)
elif env.is_linux():
linux_package(filename_base, version)
else:
raise RuntimeError(f"Unsupported platform: {env.get_os()}")
def get_filename_base(version, use_linux_distro=True):
os = env.get_os()
machine = platform.machine().lower()
package_base = env.get_env("SYNERGY_PACKAGE_PREFIX", default=default_package_prefix)
if os == "linux" and use_linux_distro:
distro_name, _distro_like, distro_version = env.get_linux_distro()
if not distro_name:
raise RuntimeError("Failed to detect Linux distro")
if distro_version:
version_for_filename = distro_version.replace(".", "_")
distro = f"{distro_name}-{version_for_filename}"
else:
distro = distro_name
return f"{package_base}-{distro}-{machine}-{version}"
else:
return f"{package_base}-{os}-{machine}-{version}"
def windows_package(filename_base):
import lib.windows as windows
windows.package(filename_base)
def mac_package(filename_base):
import lib.mac as mac
mac.package(filename_base)
def linux_package(filename_base, version):
import lib.linux as linux
extra_packages = env.get_env_bool("LINUX_EXTRA_PACKAGES", False)
linux.package(filename_base)
if extra_packages:
filename_base = get_filename_base(version, use_linux_distro=False)
linux.package(filename_base, build_tgz=True)
linux.package(filename_base, build_stgz=True)
if __name__ == "__main__":
main()