[chromium] No modifier flags (shift/ctrl/alt) in drag&drop events on chromium linux
[WebKit-https.git] / wscript
1 #! /usr/bin/env python
2
3 # Copyright (C) 2009 Kevin Ollivier  All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 # 1. Redistributions of source code must retain the above copyright
9 #    notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 #    notice, this list of conditions and the following disclaimer in the
12 #    documentation and/or other materials provided with the distribution.
13 #
14 # THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
25 #
26 # WebCore build script for the waf build system
27
28 import Options
29
30 from settings import *
31 import wxpresets
32
33 import TaskGen
34 from TaskGen import taskgen, feature, after
35 import Task, ccroot
36
37 def generate_webcore_derived_sources(conf):
38     # build the derived sources
39     derived_sources_dir = os.path.join(webcore_dir, 'DerivedSources')
40     wc_dir = webcore_dir
41     if building_on_win32:
42         wc_dir = get_output('cygpath --unix "%s"' % wc_dir)
43     if not os.path.exists(derived_sources_dir):
44         os.mkdir(derived_sources_dir)
45
46     olddir = os.getcwd()
47     os.chdir(derived_sources_dir)
48     
49     # DerivedSources.make expects Cygwin (i.e. Unix-style) python, so use that instead.
50     if building_on_win32:
51         oldpath = os.environ["PATH"]
52         os.environ["PATH"] = "/usr/bin" + os.pathsep + os.environ["PATH"]
53     os.system('make -f %s/DerivedSources.make WebCore=%s SOURCE_ROOT=%s all FEATURE_DEFINES="%s"' % (wc_dir, wc_dir, wc_dir, conf.env["FEATURE_DEFINES"]))
54     if building_on_win32:
55         os.environ["PATH"] = oldpath
56     
57     os.chdir(olddir)
58
59 def generate_jscore_derived_sources(conf):
60     # build the derived sources
61     js_dir = jscore_dir
62     if building_on_win32:
63         js_dir = get_output('cygpath --unix "%s"' % js_dir)
64     derived_sources_dir = os.path.join(jscore_dir, 'DerivedSources')
65     if not os.path.exists(derived_sources_dir):
66         os.mkdir(derived_sources_dir)
67
68     olddir = os.getcwd()
69     os.chdir(derived_sources_dir)
70
71     # DerivedSources.make expects Cygwin (i.e. Unix-style) python, so use that instead.
72     if building_on_win32:
73         oldpath = os.environ["PATH"]
74         os.environ["PATH"] = "/usr/bin" + os.pathsep + os.environ["PATH"]
75     command = 'make -f %s/DerivedSources.make JavaScriptCore=%s BUILT_PRODUCTS_DIR=%s all FEATURE_DEFINES="%s"' % (js_dir, js_dir, js_dir, conf.env["FEATURE_DEFINES"])
76     os.system(command)
77     if building_on_win32:
78         os.environ["PATH"] = oldpath
79     os.chdir(olddir)
80
81 def set_options(opt):
82     common_set_options(opt)
83
84 def configure(conf):
85     common_configure(conf)
86     generate_jscore_derived_sources(conf)
87     generate_webcore_derived_sources(conf)
88     if Options.options.port == "wx" and sys.platform.startswith('win'):
89         graphics_dir = os.path.join(wk_root, 'Source', 'WebCore', 'platform', 'graphics')
90         # we used to copy these files into the graphics/wx directory due to 
91         # both wx and win directories having FontPlatformData.h. That is no 
92         # longer the case, so we remove the old files if they exist.
93         for afile in ['UniscribeController.h', 'UniscribeController.cpp', 'GlyphPageTreeNodeCairoWin.cpp']:
94             wx_copy = os.path.join(graphics_dir, 'wx', afile)
95             if os.path.exists(wx_copy):
96                 os.remove(wx_copy)
97
98     webcore_out_dir = os.path.join(output_dir, 'WebCore')
99     if not os.path.exists(webcore_out_dir):
100         os.makedirs(webcore_out_dir)
101     shutil.copy('Source/WebCore/platform/mac/WebCoreSystemInterface.h', os.path.join(output_dir, 'WebCore', 'WebCoreSystemInterface.h'))
102     jscore_out_dir = os.path.join(output_dir, 'JavaScriptCore')
103     if not os.path.exists(jscore_out_dir):
104         os.makedirs(jscore_out_dir)
105     for api_file in glob.glob(os.path.join(jscore_dir, 'API/*.h')):
106         shutil.copy(api_file, os.path.join(jscore_out_dir, os.path.basename(api_file)))
107
108     if Options.options.port == "wx" and Options.options.wxpython:
109         common_configure(conf)
110         conf.check_tool('swig', tooldir='Source/WebKit/wx/bindings/python')
111         conf.check_swig_version('1.3.29')
112
113 def build(bld):
114
115     webcore_dirs = list(webcore_dirs_common)
116
117     # auto-generate WebKitVersion.h if needed before we start the build.
118     # Also, remove the file from the old location where we generated it before running
119     wk_version_h = 'Source/WebCore/DerivedSources/WebKitVersion.h'
120     if os.path.exists(wk_version_h):
121         os.remove(wk_version_h)
122     bld.new_task_gen(source = "Source/WebKit/mac/Configurations/Version.xcconfig",
123                      target = wk_version_h,
124                      rule = 'perl %s/Source/WebKit/scripts/generate-webkitversion.pl --outputDir=${TGT[0].dir(env)} --config ${SRC}' % wk_root)
125     bld.add_group()
126
127     if Options.options.port == "wx":
128         webcore_dirs.extend(['Source/WebKit/wx', 'Source/WebKit/wx/WebKitSupport'])
129     
130     wk_includes = ['.',
131                     os.path.join(wk_root, 'Source', 'WTF'),
132                     os.path.join(wk_root, 'Source', 'WTF', 'wtf'),
133                     os.path.join(wk_root, 'Source', 'JavaScriptCore'),
134                     os.path.join(wk_root, 'Source', 'WebCore'),
135                     os.path.join(wk_root, 'Source', 'WebCore', 'DerivedSources'),
136                     os.path.join(wk_root, 'Source', 'WebCore', 'platform', 'image-decoders'),
137                     os.path.join(wk_root, 'Source', 'WebCore', 'platform', 'win'),
138                     os.path.join(wk_root, 'Source', 'WebCore', 'workers'),
139                     os.path.join(output_dir),
140             ]
141     
142     if Options.options.port == "wx":
143         wk_includes.append(os.path.join(wk_root, 'Source', 'WebKit', 'wx'))
144         wk_includes.append(os.path.join(wk_root, 'Source', 'WebCore', 'platform', 'wx', 'wxcode'))
145     
146     if sys.platform.startswith("win"):
147         wk_includes.append(os.path.join(wk_root, 'Source', 'WebCore', 'platform', 'win'))
148         wk_includes.append(os.path.join(wk_root, 'Source', 'WebCore', 'platform', 'graphics', 'win'))
149     
150     windows_deps = [
151                     'lib/pthreadVC2.dll',
152                     'bin/icuuc40.dll', 'bin/icudt40.dll', 'bin/icuin40.dll',
153                     'bin/libcurl.dll', 'bin/libeay32.dll', 'bin/ssleay32.dll', 'bin/zlib1.dll',
154                     'lib/sqlite3.dll', 'bin/libxml2.dll', 'bin/libxslt.dll', 'bin/iconv.dll',
155                     ]
156     
157     webcore_sources = {}
158     
159     if Options.options.port == "wx":
160         webcore_sources['wx'] = [
161             'Source/WebCore/bindings/cpp/WebDOMEventTarget.cpp',
162             'Source/WebCore/platform/KillRingNone.cpp',
163             'Source/WebCore/platform/text/LocalizedDateNone.cpp',
164             'Source/WebCore/platform/text/LocalizedNumberNone.cpp',
165             'Source/WebCore/page/scrolling/ScrollingCoordinatorNone.cpp',
166         ]  
167     
168         if building_on_win32:
169             # make sure platform/wx comes after this so we get the right
170             # FontPlatformData.h
171             webcore_dirs.extend(['Source/WebCore/platform/wx/wxcode/win', 'Source/WebCore/plugins/win'])
172             webcore_sources['wx-win'] = [
173                    'Source/WebCore/platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp',
174                    'Source/WebCore/platform/graphics/win/TransformationMatrixWin.cpp',
175                    'Source/WebCore/platform/graphics/win/UniscribeController.cpp',
176                    'Source/WebCore/platform/ScrollAnimatorNone.cpp',
177                    # wxTimer on Windows has a bug that causes it to eat crashes in callbacks
178                    # so we need to use the Win port's implementation until the wx bug fix is
179                    # widely available (it was fixed in 2.8.10).
180                    'Source/WebCore/platform/win/SharedTimerWin.cpp',
181                    'Source/WebCore/platform/win/SystemInfo.cpp',
182                    'Source/WebCore/platform/win/WebCoreInstanceHandle.cpp',
183                    # Use the Windows plugin architecture
184                    #'Source/WebCore/plugins/win/PluginDataWin.cpp',
185                    'Source/WebCore/plugins/win/PluginDatabaseWin.cpp',
186                    'Source/WebCore/plugins/win/PluginMessageThrottlerWin.cpp',
187                    'Source/WebCore/plugins/win/PluginPackageWin.cpp',
188                    'Source/WebCore/plugins/win/PluginViewWin.cpp',
189             ]
190             if Options.options.cairo:
191                 webcore_dirs.append('Source/WebCore/platform/wx/wxcode/cairo')
192             else:
193                 webcore_dirs.append('Source/WebCore/platform/wx/wxcode/gdiplus')
194         elif sys.platform.startswith('darwin'):
195             webcore_dirs.append('Source/WebCore/plugins/mac')
196             webcore_dirs.append('Source/WebCore/platform/wx/wxcode/mac/carbon')
197             webcore_dirs.append('Source/WebCore/platform/text/mac')
198             webcore_sources['wx-mac'] = [
199                    'Source/WebCore/platform/mac/PurgeableBufferMac.cpp',
200                    'Source/WebCore/platform/mac/WebCoreNSStringExtras.mm',
201                    'Source/WebCore/platform/mac/WebCoreSystemInterface.mm',
202                    'Source/WebCore/platform/graphics/cg/FloatSizeCG.cpp',
203                    'Source/WebCore/platform/graphics/mac/ComplexTextController.cpp',
204                    'Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm',
205                    'Source/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp',
206                    'Source/WebCore/platform/graphics/mac/GlyphPageTreeNodeMac.cpp',
207                    'Source/WebCore/platform/graphics/mac/SimpleFontDataATSUI.mm',
208                    'Source/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp',
209                    'Source/WebCore/platform/graphics/wx/FontPlatformDataWxMac.mm',
210                    'Source/WebCore/platform/wx/wxcode/mac/carbon/fontprops.mm',
211                    'Source/WebCore/plugins/mac/PluginPackageMac.cpp',
212                    'Source/WebCore/plugins/mac/PluginViewMac.mm'
213             ]
214         else:
215             webcore_sources['wx-gtk'] = [
216                    'Source/WebCore/plugins/PluginViewNone.cpp',
217                    'Source/WebCore/plugins/PluginPackageNone.cpp'
218             ]
219             webcore_dirs.append('Source/WebCore/platform/wx/wxcode/gtk')
220             webcore_dirs.append('Source/WebCore/platform/wx/wxcode/cairo')
221         
222
223     import TaskGen
224
225     bld.add_subdirs('Source/JavaScriptCore')
226
227     if sys.platform.startswith('darwin'):
228         TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cxx']
229         TaskGen.task_gen.mappings['.m'] = TaskGen.task_gen.mappings['.cxx']
230
231     features = [Options.options.port.lower()]
232     thisport = Options.options.port
233     
234     exclude_patterns = ['*AllInOne.cpp', '*None.cpp',]
235
236     if sys.platform.startswith('darwin'):
237         features.append('cf')
238
239     # exclude the filename patterns for all other ports.
240     exclude_patterns.extend(get_port_excludes(Options.options.port))
241             
242     if Options.options.port == 'wx':
243         features.append('curl')
244         exclude_patterns.extend(['*CFNet.cpp', 'test*bindings.*', "WebDOMCanvas*.cpp", "WebDOMSVG*.cpp"])
245         
246     full_dirs = get_dirs_for_features(wk_root, features=features, dirs=webcore_dirs)
247
248     # make sure we don't use the CF networking engine
249     if Options.options.port == 'wx' and sys.platform.startswith('darwin'):
250         full_dirs.remove('Source/WebCore/platform/network/cf')
251         
252     jscore_dir = os.path.join(wk_root, 'Source', 'JavaScriptCore')
253     for item in os.listdir(jscore_dir):
254         fullpath = os.path.join(jscore_dir, item)
255         if os.path.isdir(fullpath) and not item == "os-win32" and not item == 'icu':
256             wk_includes.append(fullpath)
257
258     wk_includes.append('Source')
259     wk_includes.append(os.path.join(jscore_dir, 'collector', 'handles'))
260     wk_includes += common_includes + full_dirs
261     if sys.platform.startswith('darwin'):
262         wk_includes.append(os.path.join(webcore_dir, 'icu'))
263
264     cxxflags = []
265     if building_on_win32:
266         cxxflags.append('/FIWebCorePrefix.h')
267         # FIXME: We do this because in waf, local include dirs take precedence
268         # over global ones. This makes sense, but because unicode/utf8.h is both
269         # an ICU header name and a WebKit header name (in Source/JavaScriptCore/wtf)
270         # we have to make sure <unicode/utf8.h> picks up the ICU one first.
271         global msvclibs_dir
272         wk_includes.append(os.path.join(msvclibs_dir, 'include'))
273         wk_includes.append('Source/WebCore/platform/graphics/win')
274     else:
275         cxxflags.extend(['-include', 'WebCorePrefix.h'])
276
277     webcore = bld.new_task_gen(
278         features = 'cc cxx cshlib',
279         includes = ' '.join(wk_includes),
280         source = ' '.join(flattenSources(webcore_sources.values())),
281         cxxflags = cxxflags,
282         defines = ['WXMAKINGDLL_WEBKIT', 'BUILDING_WebCore'],
283         libpath = [output_dir],
284         target = 'wxwebkit',
285         uselib = 'WX ICU XML XSLT CURL SQLITE3 WKINTERFACE ' + get_config(),
286         uselib_local = 'jscore',
287         install_path = output_dir,
288         )
289         
290     excludes = []
291     
292     if Options.options.port == 'wx':
293         excludes = get_excludes(webcore_dir, exclude_patterns)
294         excludes.extend(['UserStyleSheetLoader.cpp', 'RenderMediaControls.cpp'])
295
296         # intermediate sources
297         excludes.append('DocTypeStrings.cpp')
298         excludes.append('HTMLEntityNames.cpp')
299
300         # Qt specific file in common sources
301         excludes.append('ContextShadow.cpp')
302
303         # FIXME: these three require headers that I can't seem to find in trunk.
304         # Investigate how to resolve these issues.
305         excludes.append('JSAbstractView.cpp')
306         excludes.append('JSPositionCallback.cpp')
307         excludes.append('JSInspectorController.cpp')
308         
309         # The bindings generator seems to think these are ref-counted, while they aren't in trunk.
310         excludes.append('JSElementTimeControl.cpp')
311         excludes.append('JSSVGAnimatedPathData.cpp')
312         excludes.append('JSSVGAnimatedPoints.cpp')
313         excludes.append('JSSVGExternalResourcesRequired.cpp')
314         excludes.append('JSSVGFilterPrimitiveStandardAttributes.cpp')
315         excludes.append('JSSVGLocatable.cpp')
316         excludes.append('JSSVGStyleTable.cpp')
317         excludes.append('JSSVGTests.cpp')
318         excludes.append('JSSVGStylable.cpp')
319         excludes.append('JSSVGZoomAndPan.cpp')
320         
321         # These are files that expect methods not in the base C++ class, usually XYZAnimated methods.
322         excludes.append('JSSVGFitToViewBox.cpp')
323         excludes.append('JSSVGLangSpace.cpp')
324         excludes.append('JSSVGTransformable.cpp')
325         excludes.append('JSSVGURIReference.cpp')
326         
327         # These are C++ DOM Bindings that won't compile because they look for things not in trunk.
328         excludes.append('WebDOMEventTarget.cpp')
329         excludes.append('WebDOMAbstractView.cpp')
330         excludes.append('WebDOMBlobBuilder.cpp')
331         excludes.append('WebDOMEventListenerCustom.cpp')
332         excludes.append('WebDOMElementTimeControl.cpp')
333         excludes.append('WebDOMImageData.cpp')
334         excludes.append('WebDOMInspectorBackend.cpp')
335         excludes.append('WebDOMScriptProfile.cpp')
336         excludes.append('WebDOMScriptProfileNode.cpp')
337         excludes.append('WebNativeEventListener.cpp')
338         
339         # FIXME: It appears these are no longer needed by any port, once this is confirmed,
340         # we should remove these sources from the tree.
341         excludes.append('WebDOMDOMWindowCustom.cpp')
342         excludes.append('WebDOMHTMLOptionsCollectionCustom.cpp')
343         excludes.append('WebDOMNodeCustom.cpp')
344         excludes.append('WebDOMHTMLDocumentCustom.cpp')
345         excludes.append('WebDOMHTMLCollectionCustom.cpp')
346         excludes.append('WebNativeNodeFilterCondition.cpp')
347         excludes.append('WebDOMNodeFilterCustom.cpp')
348         
349         # this file is unused by any port, not sure why it was
350         # left in the tree
351         excludes.append('GeneratedImage.cpp')
352         
353         # features we don't build / use
354         excludes.append('JSNavigatorCustom.cpp')
355         excludes.append('WebGLContextEvent.cpp')
356         excludes.append('FileSystemPOSIX.cpp')
357         excludes.append('LocaleICU.cpp')
358         excludes.append('LocalizedDateICU.cpp')
359         excludes.append('PlatformGestureRecognizer.cpp')
360         excludes.append('SharedBufferPOSIX.cpp')
361         excludes.append('TouchAdjustment.cpp')
362         excludes.append('DNSResolveQueue.cpp')
363         excludes.append('WebDOMRadioNodeList.cpp')
364         
365         # These files appear not to build with older versions of ICU
366         excludes.append('LocalizedNumberICU.cpp')
367         excludes.append('LocaleToScriptMappingICU.cpp')
368         
369         if building_on_win32:
370             excludes.append('SharedTimerWx.cpp')
371             excludes.append('RenderThemeWin.cpp')
372             excludes.append('KeyEventWin.cpp')
373             
374         if building_on_win32 or sys.platform.startswith('darwin'):
375             excludes.append('GlyphMapWx.cpp')
376         excludes.append('AuthenticationCF.cpp')
377         excludes.append('LoaderRunLoopCF.cpp')
378         excludes.append('ResourceErrorCF.cpp')
379         
380         # once we move over to the new FPD implementation, remove this.
381         excludes.append('FontPlatformData.cpp')
382         
383         # we need a better system to exclude CF stuff
384         excludes.append('HyphenationCF.cpp')
385         
386         if sys.platform.startswith('darwin'):
387             webcore.includes += ' Source/WebKit/mac/WebCoreSupport Source/WebCore/platform/mac'
388             webcore.source += ' Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm'
389             
390         if building_on_win32:
391             for wxlib in bld.env['LIB_WX']:
392                 wx_version = wxpresets.get_wx_version(os.environ['WXWIN'])
393                 if int(wx_version[1]) % 2 == 1:
394                     wxlib = wxlib.replace(''.join(wx_version[:2]), ''.join(wx_version))
395                 wxlibname = os.path.join(bld.env['LIBPATH_WX'][0], wxlib + '_vc.dll')
396                 print "Copying %s" % wxlibname
397                 if os.path.exists(wxlibname):
398                     bld.install_files(webcore.install_path, [wxlibname])
399         
400             for dep in windows_deps:
401                 bld.install_files(webcore.install_path, [os.path.join(msvclibs_dir, dep)])
402             
403             if "CAIRO_ROOT" in os.environ and Options.options.cairo:
404                 cairo_bin_dir = os.path.join(os.environ["CAIRO_ROOT"], "bin") 
405                 for dep in glob.glob(os.path.join(cairo_bin_dir, "*.dll")):
406                     bld.install_files(webcore.install_path, [os.path.join(cairo_bin_dir, dep)])
407                     
408     webcore.find_sources_in_dirs(full_dirs, excludes = excludes, exts=['.c', '.cpp'])
409
410     bld.add_group()
411     
412     if Options.options.port == "wx":    
413         bld.add_subdirs(['Tools/DumpRenderTree', 'Tools/wx/browser', 'Source/WebKit/wx/bindings/python'])