3 # Copyright (C) 2007 Robin Dunn, Kevin Ollivier All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
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.
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.
26 # Driver for the wxWebKit build process.
31 #----------------------------------------------------------------------
32 # Set up the environment
34 scriptDir="$(cd $(dirname $0);pwd)"
35 WK_ROOT=$scriptDir/../..
40 if [ -z $WEBKITOUTPUTDIR ]; then
41 WEBKITOUTPUTDIR=`cd $WK_ROOT/WebKitTools/Scripts; perl -e "use webkitdirs; print productDir()"`
44 WINDEPS="pthreads/lib/pthreadVC2.dll icu/bin/icuuc34.dll icu/bin/icudt34.dll libcurl/*.dll sqlite3/sqlite3.dll"
46 # TODO: check that we are running from the root of the source tree...
48 # cygpath will bork if the dir doesn't exist...
49 mkdir -p $WEBKITOUTPUTDIR
51 if [ $OSTYPE == cygwin ]; then
53 WK_ROOTDIR=`cygpath -d $WK_ROOT`
54 WEBKITOUTPUTDIR=`cygpath -d $WEBKITOUTPUTDIR`
55 export WEBKITOUTPUTDIR
56 if [ -z $WXWIN ]; then
57 echo "Error, you must set WXWIN to your wxWidgets root directory."
60 if [ -z $BAKEFILE_PATHS ]; then
61 export BAKEFILE_PATHS=$WXWIN/build/bakefiles/wxpresets
64 if [ "$LINKER" = "/usr/bin/link" ]; then
65 echo "WARNING: wxWebKit builds using MSVC on Windows, but it looks like"
66 echo "you have the GCC linker on your path. If /usr/bin/link does NOT point"
67 echo "to the MSVC linker, you need to move it or change your path to pick up"
68 echo "Microsoft's link.exe program first."
72 export WEBKITOUTPUTDIR
73 WX_PREFIX=`wx-config --prefix`
74 if [ ! -d "$WX_PREFIX" ]; then
75 echo "ERROR: Cannot find your wxWidgets installation."
76 echo "Make sure wx-config is on your PATH and points to a valid wxWidgets installation."
79 if [ ! -d "$WX_PREFIX/share/bakefile" ]; then
80 echo "ERROR: wxWidgets installation does not have wxpresets."
81 echo "wx-config is pointing to an installation that does not have Bakefile presets installed. Run `wx-config --version` to ensure your wxWidgets is of version 2.8+."
85 if [ -z $BAKEFILE_PATHS ]; then
86 export BAKEFILE_PATHS=$WX_PREFIX/share/bakefile
90 # after all that, make sure that BAKEFILE_PATHS was either set
91 # previously, or by the code above
92 if [ -z $BAKEFILE_PATHS ]; then
93 echo "Error, you must set BAKEFILE_PATHS to the directory containing wxpresets."
97 #----------------------------------------------------------------------
98 # process command line args
117 all) do_extras=1; do_bake=1; do_prep=1; do_build=1 ;;
118 clean) other_args=clean; do_clean=1 ;;
120 wxdebug) wxdebug=1 ;;
121 wxpython) wxpython=1 ;;
122 wxpython-install) wxpython_install=1 ;;
123 *) export $flag ;; #other_args='$other_args "$flag"' ;;
128 #----------------------------------------------------------------------
130 # if no arguments were passed, do a full build.
131 if [ $do_bake == 0 -a $do_prep == 0 -a $do_build == 0 -a $do_clean == 0 ]; then
132 do_bake=1; do_prep=1; do_build=1
141 if [ $OSTYPE == cygwin ]; then
143 nmake -f makefile.vc CXXFLAGS="$cxxflags" $@
146 make -C $dir -f GNUmakefile $MAKE_ARGS CXXFLAGS="$cxxflags" $@
155 if [ $do_clean == 1 ]; then
156 rm -rf $WK_ROOT/JavaScriptCore/DerivedSources
157 rm -rf $WK_ROOT/WebCore/DerivedSources
158 rm -rf $WK_ROOT/WebCore/include/JavaScriptCore
161 mkdir -p $WEBKITOUTPUTDIR/build
163 if [ $do_bake == 1 ]; then
165 cd $WK_ROOT/WebKit/wx
168 # we need to do this because Bakefile doesn't know which
169 # platform it's running on with GNU format, and so it defaults
170 # to the standard Unix file endings and linker args.
171 if [ "${OSTYPE:0:6}" = "darwin" ]; then
172 sed "s/libwebcore-wx.so/libwebcore-wx.dylib/" < $WK_ROOT/WebCore/GNUmakefile > temp
173 mv temp $WK_ROOT/WebCore/GNUmakefile
175 sed "s/\-shared/\-dynamiclib/" < $WK_ROOT/WebCore/GNUmakefile > temp
176 mv temp $WK_ROOT/WebCore/GNUmakefile
178 sed "s/libwxwebkit.so/libwxwebkit.dylib/" < $WK_ROOT/WebKit/wx/GNUmakefile > temp
179 mv temp $WK_ROOT/WebKit/wx/GNUmakefile
181 sed "s/\-shared/\-dynamiclib/" < $WK_ROOT/WebKit/wx/GNUmakefile > temp
182 mv temp $WK_ROOT/WebKit/wx/GNUmakefile
186 if [ $do_prep == 1 ]; then
187 # Other preparation steps
188 cd $WK_ROOT/JavaScriptCore
189 # FIXME: The below is needed because Bakefile doesn't yet properly set dependencies on
190 # creating the build dir. Everything works when you do make all, but not when you
191 # try to make a specific target. For more info, see: http://www.bakefile.org/ticket/167
194 do_make . "" dftables$EXE
195 ./make-generated-sources.sh
205 ./make-generated-sources.sh platform/wx/wx-encodings.txt
213 if [ $do_build == 1 -o $do_clean == 1 ]; then
216 if [ $use_wxgc == 1 ]; then
217 WXGC_DEFINE="-DWTF_USE_WXGC=1"
220 if [ "$OSTYPE" == "cygwin" -a $wxdebug == 1 ]; then
223 if [ "$OSTYPE" == "cygwin" -a $wxpython == 1 ]; then
224 other_args=WX_PYTHON=1
230 if [ "${OSTYPE:0:6}" == "darwin" ]; then
236 WINDEPS="$WINDEPS $WXWIN/lib/vc_dll/wxmsw28u${WX_EXT}_core_vc.dll $WXWIN/lib/vc_dll/wxbase28u${WX_EXT}_vc.dll"
238 do_make $WK_ROOT/JavaScriptCore "-DBUILDING_WX__=1 $WXGC_DEFINE" WX_DEBUG=$wxdebug WEBKIT_ROOT=$WK_ROOTDIR PLATFORM_OS=$PLATFORM_OS $other_args
239 do_make $WK_ROOT/WebCore "-DBUILDING_WX__=1 $WXGC_DEFINE" WX_DEBUG=$wxdebug WEBKIT_ROOT=$WK_ROOTDIR PLATFORM_OS=$PLATFORM_OS $other_args
240 do_make $WK_ROOT/WebKit/wx "-DBUILDING_WX__=1 -DWXMAKINGDLL_WEBKIT=1 $WXGC_DEFINE" WX_DEBUG=$wxdebug WEBKIT_ROOT=$WK_ROOTDIR PLATFORM_OS=$PLATFORM_OS $other_args
241 do_make $WK_ROOT/WebKitTools/wx/browser "-DBUILDING_WX__=1 -DWXUSINGDLL_WEBKIT=1 $WXGC_DEFINE" WX_DEBUG=$wxdebug WEBKIT_ROOT=$WK_ROOTDIR PLATFORM_OS=$PLATFORM_OS $other_args
243 if [ $do_build == 1 ]; then
244 if [ "${OSTYPE:0:6}" = "darwin" ]; then
246 mkdir -p wxBrowser.app/Contents/MacOS
247 mkdir -p wxBrowser.app/Contents/Frameworks
248 cp wxBrowser wxBrowser.app/Contents/MacOS
249 install_name_tool -change libwxwebkit.dylib @executable_path/../Frameworks/libwxwebkit.dylib wxBrowser.app/Contents/MacOS/wxBrowser
250 if [ ! -f "$WEBKITOUTPUTDIR/libwxwebkit.dylib" ]; then
251 ln -s $WEBKITOUTPUTDIR/libwxwebkit.dylib wxBrowser.app/Contents/Frameworks
255 if [ $wxpython == 1 ]; then
258 if [ ! -f "$SWIG" ]; then
259 echo "ERROR: Cannot find SWIG. Make sure that SWIG 1.3.29 is located on your path.";
263 cd $WK_ROOT/WebKit/wx/bindings/python
265 SWIG_FLAGS=`python -c "import wx.build.config; import string; print string.join(wx.build.config.swig_args, ' ')"`
266 WEBKIT_INCLUDE="-I$WK_ROOT/WebKit/wx"
267 if [ "${OSTYPE:0:6}" == "cygwin" ]; then
268 WEBKIT_INCLUDE="-I`cygpath -d $WK_ROOT/WebKit/wx`"
270 $SWIG $SWIG_FLAGS -I$WX_PREFIX/include/wx-2.8/wx/wxPython/i_files $WEBKIT_INCLUDE -o webview.cpp webview.i
271 #$SWIG -I$WX_PREFIX/include/wx-2.8/wx/wxPython/i_files $WEBKIT_INCLUDE -xml -o webview.xml webview.i
274 PY_INCLUDE=`python -c "import distutils.sysconfig; print distutils.sysconfig.get_python_inc()"`
275 PY_VERSION=`python -c "import sys; print str(sys.version_info[0]) + str(sys.version_info[1])"`
276 PY_LIBDIR=`python -c "import distutils.sysconfig; import sys; sys.stdout.write(distutils.sysconfig.PREFIX)"`
278 if [ "${OSTYPE:0:6}" == "cygwin" ]; then
279 PY_LIBDIR="$PY_LIBDIR\\Libs"
281 PY_LIBDIR="$PY_LIBDIR/lib"
284 do_make $WK_ROOT/WebKit/wx/bindings/python "-DBUILDING_WX__=1 -DWXUSINGDLL=1 -DWXUSINGDLL_WEBKIT=1 -I$PY_INCLUDE $WXGC_DEFINE" \
285 WX_DEBUG=$wxdebug WEBKIT_ROOT=$WK_ROOTDIR PLATFORM_OS=$PLATFORM_OS PYTHON_VERSION=$PY_VERSION PYTHON_LIBDIR=$PY_LIBDIR $other_args
286 if [ "${OSTYPE:0:6}" == "cygwin" ]; then
287 if [ -f $WEBKITOUTPUTDIR/_webview.pyd -a -f $WEBKITOUTPUTDIR/_webview.dll ]; then
288 rm $WEBKITOUTPUTDIR/_webview.pyd
289 mv $WEBKITOUTPUTDIR/_webview.dll $WEBKITOUTPUTDIR/_webview.pyd
295 if [ "$OSTYPE" == "cygwin" ]; then
296 echo "Copying necessary DLLs to run test and sample applications..."
298 cp $WINDEPS $WEBKITOUTPUTDIR
301 BROWSERAPP="wxBrowser"
303 if [ "${OSTYPE:0:6}" == "darwin" ]; then
304 BROWSERAPP="wxBrowser.app/Contents/MacOS/wxBrowser"
309 echo "--- BUILD COMPLETE ---"
313 if [ "${OSTYPE:0:5}" = "linux" ]; then
314 echo "-- Add /usr/local/lib and $WEBKITOUTPUTDIR to your LD_LIBRARY_PATH environment variable."
317 echo "-- Run '$WK_ROOT/WebKitTools/Scripts/run-javascriptcore-tests --wx' to ensure JSCore tests pass."
319 echo "-- Run $WEBKITOUTPUTDIR/$BROWSERAPP to test your wxWebKit build."