diff options
author | Eli Schwartz <eschwartz93@gmail.com> | 2022-08-05 05:49:39 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-05 11:49:39 +0200 |
commit | c656624a4fc638e4c0cc098dab0f59a6f8331b1c (patch) | |
tree | 2abb4a5d71f877be7c05e1235a30cf905fc6fcae /Cython/Utils.py | |
parent | 189f6684474b9d3c5e27696f2ed961657b951204 (diff) | |
download | cython-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/Utils.py')
-rw-r--r-- | Cython/Utils.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Cython/Utils.py b/Cython/Utils.py index d59d67d78..69563794c 100644 --- a/Cython/Utils.py +++ b/Cython/Utils.py @@ -447,3 +447,24 @@ def build_hex_version(version_string): hexversion = (hexversion << 8) + digit return '0x%08X' % hexversion + + +def write_depfile(target, source, dependencies): + src_base_dir = os.path.dirname(source) + cwd = os.getcwd() + 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: + fname = os.path.abspath(fname) + if fname.startswith(src_base_dir): + paths.append(os.path.relpath(fname, cwd)) + else: + paths.append(fname) + + depline = os.path.relpath(target, cwd) + ": \\\n " + depline += " \\\n ".join(paths) + "\n" + + with open(target+'.dep', 'w') as outfile: + outfile.write(depline) |