summaryrefslogtreecommitdiffstats
path: root/llvm/utils/llvm-build/llvmbuild/configutil.py
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2018-04-20 17:21:10 +0000
committerNico Weber <nicolasweber@gmx.de>2018-04-20 17:21:10 +0000
commit3a1b697d6e4ae861ef23965e2d4948aeb5b065b0 (patch)
treea428524c8d248c1a09f4f36bfd5184de88588807 /llvm/utils/llvm-build/llvmbuild/configutil.py
parenta1e299f58b2340a3c452f567626ed4baa62f8818 (diff)
downloadbcm5719-llvm-3a1b697d6e4ae861ef23965e2d4948aeb5b065b0.tar.gz
bcm5719-llvm-3a1b697d6e4ae861ef23965e2d4948aeb5b065b0.zip
Remove llvm-build's --configure-target-def-file.
It was added 6.5 years ago in r144345, but was never hooked up and has been unused since. If _you_ do use this, feel free to revert, but add a comment on where it's used. https://reviews.llvm.org/D45262 llvm-svn: 330455
Diffstat (limited to 'llvm/utils/llvm-build/llvmbuild/configutil.py')
-rw-r--r--llvm/utils/llvm-build/llvmbuild/configutil.py66
1 files changed, 0 insertions, 66 deletions
diff --git a/llvm/utils/llvm-build/llvmbuild/configutil.py b/llvm/utils/llvm-build/llvmbuild/configutil.py
deleted file mode 100644
index b5582c34de4..00000000000
--- a/llvm/utils/llvm-build/llvmbuild/configutil.py
+++ /dev/null
@@ -1,66 +0,0 @@
-"""
-Defines utilities useful for performing standard "configuration" style tasks.
-"""
-
-import re
-import os
-
-def configure_file(input_path, output_path, substitutions):
- """configure_file(input_path, output_path, substitutions) -> bool
-
- Given an input and output path, "configure" the file at the given input path
- by replacing variables in the file with those given in the substitutions
- list. Returns true if the output file was written.
-
- The substitutions list should be given as a list of tuples (regex string,
- replacement), where the regex and replacement will be used as in 're.sub' to
- execute the variable replacement.
-
- The output path's parent directory need not exist (it will be created).
-
- If the output path does exist and the configured data is not different than
- it's current contents, the output file will not be modified. This is
- designed to limit the impact of configured files on build dependencies.
- """
-
- # Read in the input data.
- f = open(input_path, "rb")
- try:
- data = f.read()
- finally:
- f.close()
-
- # Perform the substitutions.
- for regex_string,replacement in substitutions:
- regex = re.compile(regex_string)
- data = regex.sub(replacement, data)
-
- # Ensure the output parent directory exists.
- output_parent_path = os.path.dirname(os.path.abspath(output_path))
- if not os.path.exists(output_parent_path):
- os.makedirs(output_parent_path)
-
- # If the output path exists, load it and compare to the configured contents.
- if os.path.exists(output_path):
- current_data = None
- try:
- f = open(output_path, "rb")
- try:
- current_data = f.read()
- except:
- current_data = None
- f.close()
- except:
- current_data = None
-
- if current_data is not None and current_data == data:
- return False
-
- # Write the output contents.
- f = open(output_path, "wb")
- try:
- f.write(data)
- finally:
- f.close()
-
- return True
OpenPOWER on IntegriCloud