summaryrefslogtreecommitdiff
path: root/Cython/Build/Dependencies.py
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz93@gmail.com>2022-08-05 05:49:39 -0400
committerGitHub <noreply@github.com>2022-08-05 11:49:39 +0200
commitc656624a4fc638e4c0cc098dab0f59a6f8331b1c (patch)
tree2abb4a5d71f877be7c05e1235a30cf905fc6fcae /Cython/Build/Dependencies.py
parent189f6684474b9d3c5e27696f2ed961657b951204 (diff)
downloadcython-c656624a4fc638e4c0cc098dab0f59a6f8331b1c.tar.gz
[0.29] implement the --depfile command-line option for the "cython" tool (GH-4949)release
Backports https://github.com/cython/cython/pull/4916
Diffstat (limited to 'Cython/Build/Dependencies.py')
-rw-r--r--Cython/Build/Dependencies.py19
1 files changed, 2 insertions, 17 deletions
diff --git a/Cython/Build/Dependencies.py b/Cython/Build/Dependencies.py
index 7eb55e260..1ba574d52 100644
--- a/Cython/Build/Dependencies.py
+++ b/Cython/Build/Dependencies.py
@@ -43,7 +43,7 @@ except:
pythran = None
from .. import Utils
-from ..Utils import (cached_function, cached_method, path_exists,
+from ..Utils import (cached_function, cached_method, path_exists, write_depfile,
safe_makedirs, copy_file_to_dir_if_newer, is_package_dir, replace_suffix)
from ..Compiler.Main import Context, CompilationOptions, default_options
@@ -1030,22 +1030,7 @@ def cythonize(module_list, exclude=None, nthreads=0, aliases=None, quiet=False,
# write out the depfile, if requested
if depfile:
dependencies = deps.all_dependencies(source)
- src_base_dir, _ = os.path.split(source)
- if not src_base_dir.endswith(os.sep):
- src_base_dir += os.sep
- # paths below the base_dir are relative, otherwise absolute
- paths = []
- for fname in dependencies:
- if (fname.startswith(src_base_dir) or
- fname.startswith('.' + os.path.sep)):
- paths.append(os.path.relpath(fname, src_base_dir))
- else:
- paths.append(os.path.abspath(fname))
-
- depline = os.path.split(c_file)[1] + ": \\\n "
- depline += " \\\n ".join(paths) + "\n"
- with open(c_file+'.dep', 'w') as outfile:
- outfile.write(depline)
+ write_depfile(c_file, source, dependencies)
if os.path.exists(c_file):
c_timestamp = os.path.getmtime(c_file)