From d3d4aadec31c6d5144fa1a2a3940257b843fd432 Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Sun, 22 Dec 2024 20:27:44 -0800 Subject: [PATCH] Support for UEFI target --- docs/markdown/Reference-tables.md | 1 + mesonbuild/build.py | 4 ++++ mesonbuild/envconfig.py | 8 +++++++- mesonbuild/utils/universal.py | 3 +++ test cases/common/132 get define/meson.build | 1 + 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/markdown/Reference-tables.md b/docs/markdown/Reference-tables.md index 0cf8bcfd73a2..4fba859436ee 100644 --- a/docs/markdown/Reference-tables.md +++ b/docs/markdown/Reference-tables.md @@ -168,6 +168,7 @@ These are provided by the `.system()` method call. | openbsd | | | windows | Native Windows (not Cygwin or MSYS2) | | sunos | illumos and Solaris | +| uefi | | Any string not listed above is not guaranteed to remain stable in future releases. diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 35f1f24a42f8..6b81ff4603ac 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -2366,6 +2366,10 @@ def determine_filenames(self): suffix = 'so' # Android doesn't support shared_library versioning self.filename_tpl = '{0.prefix}{0.name}.{0.suffix}' + elif self.environment.machines[self.for_machine].is_uefi(): + prefix = 'lib' + suffix = 'lib' + self.filename_tpl = '{0.prefix}{0.name}.{0.suffix}' else: prefix = 'lib' suffix = 'so' diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py index 86bad9be23ee..452633f91927 100644 --- a/mesonbuild/envconfig.py +++ b/mesonbuild/envconfig.py @@ -366,12 +366,18 @@ def is_irix(self) -> bool: """Machine is IRIX?""" return self.system.startswith('irix') + def is_uefi(self) -> bool: + """Machine is UEFI?""" + return self.system == 'uefi' + # Various prefixes and suffixes for import libraries, shared libraries, # static libraries, and executables. # Versioning is added to these names in the backends as-needed. def get_exe_suffix(self) -> str: if self.is_windows() or self.is_cygwin(): return 'exe' + elif self.is_uefi(): + return 'efi' else: return '' @@ -382,7 +388,7 @@ def get_object_suffix(self) -> str: return 'o' def libdir_layout_is_win(self) -> bool: - return self.is_windows() or self.is_cygwin() + return self.is_windows() or self.is_cygwin() or self.is_uefi() class BinaryTable: diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py index f26a9a3de8c6..7a07ce12da17 100644 --- a/mesonbuild/utils/universal.py +++ b/mesonbuild/utils/universal.py @@ -687,6 +687,9 @@ def is_qnx() -> bool: def is_aix() -> bool: return platform.system().lower() == 'aix' +def is_uefi() -> bool: + return platform.system().lower() == 'uefi' + @lru_cache(maxsize=None) def darwin_get_object_archs(objpath: str) -> 'ImmutableListProtocol[str]': ''' diff --git a/test cases/common/132 get define/meson.build b/test cases/common/132 get define/meson.build index 66ac3f9ebc29..9bc9006396d7 100644 --- a/test cases/common/132 get define/meson.build +++ b/test cases/common/132 get define/meson.build @@ -13,6 +13,7 @@ system_define_map = { 'openbsd' : ['__OpenBSD__', '1'], 'gnu' : ['__GNU__', '1'], 'sunos' : ['__sun__', '1'], + 'uefi' : ['__uefi__', '1'], # The __FreeBSD__ define will be equal to the major version of the release # (ex, in FreeBSD 11.x, __FreeBSD__ == 11). To make the test robust when