#!/usr/bin/python ################################################################### # Helper script to build with various options. ################################################################### import sys, os import getopt import signal # defines global options machines = ("armv7el", "i586") repositories = ("standard", "i586emul") extraOptions = "" enableDebug = False enableExp = False experimentalPatches = ( "78cd1be48cb9fe799a80cc3981e6456e1c89db66", "c376936d5a68acdcb8e4303625a75912f0fe9a24" ) enableInjectedProfile = False directoryPath = "" enableDryRun = False # To debug buildMachine = machines[0] # default machie is armv7el buildRepository = repositories[0] # default repository is standard optionsOnline = "" gMakeOption = "" gSimulator = False gFixVersion = False def signalHandler(signal, frame): print ' # SIGINT will be ignored for stable work' def execute(command): if enableDryRun: print(command) else: os.system(command) def help(): print("""# helper scripts to build webkit-efl with dynamic options" # # tizen-scripts/build-webkit.py [options] # [options] -h, --help : print this message. -d, --debug : build with debug info. -e : build with experimental patches. -i, --injected-profile : build with injected profile code -l, --layouttest : build for layout test -m, --machine [ %s ] -n, --dry-run : Don't actually run any commands; just print them. -o, --online : build with --online option. -r, --repository [ %s ] : choose repository (default is %s) -s : Add simulator definition (just for testing emulator) -v : Fix package version to 123997_0.999.0. It will prevent CMakeCache Errors although version is changed. -u, --unittest : build for unit test -0, --disable-tizen-options : build without tizen options (not supported yet) --makeargs [ targets ] : Just call make targets instead of calling 'cmake ... && make' Below are possible targets ( /fast would be faster but not safe ) wtf_efl javascriptcore_efl jsc_efl webcore_efl WebKit2StaticForDebug ewebkit2 WebCoreTestSupport gtest forwarding-headerEfl forwarding-headerSoup PluginProcess WebProcess aboutFeatures po ewk2UnitTestUtils test_ewk2_context test_ewk2_cookie_manager test_ewk2_download_job test_ewk2_settings test_ewk2_view wk2-web-inspector-resources DefaultTheme MiniBrowser """ % (' | '.join(machines), ' | '.join(repositories), buildRepository)) specFileName = "packaging/webkit2-efl.spec" def prepare(): if enableExp: pHandler = signal.signal(signal.SIGINT, signalHandler) execute("git diff > backupForBuildScript.patch") # backup.patch is to restore local changes. execute("git diff %s^ %s > exp.patch" % experimentalPatches) execute("patch -p1 < exp.patch") signal.signal(signal.SIGINT, pHandler) if enableInjectedProfile: execute("python TizenScripts/code-injecter.py") if gFixVersion: execute("cp %s backupForSpecfile.spec" % specFileName) execute("python TizenScripts/fix-version-of-spec.py") def cleanup(): if enableInjectedProfile: execute("python TizenScripts/code-injecter.py reset") if enableExp: pHandler = signal.signal(signal.SIGINT, signalHandler) execute("patch -p1 -R < exp.patch") execute("rm exp.patch") signal.signal(signal.SIGINT, pHandler) if gFixVersion: execute("mv backupForSpecfile.spec %s" % specFileName) def build(): execute('sudo echo build start') # touch sudo prepare() directoryDefine = "" optionsDefine = "" debugDefine = "" simulatorDefine = "" if directoryPath: directoryDefine = '--define=\\\"\"WEBKIT_BUILD_DIR %s\"\\\"' % directoryPath if extraOptions: optionsDefine = ' --define=\\\"\"TIZEN_WEBKIT_EXTRA_OPTIONS %s\"\\\"' % extraOptions if gMakeOption: optionsDefine = optionsDefine + ' --define=\\\"\"MAKE_OPTION %s\"\\\"' % gMakeOption if enableDebug: debugDefine = "--debug" if buildMachine == "i586" and gSimulator: simulatorDefine = ' --define=\\\"\"simulator 1\"\\\"' execute('time osce build %s %s %s %s %s %s %s' % (buildRepository, buildMachine, optionsOnline, debugDefine, directoryDefine, optionsDefine, simulatorDefine)) cleanup() def main(): global directoryPath, enableDebug, extraOptions, enableInjectedProfile, buildMachine, buildRepository, optionsOnline, enableDryRun, enableExp, gMakeOption, gSimulator, gFixVersion optlist, args = getopt.getopt(sys.argv[1:], 'hdeilunm:r:osv', [ 'help', 'debug', 'injected-profile', 'layouttest', 'unittest', 'dry-run', 'machine=', 'online', 'makeargs=', 'repository=' ]) for opt, var in optlist: if opt in ('--help', '-h'): help() exit() if opt in ('--debug', '-d'): enableDebug = True if opt in ('-e'): enableExp = True if opt in ('--injected-profile', '-i'): enableInjectedProfile = True extraOptions += " -DENABLE_TIZEN_PROFILE=On" if opt in ('--layouttest', '-l'): directoryPath = "WebKitBuild/Release" extraOptions += " -DENABLE_TIZEN_WEBKIT2_EFL_WTR=1" if opt in ('--unittest', '-u'): directoryPath = "WebKitBuild/Release" # TIZEN_GESTURE and TIZEN_WEBKIT2_TEXT_SELECTION cause segmentation fault while running unit tests. extraOptions += " '-DENABLE_API_TESTS=1 -DENABLE_TIZEN_WEBKIT2_UNIT_TESTS=1 -DENABLE_TIZEN_WEBKIT2_TEXT_SELECTION=0 -DENABLE_TIZEN_GESTURE=0'" if opt in ('--dry-run', '-n'): enableDryRun = True if opt in ('--repository', '-r'): if var not in repositories: print "## ! Error : repository should be %s or %s" % repositories print help() exit() buildRepository = var if opt in ('--machine', '-m'): if var not in machines: print "## ! Error : machine should be %s or %s" % machines print help() exit() buildMachine = var if opt in ('--online', '-o'): optionsOnline = "--online" if opt == '-s': gSimulator = True if opt == '-v': gFixVersion = True if opt == '--makeargs': print "make args" + var gMakeOption = var build() if __name__ == "__main__": main()