97c24619c8b61d1fda68b24dd732e294d01d3ac4
[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/PluginViewNone.cpp',
78                'plugins/PluginPackageNone.cpp'
79         ]
80         webcore_dirs.append('platform/wx/wxcode/gtk')
81         
82 import TaskGen
83 from TaskGen import taskgen, feature, after
84 import Task, ccroot
85
86 def generate_webcore_derived_sources():
87     # build the derived sources
88     derived_sources_dir = os.path.join(webcore_dir, 'DerivedSources')
89     wc_dir = webcore_dir
90     if building_on_win32:
91         wc_dir = get_output('cygpath --unix "%s"' % wc_dir)
92     if not os.path.exists(derived_sources_dir):
93         os.mkdir(derived_sources_dir)
94
95     olddir = os.getcwd()
96     os.chdir(derived_sources_dir)
97
98     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)))
99     os.chdir(olddir)
100
101 def set_options(opt):
102     common_set_options(opt)
103
104 def configure(conf):
105     common_configure(conf)
106     generate_webcore_derived_sources()
107     if sys.platform.startswith('win'):
108         graphics_dir = os.path.join(wk_root, 'WebCore', 'platform', 'graphics')
109         # HACK ALERT: MSVC automatically adds the source file's directory as the first entry in the
110         # path. Unfortunately, that means when compiling these files we will end up including
111         # win/FontPlatformData.h, which breaks wx compilation. So we copy the files to the wx dir.
112         for afile in ['UniscribeController.h', 'UniscribeController.cpp', 'GlyphPageTreeNodeCairoWin.cpp']:
113             shutil.copy(os.path.join(graphics_dir, 'win', afile), os.path.join(graphics_dir, 'wx'))
114
115 def build(bld):
116     import Options
117     
118     import TaskGen
119
120     if sys.platform.startswith('darwin'):
121         TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cxx']
122         TaskGen.task_gen.mappings['.m'] = TaskGen.task_gen.mappings['.cxx']
123     
124     wk_includes = ['.', '..', 'DerivedSources',
125                 wk_root, 
126                 os.path.join(wk_root, 'JavaScriptCore'),
127                 os.path.join(wk_root, 'JavaScriptCore', 'wtf', 'text'),
128                 os.path.join(wk_root, 'WebCore'),
129                 os.path.join(wk_root, 'WebKit/wx'),
130                 'platform/image-decoders',
131                 'platform/win',
132                 'platform/wx/wxcode',
133                 'workers',
134         ]
135
136     features = [build_port]
137     exclude_patterns = ['*AllInOne.cpp', '*Brew.cpp', '*CFNet.cpp', '*Chromium*.cpp', 
138             '*Efl.cpp', '*Gtk.cpp', '*Haiku.cpp', '*Mac.cpp', '*None.cpp', '*Qt.cpp', '*Safari.cpp',
139             'test*bindings.*', '*Wince.cpp', "WebDOMCanvas*.cpp", "WebDOMSVG*.cpp"]
140     if build_port == 'wx':
141         features.append('curl')
142         if not building_on_win32:
143             exclude_patterns.append('*Win.cpp')
144         
145     if sys.platform.startswith('darwin'):
146         features.append('cf')
147         bld.install_files(os.path.join(output_dir, 'WebCore'), 'platform/mac/WebCoreSystemInterface.h')
148     else:
149         exclude_patterns.append('*CF.cpp')
150
151     full_dirs = get_dirs_for_features(webcore_dir, features=features, dirs=webcore_dirs)
152
153     jscore_dir = os.path.join(wk_root, 'JavaScriptCore')
154     for item in os.listdir(jscore_dir):
155         fullpath = os.path.join(jscore_dir, item)
156         if os.path.isdir(fullpath) and not item == "os-win32" and not item == 'icu':
157             wk_includes.append(fullpath)
158
159     wk_includes.append(os.path.join(jscore_dir, 'wtf', 'unicode'))
160     wk_includes.append(os.path.join(jscore_dir, 'wtf', 'unicode', 'icu'))
161     wk_includes += common_includes + full_dirs
162     if sys.platform.startswith('darwin'):
163         wk_includes.append(os.path.join(webcore_dir, 'icu'))
164
165     cxxflags = []
166     if building_on_win32:
167         cxxflags.append('/FIWebCorePrefix.h')
168     else:
169         cxxflags.extend(['-include', 'WebCorePrefix.h'])
170
171     webcore = bld.new_task_gen(
172         features = 'cc cxx cstaticlib',
173         includes = ' '.join(wk_includes),
174         source = ' '.join(flattenSources(webcore_sources.values())),
175         cxxflags = cxxflags,
176         defines = ['WXMAKINGDLL_WEBKIT'],
177         target = 'webcore',
178         uselib = 'WX ICU XML XSLT CURL SQLITE3 ' + get_config(),
179         uselib_local = '',
180         install_path = output_dir,
181         )
182         
183     excludes = []
184     
185     if build_port == 'wx':
186         excludes = get_excludes(webcore_dir, exclude_patterns)
187         excludes.extend(['UserStyleSheetLoader.cpp', 'RenderMediaControls.cpp'])
188
189         # intermediate sources
190         excludes.append('CSSValueKeywords.cpp')
191         excludes.append('CSSPropertyNames.cpp')
192         excludes.append('tokenizer.cpp')
193
194         # FIXME: these three require headers that I can't seem to find in trunk.
195         # Investigate how to resolve these issues.
196         excludes.append('JSAbstractView.cpp')
197         excludes.append('JSPositionCallback.cpp')
198         excludes.append('JSInspectorController.cpp')
199         
200         # The bindings generator seems to think these are ref-counted, while they aren't in trunk.
201         excludes.append('JSElementTimeControl.cpp')
202         excludes.append('JSSVGAnimatedPathData.cpp')
203         excludes.append('JSSVGAnimatedPoints.cpp')
204         excludes.append('JSSVGExternalResourcesRequired.cpp')
205         excludes.append('JSSVGFilterPrimitiveStandardAttributes.cpp')
206         excludes.append('JSSVGLocatable.cpp')
207         excludes.append('JSSVGStyleTable.cpp')
208         excludes.append('JSSVGTests.cpp')
209         excludes.append('JSSVGStylable.cpp')
210         excludes.append('JSSVGZoomAndPan.cpp')
211         
212         # These are files that expect methods not in the base C++ class, usually XYZAnimated methods.
213         excludes.append('JSSVGFitToViewBox.cpp')
214         excludes.append('JSSVGLangSpace.cpp')
215         excludes.append('JSSVGTransformable.cpp')
216         excludes.append('JSSVGURIReference.cpp')
217         
218         # These are C++ DOM Bindings that won't compile because they look for things not in trunk.
219         excludes.append('WebDOMEventTarget.cpp')
220         excludes.append('WebDOMAbstractView.cpp')
221         excludes.append('WebDOMBlobBuilder.cpp')
222         excludes.append('WebDOMEventListenerCustom.cpp')
223         excludes.append('WebDOMElementTimeControl.cpp')
224         excludes.append('WebDOMImageData.cpp')
225         excludes.append('WebDOMInspectorBackend.cpp')
226         excludes.append('WebDOMScriptProfile.cpp')
227         excludes.append('WebDOMScriptProfileNode.cpp')
228         excludes.append('WebNativeEventListener.cpp')
229         
230         if building_on_win32:
231             excludes.append('SharedTimerWx.cpp')
232             excludes.append('RenderThemeWin.cpp')
233             excludes.append('KeyEventWin.cpp')
234             
235         if building_on_win32 or sys.platform.startswith('darwin'):
236             excludes.append('GlyphMapWx.cpp')
237         excludes.append('AuthenticationCF.cpp')
238         excludes.append('LoaderRunLoopCF.cpp')
239         excludes.append('ResourceErrorCF.cpp')
240         
241     webcore.find_sources_in_dirs(full_dirs, excludes = excludes, exts=['.c', '.cpp'])