def build_squish(options): print('--------------------------------------------------------------------') print('Configuring Squish') qmake_bin = os.path.join(options.qt_build_dir, 'qtbase', 'bin', options.qt_qmake_bin) print ('qmake path ' + qmake_bin) if bldinstallercommon.is_win_platform(): cmd_args = "configure --with-qmake=" + qmake_bin + " --enable-qmake-config --disable-all --enable-idl --enable-qt" print("command args " + cmd_args) bldinstallercommon.do_execute_sub_process(cmd_args, options.squish_src) else: cmd_args = os.path.join(options.squish_src, "configure") + " --with-qmake=" + qmake_bin + " --enable-qmake-config --disable-all --enable-idl --enable-qt" print("command args " + cmd_args) bldinstallercommon.do_execute_sub_process(shlex.split(cmd_args), options.squish_src) print('--------------------------------------------------------------------') print("building form source " + options.squish_src) print('Building Squish') if bldinstallercommon.is_win_platform(): bldinstallercommon.do_execute_sub_process('build', options.squish_src) bldinstallercommon.do_execute_sub_process('build install DESTDIR=' + options.squish_dir, options.squish_src) else: bldinstallercommon.do_execute_sub_process(shlex.split(os.path.join(options.squish_src, 'build')), options.squish_src) bldinstallercommon.do_execute_sub_process(shlex.split(os.path.join(options.squish_src,'build install DESTDIR=') + options.squish_dir), options.squish_src)
def init_mkqt5bld(): global CONFIGURE_CMD global CONFIGURE_OPTIONS global MAKE_INSTALL_CMD global QT_BUILD_OPTIONS print_wrap('---------------- Initializing build --------------------------------') #do not edit configure options, if configure options are overridden from commandline options if bldinstallercommon.is_unix_platform(): CONFIGURE_CMD = './' if QT_BUILD_OPTIONS.silent_build and not bldinstallercommon.is_win_platform(): CONFIGURE_OPTIONS += ' -silent' # add required configuration arguments if Android build if ANDROID_BUILD: CONFIGURE_OPTIONS += ' -android-ndk ' + QT_BUILD_OPTIONS.android_ndk_home CONFIGURE_OPTIONS += ' -android-sdk ' + QT_BUILD_OPTIONS.android_sdk_home QT_BUILD_OPTIONS.system_env['ANDROID_NDK_HOST'] = QT_BUILD_OPTIONS.android_ndk_host QT_BUILD_OPTIONS.system_env['ANDROID_API_VERSION'] = QT_BUILD_OPTIONS.android_api_version CONFIGURE_CMD += 'configure' # make cmd if QT_BUILD_OPTIONS.make_cmd == '': #if not given in commandline param, use nmake or make according to the os if bldinstallercommon.is_win_platform(): #win QT_BUILD_OPTIONS.make_cmd = 'nmake' MAKE_INSTALL_CMD = 'nmake' if QT_BUILD_OPTIONS.silent_build: QT_BUILD_OPTIONS.make_cmd += ' /s' MAKE_INSTALL_CMD += ' /s' MAKE_INSTALL_CMD += ' install' elif bldinstallercommon.is_unix_platform(): #linux & mac QT_BUILD_OPTIONS.make_cmd = 'make' MAKE_INSTALL_CMD = 'make' if QT_BUILD_OPTIONS.silent_build: QT_BUILD_OPTIONS.make_cmd += ' -s' MAKE_INSTALL_CMD += ' -s' MAKE_INSTALL_CMD += ' install' else: if QT_BUILD_OPTIONS.make_cmd == 'jom': MAKE_INSTALL_CMD = 'jom -j1 install' if QT_BUILD_OPTIONS.silent_build: QT_BUILD_OPTIONS.make_cmd += ' -s -nologo' MAKE_INSTALL_CMD += ' -s -nologo' ## QTBUG-38555: make install INSTALL_ROOT=\some\path does not work on Windows # always use 'make' for 'make install', 'mingw32-make install' does not work atm elif QT_BUILD_OPTIONS.make_cmd == 'mingw32-make' and bldinstallercommon.is_win_platform() and QNX_BUILD: MAKE_INSTALL_CMD = 'make install' #remove old working dirs if os.path.exists(WORK_DIR): print_wrap(' Removing old work dir ' + WORK_DIR) bldinstallercommon.remove_tree(WORK_DIR) if os.path.exists(MODULE_ARCHIVE_DIR): print_wrap(' Removing old module archive dir ' + MODULE_ARCHIVE_DIR) bldinstallercommon.remove_tree(MODULE_ARCHIVE_DIR) print_wrap(' Build : ' + QT_BUILD_OPTIONS.make_cmd) print_wrap(' Install : ' + MAKE_INSTALL_CMD) print_wrap(' Configure: ' + CONFIGURE_OPTIONS) print_wrap('--------------------------------------------------------------------')
def build_installer_framework_examples(options): print('--------------------------------------------------------------------') print('Building Installer Framework Examples') file_binarycreator = os.path.join(options.installer_framework_build_dir, 'bin', 'binarycreator') if bldinstallercommon.is_win_platform(): file_binarycreator += '.exe' if not os.path.exists(file_binarycreator): print('*** Unable to find binarycreator: {0}, aborting!'.format(file_binarycreator)) sys.exit(-1) ifw_examples = os.path.join(options.installer_framework_source_dir, 'examples') for root, dirs, files in os.walk(ifw_examples): if 'doc' in dirs: dirs.remove('doc') # don't visit doc dir if 'translations' in dirs: dirs.remove('translations') # for now don't visit translation example as qm files needs to be generated first for directory in dirs: print("********** building example " + directory) config_file = os.path.join(root, directory, 'config', 'config.xml') package_dir = os.path.join(root, directory, 'packages') target_dir = os.path.join(root, directory, 'installer') bldinstallercommon.do_execute_sub_process(args=(file_binarycreator, '--offline-only', '-c', config_file, '-p', package_dir, target_dir), execution_path=package_dir) #Breaking here as we don't want to go through sub directories break;
def install_command(toolchain): if bldinstallercommon.is_win_platform(): command = ['mingw32-make'] if is_mingw_toolchain(toolchain) else ["nmake"] else: command = ["make", "-j1"] return command + install_targets(toolchain)
def make_command(toolchain): if bldinstallercommon.is_win_platform(): command = ['mingw32-make'] if is_mingw_toolchain(toolchain) else ['jom'] else: command = ['make'] return command + make_targets(toolchain)
def patch_android_prl_files(): ## QTBUG-33660 # remove references to absolute path of the NDK on the build machine if ANDROID_BUILD: install_path_essent = MAKE_INSTALL_ROOT_DIR + os.sep + ESSENTIALS_INSTALL_DIR_NAME install_path_addons = MAKE_INSTALL_ROOT_DIR + os.sep + ADDONS_INSTALL_DIR_NAME # temporary solution for Android on Windows compilations if bldinstallercommon.is_win_platform(): install_path_essent = MAKE_INSTALL_ROOT_DIR + os.sep + SINGLE_INSTALL_DIR_NAME install_path_essent = 'C' + install_path_essent[1:] # find the lib directory under the install directory for essentials and addons lib_path_essent = os.path.normpath(install_path_essent + os.sep + INSTALL_PREFIX + os.sep + 'lib') lib_path_addons = os.path.normpath(install_path_addons + os.sep + INSTALL_PREFIX + os.sep + 'lib') # just list the files with a pattern like 'libQt5Core.prl' for lib_path_final in [lib_path_essent, lib_path_addons]: print_wrap('---------- Remove references to a static library in the NDK under ' + lib_path_final + ' ----------------') if os.path.exists(lib_path_final): prl_files = [f for f in os.listdir(lib_path_final) if re.match(r'libQt5.*\.prl', f)] # let's replace the ' .*libgcc.a' string regex = re.compile(' .*libgcc.a') for prl_name in prl_files: # let's just remove the undesired string for QMAKE_PRL_LIBS prl_name_path = os.path.join(lib_path_final, prl_name) print_wrap('---> Replacing regex .*libgcc.a in file: ' + prl_name_path) if os.path.isfile(prl_name_path): for line in fileinput.FileInput(prl_name_path, inplace=1): if line.startswith('QMAKE_PRL_LIBS'): line = regex.sub('', line) print line, else: print_wrap('*** Warning! The file : ' + prl_name_path + ' does not exist') else: print_wrap('*** Warning! Unable to locate ' + lib_path_final + ' directory')
def archive_installerbase(options): print('--------------------------------------------------------------------') print('Archive Installerbase') cmd_args_archive = [] cmd_args_clean = [] bin_temp = '' if bldinstallercommon.is_linux_platform() or bldinstallercommon.is_mac_platform(): bin_path = bldinstallercommon.locate_executable(options.installer_framework_build_dir, 'installerbase') bin_temp = ROOT_DIR + os.sep + '.tempSDKMaintenanceTool' shutil.copy(bin_path, bin_temp) cmd_args_archive = ['7z', 'a', options.installer_base_archive_name, bin_temp] cmd_args_clean = ['rm', bin_temp] if bldinstallercommon.is_win_platform(): bin_path = bldinstallercommon.locate_executable(options.installer_framework_build_dir, 'installerbase.exe') bin_temp = ROOT_DIR + os.sep + 'tempSDKMaintenanceToolBase.exe' shutil.copy(bin_path, bin_temp) if options.signserver and options.signpwd: sign_windows_installerbase('tempSDKMaintenanceToolBase.exe', ROOT_DIR + os.sep, True, options) cmd_args_archive = ['7z', 'a', options.installer_base_archive_name, bin_temp] cmd_args_clean = ['del', bin_temp] bldinstallercommon.do_execute_sub_process(cmd_args_archive, ROOT_DIR) bldinstallercommon.do_execute_sub_process(cmd_args_clean, ROOT_DIR) if not os.path.isfile(options.installer_base_archive_name): print('*** Failed to generate archive: {0}'.format(options.installer_base_archive_name)) sys.exit(-1) shutil.move(options.installer_base_archive_name, options.build_artifacts_dir)
def create_installer(job, packages_base_url, installer_type): # ensure the string ends with '/' if not packages_base_url.endswith('/'): packages_base_url += '/' job.print_data() cmd_args = ['python', '-u', 'create_installer.py'] cmd_args = cmd_args + ['-c', job.configurations_dir] cmd_args = cmd_args + ['-f', job.configurations_file] cmd_args = cmd_args + [installer_type] cmd_args = cmd_args + ['-l', job.license] cmd_args = cmd_args + ['-u', packages_base_url] cmd_args = cmd_args + ['--ifw-tools=' + job.ifw_tools] cmd_args = cmd_args + ['--preferred-installer-name=' + job.installer_name] cmd_args = cmd_args + [ '--max-cpu-count=' + str(6 if bldinstallercommon.is_win_platform() else 8) ] if (len(job.substitution_arg_list) > 0): for item in job.substitution_arg_list: cmd_args = cmd_args + [item] # execute, do not bail out if installer job fails subprocess_exec_stataus = False try: bldinstallercommon.do_execute_sub_process(cmd_args, SCRIPT_ROOT_DIR) subprocess_exec_stataus = True except: # catch any interrupt into installer creation, we assume the operation failed subprocess_exec_stataus = False return subprocess_exec_stataus
def build_docs(): print_wrap('------------------------- Building documentation -------------------') print_wrap(' Running \'make qmake_all\' ...') cmd_args = QT_BUILD_OPTIONS.make_cmd + ' qmake_all' bldinstallercommon.do_execute_sub_process(cmd_args.split(' '), QT_SOURCE_DIR, abort_on_fail=False, extra_env=QT_BUILD_OPTIONS.system_env) #first we need to do make install for the sources print_wrap(' Running make install...') install_args = MAKE_INSTALL_CMD bldinstallercommon.do_execute_sub_process(install_args.split(' '), QT_SOURCE_DIR, abort_on_fail=False, extra_env=QT_BUILD_OPTIONS.system_env) cmd_args = QT_BUILD_OPTIONS.make_cmd + ' docs' print_wrap(' Running make docs in ' + QT_SOURCE_DIR) #do not abort on fail, if the doc build fails, we still want to get the binary package bldinstallercommon.do_execute_sub_process(cmd_args.split(' '), QT_SOURCE_DIR, abort_on_fail=False, extra_env=QT_BUILD_OPTIONS.system_env) print_wrap(' Running make install_docs in ' + QT_SOURCE_DIR) make_cmd = QT_BUILD_OPTIONS.make_cmd install_root_path = MAKE_INSTALL_ROOT_DIR + os.sep + ESSENTIALS_INSTALL_DIR_NAME if bldinstallercommon.is_win_platform(): install_root_path = install_root_path[2:] doc_install_args = make_cmd + ' -j1 install_docs INSTALL_ROOT=' + install_root_path #do not abort on fail, if the doc build fails, we still want to get the binary package bldinstallercommon.do_execute_sub_process(doc_install_args.split(' '), QT_SOURCE_DIR, abort_on_fail=False, extra_env=QT_BUILD_OPTIONS.system_env) # Also archive docs in a separate qt5_docs.7z file print_wrap(' Archiving qt5_docs.7z') cmd_args = '7z a ' + MODULE_ARCHIVE_DIR + os.sep + 'qt5_docs' + '.7z *' run_in = os.path.normpath(MAKE_INSTALL_ROOT_DIR + os.sep + ESSENTIALS_INSTALL_DIR_NAME + os.sep + INSTALL_PREFIX + os.sep + 'doc') bldinstallercommon.do_execute_sub_process(cmd_args.split(' '), run_in, get_output=True) print_wrap('--------------------------------------------------------------------')
def build_installer_framework(options): if options.incremental_mode: file_to_check = os.path.join(options.installer_framework_build_dir, 'bin', 'installerbase') if bldinstallercommon.is_win_platform(): file_to_check += '.exe' if os.path.exists(file_to_check): return print('--------------------------------------------------------------------') print('Building Installer Framework') qmake_bin = os.path.join(options.qt_build_dir, 'qtbase', 'bin', options.qt_qmake_bin) if not os.path.isfile(qmake_bin): print('*** Unable to find qmake, aborting!') print('qmake: {0}'.format(qmake_bin)) sys.exit(-1) if not os.path.exists(options.installer_framework_build_dir): bldinstallercommon.create_dirs(options.installer_framework_build_dir) cmd_args = [qmake_bin] cmd_args += options.qt_installer_framework_qmake_args cmd_args += [options.installer_framework_source_dir] start_IFW_build(options, cmd_args, options.installer_framework_build_dir) if options.squish_dir: print('--------------------------------------------------------------------') print('Build Installer Framework with squish support') if not os.path.exists(options.installer_framework_build_dir_squish): bldinstallercommon.create_dirs(options.installer_framework_build_dir_squish) cmd_args = [qmake_bin] cmd_args += options.qt_installer_framework_qmake_args cmd_args += ['SQUISH_PATH=' + options.squish_dir] cmd_args += [options.installer_framework_source_dir] start_IFW_build(options, cmd_args, options.installer_framework_build_dir_squish)
def archive_installerbase(options): print( '--------------------------------------------------------------------') print('Archive Installerbase') cmd_args_archive = [] cmd_args_clean = [] bin_temp = '' if bldinstallercommon.is_linux_platform( ) or bldinstallercommon.is_mac_platform(): bin_path = bldinstallercommon.locate_executable( options.installer_framework_build_dir, 'installerbase') bin_temp = ROOT_DIR + os.sep + '.tempSDKMaintenanceTool' shutil.copy(bin_path, bin_temp) cmd_args_archive = [ '7z', 'a', options.installer_base_archive_name, bin_temp ] cmd_args_clean = ['rm', bin_temp] if bldinstallercommon.is_win_platform(): bin_path = bldinstallercommon.locate_executable( options.installer_framework_build_dir, 'installerbase.exe') bin_temp = ROOT_DIR + os.sep + 'tempSDKMaintenanceToolBase.exe' shutil.copy(bin_path, bin_temp) cmd_args_archive = [ '7z', 'a', options.installer_base_archive_name, bin_temp ] cmd_args_clean = ['del', bin_temp] bldinstallercommon.do_execute_sub_process(cmd_args_archive, ROOT_DIR) bldinstallercommon.do_execute_sub_process(cmd_args_clean, ROOT_DIR) if not os.path.isfile(options.installer_base_archive_name): print('*** Failed to generate archive: {0}'.format( options.installer_base_archive_name)) sys.exit(-1) shutil.move(options.installer_base_archive_name, options.build_artifacts_dir)
def build_installer_framework(options): if options.incremental_mode: file_to_check = os.path.join(options.installer_framework_build_dir, 'bin', 'installerbase') if bldinstallercommon.is_win_platform(): file_to_check += '.exe' if os.path.exists(file_to_check): return print( '--------------------------------------------------------------------') print('Building Installer Framework') qmake_bin = os.path.join(options.qt_build_dir, 'qtbase', 'bin', options.qt_qmake_bin) if not os.path.isfile(qmake_bin): print('*** Unable to find qmake, aborting!') print('qmake: {0}'.format(qmake_bin)) sys.exit(-1) if not os.path.exists(options.installer_framework_build_dir): bldinstallercommon.create_dirs(options.installer_framework_build_dir) cmd_args = [qmake_bin] cmd_args += options.qt_installer_framework_qmake_args cmd_args += [options.installer_framework_source_dir] bldinstallercommon.do_execute_sub_process( cmd_args, options.installer_framework_build_dir) cmd_args = options.make_cmd bldinstallercommon.do_execute_sub_process( cmd_args.split(' '), options.installer_framework_build_dir)
def install_command(toolchain): if bldinstallercommon.is_win_platform(): command = ['mingw32-make', '-j1' ] if is_mingw_toolchain(toolchain) else ['nmake'] else: command = ['make', '-j1'] return command
def build_command(toolchain): if bldinstallercommon.is_win_platform(): command = ['mingw32-make', '-j{}'.format(multiprocessing.cpu_count()) ] if is_mingw_toolchain(toolchain) else ['jom'] else: command = ['make'] return command
def build_sdktool_impl(params, qt_build_path): bldinstallercommon.create_dirs(params.build_path) if not params.use_cmake: qmake_command = os.path.join(qt_build_path, 'bin', 'qmake') bldinstallercommon.do_execute_sub_process([qmake_command, '-after', 'DESTDIR=' + params.target_path, params.src_path], params.build_path, redirect_output=params.redirect_output) bldinstallercommon.do_execute_sub_process([params.make_command], params.build_path, redirect_output=params.redirect_output) else: cmake_args = ['cmake', '-DCMAKE_PREFIX_PATH=' + qt_build_path, '-DCMAKE_BUILD_TYPE=Release'] # force MSVC on Windows, because it looks for GCC in the PATH first, # even if MSVC is first mentioned in the PATH... # TODO would be nicer if we only did this if cl.exe is indeed first in the PATH if bldinstallercommon.is_win_platform(): cmake_args += ['-DCMAKE_C_COMPILER=cl', '-DCMAKE_CXX_COMPILER=cl'] bldinstallercommon.do_execute_sub_process(cmake_args + ['-G', 'Ninja', params.src_path], params.build_path, redirect_output=params.redirect_output) bldinstallercommon.do_execute_sub_process(['cmake', '--build', '.'], params.build_path, redirect_output=params.redirect_output) bldinstallercommon.do_execute_sub_process(['cmake', '--install', '.', '--prefix', params.target_path], params.build_path, redirect_output=params.redirect_output)
def prepare_qt_sources(options): if options.incremental_mode and os.path.exists(options.qt_source_dir): return print('--------------------------------------------------------------------') print('Prepare Qt src package: {0}'.format(options.qt_source_package_uri)) prepare_compressed_package(options.qt_source_package_uri, options.qt_source_package_uri_saveas, options.qt_source_dir) if bldinstallercommon.is_win_platform(): patch_win32_mkspecs(os.path.join(options.qt_source_dir, "qtbase", "mkspecs"))
def prepare_qt_sources(options): if options.incremental_mode and os.path.exists(options.qt_source_dir): return print('--------------------------------------------------------------------') print('Prepare Qt src package: {0}'.format(options.qt_source_package_uri)) prepare_src_package(options.qt_source_package_uri, options.qt_source_package_uri_saveas, options.qt_source_dir) if bldinstallercommon.is_win_platform(): patch_win32_mkspecs(os.path.join(options.qt_source_dir, "qtbase", "mkspecs"))
def install_qt(): print_wrap('---------------- Installing Qt -------------------------------------') if QNX_BUILD: install_root_path = MAKE_INSTALL_ROOT_DIR + os.sep + SINGLE_INSTALL_DIR_NAME if bldinstallercommon.is_win_platform(): # do not use drive letter when running make install [because of c:$(INSTALL_ROOT)/$(PREFIX)] install_root_path = install_root_path[2:] # apply the workaround from QTBUG-38555 install_root_path = install_root_path.replace('\\','/').replace('/', '\\', 1) cmd_args = MAKE_INSTALL_CMD + ' ' + 'INSTALL_ROOT=' + install_root_path print_wrap('Installing module: Qt top level') return_code, output = bldinstallercommon.do_execute_sub_process(cmd_args.split(' '), QT_SOURCE_DIR, abort_on_fail=QT_BUILD_OPTIONS.strict_mode, extra_env=QT_BUILD_OPTIONS.system_env) return #make install for each module with INSTALL_ROOT print_wrap('Install modules to separate INSTALL_ROOT') for module_name in QT5_MODULES_LIST: # we do not provide pre-built examples if module_name in QT5_MODULE_INSTALL_EXCLUDE_LIST: print_wrap('Qt5 module excluded from make install: ' + module_name) continue # determine into which final archive this module belongs into install_dir = '' if module_name in QT_BUILD_OPTIONS.module_separate_install_list: install_dir = module_name elif module_name in QT5_ESSENTIALS: install_dir = ESSENTIALS_INSTALL_DIR_NAME else: install_dir = ADDONS_INSTALL_DIR_NAME install_root_path = MAKE_INSTALL_ROOT_DIR + os.path.sep + install_dir if bldinstallercommon.is_win_platform(): install_root_path = install_root_path[2:] print_wrap('Using install root path: ' + install_root_path) submodule_dir_name = QT_SOURCE_DIR + os.sep + module_name cmd_args = MAKE_INSTALL_CMD + ' ' + 'INSTALL_ROOT=' + install_root_path print_wrap('Installing module: ' + module_name) return_code, output = bldinstallercommon.do_execute_sub_process(cmd_args.split(' '), submodule_dir_name, abort_on_fail=QT_BUILD_OPTIONS.strict_mode, extra_env=QT_BUILD_OPTIONS.system_env) if return_code >= 0: file_handle = open(MISSING_MODULES_FILE, 'a') file_handle.write('\nFailed to install ' + module_name) file_handle.close() print_wrap('--------------------------------------------------------------------')
def add_common_commandline_arguments(parser): if bldinstallercommon.is_win_platform(): parser.epilog = "example: " + os.linesep + "\tpython {0} --clean " \ "--buildcommand C:\\bin\\ibjom.cmd --installcommand nmake " \ "--qt-module http://it-dl241-hki.it.local/packages/qt/5.5.0-released/windows_vs2013_32/qt_all.7z " \ "--sevenzippath \"C:\\Program Files\\7-Zip\" " \ "--gitpath \"C:\\Program Files (x86)\\Git\\cmd\" "\ "--d3dcompiler7z http://download.qt.io/development_releases/prebuilt/d3dcompiler/msvc2010/D3DCompiler_43-x86.dll.7z " \ "--opengl32sw7z http://download.qt.io/development_releases/prebuilt/llvmpipe/windows/opengl32sw-32.7z " \ "--environment_batch \"C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\vcvarsall.bat\" " \ "--environment_batch_argument x86" \ "".format(os.path.basename(sys.argv[0])) elif bldinstallercommon.is_mac_platform(): parser.epilog = "example: " + os.linesep + "\tpython {0} --clean " \ "--qt-module http://it-dl241-hki.it.local/packages/qt/5.0.1-released/mac_cocoa_10.7/qt_all.7z" \ "".format(os.path.basename(sys.argv[0])) else: parser.epilog = "example: " + os.linesep + "\tpython {0} --clean " \ "--qt-module http://it-dl241-hki.it.local/packages/qt/5.0.1-released/linux_gcc_64_ubuntu1110/qt_all.7z " \ "--icu7z http://it-dl241-hki.it.local/packages/qt/5.0.1-released/linux_gcc_64_ubuntu1110/libicu_x86_64_ubuntu1110.7z" \ "".format(os.path.basename(sys.argv[0])) # general arguments parser.add_argument('--clean', help="clean up everything from old builds", action='store_true', default=False) parser.add_argument('--buildcommand', help="this means usually make", default="make") parser.add_argument('--installcommand', help="this means usually make", default="make") parser.add_argument('--debug', help="use debug builds", action='store_true', default=False) parser.add_argument('--qt-module', help="Qt module package url (.7z) needed for building", action='append', dest='qt_modules') parser.add_argument('--add-qmake-argument', help='Adds an argument to the qmake command line', dest='additional_qmake_arguments', action='append') if bldinstallercommon.is_linux_platform(): parser.add_argument('--icu7z', help="a file or url where it get icu libs as 7z", required=True) # if we are on windows, maybe we want some other arguments if bldinstallercommon.is_win_platform(): parser.add_argument('--d3dcompiler7z', help="a file or url where it get d3dcompiler lib") parser.add_argument('--opengl32sw7z', help="a file or url where it get d3dcompiler lib") parser.add_argument('--openssl7z', help="a file or url where to get the openssl libs as 7z") parser.add_argument('--environment_batch', help="batch file that sets up environment") parser.add_argument('--environment_batch_argument', help="if the batch file needs an argument just add it with this argument") parser.add_argument('--sevenzippath', help="path where the 7zip binary is located") parser.add_argument('--gitpath', help="path where the git binary is located")
def check_env(): if bldinstallercommon.is_win_platform(): print('Checking for 7z ...') subprocess.check_output(['7z', '-h']) print('Checking for bash ...') subprocess.check_output(['bash', '--version']) print('Checking for cygpath ...') subprocess.check_output(['cygpath', '-V']) print('Checking for make ...') subprocess.check_output(['make', '-v'])
def format_substitution_list(self, substitution_list): item_list = substitution_list.split(",") for item in item_list: temp = item.replace(" ", "") if temp: if bldinstallercommon.is_win_platform(): # On Windows we must escape the '%' so that the subprocess shell will # not attempt to replace the environment variables temp = temp.replace("%", "^%") self.substitution_arg_list.append("--add-substitution=" + temp)
def format_substitution_list(self, substitution_list): item_list = substitution_list.split(',') for item in item_list: temp = item.strip() if temp: if bldinstallercommon.is_win_platform(): # On Windows we must escape the '%' so that the subprocess shell will # not attempt to replace the environment variables temp = temp.replace('%', '^%') self.substitution_arg_list.append('--add-substitution=' + temp)
def add_common_commandline_arguments(parser): if bldinstallercommon.is_win_platform(): parser.epilog = "example: " + os.linesep + "\tpython {0} --clean " \ "--buildcommand C:\\bin\\ibjom.cmd --installcommand nmake " \ "--qt-module http://it-dl241-hki.it.local/packages/qt/5.5.0-released/windows_vs2013_32/qt_all.7z " \ "--sevenzippath \"C:\\Program Files\\7-Zip\" " \ "--gitpath \"C:\\Program Files (x86)\\Git\\cmd\" "\ "--d3dcompiler7z http://download.qt.io/development_releases/prebuilt/d3dcompiler/msvc2010/D3DCompiler_43-x86.dll.7z " \ "--opengl32sw7z http://download.qt.io/development_releases/prebuilt/llvmpipe/windows/opengl32sw-32.7z " \ "--environment_batch \"C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\vcvarsall.bat\" " \ "--environment_batch_argument x86" \ "".format(os.path.basename(sys.argv[0])) elif bldinstallercommon.is_mac_platform(): parser.epilog = "example: " + os.linesep + "\tpython {0} --clean " \ "--qt-module http://it-dl241-hki.it.local/packages/qt/5.0.1-released/mac_cocoa_10.7/qt_all.7z" \ "".format(os.path.basename(sys.argv[0])) else: parser.epilog = "example: " + os.linesep + "\tpython {0} --clean " \ "--qt-module http://it-dl241-hki.it.local/packages/qt/5.0.1-released/linux_gcc_64_ubuntu1110/qt_all.7z " \ "--icu7z http://it-dl241-hki.it.local/packages/qt/5.0.1-released/linux_gcc_64_ubuntu1110/libicu_x86_64_ubuntu1110.7z" \ "".format(os.path.basename(sys.argv[0])) # general arguments parser.add_argument('--clean', help="clean up everything from old builds", action='store_true', default=False) parser.add_argument('--buildcommand', help="this means usually make", default="make") parser.add_argument('--installcommand', help="this means usually make", default="make") parser.add_argument('--debug', help="use debug builds", action='store_true', default=False) parser.add_argument('--qt-module', help="Qt module package url (.7z) needed for building", action='append', dest='qt_modules') if bldinstallercommon.is_linux_platform(): parser.add_argument('--icu7z', help="a file or url where it get icu libs as 7z", required=True) # if we are on windows, maybe we want some other arguments if bldinstallercommon.is_win_platform(): parser.add_argument('--d3dcompiler7z', help="a file or url where it get d3dcompiler lib") parser.add_argument('--opengl32sw7z', help="a file or url where it get d3dcompiler lib") parser.add_argument('--openssl7z', help="a file or url where to get the openssl libs as 7z") parser.add_argument('--environment_batch', help="batch file that sets up environment") parser.add_argument('--environment_batch_argument', help="if the batch file needs an argument just add it with this argument") parser.add_argument('--sevenzippath', help="path where the 7zip binary is located") parser.add_argument('--gitpath', help="path where the git binary is located")
def build_environment(toolchain, bitness): if bldinstallercommon.is_win_platform(): if is_mingw_toolchain(toolchain): environment = dict(os.environ) # cmake says "For MinGW make to work correctly sh.exe must NOT be in your path." environment['PATH'] = paths_with_sh_exe_removed(environment['PATH']) return environment else: return msvc_environment(bitness) else: return None # == process environment
def add_commandline_arguments(parser): parser.add_argument('--qt5path', help="here it expects a compiled Qt5", required=True) parser.epilog += " --qt5path qtcreator_qt5" if bldinstallercommon.is_mac_platform(): parser.add_argument('--keychain_unlock_script', help="script for unlocking the keychain used for signing") parser.epilog += " --keychain_unlock_script $HOME/unlock-keychain.sh" if bldinstallercommon.is_win_platform(): parser.add_argument('--python_path', help="path to python libraries for use by cdbextension") parser.add_argument('--skip_cdb', help="skip cdbextension and the python dependency packaging step", action='store_true', default=False) parser.add_argument('--elfutils_path', help='elfutils installation path for use by perfprofiler')
def push_online_repository(optionDict, server_addr, username, directory_to_copy, where_to_copy): print('Preparing to copy: {0}'.format(directory_to_copy)) where_to_copy = ensure_unix_paths(where_to_copy) destination = username + '@' + server_addr + ':' + where_to_copy + '/' parts = directory_to_copy.strip(os.path.sep).split(os.path.sep) parentDir = os.path.sep + os.path.sep.join(parts[:-1]) dirToCopy = parts[-1] if bldinstallercommon.is_win_platform(): parentDir = os.path.sep.join(parts[:-1]) cmd_args = [optionDict['SCP_COMMAND'], '-r', dirToCopy, destination] bldinstallercommon.do_execute_sub_process(cmd_args, parentDir)
def build_installer_framework_examples(options): print('--------------------------------------------------------------------') print('Building Installer Framework Examples') if options.squish_dir: file_binarycreator = os.path.join(options.installer_framework_build_dir_squish, 'bin', 'binarycreator') else: file_binarycreator = os.path.join(options.installer_framework_build_dir, 'bin', 'binarycreator') if bldinstallercommon.is_win_platform(): file_binarycreator += '.exe' if not os.path.exists(file_binarycreator): print('*** Unable to find binarycreator: {0}, aborting!'.format(file_binarycreator)) sys.exit(-1) ifw_examples = os.path.join(options.installer_framework_source_dir, 'examples') ifw_example_binaries = [] for root, dirs, files in os.walk(ifw_examples): if 'doc' in dirs: dirs.remove('doc') # don't visit doc dir if 'translations' in dirs: dirs.remove('translations') # for now don't visit translation example as qm files needs to be generated first for directory in dirs: print("********** building example " + directory) config_file = os.path.join(root, directory, 'config', 'config.xml') package_dir = os.path.join(root, directory, 'packages') target_filename = os.path.join(root, directory, 'installer') bldinstallercommon.do_execute_sub_process(args=(file_binarycreator, '--offline-only', '-c', config_file, '-p', package_dir, target_filename), execution_path=package_dir) if bldinstallercommon.is_win_platform: target_filename += '.exe' ifw_example_binaries.append(target_filename) #Breaking here as we don't want to go through sub directories break file_squishDir = options.squish_dir if os.path.exists(file_squishDir): print('--------------------------------------------------------------------') print('Running squish tests') # Windows if sys.platform.startswith('win'): squishserver_handle = subprocess.Popen(os.path.join(file_squishDir, 'bin', 'squishserver.exe')) bldinstallercommon.do_execute_sub_process(args=('squishrunner.exe --testsuite ' + os.path.join(os.getcwd(), 'squish_suites', 'suite_IFW_examples')), execution_path=os.path.join(file_squishDir, 'bin')) squishserver_handle.kill() # this will not kill squishserver most likely subprocess.Popen("TASKKILL /IM _squishserver.exe /F") #this should kill squish server # Unix else: squishserver_handle = subprocess.Popen(shlex.split(os.path.join(file_squishDir, "bin", "squishserver")), shell=False) bldinstallercommon.do_execute_sub_process(args=shlex.split(os.path.join(file_squishDir, "bin", "squishrunner") + ' --testsuite ' +os.path.join(os.getcwd(), "squish_suites", "suite_IFW_examples")), execution_path=os.path.join(file_squishDir, "bin")) squishserver_handle.kill() #kills squish server # Delete the example executables we have created for Squish for example in ifw_example_binaries: print("Removing " + example) os.remove(example)
def init_build_icu(icu_src, icu_version='', archive_icu=False, environment=dict(os.environ)): # clean up first cleanup_icu() icu_src_dir = os.path.join(SCRIPT_ROOT_DIR, ICU_SRC_DIR_NAME) # what to do if not icu_src: print( '*** Error! You asked to build the ICU but did not tell from where to find the sources?' ) sys.exit(-1) if icu_src.endswith('git'): if not icu_version: print( '*** Error! You asked to clone ICU sources from git repository but did not tell from which branch/tag/sha?' ) sys.exit(-1) bldinstallercommon.clone_repository(icu_src, icu_version, icu_src_dir) else: if not bldinstallercommon.is_content_url_valid(icu_src): print('*** Error! The given URL for ICU sources is not valid: {0}'. format(icu_src)) sys.exit(-1) package_save_as_temp = os.path.join(SCRIPT_ROOT_DIR, os.path.basename(icu_src)) bldinstallercommon.create_dirs(icu_src_dir) print('Downloading ICU src package: ' + icu_src) bldinstallercommon.retrieve_url(icu_src, package_save_as_temp) bldinstallercommon.extract_file(package_save_as_temp, icu_src_dir) # now build the icu icu_configuration = None if bldinstallercommon.is_linux_platform(): icu_configuration = build_icu_linux( environment, os.path.join(SCRIPT_ROOT_DIR, icu_src_dir), archive_icu) elif bldinstallercommon.is_mac_platform(): print('*** ICU build for macOS not implemented yet!') elif bldinstallercommon.is_win_platform(): icu_configuration = build_icu_win( environment, os.path.join(SCRIPT_ROOT_DIR, icu_src_dir), archive_icu) else: print('*** Unsupported platform') # set options for Qt5 build extra_qt_configure_args = ' -L' + icu_configuration.icu_lib_path extra_qt_configure_args += ' -I' + icu_configuration.icu_include_path icu_configuration.qt_configure_extra_args = extra_qt_configure_args icu_configuration.environment = get_icu_env( icu_configuration.icu_lib_path, icu_configuration.icu_include_path) return icu_configuration
def build_qt(): print_wrap('---------------- Building Qt ---------------------------------------') #remove if old dir exists if os.path.exists(MAKE_INSTALL_ROOT_DIR): shutil.rmtree(MAKE_INSTALL_ROOT_DIR) #create install dirs bldinstallercommon.create_dirs(MAKE_INSTALL_ROOT_DIR) cmd_args = QT_BUILD_OPTIONS.make_cmd if bldinstallercommon.is_unix_platform(): cmd_args += ' -j' + str(QT_BUILD_OPTIONS.make_thread_count) elif bldinstallercommon.is_win_platform() and 'mingw32-make' in QT_BUILD_OPTIONS.make_cmd: cmd_args += ' -j' + str(QT_BUILD_OPTIONS.make_thread_count) bldinstallercommon.do_execute_sub_process(cmd_args.split(' '), QT_SOURCE_DIR, abort_on_fail=QT_BUILD_OPTIONS.strict_mode, extra_env=QT_BUILD_OPTIONS.system_env) print_wrap('--------------------------------------------------------------------')
def build_environment(toolchain, bitness): if bldinstallercommon.is_win_platform(): if is_mingw_toolchain(toolchain): environment = dict(os.environ) # cmake says "For MinGW make to work correctly sh.exe must NOT be in your path." environment['PATH'] = paths_with_sh_exe_removed(environment['PATH']) return environment else: program_files = os.path.join('C:', '/Program Files (x86)') if not os.path.exists(program_files): program_files = os.path.join('C:', '/Program Files') vcvarsall = os.path.join(program_files, 'Microsoft Visual Studio ' + os.environ['MSVC_VERSION'], 'VC', 'vcvarsall.bat') arg = 'amd64' if bitness == 64 else 'x86' return environmentfrombatchfile.get(vcvarsall, arguments=arg) else: return None # == process environment
def init(): if bldinstallercommon.is_win_platform() == False: print_wrap(' *** Error: Not a windows platform, can not create configure.exe! Exiting...') sys.exit(-1) print_wrap('Emptying the working directory...') contents = os.listdir(QT_SRC_DIR) if len(contents) > 0: for item in contents: print_wrap(' Deleting ' + item) if os.path.isdir(item): bldinstallercommon.remove_tree(item) else: os.remove(item) else: print_wrap(' Nothing to delete.')
def init(): if bldinstallercommon.is_win_platform() == False: print_wrap( ' *** Error: Not a windows platform, can not create configure.exe! Exiting...' ) sys.exit(-1) print_wrap('Emptying the working directory...') contents = os.listdir(QT_SRC_DIR) if len(contents) > 0: for item in contents: print_wrap(' Deleting ' + item) if os.path.isdir(item): bldinstallercommon.remove_tree(item) else: os.remove(item) else: print_wrap(' Nothing to delete.')
def extract_src_package(): global QT_SOURCE_DIR global QT_BUILD_OPTIONS print_wrap('---------------- Extracting source package -------------------------') if os.path.exists(QT_SOURCE_DIR): print_wrap('Source dir ' + QT_SOURCE_DIR + ' already exists, using that (not re-extracting the archive!)') else: 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) time.sleep(10) l = os.listdir(QT_SOURCE_DIR) items = len(l) if items == 1: print_wrap(' Replacing qt-everywhere-xxx-src-5.0.0 with shorter path names') shorter_dir_path = QT_SOURCE_DIR + os.sep + QT_PACKAGE_SHORT_NAME time.sleep(10) print_wrap(QT_SOURCE_DIR + os.sep + l[0] + ',' + shorter_dir_path) time.sleep(20) os.rename(QT_SOURCE_DIR + os.sep + l[0], shorter_dir_path) time.sleep(10) 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_wrap('*** Unsupported directory structure!!!') sys.exit(-1) #Remove the modules to be ignored for ignore in QT_BUILD_OPTIONS.module_ignore_list: if os.path.exists(QT_SOURCE_DIR + os.sep + ignore): print_wrap(' Removing ' + ignore) bldinstallercommon.remove_tree(QT_SOURCE_DIR + os.sep + ignore) # Locate gnuwin32 tools if bldinstallercommon.is_win_platform(): gnuwin32_path = bldinstallercommon.locate_directory(QT_SOURCE_DIR, 'gnuwin32') gnuwin32_path = os.path.join(gnuwin32_path, 'bin') QT_BUILD_OPTIONS.system_env['PATH'] = gnuwin32_path + ';' + QT_BUILD_OPTIONS.system_env['PATH'] print_wrap('--------------------------------------------------------------------')
def get_icu_env(icu_lib_path, icu_include_path): if not os.path.isdir(icu_lib_path) or not os.path.isdir(icu_include_path): return icu_environment = dict() if bldinstallercommon.is_linux_platform(): icu_environment['LD_LIBRARY_PATH'] = icu_lib_path icu_environment['LIBRARY_PATH'] = icu_lib_path icu_environment['CPLUS_INCLUDE_PATH'] = icu_include_path icu_environment['CPATH'] = icu_include_path elif bldinstallercommon.is_mac_platform(): print('*** ICU build for macOS not implemented yet!') elif bldinstallercommon.is_win_platform(): icu_environment['PATH'] = icu_lib_path icu_environment['LIB'] = icu_lib_path icu_environment['INCLUDE'] = icu_include_path else: print('*** Unsupported platform') return icu_environment
def clean_up(): print_wrap('---------------- Cleaning unnecessary files from ' + MAKE_INSTALL_ROOT_DIR + '----------') # remove examples from binary packages bldinstallercommon.remove_directories_by_type(MAKE_INSTALL_ROOT_DIR, 'examples') # all platforms for root, dummy, files in os.walk(MAKE_INSTALL_ROOT_DIR): for name in files: if (any(name.endswith(to_remove) for to_remove in FILES_TO_REMOVE_LIST)): path = os.path.join(root, name) print_wrap(' ---> Deleting file: ' + name) os.remove(path) # on windows remove redundant .dll files from \lib if bldinstallercommon.is_win_platform(): for name in os.listdir(MAKE_INSTALL_ROOT_DIR): dir_name = os.path.join(MAKE_INSTALL_ROOT_DIR, name) lib_path = bldinstallercommon.locate_directory(dir_name, 'lib') if lib_path: bldinstallercommon.delete_files_by_type_recursive(lib_path, '\\.dll') print_wrap('--------------------------------------------------------------------')
def add_commandline_arguments(parser): parser.add_argument('--qt5path', help="here it expects a compiled Qt5", required=True) parser.epilog += " --qt5path qtcreator_qt5" if bldinstallercommon.is_mac_platform(): parser.add_argument( '--keychain_unlock_script', help="script for unlocking the keychain used for signing") parser.epilog += " --keychain_unlock_script $HOME/unlock-keychain.sh" if bldinstallercommon.is_win_platform(): parser.add_argument( '--python_path', help="path to python libraries for use by cdbextension") parser.add_argument( '--skip_cdb', help="skip cdbextension and the python dependency packaging step", action='store_true', default=False)
def build_ifw(options, create_installer=False, build_ifw_examples=False): # verbose options.print_data() #clean environment first clean_build_environment(options) #checkout sources prepare_installer_framework(options) if options.qt_binaries_static: prepare_compressed_package(options.qt_binaries_static, options.qt_binaries_static_saveas, options.qt_build_dir) else: prepare_qt_sources(options) build_qt(options, options.qt_build_dir, options.qt_configure_options, options.qt_build_modules) if(options.squish_src): build_squish(options) # build installer framework build_installer_framework(options) if build_ifw_examples or options.squish_dir: build_installer_framework_examples(options) # steps when creating ifw installer if create_installer: if options.qt_binaries_dynamic: prepare_compressed_package(options.qt_binaries_dynamic, options.qt_binaries_dynamic_saveas, options.qt_build_dir_dynamic) if bldinstallercommon.is_win_platform(): patch_win32_mkspecs(os.path.join(options.qt_build_dir_dynamic, "qtbase", "mkspecs")) else: configure_options = get_dynamic_qt_configure_options() + '-prefix ' + options.qt_build_dir_dynamic + os.sep + 'qtbase' # Although we have a shadow build qt sources are still taminated. Unpack sources again. if os.path.exists(options.qt_source_dir): bldinstallercommon.remove_tree(options.qt_source_dir) prepare_qt_sources(options) build_qt(options, options.qt_build_dir_dynamic, configure_options, options.qt_build_modules_docs) build_ifw_docs(options) create_installer_package(options) #archive archive_installerbase(options) archive_installer_framework(options.installer_framework_build_dir, options.installer_framework_archive_name, options.build_artifacts_dir) if (options.squish_dir): archive_installer_framework(options.installer_framework_build_dir_squish, options.installer_framework_with_squish_archive_name, options.build_artifacts_dir) return os.path.basename(options.installer_framework_build_dir)
def get_common_environment(qt5_path, caller_arguments): # PATH path_list = [] # -- Qt path_list.append(os.path.abspath(os.path.join(qt5_path, 'bin'))) # -- python path_list.append(os.path.dirname(sys.executable)) if hasattr(caller_arguments, 'sevenzippath') and caller_arguments.sevenzippath: path_list.append(caller_arguments.sevenzippath) if hasattr(caller_arguments, 'gitpath') and caller_arguments.gitpath: path_list.append(caller_arguments.gitpath) environment = {"PATH": os.pathsep.join(path_list)} if bldinstallercommon.is_linux_platform(): environment["LD_LIBRARY_PATH"] = os.path.join(qt5_path, 'lib') environment["QMAKESPEC"] = "linux-g++" if bldinstallercommon.is_mac_platform(): environment["DYLD_FRAMEWORK_PATH"] = os.path.join(qt5_path, 'lib') if not bldinstallercommon.is_win_platform(): environment["MAKEFLAGS"] = "-j" + str(multiprocessing.cpu_count() + 1) return environment
def init_build_icu(icu_src, icu_version = '', archive_icu = False, environment = dict(os.environ)): # clean up first cleanup_icu() icu_src_dir = os.path.join(SCRIPT_ROOT_DIR, ICU_SRC_DIR_NAME) # what to do if not icu_src: print('*** Error! You asked to build the ICU but did not tell from where to find the sources?') sys.exit(-1) if icu_src.endswith('git'): if not icu_version: print('*** Error! You asked to clone ICU sources from git repository but did not tell from which branch/tag/sha?') sys.exit(-1) bldinstallercommon.clone_repository(icu_src, icu_version, icu_src_dir) else: if not bldinstallercommon.is_content_url_valid(icu_src): print('*** Error! The given URL for ICU sources is not valid: {0}'.format(icu_src)) sys.exit(-1) package_save_as_temp = os.path.join(SCRIPT_ROOT_DIR, os.path.basename(icu_src)) bldinstallercommon.create_dirs(icu_src_dir) print('Downloading ICU src package: ' + icu_src) bldinstallercommon.retrieve_url(icu_src, package_save_as_temp) bldinstallercommon.extract_file(package_save_as_temp, icu_src_dir) # now build the icu icu_configuration = None if bldinstallercommon.is_linux_platform(): icu_configuration = build_icu_linux(environment, os.path.join(SCRIPT_ROOT_DIR, icu_src_dir), archive_icu) elif bldinstallercommon.is_mac_platform(): print('*** ICU build for macOS not implemented yet!') elif bldinstallercommon.is_win_platform(): icu_configuration = build_icu_win(environment, os.path.join(SCRIPT_ROOT_DIR, icu_src_dir), archive_icu) else: print('*** Unsupported platform') # set options for Qt5 build extra_qt_configure_args = ' -L' + icu_configuration.icu_lib_path extra_qt_configure_args += ' -I' + icu_configuration.icu_include_path icu_configuration.qt_configure_extra_args = extra_qt_configure_args icu_configuration.environment = get_icu_env(icu_configuration.icu_lib_path, icu_configuration.icu_include_path) return icu_configuration
def patch_qnx6_files(dir_tofind, regex_filename, line_toreplace, regex_toreplace, replace_with=''): # remove references to absolute path of the SDP on the build machine if QNX_BUILD: install_path_final = MAKE_INSTALL_ROOT_DIR + os.sep + SINGLE_INSTALL_DIR_NAME if bldinstallercommon.is_win_platform(): install_path_final = 'C' + install_path_final[1:] # find the 'dir_tofind' directory under the install directory path_final = bldinstallercommon.locate_directory(install_path_final, dir_tofind) # just list the files with a pattern matching 'expression' print_wrap('---------- Remove references to hard coded paths of the SDP under ' + path_final + ' ----------------') print_wrap('*** Replacing hard coded paths to SDP under : ' + path_final) files_to_patch = [f for f in os.listdir(path_final) if re.match(regex_filename, f)] # let's replace the 'regex_toreplace' string regex = re.compile(regex_toreplace) for name_to_patch in files_to_patch: # let's just replace the line containing the 'line_toreplace' string name_path = os.path.join(path_final, name_to_patch) for line in fileinput.FileInput(name_path, inplace=1): if line.startswith(line_toreplace): line = regex.sub(replace_with, line) print line,
def build_installer_framework(options): if options.incremental_mode: file_to_check = os.path.join(options.installer_framework_build_dir, 'bin', 'installerbase') if bldinstallercommon.is_win_platform(): file_to_check += '.exe' if os.path.exists(file_to_check): return print('--------------------------------------------------------------------') print('Building Installer Framework') qmake_bin = bldinstallercommon.locate_file(options.qt_build_dir, options.qt_qmake_bin) if not os.path.isfile(qmake_bin): print('*** Unable to find qmake, aborting!') print('qmake: {0}'.format(qmake_bin)) sys.exit(-1) if not os.path.exists(options.installer_framework_build_dir): bldinstallercommon.create_dirs(options.installer_framework_build_dir) cmd_args = [qmake_bin] cmd_args += options.qt_installer_framework_qmake_args cmd_args += [options.installer_framework_source_dir] bldinstallercommon.do_execute_sub_process(cmd_args, options.installer_framework_build_dir) cmd_args = options.make_cmd bldinstallercommon.do_execute_sub_process(cmd_args.split(' '), options.installer_framework_build_dir)
def patch_build(): # replace build directory paths in install_root locations replace_build_paths(MAKE_INSTALL_ROOT_DIR) # remove system specific paths from qconfig.pri if not ANDROID_BUILD and not QNX_BUILD: replace_system_paths() # fix qmake prl build fir references erase_qmake_prl_build_dir() if ANDROID_BUILD: if bldinstallercommon.is_win_platform(): install_path = MAKE_INSTALL_ROOT_DIR + os.sep + SINGLE_INSTALL_DIR_NAME install_path = 'C' + install_path[1:] lib_path_essentials = os.path.normpath(install_path + os.sep + INSTALL_PREFIX + os.sep) bldinstallercommon.rename_android_soname_files(lib_path_essentials) patch_android_prl_files() if QNX_BUILD: patch_qnx6_files('lib', 'libQt5.*\.prl', 'QMAKE_PRL_LIBS', '-L[^ ]* ') patch_qnx6_files('lib', 'libQt5.*\.la', 'dependency_libs', '-L[^ ]* ') # QT-701: internal qnx bug report patch_qnx6_files('common', 'qcc-base-qnx\.conf', 'QMAKE_LFLAGS ', '\n', ' -Wl,-rpath-link,$$[QT_INSTALL_LIBS]') patch_qnx6_files('pkgconfig', 'Qt5.*\.pc', 'Libs.private', '-L[^ ]* ') # patch RPath if requested if QT_BUILD_OPTIONS.replace_rpath: replace_rpath() # patch icu_install paths from files if bldinstallercommon.is_linux_platform(): bld_icu_tools.patch_icu_paths(MAKE_INSTALL_ROOT_DIR) # make sure the 'fixqt4headers.pl' ends up in final package if it does not exist there already fixqt4headers_filename = 'fixqt4headers.pl' fixqt4headers_file = bldinstallercommon.locate_file(MAKE_INSTALL_ROOT_DIR, fixqt4headers_filename) if not fixqt4headers_file: # copy it from the used src package fixqt4headers_file = bldinstallercommon.locate_file(QT_SOURCE_DIR, fixqt4headers_filename) target_dir = bldinstallercommon.locate_directory(os.path.join(MAKE_INSTALL_ROOT_DIR, ESSENTIALS_INSTALL_DIR_NAME), 'bin') if fixqt4headers_file and target_dir: shutil.copy(fixqt4headers_file, target_dir)
def archive_submodules(): print_wrap('---------------- Archiving submodules ------------------------------') bldinstallercommon.create_dirs(MODULE_ARCHIVE_DIR) if QNX_BUILD: print_wrap('---------- Archiving Qt modules') install_path = MAKE_INSTALL_ROOT_DIR + os.sep + SINGLE_INSTALL_DIR_NAME if bldinstallercommon.is_win_platform(): install_path = 'C' + install_path[1:] if os.path.exists(install_path): cmd_args = '7z a ' + MODULE_ARCHIVE_DIR + os.sep + 'qt5_essentials' + '.7z *' run_in = os.path.normpath(install_path + os.sep + INSTALL_PREFIX) bldinstallercommon.do_execute_sub_process(cmd_args.split(' '), run_in, get_output=True) else: print_wrap(install_path + os.sep + SINGLE_INSTALL_DIR_NAME + ' DIRECTORY NOT FOUND\n -> Qt not archived!') return file_list = os.listdir(MAKE_INSTALL_ROOT_DIR) for item in file_list: print_wrap('---------- Archiving: ' + item) cmd_args = ['7z', 'a', MODULE_ARCHIVE_DIR + os.sep + 'qt5_' + item, '.7z' , '*'] run_in = os.path.normpath(MAKE_INSTALL_ROOT_DIR + os.sep + item + os.sep + INSTALL_PREFIX) bldinstallercommon.do_execute_sub_process(cmd_args, run_in, get_output=True) return
def upload_clang(file_path, remote_path): (path, filename) = os.path.split(file_path) scp_bin = '%SCP%' if bldinstallercommon.is_win_platform() else 'scp' scp_command = [scp_bin, filename, remote_path] bld_utils.runCommand(scp_command, path)
def zip_sdktool(sdktool_target_path, out_7zip, redirect_output=None): glob = "*.exe" if bldinstallercommon.is_win_platform() else "*" bldinstallercommon.do_execute_sub_process(['7z', 'a', out_7zip, glob], sdktool_target_path, redirect_output=redirect_output)
def cmake_generator(toolchain): if bldinstallercommon.is_win_platform(): return 'Ninja' else: return 'Unix Makefiles'
def install_command(toolchain): if bldinstallercommon.is_win_platform(): command = ['ninja'] else: command = ['make', '-j1'] return command
def profile_data(toolchain): if bldinstallercommon.is_win_platform() and is_mingw_toolchain(toolchain): return os.getenv('PROFILE_DATA_URL')
def cmake_generator(toolchain): if bldinstallercommon.is_win_platform(): return 'MinGW Makefiles' if is_mingw_toolchain( toolchain) else 'NMake Makefiles JOM' else: return 'Unix Makefiles'
formatter_class=argparse.RawTextHelpFormatter) add_common_commandline_arguments(parser) add_commandline_arguments(parser) callerArguments = parser.parse_args() callerArguments = fix_arguments(callerArguments) qtCreatorSourceDirectory = os.path.abspath('qt-creator') qtCreatorBuildDirectory = os.path.abspath( os.path.join(qtCreatorSourceDirectory, '..', 'qt-creator_build')) qtCreatorInstallDirectory = os.path.abspath( os.path.join(qtCreatorSourceDirectory, '..', 'qt-creator_install')) qtCreatorTempDevDirectory = os.path.abspath( os.path.join(qtCreatorSourceDirectory, '..', 'qt-creator_dev')) if bldinstallercommon.is_win_platform(): cdbextSourceDirectory = os.path.join(qtCreatorSourceDirectory, 'src', 'libs', 'qtcreatorcdbext') cdbextBuildDirectory = os.path.abspath( os.path.join(qtCreatorSourceDirectory, '..', 'cdbextension_build')) cdbextInstallDirectory = os.path.abspath( os.path.join(qtCreatorSourceDirectory, '..', 'cdbextension_install')) wininterruptSourceDirectory = os.path.join(qtCreatorSourceDirectory, 'src', 'tools', 'wininterrupt') wininterruptBuildDirectory = os.path.abspath( os.path.join(qtCreatorSourceDirectory, '..', 'wininterrupt_build')) wininterruptInstallDirectory = os.path.abspath( os.path.join(qtCreatorSourceDirectory, '..', 'wininterrupt_install'))
def qt_static_platform_configure_options(): if bldinstallercommon.is_win_platform(): return ['-static-runtime', '-no-icu', '-mp'] elif bldinstallercommon.is_linux_platform(): return ['-no-icu', '-no-glib', '-qt-zlib', '-qt-pcre'] return []
def __init__(self, qt_source_package_uri, qt_configure_options, qt_installer_framework_uri, qt_installer_framework_branch, qt_installer_framework_qmake_args, openssl_dir, product_key_checker_pri, incremental_build=False): self.incremental_mode = incremental_build self.qt_source_dir = os.path.join(ROOT_DIR, 'qt-src') self.qt_build_dir = os.path.join(ROOT_DIR, 'qt-bld') self.qt_build_dir_dynamic = os.path.join(ROOT_DIR, 'qt-bld-dynamic') self.installer_framework_source_dir = os.path.join(ROOT_DIR, 'ifw-src') self.installer_framework_build_dir = os.path.join(ROOT_DIR, 'ifw-bld') self.installer_framework_pkg_dir = os.path.join(ROOT_DIR, 'ifw-pkg') self.installer_framework_target_dir = os.path.join( ROOT_DIR, 'ifw-target') self.qt_installer_framework_uri = qt_installer_framework_uri self.qt_installer_framework_uri_saveas = os.path.join( ROOT_DIR, os.path.basename(self.qt_installer_framework_uri)) self.qt_installer_framework_branch = qt_installer_framework_branch self.qt_installer_framework_qmake_args = qt_installer_framework_qmake_args self.openssl_dir = openssl_dir self.qt_build_modules = " module-qtbase module-qtdeclarative module-qttools module-qttranslations" self.qt_build_modules_docs = " module-qttools" if bldinstallercommon.is_win_platform(): self.qt_build_modules += " module-qtwinextras" self.make_cmd = 'nmake' self.make_doc_cmd = 'nmake' self.make_install_cmd = 'nmake install' self.qt_qmake_bin = 'qmake.exe' self.qt_configure_bin = self.qt_source_dir + os.sep + 'configure.bat' else: self.make_cmd = 'make -j' + str(multiprocessing.cpu_count() + 1) self.make_doc_cmd = 'make' self.make_install_cmd = 'make install' self.qt_qmake_bin = 'qmake' self.qt_configure_bin = self.qt_source_dir + os.sep + 'configure' self.build_artifacts_dir = os.path.join( ROOT_DIR, pkg_constants.IFW_BUILD_ARTIFACTS_DIR) self.mac_deploy_qt_archive_name = 'macdeployqt.7z' self.mac_qt_menu_nib_archive_name = 'qt_menu.nib.7z' # determine filenames used later on self.architecture = '' # if this is cross-compilation attempt to parse the target architecture from the given -platform if '-platform' in qt_configure_options: temp = qt_configure_options.split(' ') plat = temp[temp.index('-platform') + 1] bits = ''.join(re.findall(r'\d+', plat)) if bits == '32': self.architecture = 'x86' else: self.architecture = 'x64' if not self.architecture: self.architecture = bldinstallercommon.get_architecture() self.plat_suffix = bldinstallercommon.get_platform_suffix() self.installer_framework_archive_name = 'installer-framework-build-' + self.plat_suffix + '-' + self.architecture + '.7z' self.installer_base_archive_name = 'installerbase-' + self.plat_suffix + '-' + self.architecture + '.7z' self.installer_framework_payload_arch = 'installer-framework-build-stripped-' + self.plat_suffix + '-' + self.architecture + '.7z' self.qt_source_package_uri = qt_source_package_uri self.qt_source_package_uri_saveas = os.path.join( ROOT_DIR, os.path.basename(self.qt_source_package_uri)) # Set Qt build prefix qt_prefix = ' -prefix ' + self.qt_build_dir + os.sep + 'qtbase' self.qt_configure_options = qt_configure_options + qt_prefix # Product key checker self.product_key_checker_pri = product_key_checker_pri if product_key_checker_pri: if os.path.isfile(product_key_checker_pri): self.qt_installer_framework_qmake_args += [ '-r', 'PRODUCTKEYCHECK_PRI_FILE=' + self.product_key_checker_pri ] # macOS specific if bldinstallercommon.is_mac_platform(): self.qt_installer_framework_qmake_args += [ '-r', '"LIBS+=-framework IOKit"' ] # sanity check self.sanity_check()