Initialize Tizen 2.3
[framework/web/webkit-efl.git] / TizenScripts / build-webkit
1 #!/usr/bin/python
2 ###################################################################
3 # Helper script to build with various options.
4 ###################################################################
5 import sys, os
6 import getopt
7 import signal
8
9 # defines global options
10 machines = ("armv7el", "i586")
11 repositories = ("standard", "i586emul")
12
13 extraOptions = ""
14
15 enableDebug = False
16
17 enableInjectedProfile = False
18 directoryPath = ""
19 enableDryRun = False # To debug
20 buildMachine = machines[0] # default machie is armv7el
21 buildRepository = repositories[0] # default repository is standard
22 optionsOnline = ""
23 gMakeOption = ""
24 gSimulator = False
25 gMicro = False
26 gFixVersion = False
27
28 def signalHandler(signal, frame):
29     print ' # SIGINT will be ignored for stable work'
30
31 def execute(command):
32     if enableDryRun:
33         print(command)
34     else:
35         os.system(command)
36
37 def help():
38     print("""# helper scripts to build webkit-efl with dynamic options"
39 #
40 # tizen-scripts/build-webkit.py [options]
41 #
42
43 [options]
44   -h, --help : print  this message.
45   -d, --debug : build with debug info.
46   -i, --injected-profile : build with injected profile code
47   -l, --layouttest : build for layout test
48   -m, --machine [ %s ]
49   -n, --dry-run : Don't actually run any commands; just print them.
50   -o, --online : build with --online option.
51   -r, --repository [ %s ] : choose repository (default is %s)
52   -s : Add simulator definition (just for testing emulator)
53   -w : Add micro definition (just for testing micro)
54   -v : Fix package version to 123997_0.999.0. It will prevent CMakeCache Errors although version is changed.
55   -u, --unittest : build for unit test
56   -0, --disable-tizen-options : build without tizen options (not supported yet)
57   --makeargs [ targets ] : Just call make targets instead of calling 'cmake ... && make'
58                            Below are possible targets ( /fast would be faster but not safe )
59
60     wtf_efl javascriptcore_efl jsc_efl webcore_efl WebKit2StaticForDebug ewebkit2
61     WebCoreTestSupport gtest
62     forwarding-headerEfl forwarding-headerSoup
63     PluginProcess WebProcess
64     aboutFeatures po
65     ewk2UnitTestUtils
66     test_ewk2_context test_ewk2_cookie_manager test_ewk2_download_job test_ewk2_settings test_ewk2_view
67     wk2-web-inspector-resources
68     DefaultTheme MiniBrowser
69
70 """ % (' | '.join(machines), ' | '.join(repositories), buildRepository))
71
72 specFileName = "packaging/webkit2-efl.spec"
73 def prepare():
74
75     if enableInjectedProfile:
76         execute("python TizenScripts/code-injecter.py")
77
78     if gFixVersion:
79         execute("cp %s backupForSpecfile.spec" % specFileName)
80
81         execute("python TizenScripts/fix-version-of-spec.py")
82
83 def cleanup():
84     if enableInjectedProfile:
85         execute("python TizenScripts/code-injecter.py reset")
86
87     if gFixVersion:
88         execute("mv backupForSpecfile.spec %s" % specFileName)
89
90 def build():
91     execute('sudo echo build start') # touch sudo
92     prepare()
93
94     directoryDefine = ""
95     optionsDefine = ""
96     debugDefine = ""
97     simulatorDefine = ""
98     if directoryPath:
99         directoryDefine = '--define=\\\"\"_webkit_build_dir %s\"\\\"' % directoryPath
100     if extraOptions:
101         optionsDefine = ' --define=\\\"\"_webkit_cmake_options %s\"\\\"' % extraOptions
102     if gMakeOption:
103         optionsDefine = optionsDefine + ' --define=\\\"\"_make_option %s\"\\\"' % gMakeOption
104
105     if enableDebug:
106         debugDefine = "--debug"
107
108     if buildMachine == "i586" and gSimulator:
109         simulatorDefine = ' --define=\\\"\"simulator 1\"\\\"'
110
111     if gMicro:
112         simulatorDefine = ' --define=\\\"\"sec_build_project_name tizenw2_master\"\\\"'
113
114     execute('time osce build %s %s %s %s %s %s %s' % (buildRepository, buildMachine, optionsOnline, debugDefine, directoryDefine, optionsDefine, simulatorDefine))
115     cleanup()
116
117 def main():
118     global directoryPath, enableDebug, extraOptions, enableInjectedProfile, buildMachine, buildRepository, optionsOnline, enableDryRun, gMakeOption, gSimulator, gMicro, gFixVersion
119
120     optlist, args = getopt.getopt(sys.argv[1:], 'hdilunm:r:oswv', [ 'help', 'debug', 'injected-profile', 'layouttest', 'unittest', 'dry-run', 'machine=', 'online', 'makeargs=', 'repository=' ])
121     for opt, var in optlist:
122         if opt in ('--help', '-h'):
123             help()
124             exit()
125         if opt in ('--debug', '-d'):
126             enableDebug = True
127         if opt in ('--injected-profile', '-i'):
128             enableInjectedProfile = True
129             extraOptions += " -DENABLE_TIZEN_PROFILE=On"
130         if opt in ('--layouttest', '-l'):
131             directoryPath = "WebKitBuild/Release"
132             extraOptions += " -DENABLE_TIZEN_WEBKIT2_EFL_WTR=1"
133         if opt in ('--unittest', '-u'):
134             directoryPath = "WebKitBuild/Release"
135             # TIZEN_GESTURE and TIZEN_WEBKIT2_TEXT_SELECTION cause segmentation fault while running unit tests.
136             extraOptions += " '-DENABLE_API_TESTS=1 -DENABLE_TIZEN_WEBKIT2_UNIT_TESTS=1 -DENABLE_TIZEN_WEBKIT2_TEXT_SELECTION=0 -DENABLE_TIZEN_GESTURE=0'"
137         if opt in ('--dry-run', '-n'):
138             enableDryRun = True
139         if opt in ('--repository', '-r'):
140             if var not in repositories:
141                 print "## ! Error : repository should be %s or %s" % repositories
142                 print
143                 help()
144                 exit()
145             buildRepository = var
146         if opt in ('--machine', '-m'):
147             if var not in machines:
148                 print "## ! Error : machine should be %s or %s" % machines
149                 print
150                 help()
151                 exit()
152             buildMachine = var
153         if opt in ('--online', '-o'):
154             optionsOnline = "--online"
155         if opt == '-s':
156             gSimulator = True
157         if opt == '-w':
158             gMicro = True
159         if opt == '-v':
160             gFixVersion = True
161         if opt == '--makeargs':
162             print "make args" + var
163             gMakeOption = var
164
165     build()
166
167 if __name__ == "__main__":
168     main()