summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--release-tools/bldinstallercommon.py26
-rw-r--r--release-tools/mkqt5bld.py39
2 files changed, 46 insertions, 19 deletions
diff --git a/release-tools/bldinstallercommon.py b/release-tools/bldinstallercommon.py
index d5244d1..b9c8eaa 100644
--- a/release-tools/bldinstallercommon.py
+++ b/release-tools/bldinstallercommon.py
@@ -41,6 +41,7 @@ import stat
import tarfile
import urllib2
import zipfile
+import string
# need to include this for win platforms as long path names
# cause problems
@@ -443,6 +444,31 @@ def is_executable(path):
###############################
# Function
###############################
+# original snippet: http://code.activestate.com/recipes/173220-test-if-a-file-or-string-is-text-or-binary/
+
+text_characters = "".join(map(chr, range(32, 127)) + list("\n\r\t\b"))
+_null_trans = string.maketrans("", "")
+
+def is_text(s):
+ if "\0" in s:
+ return 0
+ if not s: # Empty files are considered text
+ return 1
+ # Get the non-text characters (maps a character to itself then
+ # use the 'remove' option to get rid of the text characters.)
+ t = s.translate(_null_trans, text_characters)
+ # If more than 30% non-text characters, then
+ # this is considered a binary file
+ if len(t)/len(s) > 0.30:
+ return 0
+ return 1
+
+def is_text_file(filename, blocksize = 512):
+ return is_text(open(filename).read(blocksize))
+
+###############################
+# Function
+###############################
def requires_rpath(file_path):
if IS_WIN_PLATFORM:
return False
diff --git a/release-tools/mkqt5bld.py b/release-tools/mkqt5bld.py
index 5763b67..ecf298e 100644
--- a/release-tools/mkqt5bld.py
+++ b/release-tools/mkqt5bld.py
@@ -368,26 +368,27 @@ def replace_build_paths(path_to_checked):
qt_source_dir_delimeter_2 = QT_SOURCE_DIR.replace('/', os.sep)
for root, dirs, files in os.walk(path_to_checked):
for name in files:
- if name.endswith('.prl') or name.endswith('.la') or name.endswith('.pc') or name.endswith('.pri'):
- path = os.path.join(root, name)
- print_wrap('---> Replacing build path in: ' + path)
- print_wrap('---> String to match: ' + QT_SOURCE_DIR)
- print_wrap('---> String to match: ' + qt_source_dir_delimeter_2)
- print_wrap('---> Replacement: ' + ORIGINAL_QMAKE_QT_PRFXPATH)
- for line in fileinput.FileInput(path,inplace=1):
- output1 = line.replace(QT_SOURCE_DIR, ORIGINAL_QMAKE_QT_PRFXPATH)
- if line != output1:
- # we had a match
- print output1.rstrip('\n')
- continue
- else:
- output2 = line.replace(qt_source_dir_delimeter_2, ORIGINAL_QMAKE_QT_PRFXPATH)
- if line != output2:
- # we had a match for the second replacement
- print output2.rstrip('\n')
+ path = os.path.join(root, name)
+ if not os.path.isdir(path) and not os.path.islink(path):
+ if bldinstallercommon.is_text_file(path):
+ print_wrap('---> Replacing build path in: ' + path)
+ print_wrap('---> String to match: ' + QT_SOURCE_DIR)
+ print_wrap('---> String to match: ' + qt_source_dir_delimeter_2)
+ print_wrap('---> Replacement: ' + ORIGINAL_QMAKE_QT_PRFXPATH)
+ for line in fileinput.FileInput(path,inplace=1):
+ output1 = line.replace(QT_SOURCE_DIR, ORIGINAL_QMAKE_QT_PRFXPATH)
+ if line != output1:
+ # we had a match
+ print output1.rstrip('\n')
continue
- # no match so write original line back to file
- print line.rstrip('\n')
+ else:
+ output2 = line.replace(qt_source_dir_delimeter_2, ORIGINAL_QMAKE_QT_PRFXPATH)
+ if line != output2:
+ # we had a match for the second replacement
+ print output2.rstrip('\n')
+ continue
+ # no match so write original line back to file
+ print line.rstrip('\n')
print_wrap('--------------------------------------------------------------------')