diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2020-06-14 14:11:47 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2020-06-14 20:30:56 +0530 |
commit | 82afd16e2891e29f15827e89c7b89f1607bdda3c (patch) | |
tree | e971365a2777c556e86ff3f104959226670f888f | |
parent | b639d3cefcd59d90bbbcf6ae1e75861596761dea (diff) | |
download | meson-82afd16e2891e29f15827e89c7b89f1607bdda3c.zip meson-82afd16e2891e29f15827e89c7b89f1607bdda3c.tar.gz meson-82afd16e2891e29f15827e89c7b89f1607bdda3c.tar.bz2 |
windows: Canonicalize `:` in filenames
Fixes https://github.com/mesonbuild/meson/issues/7265
-rw-r--r-- | mesonbuild/backend/backends.py | 8 | ||||
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 2 | ||||
-rw-r--r-- | test cases/fortran/7 generated/meson.build | 2 |
3 files changed, 10 insertions, 2 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index f49b9b2..4f7dbf5 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -444,6 +444,12 @@ class Backend: result.update(self.rpaths_for_bundled_shared_libraries(target)) return tuple(result) + @staticmethod + def canonicalize_filename(fname): + for ch in ('/', '\\', ':'): + fname = fname.replace(ch, '_') + return fname + def object_filename_from_source(self, target, source): assert isinstance(source, mesonlib.File) build_dir = self.environment.get_build_dir() @@ -474,7 +480,7 @@ class Backend: source = os.path.relpath(os.path.join(build_dir, rel_src), os.path.join(self.environment.get_source_dir(), target.get_subdir())) machine = self.environment.machines[target.for_machine] - return source.replace('/', '_').replace('\\', '_') + '.' + machine.get_object_suffix() + return self.canonicalize_filename(source) + '.' + machine.get_object_suffix() def determine_ext_objs(self, extobj, proj_dir_to_build_root): result = [] diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 13b7bc6..c5185b8 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1974,7 +1974,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) src_filename = os.path.basename(src) else: src_filename = src - obj_basename = src_filename.replace('/', '_').replace('\\', '_') + obj_basename = self.canonicalize_filename(src_filename) rel_obj = os.path.join(self.get_target_private_dir(target), obj_basename) rel_obj += '.' + self.environment.machines[target.for_machine].get_object_suffix() commands += self.get_compile_debugfile_args(compiler, target, rel_obj) diff --git a/test cases/fortran/7 generated/meson.build b/test cases/fortran/7 generated/meson.build index cbdbe4e..b01ddc9 100644 --- a/test cases/fortran/7 generated/meson.build +++ b/test cases/fortran/7 generated/meson.build @@ -10,6 +10,8 @@ conf_data.set('THREE', 3) outfile = configure_file( input : 'mod3.fpp', output : 'mod3.f90', configuration : conf_data) +# Manually build absolute path to source file to test +# https://github.com/mesonbuild/meson/issues/7265 three = library('mod3', meson.current_build_dir() / 'mod3.f90') templates_basenames = ['mod2', 'mod1'] |