From 29fead5e720eeb98e396c505185ca1050a293855 Mon Sep 17 00:00:00 2001 From: joaijala Date: Fri, 3 Aug 2012 15:10:42 +0300 Subject: Fixes and fine tuning of the Qt5 build script. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added: - print_wrap() function for easier grepping the logs generated by the build script from the full build log - removed -release option from configure options - added commandline parameter for thread count used and should translations and webkit be builded - fixed submodule default order generation - removed pri files backuping and restoring as unecessary Change-Id: Ic4ebfe8ddf87d35d45a2678c554f5e4a6acfd078 Reviewed-by: Jason McDonald Reviewed-by: Simo Fält --- release-tools/bldinstallercommon.py | 30 ++- release-tools/mkqt5bld.py | 445 +++++++++++++++++------------------- release-tools/mksrc.sh | 12 +- 3 files changed, 241 insertions(+), 246 deletions(-) diff --git a/release-tools/bldinstallercommon.py b/release-tools/bldinstallercommon.py index ffd7f3a..ae756ee 100644 --- a/release-tools/bldinstallercommon.py +++ b/release-tools/bldinstallercommon.py @@ -560,10 +560,12 @@ def do_execute_sub_process(args, execution_path, abort_on_fail): else: theproc = subprocess.Popen(args) output = theproc.communicate()[0] - if theproc.returncode and output: - print ' -*-*-*-*-*- Error!! do_execute_sub_process() failed! theproc.returncode: ' + str(theproc.returncode) + ' output: ' + output - output = output[len(output) - MAX_DEBUG_PRINT_LENGTH:] if len(output) > MAX_DEBUG_PRINT_LENGTH else output - print output + if theproc.returncode: + if output: + output = output[len(output) - MAX_DEBUG_PRINT_LENGTH:] if len(output) > MAX_DEBUG_PRINT_LENGTH else output + print output + else: + print ' Note, no output from the sub process!' print '*** Execution failed with code: %s' % str(theproc.returncode) if abort_on_fail: sys.exit(-1) @@ -590,10 +592,12 @@ def do_execute_sub_process_2(args, execution_path, abort_on_fail): os.chdir(execution_path) theproc = subprocess.Popen(args, shell=True) output = theproc.communicate()[0] - if theproc.returncode and output: - print ' -*-*-*-*-*- Error!! do_execute_sub_process_2() failed! theproc.returncode: ' + str(theproc.returncode) + ' output: ' + output - output = output[len(output) - MAX_DEBUG_PRINT_LENGTH:] if len(output) > MAX_DEBUG_PRINT_LENGTH else output - print output + if theproc.returncode: + if output: + output = output[len(output) - MAX_DEBUG_PRINT_LENGTH:] if len(output) > MAX_DEBUG_PRINT_LENGTH else output + print output + else: + print ' Note, no output from the sub process!' print '*** Execution failed with code: %s' % str(theproc.returncode) if abort_on_fail: sys.exit(-1) @@ -626,10 +630,12 @@ def do_execute_sub_process_get_std_out(args, execution_path, abort_on_fail, prin else: theproc = subprocess.Popen(args, shell=False, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True) output = theproc.communicate()[0] - if theproc.returncode and output: - print ' -*-*-*-*-*- Error!! do_execute_sub_process_get_std_out() failed! theproc.returncode: ' + str(theproc.returncode) + ' output: ' + output - output = output[len(output) - MAX_DEBUG_PRINT_LENGTH:] if len(output) > MAX_DEBUG_PRINT_LENGTH else output - print output + if theproc.returncode: + if output: + output = output[len(output) - MAX_DEBUG_PRINT_LENGTH:] if len(output) > MAX_DEBUG_PRINT_LENGTH else output + print output + else: + print ' Note, no output from the sub process!' print '*** Execution failed with code: %s' % str(theproc.returncode) if abort_on_fail: sys.exit(-1) diff --git a/release-tools/mkqt5bld.py b/release-tools/mkqt5bld.py index 44d17dd..de60a35 100644 --- a/release-tools/mkqt5bld.py +++ b/release-tools/mkqt5bld.py @@ -48,22 +48,39 @@ QT_SOURCE_DIR = WORK_DIR + os.sep + 'w' MAKE_INSTALL_ROOT_DIR = WORK_DIR + os.sep + 'qt5_install_root' #main dir for submodule installations CONFIGURE_CMD = '' MAKE_CMD = '' +MAKE_THREAD_COUNT = '8' # some initial default value MAKE_INSTALL_CMD = '' MODULE_ARCHIVE_DIR_NAME = 'module_archives' MODULE_ARCHIVE_DIR = SCRIPT_ROOT_DIR + os.sep + MODULE_ARCHIVE_DIR_NAME MAIN_INSTALL_DIR_NAME = 'main_install' -MODULE_PRI_FILES_DIR_NAME = 'modules_pri_files' -ALL_MODULE_PRI_FILES_DIR_NAME = 'all_modules_pri_files' - -QT5_MODULES_LIST = ['qt3d', 'qlalr', 'qtactiveqt', 'qtbase', 'qtconnectivity', 'qtdeclarative', 'qtdoc', 'qtdocgallery', 'qtfeedback', 'qtgraphicaleffects', 'qtimageformats', 'qtjsondb', 'qtjsbackend', 'qtlocation', 'qtmultimedia', 'qtphonon', 'qtpim', 'qtqa', 'qtquick1', 'qtrepotools', 'qtscript', 'qtsensors', 'qtsvg', 'qtsystems', 'qttools', 'qttranslations', 'qtwayland', 'webkit', 'qtwebkit-examples-and-demos', 'qtxmlpatterns'] - -CONFIGURE_OPTIONS = '-opensource -release -nomake tests -confirm-license' #-make examples +SUBMODULE_INSTALL_BASE_DIR_NAME = "submodule_install_" + +QT5_MODULES_LIST = [ 'qt3d', 'qlalr', 'qtactiveqt', 'qtbase', \ + 'qtconnectivity', 'qtdeclarative', 'qtdoc', \ + 'qtdocgallery', 'qtfeedback', 'qtgraphicaleffects', \ + 'qtimageformats', 'qtjsondb', 'qtjsbackend', \ + 'qtlocation', 'qtmultimedia', 'qtphonon', 'qtpim', \ + 'qtqa', 'qtquick1', 'qtrepotools', 'qtscript', \ + 'qtsensors', 'qtsvg', 'qtsystems', 'qttools', \ + 'qttranslations', 'qtwayland', 'webkit', \ + 'qtwebkit-examples-and-demos', 'qtxmlpatterns'] + +CONFIGURE_OPTIONS = '-opensource -nomake tests -confirm-license' #-make examples DEVEL_MODE = 0 FORCE_MAKE = 0 -RUN_RPATH = 0 +RUN_RPATH = False ORIGINAL_QMAKE_QT_PRFXPATH = '' +BUILD_WEBKIT = True +BUILD_TRANSLATIONS = False +PADDING = "______________________________PADDING______________________________" +############################### +# function +############################### +def print_wrap(text): + print 'QT5BLD: ' + text + ############################### # function @@ -73,8 +90,10 @@ def init_mkqt5bld(): global CONFIGURE_OPTIONS global MAKE_CMD global MAKE_INSTALL_CMD + global SUBMODULE_INSTALL_BASE_DIR_NAME + global MAKE_INSTALL_ROOT_DIR - print '----------------------- Initializing build -------------------------' + print_wrap('---------------- Initializing build --------------------------------') if bldinstallercommon.is_linux_platform(): #linux CONFIGURE_CMD = './' CONFIGURE_OPTIONS += ' -no-gtkstyle' @@ -82,15 +101,13 @@ def init_mkqt5bld(): CONFIGURE_CMD = './' #CONFIGURE_OPTIONS += ' -make libs -no-pch' <- not sure if these are needed, #Added -developer-build to get the sources built, should be removed later..? - CONFIGURE_OPTIONS = '-release -developer-build -opensource -confirm-license -nomake tests' + CONFIGURE_OPTIONS = '-developer-build -opensource -confirm-license -nomake tests -platform macx-clang -prefix $PWD/qtbase' #Add padding to original rpaths to make sure that original rpath is longer than the new if bldinstallercommon.is_linux_platform() or bldinstallercommon.is_solaris_platform(): - CONFIGURE_OPTIONS += ' -R ______________________________PADDING______________________________' + CONFIGURE_OPTIONS += ' -R ' + PADDING CONFIGURE_CMD += 'configure' - if bldinstallercommon.is_win_platform(): #win - CONFIGURE_CMD += '.bat' # make cmd if MAKE_CMD == '': #if not given in commandline param, use nmake or make according to the os @@ -111,15 +128,15 @@ def init_mkqt5bld(): #remove old working dirs if os.path.exists(WORK_DIR): - print ' Removing old work dir ' + WORK_DIR + print_wrap(' Removing old work dir ' + WORK_DIR) bldinstallercommon.remove_tree(WORK_DIR) if os.path.exists(MODULE_ARCHIVE_DIR): - print ' Removing old module archive dir ' + MODULE_ARCHIVE_DIR + print_wrap(' Removing old module archive dir ' + MODULE_ARCHIVE_DIR) bldinstallercommon.remove_tree(MODULE_ARCHIVE_DIR) - print ' Using ' + MAKE_CMD + ' for making and ' + MAKE_INSTALL_CMD + ' for installing' - print ' Qt configure command set to: ' + CONFIGURE_CMD + CONFIGURE_OPTIONS - print '--------------------------------------------------------------------' + print_wrap(' Using ' + MAKE_CMD + ' for making and ' + MAKE_INSTALL_CMD + ' for installing') + print_wrap(' Qt configure command set to: ' + CONFIGURE_CMD + ' ' + CONFIGURE_OPTIONS) + print_wrap('--------------------------------------------------------------------') ############################### @@ -128,19 +145,19 @@ def init_mkqt5bld(): def fetch_src_package(): global QT_PACKAGE_SAVE_AS_TEMP QT_PACKAGE_SAVE_AS_TEMP = os.path.normpath(WORK_DIR + os.sep + os.path.basename(QT_SRC_PACKAGE_URL)) - - print '--------------------- Fetching Qt src package ----------------------' + print_wrap('---------------- Fetching Qt src package ---------------------------') + # check first if package on local file system if not os.path.isfile(QT_PACKAGE_SAVE_AS_TEMP): if not bldinstallercommon.is_content_url_valid(QT_SRC_PACKAGE_URL): - print '*** Qt src package url is invalid! Abort!' + print_wrap('*** Qt src package url: [' + QT_SRC_PACKAGE_URL + '] is invalid! Abort!') sys.exit(-1) - print ' Downloading: ' + QT_SRC_PACKAGE_URL - print ' into: ' + QT_PACKAGE_SAVE_AS_TEMP + print_wrap(' Downloading: ' + QT_SRC_PACKAGE_URL) + print_wrap(' into: ' + QT_PACKAGE_SAVE_AS_TEMP) # start download urllib.urlretrieve(QT_SRC_PACKAGE_URL, QT_PACKAGE_SAVE_AS_TEMP, reporthook=bldinstallercommon.dlProgress) else: - print 'Found old local package, using that: ' + QT_PACKAGE_SAVE_AS_TEMP - print '--------------------------------------------------------------------' + print_wrap('Found local package, using that: ' + QT_PACKAGE_SAVE_AS_TEMP) + print_wrap('--------------------------------------------------------------------') ############################### @@ -149,171 +166,124 @@ def fetch_src_package(): def extract_src_package(): global QT_SOURCE_DIR global CONFIGURE_CMD - print '------------------ Extracting source package -----------------------' - + print_wrap('---------------- Extracting source package -------------------------') if os.path.exists(QT_SOURCE_DIR): - print 'Source dir ' + QT_SOURCE_DIR + ' already exists, using that (not re-extracting the archive)' + print_wrap('Source dir ' + QT_SOURCE_DIR + ' already exists, using that (not re-extracting the archive!)') else: - print 'Extracting source package: ' + QT_PACKAGE_SAVE_AS_TEMP - print 'Into: ' + QT_SOURCE_DIR + print_wrap('Extracting source package: ' + QT_PACKAGE_SAVE_AS_TEMP) + print_wrap('Into: ' + QT_SOURCE_DIR) bldinstallercommon.create_dirs(QT_SOURCE_DIR) bldinstallercommon.extract_file(QT_PACKAGE_SAVE_AS_TEMP, QT_SOURCE_DIR) l = os.listdir(QT_SOURCE_DIR) items = len(l) if items == 1: - print ' Replacing qt-everywhere-xxx-src-5.0.0 with a to get shorter path names' + print_wrap(' Replacing qt-everywhere-xxx-src-5.0.0 with shorter path names') shorter_dir_path = QT_SOURCE_DIR + os.sep + 's' - bldinstallercommon.create_dirs(shorter_dir_path) - print ' moving ' + QT_SOURCE_DIR + os.sep + l[0] + ' to ' + shorter_dir_path - bldinstallercommon.move_tree(QT_SOURCE_DIR + os.sep + l[0], shorter_dir_path) - print ' Source dir ' + QT_SOURCE_DIR - QT_SOURCE_DIR = QT_SOURCE_DIR + os.sep + 's' - #QT_SOURCE_DIR = QT_SOURCE_DIR + os.sep + l[0] - print ' new source dir ' + QT_SOURCE_DIR + os.rename(QT_SOURCE_DIR + os.sep + l[0], shorter_dir_path) + print_wrap(' Old source dir: ' + QT_SOURCE_DIR) + QT_SOURCE_DIR = shorter_dir_path + print_wrap(' New source dir: ' + QT_SOURCE_DIR) #CONFIGURE_CMD = QT_SOURCE_DIR + os.sep + CONFIGURE_CMD #is this needed in shadow build? else: - print '*** Unsupported directory structure!!!' + print_wrap('*** Unsupported directory structure!!!') sys.exit(-1) #remove not working dirs - if os.path.exists(QT_SOURCE_DIR + os.sep + 'qttranslations'): - print ' Removing qttranslations' - bldinstallercommon.remove_tree(QT_SOURCE_DIR + os.sep + 'qttranslations') - if os.path.exists(QT_SOURCE_DIR + os.sep + 'qtwebkit'): - print ' Removing qtwebkit' - bldinstallercommon.remove_tree(QT_SOURCE_DIR + os.sep + 'qtwebkit') - if os.path.exists(QT_SOURCE_DIR + os.sep + 'qtwebkit-examples-and-demos'): - print ' Removing qtwebkit-examples-and-demos' - bldinstallercommon.remove_tree(QT_SOURCE_DIR + os.sep + 'qtwebkit-examples-and-demos') - -# just for testing, remove!! -# for module in QT5_MODULES_LIST: -# if module != 'qtbase' and module != 'qtsvg' and module != 'qtxmlpatterns': -# if os.path.exists(QT_SOURCE_DIR + os.sep + module): -# bldinstallercommon.remove_tree(QT_SOURCE_DIR + os.sep + module) - - print '--------------------------------------------------------------------' - - -############################### -# function -############################### -def copy_modules(): - print '--------- Taking back-up copies of .pri files -----------------------' + if not BUILD_TRANSLATIONS: + if os.path.exists(QT_SOURCE_DIR + os.sep + 'qttranslations'): + print_wrap(' Removing qttranslations') + bldinstallercommon.remove_tree(QT_SOURCE_DIR + os.sep + 'qttranslations') + if not BUILD_WEBKIT: + if os.path.exists(QT_SOURCE_DIR + os.sep + 'qtwebkit'): + print_wrap(' Removing qtwebkit') + bldinstallercommon.remove_tree(QT_SOURCE_DIR + os.sep + 'qtwebkit') + if os.path.exists(QT_SOURCE_DIR + os.sep + 'qtwebkit-examples-and-demos'): + print_wrap(' Removing qtwebkit-examples-and-demos') + bldinstallercommon.remove_tree(QT_SOURCE_DIR + os.sep + 'qtwebkit-examples-and-demos') - temp_base_dir = WORK_DIR + os.sep + MODULE_PRI_FILES_DIR_NAME - temp_base_dir_all = WORK_DIR + os.sep + ALL_MODULE_PRI_FILES_DIR_NAME - bldinstallercommon.create_dirs(temp_base_dir) - bldinstallercommon.create_dirs(temp_base_dir_all) + print_wrap('--------------------------------------------------------------------') - for module_name in QT5_MODULES_LIST: - destination_dir = temp_base_dir + os.sep + module_name - modules_source_dir_1 = QT_SOURCE_DIR + os.sep + module_name + os.sep + 'modules' + os.sep - modules_source_dir_2 = QT_SOURCE_DIR + os.sep + module_name + os.sep + 'src' + os.sep + 'modules' + os.sep - temp_source = modules_source_dir_1 - if not os.path.exists(temp_source): - temp_source = modules_source_dir_2 - # loop on all files - for root, dirs, files in os.walk(temp_source): - for name in files: - if name.endswith('.pri'): - file_full_path = os.path.join(root, name) - if not os.path.isdir(file_full_path) and not os.path.islink(file_full_path): - destination_dir = temp_base_dir + os.sep + module_name - destination_dir_all = temp_base_dir_all - print ' Copying: ' + module_name - print ' Src:' + file_full_path - print ' Dst:' + destination_dir - bldinstallercommon.create_dirs(destination_dir) - shutil.copy(file_full_path, destination_dir) - # copy also as one chunk - shutil.copy(file_full_path, destination_dir_all) ############################### # function ############################### def build_qt(): global QT5_MODULES_LIST - # configure - print '--------------------- Configuring Qt -------------------------------' - + print_wrap('---------------- Configuring Qt ------------------------------------') cmd_args = CONFIGURE_CMD + ' ' + CONFIGURE_OPTIONS - print ' configure line: ' + cmd_args + print_wrap(' Configure line: ' + cmd_args) bldinstallercommon.do_execute_sub_process(cmd_args.split(' '), QT_SOURCE_DIR, True) - # build - print '---------------------- Building Qt ---------------------------------' + print_wrap('---------------- Building Qt ---------------------------------------') #create list of modules in default make order - regex = re.compile('^make_default:.*') #search line starting with 'make_default:' + regex = re.compile('^make_first:.*') #search line starting with 'make_default:' submodule_list = [] - + modules_found = 0 if os.path.exists(QT_SOURCE_DIR + os.sep + 'Makefile'): - print ' Generating ordered list of submodules from main Makefile' + print_wrap(' Generating ordered list of submodules from main Makefile') makefile = open(QT_SOURCE_DIR + os.sep + 'Makefile', 'r') for line in makefile: lines = regex.findall(line) for make_def_line in lines: - #print make_def_line + #print_wrap(make_def_line) make_def_list = make_def_line.split(' ') - - #TODO: check if there is more than one line in Makefile - #change 'module-qtbase-make_default' to 'qtbase' + #TODO: check if there is more than one line in Makefile + #change 'module-qtbase-make_first' to 'qtbase' for item in make_def_list: if item.startswith('module-'): submodule_name = item[7:] #7 <- module- - index = submodule_name.index('-make_default') + index = submodule_name.index('-make_first') submodule_list.append(submodule_name[:index]) + modules_found = 1 - QT5_MODULES_LIST = submodule_list + if modules_found == 1: + QT5_MODULES_LIST = submodule_list + print_wrap(' Modules list updated, modules list is now in default build order.') + else: + print_wrap(' Warning! Could not extract module build order from ' + QT_SOURCE_DIR + os.sep + 'Makefile. Using default (non-ordered) list.') else: - print ' Error, main Makefile not found, using hard coded modules list for make.' - - if os.path.exists(MAKE_INSTALL_ROOT_DIR): #remove if old dir exists + print_wrap('*** Error! Main Makefile not found. Build failed!') + sys.exit(-1) + #remove if old dir exists + if os.path.exists(MAKE_INSTALL_ROOT_DIR): shutil.rmtree(MAKE_INSTALL_ROOT_DIR) - bldinstallercommon.create_dirs(MAKE_INSTALL_ROOT_DIR) #create install dirs - - #take backups of .pri files to be restored after build - copy_modules() - + #create install dirs + bldinstallercommon.create_dirs(MAKE_INSTALL_ROOT_DIR) #main level make cmd_args = MAKE_CMD - if bldinstallercommon.is_linux_platform(): - cmd_args += ' -j12' - print ' Running make on root level' + cmd_args += ' -j' + MAKE_THREAD_COUNT + print_wrap(' Running make on root level') bldinstallercommon.do_execute_sub_process(cmd_args.split(' '), QT_SOURCE_DIR, True) - - print '--------------------------------------------------------------------' + print_wrap('--------------------------------------------------------------------') ############################### # function ############################### def patch_rpaths(): - if RUN_RPATH == 1: + if RUN_RPATH: if (bldinstallercommon.is_linux_platform() or bldinstallercommon.is_solaris_platform()): - print '----------------- Patching rpaths -----------------------------------' + print_wrap('---------------- Patching RPaths -----------------------------------') bldinstallercommon.handle_component_rpath(QT_SOURCE_DIR, 'lib') - print '---------------------------------------------------------------------' + print_wrap('--------------------------------------------------------------------') ############################### # function ############################### def install_qt(): - - print '----------------- Installing Qt -------------------------------------' + print_wrap('---------------- Installing Qt -------------------------------------') #main level make install cmd_args = '' if bldinstallercommon.is_linux_platform(): cmd_args = 'sudo ' cmd_args += MAKE_INSTALL_CMD - print ' Running main level make install' + print_wrap(' Running main level make install') bldinstallercommon.do_execute_sub_process(cmd_args.split(' '), QT_SOURCE_DIR, True) - -#main level install with install root + #main level install with install root #main level make install cmd_args = '' install_root_path = MAKE_INSTALL_ROOT_DIR + os.sep + MAIN_INSTALL_DIR_NAME @@ -321,93 +291,96 @@ def install_qt(): cmd_args = 'sudo ' if bldinstallercommon.is_win_platform(): install_root_path = install_root_path[3:] - print ' on win, use install root path: ' + install_root_path + print_wrap(' On Windows, use install root path: ' + install_root_path) cmd_args += MAKE_INSTALL_CMD + ' INSTALL_ROOT=' + install_root_path - print ' Running main level make install with install root ' + install_root_path + print_wrap(' Running main level make install with install root ' + install_root_path) bldinstallercommon.do_execute_sub_process(cmd_args.split(' '), QT_SOURCE_DIR, True) #end - main level install with install root #make install for each module with INSTALL_ROOT - print ' Install modules to INSTALL_ROOT' + print_wrap(' Install modules to INSTALL_ROOT') for module_name in QT5_MODULES_LIST: - if module_name == 'qtwebkit': - print ' > > > > > > NOT installing qtwebkit < < < < < < < <' - elif module_name == 'qtwebkit-examples-and-demos': - print ' > > > > > > NOT installing qtwebkit-examples-and-demos < < < < < < < <' - elif module_name == 'qttranslations': - print ' > > > > > > NOT installing qttranslations < < < < < < < <' + if module_name == 'qtwebkit' and not BUILD_WEBKIT: + print_wrap(' > > > > > > NOT installing qtwebkit < < < < < < < <') + elif module_name == 'qtwebkit-examples-and-demos' and not BUILD_WEBKIT: + print_wrap(' > > > > > > NOT installing qtwebkit-examples-and-demos < < < < < < < <') + elif module_name == 'qttranslations' and not BUILD_TRANSLATIONS: + print_wrap(' > > > > > > NOT installing qttranslations < < < < < < < <') else: - install_root_path = MAKE_INSTALL_ROOT_DIR + os.sep + 'submodule_install_' + module_name + install_root_path = MAKE_INSTALL_ROOT_DIR + os.sep + SUBMODULE_INSTALL_BASE_DIR_NAME + module_name if bldinstallercommon.is_win_platform(): install_root_path = install_root_path[3:] - print ' using install root path: ' + install_root_path + print_wrap(' Using install root path: ' + install_root_path) submodule_dir_name = QT_SOURCE_DIR + os.sep + module_name cmd_args = '' - if bldinstallercommon.is_linux_platform(): cmd_args = 'sudo ' - cmd_args += MAKE_INSTALL_CMD + ' ' + 'INSTALL_ROOT=' + install_root_path - print ' Installing module: ' + module_name - print ' -> cmd args: ' + cmd_args - print ' -> in: ' + submodule_dir_name - + print_wrap(' Installing module: ' + module_name) + print_wrap(' -> cmd args: ' + cmd_args) + print_wrap(' -> in: ' + submodule_dir_name) bldinstallercommon.do_execute_sub_process(cmd_args.split(' '), submodule_dir_name, True) - - print '--------------------------------------------------------------------' + print_wrap('--------------------------------------------------------------------') ############################### # function ############################### def save_original_qt_prfxpath(): - print '---------------- Saving original qt_prfxpath ---------------------' + print_wrap('---------------- Saving original qt_prfxpath -----------------------') global ORIGINAL_QMAKE_QT_PRFXPATH qmake_executable_path = bldinstallercommon.locate_executable(QT_SOURCE_DIR, 'qmake' + bldinstallercommon.get_executable_suffix()) + if not qmake_executable_path: + print_wrap('*** Error! qmake executable not found? Looks like the build has failed in previous step? Aborting..') + sys.exit(-1) ORIGINAL_QMAKE_QT_PRFXPATH = patch_qmake_qt_key.fetch_key(os.path.normpath(qmake_executable_path), 'qt_prfxpath') - print ' ===> Original qt_prfxpath: ' + ORIGINAL_QMAKE_QT_PRFXPATH + print_wrap(' ===> Original qt_prfxpath: ' + ORIGINAL_QMAKE_QT_PRFXPATH) if not ORIGINAL_QMAKE_QT_PRFXPATH: - print '*** Could not find original qt_prfxpath from qmake executable?!' - print '*** Abort!' + print_wrap('*** Could not find original qt_prfxpath from qmake executable?!') + print_wrap('*** Abort!') sys.exit(-1) + print_wrap('--------------------------------------------------------------------') ############################### # function ############################### #def restore_qt_prfxpath(): -# print '---------------- Restoring original qt_prfxpath ---------------------' +# print_wrap('---------------- Restoring original qt_prfxpath --------------------') # qmake_executable_path = bldinstallercommon.locate_executable(MAKE_INSTALL_ROOT_DIR, 'qmake' + bldinstallercommon.get_executable_suffix()) -# print ' ===> Patching: ' + qmake_executable_path +# print_wrap(' ===> Patching: ' + qmake_executable_path) # patch_qmake_qt_key.replace_key(qmake_executable_path, 'qt_prfxpath', ORIGINAL_QMAKE_QT_PRFXPATH) +# print_wrap('--------------------------------------------------------------------') ############################### # function ############################### def replace_build_paths(path_to_checked): - print '---------------- Replacing build paths ---------------------' + print_wrap('---------------- Replacing build paths -----------------------------') 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'): + if name.endswith('.prl') or name.endswith('.la') or name.endswith('.pc') or name.endswith('.pri'): path = os.path.join(root, name) - print '---> Replacing build path in: ' + path - print '---> String to match: ' + QT_SOURCE_DIR - print '---> Replacement: ' + ORIGINAL_QMAKE_QT_PRFXPATH + print_wrap('---> Replacing build path in: ' + path) + print_wrap('---> String to match: ' + QT_SOURCE_DIR) + print_wrap('---> Replacement: ' + ORIGINAL_QMAKE_QT_PRFXPATH) for line in fileinput.FileInput(path,inplace=1): line = line.replace(QT_SOURCE_DIR, ORIGINAL_QMAKE_QT_PRFXPATH) + print_wrap('--------------------------------------------------------------------') + ############################### # function ############################### def clean_up(install_dir): - print '---------- Cleaning unnecessary files from ' + install_dir + '----------' + print_wrap('---------------- Cleaning unnecessary files from ' + install_dir + '----------') file_list = ['Makefile', '.o', '.moc', '.pro', '.pri', '.init-repository', '.cpp', '.h', '.gitignore', '.qmlproject'] for root, dirs, files in os.walk(install_dir): for name in files: if name in file_list: path = os.path.join(root, name) - print ' ---> Deleting file: ' + name + print_wrap(' ---> Deleting file: ' + name) os.remove(path) #TODO: At the moment, it seems that installing to default location is necessary @@ -415,73 +388,72 @@ def clean_up(install_dir): if bldinstallercommon.is_linux_platform() or bldinstallercommon.is_mac_platform(): default_install_dir = '/usr/local/Qt-5.0.0' if os.path.exists(default_install_dir): - print ' Removing /usr/local/Qt-5.0.0 on mac/linux..' + print_wrap(' Removing /usr/local/Qt-5.0.0 on mac/linux..') bldinstallercommon.remove_tree(default_install_dir) - -############################### -# function -############################### -def restore_pri_files(): - print '---------------- Restoring original .pri files ---------------------' - pri_dir_all = WORK_DIR + os.sep + ALL_MODULE_PRI_FILES_DIR_NAME - bin_pri_path = '' - #restore files to all install location - - print ' set bin_pri_path' + # on windows remove redundant .dll files from \lib if bldinstallercommon.is_win_platform(): - bin_pri_path = '\qt5_workdir\w\s\qtbase\modules' - print ' on win path to installed pri files: ' + bin_pri_path - if bldinstallercommon.is_linux_platform(): - bin_pri_path = '/usr/local/Qt-5.0.0/mkspecs/modules' - print ' on linux path to installed pri files: ' + bin_pri_path -# if bldinstallercommon.is_mac_platform(): #TODO -# print ' mac' - - - #restore pri files to each submodule and to the chunk of all modules - module_pri_dir = WORK_DIR + os.sep + MODULE_PRI_FILES_DIR_NAME - for root, dirs, files in os.walk(module_pri_dir): - for name in files: - if name.endswith('.pri'): - original_pri_file_path = os.path.join(root, name) - pri_file_name = name + # each submodule first + for sub_dir in QT5_MODULES_LIST: + base_path = MAKE_INSTALL_ROOT_DIR + os.sep + SUBMODULE_INSTALL_BASE_DIR_NAME + sub_dir + lib_path = bldinstallercommon.locate_directory(base_path, 'lib') + if lib_path: + bldinstallercommon.delete_files_by_type_recursive(lib_path, '\\.dll') + else: + print_wrap('*** Warning! Unable to locate \\lib directory under: ' + base_path) + # then the full install + base_path_full_install = MAKE_INSTALL_ROOT_DIR + os.sep + MAIN_INSTALL_DIR_NAME + if os.path.exists(base_path_full_install): + full_install_lib_path = bldinstallercommon.locate_directory(base_path_full_install, 'lib') + if full_install_lib_path: + bldinstallercommon.delete_files_by_type_recursive(full_install_lib_path, '\\.dll') + else: + print_wrap('*** Warning! Unable to locate \\lib directory under: ' + full_install_lib_path) + print_wrap('--------------------------------------------------------------------') - for root2, dirs2, files2 in os.walk(MAKE_INSTALL_ROOT_DIR): - for name2 in files2: - if name2 == pri_file_name: - installed_pri_file_path = os.path.join(root2, name2) - if not os.path.isdir(original_pri_file_path) and not os.path.islink(original_pri_file_path): - print ' Copying: ' + name - print ' Src:' + original_pri_file_path - print ' Dst:' + installed_pri_file_path - shutil.copy(original_pri_file_path, installed_pri_file_path) - - print '--------------------------------------------------------------------' ############################### # function ############################### def archive_submodules(): - - print '-------------------- Archiving submodules --------------------------' - + print_wrap('---------------- Archiving submodules ------------------------------') bldinstallercommon.create_dirs(MODULE_ARCHIVE_DIR) + # submodules for sub_dir in QT5_MODULES_LIST: - print '---------- Archiving ' + sub_dir - if os.path.exists(MAKE_INSTALL_ROOT_DIR + os.sep + 'submodule_install_' + sub_dir): - cmd_args = '7z a ' + MODULE_ARCHIVE_DIR + os.sep + sub_dir + '.7z ' + 'submodule_install_' + sub_dir + print_wrap('---------- Archiving ' + sub_dir) + if os.path.exists(MAKE_INSTALL_ROOT_DIR + os.sep + SUBMODULE_INSTALL_BASE_DIR_NAME + sub_dir): + cmd_args = '7z a ' + MODULE_ARCHIVE_DIR + os.sep + sub_dir + '.7z ' + SUBMODULE_INSTALL_BASE_DIR_NAME + sub_dir bldinstallercommon.do_execute_sub_process_get_std_out(cmd_args.split(' '), MAKE_INSTALL_ROOT_DIR, True, True) else: - print MAKE_INSTALL_ROOT_DIR + os.sep + 'submodule_install_' + sub_dir + ' DIRECTORY NOT FOUND\n -> ' + sub_dir + ' not archived!' - + print_wrap(MAKE_INSTALL_ROOT_DIR + os.sep + SUBMODULE_INSTALL_BASE_DIR_NAME + sub_dir + ' DIRECTORY NOT FOUND\n -> ' + sub_dir + ' not archived!') + # one chunk if os.path.exists(MAKE_INSTALL_ROOT_DIR + os.sep + MAIN_INSTALL_DIR_NAME): - print ' Archiving all modules to archive qt5_all.7z' + print_wrap(' Archiving all modules to archive qt5_all.7z') cmd_args = '7z a ' + MODULE_ARCHIVE_DIR + os.sep + 'qt5_all' + '.7z ' + MAIN_INSTALL_DIR_NAME bldinstallercommon.do_execute_sub_process_get_std_out(cmd_args.split(' '), MAKE_INSTALL_ROOT_DIR, True, True) + print_wrap('---------------------------------------------------------------------') - print '---------------------------------------------------------------------' + +############################### +# function +############################### +def print_help(): + print_wrap('*** Error! Insufficient arguments given!') + print_wrap('') + print_wrap('Example: python -u mkqt5bld.py src_url=qt-everywhere-opensource-src-5.0.0.zip force_make [make_cmd=mingw32-make]') + print_wrap('') + print_wrap('Available options:') + print_wrap('') + print_wrap(' src_url=[url where to fetch src package]') + print_wrap(' devel_mode') + print_wrap(' use_prefix=[prefix used for configure options]') + print_wrap(' force_make') + print_wrap(' patch_rpath=yes/no') + print_wrap(' make_cmd=[custom make tool]') + print_wrap(' make_thread_count=[number of threads]') + print_wrap(' build_webkit=yes/no') + print_wrap('') ############################### @@ -494,47 +466,64 @@ def parse_cmd_line(): global FORCE_MAKE global RUN_RPATH global MAKE_CMD + global MAKE_THREAD_COUNT global MAKE_INSTALL_CMD + global BUILD_WEBKIT - print '------------- Parsing commandline arguments ------------------------' + print_wrap('---------------- Parsing commandline arguments ---------------------') arg_count = len(sys.argv) if arg_count < 2: - print '*** Error! Insufficient arguments given!' - print '' - print 'Example: python -u mkqt5bld.py src_url=qt-everywhere-opensource-src-5.0.0.zip force_make [make_cmd=mingw32-make]' + print_help() sys.exit(-1) - #Parse command line options for item in sys.argv[1:]: - print ' Argument: ' + item - - if item.find('src_url') >= 0: #url for the sources + #url for the sources + if item.find('src_url') >= 0: values = item.split('=') QT_SRC_PACKAGE_URL = values[1] - print ' source url set.' - if item.find('devel_mode') >= 0: #is using development mode + print_wrap(' Qt source dir set to: ' + QT_SRC_PACKAGE_URL) + #is using development mode + if item.find('devel_mode') >= 0: DEVEL_MODE = 1 CONFIGURE_OPTIONS += ' -nomake examples' - print ' devel mode set to true.' - if item.find('use_prefix') >= 0: #prefix for configure + print_wrap(' devel mode set to true.') + #prefix for configure + if item.find('use_prefix') >= 0: values = item.split('=') CONFIGURE_OPTIONS += ' -prefix ' + values[1] - print ' -prefix added to configure line.' - if item.find('force_make') >= 0: #set force make (-i option for make) + print_wrap(' -prefix added to configure line.') + #set force make (-i option for make) + if item.find('force_make') >= 0: FORCE_MAKE = 1 - print ' using force make (ignoring errors).' - if item.find('run_rpath') >= 0: #set to run rpath - RUN_RPATH = 1 - print ' enabling chrpath execution.' - if item.find('make_cmd') >= 0: #set make command, if not set make/nmake is used + print_wrap(' using force make (ignoring errors).') + #set to run rpath + if item.find('patch_rpath') >= 0: + RUN_RPATH = True + print_wrap(' enabling RPath patching.') + #set make command, if not set make/nmake is used + if item.find('make_cmd') >= 0: values = item.split('=') if values[1] != '': MAKE_CMD = values[1] MAKE_INSTALL_CMD = values[1] + ' install' - print ' using command: ' + MAKE_CMD + ' for making and ' + MAKE_INSTALL_CMD + ' for installing' - - print 'Qt source dir set to: ' + QT_SRC_PACKAGE_URL + print_wrap(' using command: ' + MAKE_CMD + ' for making and ' + MAKE_INSTALL_CMD + ' for installing') + #how many threads to be used for building + if item.find('make_thread_count') >= 0: + values = item.split('=') + if values[1] != '': + MAKE_THREAD_COUNT = values[1] + print_wrap(' threads used for building: ' + MAKE_THREAD_COUNT) + # do we build webkit? + if item.find('build_webkit') >= 0: + values = item.split('=') + if values[1] != '': + if values[1] == 'yes' or values[1] == 'true': + BUILD_WEBKIT = True + else: + BUILD_WEBKIT = False + print_wrap(' build webkit: ' + values[1]) + print_wrap('---------------------------------------------------------------------') return True @@ -568,8 +557,6 @@ def main(): clean_up(MAKE_INSTALL_ROOT_DIR) # replace build directory paths in installed files replace_build_paths(MAKE_INSTALL_ROOT_DIR) - # restore pri files - restore_pri_files() # archive each submodule archive_submodules() diff --git a/release-tools/mksrc.sh b/release-tools/mksrc.sh index 9b11169..62c73b5 100755 --- a/release-tools/mksrc.sh +++ b/release-tools/mksrc.sh @@ -306,11 +306,13 @@ fi # Step 5, check which license type is selected, and run patches # if needed #------------------------------------------------------------------ -if [ $LICENSE = commercial ]; then - echo " -- Making Qt commercial, run $PATCH_FILE" - $PATCH_FILE $CUR_DIR/$PACKAGE_NAME/ $QTVER -else - echo " -- Not a commercial run" +if [ $PATCH_FILE ]; then + if [ $LICENSE = commercial]; then + # when doing commercial build, patch file needs src folder and qt version no as parameters + $PATCH_FILE $CUR_DIR/$PACKAGE_NAME/ $QTVER + else + $PATCH_FILE + fi fi #------------------------------------------------------------------ -- cgit v1.2.3