Home | History | Annotate | Download | only in WebCore
      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     if building_on_win32:
     34         webcore_dirs.extend(['platform/wx/wxcode/win', 'plugins/win'])
     35         webcore_sources['wx-win'] = [
     36                'platform/graphics/win/TransformationMatrixWin.cpp',
     37                # wxTimer on Windows has a bug that causes it to eat crashes in callbacks
     38                # so we need to use the Win port's implementation until the wx bug fix is
     39                # widely available (it was fixed in 2.8.10).
     40                'platform/win/SharedTimerWin.cpp',
     41                # Use the Windows plugin architecture
     42                'page/win/PageWin.cpp',
     43                'plugins/win/PluginDataWin.cpp',
     44                'plugins/win/PluginDatabaseWin.cpp',
     45                'plugins/win/PluginMessageThrottlerWin.cpp',
     46                'plugins/win/PluginPackageWin.cpp',
     47                'plugins/win/PluginViewWin.cpp',
     48         ]
     49     elif sys.platform.startswith('darwin'):
     50         webcore_dirs.append('plugins/mac')
     51         webcore_dirs.append('platform/wx/wxcode/mac/carbon')
     52         webcore_dirs.append('platform/mac')
     53         webcore_sources['wx-mac'] = [
     54                'platform/mac/WebCoreNSStringExtras.mm',
     55                'platform/mac/PurgeableBufferMac.cpp',
     56                'platform/wx/wxcode/mac/carbon/fontprops.mm',
     57                'plugins/wx/PluginDataWx.cpp',
     58                'plugins/mac/PluginPackageMac.cpp',
     59                'plugins/mac/PluginViewMac.cpp'
     60         ]
     61     else:
     62         webcore_sources['wx-gtk'] = [
     63                'plugins/PluginDataNone.cpp',
     64                'plugins/PluginViewNone.cpp',
     65                'plugins/PluginPackageNone.cpp'
     66         ]
     67         webcore_dirs.append('platform/wx/wxcode/gtk')
     68         
     69 import TaskGen
     70 from TaskGen import taskgen, feature, after
     71 import Task, ccroot
     72 
     73 def generate_webcore_derived_sources():
     74     # build the derived sources
     75     derived_sources_dir = os.path.join(webcore_dir, 'DerivedSources')
     76     wc_dir = webcore_dir
     77     if building_on_win32:
     78         wc_dir = get_output('cygpath --unix "%s"' % wc_dir)
     79     if not os.path.exists(derived_sources_dir):
     80         os.mkdir(derived_sources_dir)
     81 
     82     olddir = os.getcwd()
     83     os.chdir(derived_sources_dir)
     84 
     85     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)))
     86     os.chdir(olddir)
     87 
     88 def set_options(opt):
     89     common_set_options(opt)
     90 
     91 def configure(conf):
     92     common_configure(conf)
     93     generate_webcore_derived_sources()
     94     if sys.platform.startswith('win'):
     95         graphics_dir = os.path.join(wk_root, 'WebCore', 'platform', 'graphics')
     96         # HACK ALERT: MSVC automatically adds the source file's directory as the first entry in the
     97         # path. Unfortunately, that means when compiling these files we will end up including
     98         # win/FontPlatformData.h, which breaks wx compilation. So we copy the files to the wx dir.
     99         for afile in ['UniscribeController.h', 'UniscribeController.cpp', 'GlyphPageTreeNodeCairoWin.cpp']:
    100             shutil.copy(os.path.join(graphics_dir, 'win', afile), os.path.join(graphics_dir, 'wx'))
    101 
    102 def build(bld):
    103     import Options
    104     if sys.platform.startswith('darwin'):
    105         TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cxx']
    106     
    107     wk_includes = ['.', '..', 'DerivedSources',
    108                 wk_root, 
    109                 os.path.join(wk_root, 'JavaScriptCore'),
    110                 os.path.join(wk_root, 'WebCore'),
    111                 'platform/image-decoders',
    112                 'platform/wx/wxcode',
    113                 'workers',
    114         ]
    115 
    116     features = [build_port]
    117     exclude_patterns = ['*None.cpp', '*CFNet.cpp', '*Qt.cpp', '*Wince.cpp', '*Gtk.cpp', '*Mac.cpp', '*Safari.cpp', '*Chromium*.cpp','*SVG*.cpp', '*AllInOne.cpp', 'test*bindings.*']
    118     if build_port == 'wx':
    119         features.append('curl')
    120         if not building_on_win32:
    121             exclude_patterns.append('*Win.cpp')
    122         
    123     if sys.platform.startswith('darwin'):
    124         features.append('cf')
    125     else:
    126         exclude_patterns.append('*CF.cpp')
    127 
    128     full_dirs = get_dirs_for_features(webcore_dir, features=features, dirs=webcore_dirs)
    129 
    130     jscore_dir = os.path.join(wk_root, 'JavaScriptCore')
    131     for item in os.listdir(jscore_dir):
    132         fullpath = os.path.join(jscore_dir, item)
    133         if os.path.isdir(fullpath) and not item == "os-win32" and not item == 'icu':
    134             wk_includes.append(fullpath)
    135 
    136     wk_includes.append(os.path.join(jscore_dir, 'wtf', 'unicode'))
    137     wk_includes.append(os.path.join(jscore_dir, 'wtf', 'unicode', 'icu'))
    138     wk_includes += common_includes + full_dirs
    139     if sys.platform.startswith('darwin'):
    140         wk_includes.append(os.path.join(webcore_dir, 'icu'))
    141 
    142     cxxflags = []
    143     if building_on_win32:
    144         cxxflags.append('/FIWebCorePrefix.h')
    145     else:
    146         cxxflags.extend(['-include', 'WebCorePrefix.h'])
    147 
    148     webcore = bld.new_task_gen(
    149         features = 'cc cxx cstaticlib',
    150         includes = ' '.join(wk_includes),
    151         source = ' '.join(flattenSources(webcore_sources.values())),
    152         cxxflags = cxxflags,
    153         target = 'webcore',
    154         uselib = 'WX ICU XML XSLT CURL SQLITE3 ' + get_config(),
    155         uselib_local = '',
    156         install_path = output_dir,
    157         )
    158         
    159     excludes = []
    160     
    161     if build_port == 'wx':
    162         excludes = get_excludes(webcore_dir, exclude_patterns)
    163         excludes.extend(['UserStyleSheetLoader.cpp', 'RenderMediaControls.cpp'])
    164 
    165 
    166         # FIXME: undo this once these classes are fully implemented
    167         excludes.append('SocketStreamErrorBase.cpp')
    168         excludes.append('SocketStreamHandleBase.cpp')
    169 
    170         # intermediate sources
    171         excludes.append('CSSValueKeywords.c')
    172         excludes.append('CSSPropertyNames.cpp')
    173         excludes.append('tokenizer.cpp')
    174 
    175         # FIXME: these three require headers that I can't seem to find in trunk.
    176         # Investigate how to resolve these issues.
    177         excludes.append('JSAbstractView.cpp')
    178         excludes.append('JSPositionCallback.cpp')
    179         excludes.append('JSDOMStringList.cpp')
    180         excludes.append('JSInspectorController.cpp')
    181         if building_on_win32:
    182             excludes.append('SharedTimerWx.cpp')
    183             excludes.append('GlyphMapWx.cpp')
    184             excludes.append('RenderThemeWin.cpp')
    185             excludes.append('KeyEventWin.cpp')
    186             
    187         excludes.append('AuthenticationCF.cpp')
    188         excludes.append('LoaderRunLoopCF.cpp')
    189         
    190     webcore.find_sources_in_dirs(full_dirs, excludes = excludes, exts=['.c', '.cpp'])
    191