diff options
author | Iikka Eklund <iikka.eklund@digia.com> | 2012-08-21 10:11:23 +0300 |
---|---|---|
committer | Lars Knoll <lars.knoll@nokia.com> | 2012-08-21 11:37:37 +0200 |
commit | 4dbe3146e0d95705c138783d803f519f193ac96d (patch) | |
tree | 71ea1eb1eeb688664ce04f24463d06880a9e9808 | |
parent | 9c73a2c7700bd6a45bdc6aaada7faff7df84d670 (diff) |
Improve file patching operation for qt5 build paths
Added/fixed functionality to patch build paths after qt5 build.
The build paths must match the value that will get embedded into qmake
executable. This commit will make sure that all text files (after build)
will get scanned for local build paths and will get replaced by the
'correct' build path (qt_prfxpath). After this patching process
the Qt Installer-Framework can patch the files correctly during
installation process performed by the end user.
Change-Id: I0039de88df58e70d61ec5cbea081c236dbf8b3b3
Reviewed-by: Johanna Äijälä <johanna.aijala@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
-rw-r--r-- | release-tools/bldinstallercommon.py | 26 | ||||
-rw-r--r-- | release-tools/mkqt5bld.py | 39 |
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('--------------------------------------------------------------------') |