2010-08-12 Aaron Boodman <aa@chromium.org>
[WebKit-https.git] / WebCore / 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 from settings import *
29
30 webcore_sources = {}
31
32 if build_port == "wx":
33     webcore_sources['wx'] = ['platform/KillRingNone.cpp', 'bindings/cpp/WebDOMEventTarget.cpp']  
34
35     if building_on_win32:
36         # make sure platform/wx comes after this so we get the right
37         # FontPlatformData.h
38         webcore_dirs.extend(['platform/wx/wxcode/win', 'plugins/win'])
39         webcore_sources['wx-win'] = [
40                'platform/graphics/win/TransformationMatrixWin.cpp',
41                # wxTimer on Windows has a bug that causes it to eat crashes in callbacks
42                # so we need to use the Win port's implementation until the wx bug fix is
43                # widely available (it was fixed in 2.8.10).
44                'platform/win/SharedTimerWin.cpp',
45                'platform/win/WebCoreInstanceHandle.cpp',
46                # Use the Windows plugin architecture
47                'plugins/win/PluginDataWin.cpp',
48                'plugins/win/PluginDatabaseWin.cpp',
49                'plugins/win/PluginMessageThrottlerWin.cpp',
50                'plugins/win/PluginPackageWin.cpp',
51                'plugins/win/PluginViewWin.cpp',
52         ]
53     elif sys.platform.startswith('darwin'):
54         webcore_dirs.append('plugins/mac')
55         webcore_dirs.append('platform/wx/wxcode/mac/carbon')
56         webcore_dirs.append('platform/mac')
57         webcore_dirs.append('platform/text/mac')
58         webcore_sources['wx-mac'] = [
59                'platform/mac/PurgeableBufferMac.cpp',
60                'platform/mac/WebCoreNSStringExtras.mm',
61                'platform/mac/WebCoreSystemInterface.mm',
62                'platform/graphics/cg/FloatSizeCG.cpp',
63                'platform/graphics/mac/ComplexTextController.cpp',
64                'platform/graphics/mac/ComplexTextControllerCoreText.cpp',
65                'platform/graphics/mac/ComplexTextControllerATSUI.cpp',
66                'platform/graphics/mac/GlyphPageTreeNodeMac.cpp',
67                'platform/graphics/mac/SimpleFontDataATSUI.mm',
68                'platform/graphics/mac/SimpleFontDataCoreText.cpp',
69                'platform/graphics/wx/FontPlatformDataWxMac.mm',
70                'platform/text/mac/ShapeArabic.c',
71                'platform/wx/wxcode/mac/carbon/fontprops.mm',
72                'plugins/mac/PluginPackageMac.cpp',
73                'plugins/mac/PluginViewMac.mm'
74         ]
75     else:
76         webcore_sources['wx-gtk'] = [
77                'plugins/PluginDataNone.cpp',
78                'plugins/PluginViewNone.cpp',
79                'plugins/PluginPackageNone.cpp'
80         ]
81         webcore_dirs.append('platform/wx/wxcode/gtk')
82         
83 import TaskGen
84 from TaskGen import taskgen, feature, after
85 import Task, ccroot
86
87 def generate_webcore_derived_sources():
88     # build the derived sources
89     derived_sources_dir = os.path.join(webcore_dir, 'DerivedSources')
90     wc_dir = webcore_dir
91     if building_on_win32:
92         wc_dir = get_output('cygpath --unix "%s"' % wc_dir)
93     if not os.path.exists(derived_sources_dir):
94         os.mkdir(derived_sources_dir)
95
96     olddir = os.getcwd()
97     os.chdir(derived_sources_dir)
98
99     os.system('make -f %s/DerivedSources.make WebCore=%s SOURCE_ROOT=%s all FEATURE_DEFINES="%s"' % (wc_dir, wc_dir, wc_dir, ' '.join(feature_defines)))
100     os.chdir(olddir)
101
102 def set_options(opt):
103     common_set_options(opt)
104
105 def configure(conf):
106     common_configure(conf)
107     generate_webcore_derived_sources()
108     if sys.platform.startswith('win'):
109         graphics_dir = os.path.join(wk_root, 'WebCore', 'platform', 'graphics')
110         # HACK ALERT: MSVC automatically adds the source file's directory as the first entry in the
111         # path. Unfortunately, that means when compiling these files we will end up including
112         # win/FontPlatformData.h, which breaks wx compilation. So we copy the files to the wx dir.
113         for afile in ['UniscribeController.h', 'UniscribeController.cpp', 'GlyphPageTreeNodeCairoWin.cpp']:
114             shutil.copy(os.path.join(graphics_dir, 'win', afile), os.path.join(graphics_dir, 'wx'))
115
116 def build(bld):
117     import Options
118     
119     import TaskGen
120
121     if sys.platform.startswith('darwin'):
122         TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cxx']
123         TaskGen.task_gen.mappings['.m'] = TaskGen.task_gen.mappings['.cxx']
124     
125     wk_includes = ['.', '..', 'DerivedSources',
126                 wk_root, 
127                 os.path.join(wk_root, 'JavaScriptCore'),
128                 os.path.join(wk_root, 'JavaScriptCore', 'wtf', 'text'),
129                 os.path.join(wk_root, 'WebCore'),
130                 os.path.join(wk_root, 'WebKit/wx'),
131                 'platform/image-decoders',
132                 'platform/win',
133                 'platform/wx/wxcode',
134                 'workers',
135         ]
136
137     features = [build_port]
138     exclude_patterns = ['*AllInOne.cpp', '*Brew.cpp', '*CFNet.cpp', '*Chromium*.cpp', 
139             '*Efl.cpp', '*Gtk.cpp', '*Haiku.cpp', '*Mac.cpp', '*None.cpp', '*Qt.cpp', '*Safari.cpp',
140             'test*bindings.*', '*Wince.cpp', "WebDOMCanvas*.cpp", "WebDOMSVG*.cpp"]
141     if build_port == 'wx':
142         features.append('curl')
143         if not building_on_win32:
144             exclude_patterns.append('*Win.cpp')
145         
146     if sys.platform.startswith('darwin'):
147         features.append('cf')
148         bld.install_files(os.path.join(output_dir, 'WebCore'), 'platform/mac/WebCoreSystemInterface.h')
149     else:
150         exclude_patterns.append('*CF.cpp')
151
152     full_dirs = get_dirs_for_features(webcore_dir, features=features, dirs=webcore_dirs)
153
154     jscore_dir = os.path.join(wk_root, 'JavaScriptCore')
155     for item in os.listdir(jscore_dir):
156         fullpath = os.path.join(jscore_dir, item)
157         if os.path.isdir(fullpath) and not item == "os-win32" and not item == 'icu':
158             wk_includes.append(fullpath)
159
160     wk_includes.append(os.path.join(jscore_dir, 'wtf', 'unicode'))
161     wk_includes.append(os.path.join(jscore_dir, 'wtf', 'unicode', 'icu'))
162     wk_includes += common_includes + full_dirs
163     if sys.platform.startswith('darwin'):
164         wk_includes.append(os.path.join(webcore_dir, 'icu'))
165
166     cxxflags = []
167     if building_on_win32:
168         cxxflags.append('/FIWebCorePrefix.h')
169     else:
170         cxxflags.extend(['-include', 'WebCorePrefix.h'])
171
172     webcore = bld.new_task_gen(
173         features = 'cc cxx cstaticlib',
174         includes = ' '.join(wk_includes),
175         source = ' '.join(flattenSources(webcore_sources.values())),
176         cxxflags = cxxflags,
177         defines = ['WXMAKINGDLL_WEBKIT'],
178         target = 'webcore',
179         uselib = 'WX ICU XML XSLT CURL SQLITE3 ' + get_config(),
180         uselib_local = '',
181         install_path = output_dir,
182         )
183         
184     excludes = []
185     
186     if build_port == 'wx':
187         excludes = get_excludes(webcore_dir, exclude_patterns)
188         excludes.extend(['UserStyleSheetLoader.cpp', 'RenderMediaControls.cpp'])
189
190         # intermediate sources
191         excludes.append('CSSValueKeywords.cpp')
192         excludes.append('CSSPropertyNames.cpp')
193         excludes.append('tokenizer.cpp')
194
195         # FIXME: these three require headers that I can't seem to find in trunk.
196         # Investigate how to resolve these issues.
197         excludes.append('JSAbstractView.cpp')
198         excludes.append('JSPositionCallback.cpp')
199         excludes.append('JSInspectorController.cpp')
200         
201         # The bindings generator seems to think these are ref-counted, while they aren't in trunk.
202         excludes.append('JSElementTimeControl.cpp')
203         excludes.append('JSSVGAnimatedPathData.cpp')
204         excludes.append('JSSVGAnimatedPoints.cpp')
205         excludes.append('JSSVGExternalResourcesRequired.cpp')
206         excludes.append('JSSVGFilterPrimitiveStandardAttributes.cpp')
207         excludes.append('JSSVGLocatable.cpp')
208         excludes.append('JSSVGStyleTable.cpp')
209         excludes.append('JSSVGTests.cpp')
210         excludes.append('JSSVGStylable.cpp')
211         excludes.append('JSSVGZoomAndPan.cpp')
212         
213         # These are files that expect methods not in the base C++ class, usually XYZAnimated methods.
214         excludes.append('JSSVGFitToViewBox.cpp')
215         excludes.append('JSSVGLangSpace.cpp')
216         excludes.append('JSSVGTransformable.cpp')
217         excludes.append('JSSVGURIReference.cpp')
218         
219         # These are C++ DOM Bindings that won't compile because they look for things not in trunk.
220         excludes.append('WebDOMEventTarget.cpp')
221         excludes.append('WebDOMAbstractView.cpp')
222         excludes.append('WebDOMBlobBuilder.cpp')
223         excludes.append('WebDOMEventListenerCustom.cpp')
224         excludes.append('WebDOMElementTimeControl.cpp')
225         excludes.append('WebDOMImageData.cpp')
226         excludes.append('WebDOMInspectorBackend.cpp')
227         excludes.append('WebDOMScriptProfile.cpp')
228         excludes.append('WebDOMScriptProfileNode.cpp')
229         excludes.append('WebNativeEventListener.cpp')
230         
231         if building_on_win32:
232             excludes.append('SharedTimerWx.cpp')
233             excludes.append('RenderThemeWin.cpp')
234             excludes.append('KeyEventWin.cpp')
235             
236         if building_on_win32 or sys.platform.startswith('darwin'):
237             excludes.append('GlyphMapWx.cpp')
238         excludes.append('AuthenticationCF.cpp')
239         excludes.append('LoaderRunLoopCF.cpp')
240         excludes.append('ResourceErrorCF.cpp')
241         
242     webcore.find_sources_in_dirs(full_dirs, excludes = excludes, exts=['.c', '.cpp'])