diff options
| -rw-r--r-- | mesonbuild/backend/ninjabackend.py | 19 | ||||
| -rw-r--r-- | mesonbuild/build.py | 25 |
2 files changed, 41 insertions, 3 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 5fe753293..fbf6c42fc 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2481,6 +2481,13 @@ class NinjaBackend(backends.Backend): args = [] options = {} self.add_rule(NinjaRule(rule, cmdlist, args, description, **options, extra=None)) + if self.environment.machines[for_machine].is_os2() and complist: + rule = 'IMPORTLIB{}'.format(self.get_rule_suffix(for_machine)) + description = 'Generating import library $out' + command = ['emximp'] + args = ['-o', '$out', '$in'] + options = {} + self.add_rule(NinjaRule(rule, command, args, description, **options, extra=None)) args = self.environment.get_build_command() + \ ['--internal', @@ -3415,7 +3422,12 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) return os.path.join(targetdir, target.get_filename() + '.symbols') def generate_shsym(self, target) -> None: - target_file = self.get_target_filename(target) + # On OS/2, an import library is generated after linking a DLL, so + # if a DLL is used as a target, import library is not generated. + if self.environment.machines[target.for_machine].is_os2(): + target_file = self.get_target_filename_for_linking(target) + else: + target_file = self.get_target_filename(target) if isinstance(target, build.SharedLibrary) and target.aix_so_archive: if self.environment.machines[target.for_machine].is_aix(): linker, stdlib_args = target.get_clink_dynamic_linker_and_stdlibs() @@ -3632,6 +3644,11 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) linker_base = linker.get_language() # Fixme. if isinstance(target, build.SharedLibrary): self.generate_shsym(target) + if self.environment.machines[target.for_machine].is_os2(): + target_file = self.get_target_filename(target) + import_name = self.get_import_filename(target) + elem = NinjaBuildElement(self.all_outputs, import_name, 'IMPORTLIB', target_file) + self.add_build(elem) crstr = self.get_rule_suffix(target.for_machine) linker_rule = linker_base + '_LINKER' + crstr # Create an empty commands list, and start adding link arguments from diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 4721df113..2b5ec30f0 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -2494,7 +2494,7 @@ class SharedLibrary(BuildTarget): filename_tpl = '{0.prefix}{0.name}.{0.suffix}' create_debug_file = True # C, C++, Swift, Vala - # Only Windows uses a separate import library for linking + # Only Windows and OS/2 uses a separate import library for linking # For all other targets/platforms import_filename stays None elif self.environment.machines[self.for_machine].is_windows(): suffix = suffix if suffix is not None else 'dll' @@ -2553,6 +2553,19 @@ class SharedLibrary(BuildTarget): suffix = suffix if suffix is not None else 'so' # Android doesn't support shared_library versioning filename_tpl = '{0.prefix}{0.name}.{0.suffix}' + elif self.environment.machines[self.for_machine].is_os2(): + # Shared library is of the form foo.dll + prefix = prefix if prefix is not None else '' + suffix = suffix if suffix is not None else 'dll' + # Import library is called foo_dll.a + import_suffix = import_suffix if import_suffix is not None else '_dll.a' + import_filename_tpl = '{0.prefix}{0.name}' + import_suffix + if self.soversion: + # fooX.dll + filename_tpl = '{0.prefix}{0.name}{0.soversion}.{0.suffix}' + else: + # No versioning, foo.dll + filename_tpl = '{0.prefix}{0.name}.{0.suffix}' else: prefix = prefix if prefix is not None else 'lib' suffix = suffix if suffix is not None else 'so' @@ -2578,7 +2591,7 @@ class SharedLibrary(BuildTarget): which are needed while generating .so shared libraries for Linux. Besides this, there's also the import library name (self.import_filename), - which is only used on Windows since on that platform the linker uses a + which is only used on Windows and OS/2 since on that platform the linker uses a separate library called the "import library" during linking instead of the shared library (DLL). """ @@ -2589,6 +2602,14 @@ class SharedLibrary(BuildTarget): self.suffix = suffix self.filename_tpl = filename_tpl self.filename = self.filename_tpl.format(self) + if self.environment.machines[self.for_machine].is_os2(): + # OS/2 does not allow a longer DLL name than 8 chars + name = os.path.splitext(self.filename)[0] + if len(name) > 8: + name = name[:8] + if self.soversion: + name = name[:-len(self.soversion)] + self.soversion + self.filename = '{}.{}'.format(name, self.suffix) if import_filename_tpl: self.import_filename = import_filename_tpl.format(self) # There may have been more outputs added by the time we get here, so |
