aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/backend/ninjabackend.py
diff options
context:
space:
mode:
authorMichael Hirsch, Ph.D <scivision@users.noreply.github.com>2019-02-26 12:16:50 -0500
committerJussi Pakkanen <jpakkane@gmail.com>2019-02-26 19:16:50 +0200
commit32a344b9497ec90d31179cc3a0b385aa2a5f691c (patch)
treeef9dde9bad585c132343f14149f3f4d1cee690ee /mesonbuild/backend/ninjabackend.py
parent76e385391f87431490c2b30e33146b63beac3dc2 (diff)
downloadmeson-32a344b9497ec90d31179cc3a0b385aa2a5f691c.zip
meson-32a344b9497ec90d31179cc3a0b385aa2a5f691c.tar.gz
meson-32a344b9497ec90d31179cc3a0b385aa2a5f691c.tar.bz2
Fortran: handle self-referential files
Diffstat (limited to 'mesonbuild/backend/ninjabackend.py')
-rw-r--r--mesonbuild/backend/ninjabackend.py28
1 files changed, 19 insertions, 9 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 16962a4..0a1681f 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -19,7 +19,7 @@ import pickle
import subprocess
from collections import OrderedDict
import itertools
-from pathlib import PurePath
+from pathlib import PurePath, Path
from functools import lru_cache
from . import backends
@@ -1851,9 +1851,11 @@ rule FORTRAN_DEP_HACK%s
mod_files = []
usere = re.compile(r"\s*use,?\s*(?:non_intrinsic)?\s*(?:::)?\s*(\w+)", re.IGNORECASE)
submodre = re.compile(r"\s*\bsubmodule\b\s+\((\w+:?\w+)\)\s+(\w+)\s*$", re.IGNORECASE)
- dirname = self.get_target_private_dir(target)
+ dirname = Path(self.get_target_private_dir(target))
tdeps = self.fortran_deps[target.get_basename()]
- with open(src, encoding='ascii', errors='ignore') as f:
+ src = Path(src)
+ srcdir = Path(self.source_dir)
+ with src.open(encoding='ascii', errors='ignore') as f:
for line in f:
usematch = usere.match(line)
if usematch is not None:
@@ -1876,10 +1878,14 @@ rule FORTRAN_DEP_HACK%s
# Check if a source uses a module it exports itself.
# Potential bug if multiple targets have a file with
# the same name.
- if mod_source_file.fname == os.path.basename(src):
- continue
+ try:
+ if (srcdir / mod_source_file.fname).samefile(src):
+ continue
+ except FileNotFoundError:
+ pass
+
mod_name = compiler.module_name_to_filename(usename)
- mod_files.append(os.path.join(dirname, mod_name))
+ mod_files.append(str(dirname / mod_name))
else:
submodmatch = submodre.match(line)
if submodmatch is not None:
@@ -1890,10 +1896,14 @@ rule FORTRAN_DEP_HACK%s
for parent in parents:
if parent not in tdeps:
raise MesonException("submodule {} relies on parent module {} that was not found.".format(submodmatch.group(2).lower(), parent))
- if tdeps[parent].fname == os.path.basename(src): # same file
- continue
+
+ try:
+ if (srcdir / tdeps[parent].fname).samefile(src):
+ continue
+ except FileNotFoundError:
+ pass
mod_name = compiler.module_name_to_filename(parent)
- mod_files.append(os.path.join(dirname, mod_name))
+ mod_files.append(str(dirname / mod_name))
return mod_files