windows: Canonicalize `:` in filenames

Fixes https://github.com/mesonbuild/meson/issues/7265
0.54
Nirbheek Chauhan 5 years ago
parent b639d3cefc
commit 82afd16e28
  1. 8
      mesonbuild/backend/backends.py
  2. 2
      mesonbuild/backend/ninjabackend.py
  3. 2
      test cases/fortran/7 generated/meson.build

@ -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 = []

@ -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)

@ -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']

Loading…
Cancel
Save