WebCore Folder下面的有3个工程:QTMovieWin,WebCore,WebCoreGenerated,编译的顺序是:WebCoreGenerated-》QTMovieWin-》QTMovieWin。
首先来看WebCoreGenerated这个工程,这个工程的NMake Build Comand Line如下:
%SystemDrive%/cygwin/bin/which.exe bash if errorlevel 1 set PATH=%SystemDrive%/cygwin/bin;%PATH% cmd /c if exist "$(ConfigurationBuildDir)/buildfailed" grep XX$(ProjectName)XX "$(ConfigurationBuildDir)/buildfailed" if errorlevel 1 exit 1 echo XX$(ProjectName)XX > "$(ConfigurationBuildDir)/buildfailed" set CONFIGURATIONBUILDDIR=$(ConfigurationBuildDir) bash build-generated-files.sh "$(ConfigurationBuildDir)" "$(WebKitLibrariesDir)" "$(WebKitVSPropsRedirectionDir)../../../WebKitLibraries/win" cairo bash migrate-scripts.sh "$(ConfigurationBuildDir)/obj/WebCore/scripts" cmd /C copyForwardingHeaders.cmd cairo curl cmd /C copyInspectorFiles.cmd if exist "$(ConfigurationBuildDir)/buildfailed" del "$(ConfigurationBuildDir)/buildfailed"
比较重要的是下面四句:
bash build-generated-files.sh "$(ConfigurationBuildDir)" "$(WebKitLibrariesDir)" "$(WebKitVSPropsRedirectionDir)../../../WebKitLibraries/win" cairo bash migrate-scripts.sh "$(ConfigurationBuildDir)/obj/WebCore/scripts" cmd /C copyForwardingHeaders.cmd cairo curl cmd /C copyInspectorFiles.cmd
首先来看build-generated-files.sh:
build-generated-files.sh#!/usr/bin/bash # Copyright (C) 2007 Apple Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. Neither the name of Apple puter, Inc. ("Apple") nor the names of # its contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NUMCPUS=`../../../Tools/Scripts/num-cpus` XSRCROOT="`pwd`/.." XSRCROOT=`realpath "$XSRCROOT"` # Do a little dance to get the path into 8.3 form to make it safe for gnu make # http://bugzilla.opendarwin.org/show_bug.cgi?id=8173 XSRCROOT=`cygpath -m -s "$XSRCROOT"` XSRCROOT=`cygpath -u "$XSRCROOT"` export XSRCROOT export SOURCE_ROOT=$XSRCROOT XDSTROOT="$1" export XDSTROOT # Do a little dance to get the path into 8.3 form to make it safe for gnu make # http://bugzilla.opendarwin.org/show_bug.cgi?id=8173 XDSTROOT=`cygpath -m -s "$XDSTROOT"` XDSTROOT=`cygpath -u "$XDSTROOT"` export XDSTROOT SDKROOT="$2" export SDKROOT # Do a little dance to get the path into 8.3 form to make it safe for gnu make # http://bugzilla.opendarwin.org/show_bug.cgi?id=8173 SDKROOT=`cygpath -m -s "$SDKROOT"` SDKROOT=`cygpath -u "$SDKROOT"` export SDKROOT VSPROPSROOT="$3" export VSPROPSROOT # Do a little dance to get the path into 8.3 form to make it safe for gnu make # http://bugzilla.opendarwin.org/show_bug.cgi?id=8173 VSPROPSROOT=`cygpath -m -s "$VSPROPSROOT"` VSPROPSROOT=`cygpath -u "$VSPROPSROOT"` export VSPROPSROOT export BUILT_PRODUCTS_DIR="$XDSTROOT/obj/WebCore" mkdir -p "${BUILT_PRODUCTS_DIR}/DerivedSources" cd "${BUILT_PRODUCTS_DIR}/DerivedSources" export WebCore="${XSRCROOT}" export FEATURE_DEFINES=`$SDKROOT/tools/scripts/feature-defines.sh $VSPROPSROOT $4` make -f "$WebCore/DerivedSources.make" -j ${NUMCPUS} || exit 1
这个脚本比较重要的是倒数两句。倒数第二句将vsprops里面的值转换为FEATURE_DEFINES这个环境变量。倒数第一句调用make来编译$WebCore/DerivedSources.make (D:/tools/cygwin/home/xufan/WebKit/Source/WebCore/DerivedSources.make)这个文件,-j选项同时进行编译的任务数(多核很有优势)。DerivedSources.make的文件内容如下:
DerivedSources.makeVPATH = / $(WebCore) / $(WebCore)/bindings/generic / $(WebCore)/bindings/js / $(WebCore)/bindings/objc / $(WebCore)/css / $(WebCore)/dom / $(WebCore)/fileapi / $(WebCore)/html / $(WebCore)/html/canvas / $(WebCore)/inspector / $(WebCore)/loader/appcache / $(WebCore)/notifications / $(WebCore)/page / $(WebCore)/plugins / $(WebCore)/storage / $(WebCore)/xml / $(WebCore)/webaudio / $(WebCore)/wml / $(WebCore)/workers / $(WebCore)/svg / $(WebCore)/websockets / # DOM_CLASSES = / AbstractView / AbstractWorker / Attr / AudioBuffer / AudioBufferSourceNode / AudioChannelSplitter / AudioChannelMerger / AudioContext / ..... XPathExpression / XPathNSResolver / XPathResult / XSLTProcessor / # .PHONY : all JS_DOM_HEADERS=$(filter-out JSMediaQueryListListener.h JSEventListener.h JSEventTarget.h,$(DOM_CLASSES:%=JS%.h)) WEB_DOM_HEADERS := ifeq ($(findstring BUILDING_WX,$(FEATURE_DEFINES)), BUILDING_WX) WEB_DOM_HEADERS := $(filter-out WebDOMXSLTProcessor.h WebDOMEventTarget.h,$(DOM_CLASSES:%=WebDOM%.h)) endif # BUILDING_WX all : / $(JS_DOM_HEADERS) / $(WEB_DOM_HEADERS) / / JSJavaScriptCallFrame.h / / CSSGrammar.cpp / CSSPropertyNames.h / CSSValueKeywords.h / ColorData.cpp / DocTypeStrings.cpp / HTMLElementFactory.cpp / HTMLEntityTable.cpp / HTMLNames.cpp / WMLElementFactory.cpp / WMLNames.cpp / JSSVGElementWrapperFactory.cpp / SVGElementFactory.cpp / SVGNames.cpp / UserAgentStyleSheets.h / XLinkNames.cpp / XMLNSNames.cpp / XMLNames.cpp / MathMLElementFactory.cpp / MathMLNames.cpp / XPathGrammar.cpp / tokenizer.cpp / HeaderDetection.h / # # -------- ADDITIONAL_IDL_DEFINES := ifeq ($(OS),MACOS) FRAMEWORK_FLAGS = $(shell echo $(BUILT_PRODUCTS_DIR) $(FRAMEWORK_SEARCH_PATHS) | perl -e 'print "-F " . join(" -F ", split(" ", ));') ifeq ($(shell gcc -E -P -dM $(FRAMEWORK_FLAGS) WebCore/ForwardingHeaders/wtf/Platform.h | grep ENABLE_DASHBOARD_SUPPORT | cut -d' ' -f3), 1) ENABLE_DASHBOARD_SUPPORT = 1 else ENABLE_DASHBOARD_SUPPORT = 0 endif ifeq ($(shell gcc -E -P -dM $(FRAMEWORK_FLAGS) WebCore/ForwardingHeaders/wtf/Platform.h | grep ENABLE_ORIENTATION_EVENTS | cut -d' ' -f3), 1) ENABLE_ORIENTATION_EVENTS = 1 else ENABLE_ORIENTATION_EVENTS = 0 endif else ifndef ENABLE_DASHBOARD_SUPPORT ENABLE_DASHBOARD_SUPPORT = 0 endif ifndef ENABLE_ORIENTATION_EVENTS ENABLE_ORIENTATION_EVENTS = 0 endif endif # MACOS ifeq ($(ENABLE_ORIENTATION_EVENTS), 1) ADDITIONAL_IDL_DEFINES := $(ADDITIONAL_IDL_DEFINES) ENABLE_ORIENTATION_EVENTS endif # -------- # CSS property names and value keywords WEBCORE_CSS_PROPERTY_NAMES := $(WebCore)/css/CSSPropertyNames.in WEBCORE_CSS_VALUE_KEYWORDS := $(WebCore)/css/CSSValueKeywords.in ifeq ($(findstring ENABLE_SVG,$(FEATURE_DEFINES)), ENABLE_SVG) WEBCORE_CSS_PROPERTY_NAMES := $(WEBCORE_CSS_PROPERTY_NAMES) $(WebCore)/css/SVGCSSPropertyNames.in WEBCORE_CSS_VALUE_KEYWORDS := $(WEBCORE_CSS_VALUE_KEYWORDS) $(WebCore)/css/SVGCSSValueKeywords.in endif ifeq ($(ENABLE_DASHBOARD_SUPPORT), 1) WEBCORE_CSS_PROPERTY_NAMES := $(WEBCORE_CSS_PROPERTY_NAMES) $(WebCore)/css/DashboardSupportCSSPropertyNames.in endif # The grep commands below reject output containing anything other than: # 1. Lines beginning with '#' # 2. Lines containing only whitespace # These two types of lines will be ignored by make{prop,values}.pl. CSSPropertyNames.h : $(WEBCORE_CSS_PROPERTY_NAMES) css/makeprop.pl if sort $(WEBCORE_CSS_PROPERTY_NAMES) | uniq -d | grep -E -v '(^#)|(^[[:space:]]*$$)'; then echo 'Duplicate value!'; exit 1; fi cat $(WEBCORE_CSS_PROPERTY_NAMES) > CSSPropertyNames.in perl "$(WebCore)/css/makeprop.pl" CSSValueKeywords.h : $(WEBCORE_CSS_VALUE_KEYWORDS) css/makevalues.pl # Lower case all the values, as CSS values are case-insensitive perl -ne 'print lc' $(WEBCORE_CSS_VALUE_KEYWORDS) > CSSValueKeywords.in if sort CSSValueKeywords.in | uniq -d | grep -E -v '(^#)|(^[[:space:]]*$$)'; then echo 'Duplicate value!'; exit 1; fi perl "$(WebCore)/css/makevalues.pl" # -------- # DOCTYPE strings DocTypeStrings.cpp : html/DocTypeStrings.gperf $(WebCore)/make-hash-tools.pl perl $(WebCore)/make-hash-tools.pl . $(WebCore)/html/DocTypeStrings.gperf # -------- # HTML entity names HTMLEntityTable.cpp : html/parser/HTMLEntityNames.in $(WebCore)/html/parser/create-html-entity-table python $(WebCore)/html/parser/create-html-entity-table -o HTMLEntityTable.cpp $(WebCore)/html/parser/HTMLEntityNames.in # -------- # color names ColorData.cpp : platform/ColorData.gperf $(WebCore)/make-hash-tools.pl perl $(WebCore)/make-hash-tools.pl . $(WebCore)/platform/ColorData.gperf # -------- # CSS tokenizer tokenizer.cpp : css/tokenizer.flex css/maketokenizer flex -t $ $@ # -------- # CSS grammar # NOTE: Older versions of bison do not inject an inclusion guard, so we add one. CSSGrammar.cpp : css/CSSGrammar.y bison -d -p cssyy $ CSSGrammar.h echo '#define CSSGrammar_h' >> CSSGrammar.h cat CSSGrammar.cpp.h CSSGrammar.hpp >> CSSGrammar.h echo '#endif' >> CSSGrammar.h rm -f CSSGrammar.cpp.h CSSGrammar.hpp # -------- # XPath grammar # NOTE: Older versions of bison do not inject an inclusion guard, so we add one. XPathGrammar.cpp : xml/XPathGrammar.y $(PROJECT_FILE) bison -d -p xpathyy $ XPathGrammar.h echo '#define XPathGrammar_h' >> XPathGrammar.h cat XPathGrammar.cpp.h XPathGrammar.hpp >> XPathGrammar.h echo '#endif' >> XPathGrammar.h rm -f XPathGrammar.cpp.h XPathGrammar.hpp # -------- # user agent style sheets USER_AGENT_STYLE_SHEETS = $(WebCore)/css/html.css $(WebCore)/css/quirks.css $(WebCore)/css/view-source.css $(WebCore)/css/themeWin.css $(WebCore)/css/themeWinQuirks.css ifeq ($(findstring ENABLE_SVG,$(FEATURE_DEFINES)), ENABLE_SVG) USER_AGENT_STYLE_SHEETS := $(USER_AGENT_STYLE_SHEETS) $(WebCore)/css/svg.css endif ifeq ($(findstring ENABLE_WML,$(FEATURE_DEFINES)), ENABLE_WML) USER_AGENT_STYLE_SHEETS := $(USER_AGENT_STYLE_SHEETS) $(WebCore)/css/wml.css endif ifeq ($(findstring ENABLE_MATHML,$(FEATURE_DEFINES)), ENABLE_MATHML) USER_AGENT_STYLE_SHEETS := $(USER_AGENT_STYLE_SHEETS) $(WebCore)/css/mathml.css endif ifeq ($(findstring ENABLE_VIDEO,$(FEATURE_DEFINES)), ENABLE_VIDEO) USER_AGENT_STYLE_SHEETS := $(USER_AGENT_STYLE_SHEETS) $(WebCore)/css/mediaControls.css USER_AGENT_STYLE_SHEETS := $(USER_AGENT_STYLE_SHEETS) $(WebCore)/css/mediaControlsQuickTime.css endif ifeq ($(findstring ENABLE_FULLSCREEN_API,$(FEATURE_DEFINES)), ENABLE_FULLSCREEN_API) USER_AGENT_STYLE_SHEETS := $(USER_AGENT_STYLE_SHEETS) $(WebCore)/css/fullscreen.css endif UserAgentStyleSheets.h : css/make-css-file-arrays.pl $(USER_AGENT_STYLE_SHEETS) perl $$(HTML_FLAGS)" else HTMLElementFactory.cpp HTMLNames.cpp : dom/make_names.pl html/HTMLTagNames.in html/HTMLAttributeNames.in perl -I $(WebCore)/bindings/scripts $if svg experimental features are enabled) ifdef SVG_FLAGS SVGElementFactory.cpp SVGNames.cpp : dom/make_names.pl svg/svgtags.in svg/svgattrs.in perl -I $(WebCore)/bindings/scripts $$(SVG_FLAGS)" --factory --wrapperFactory else SVGElementFactory.cpp SVGNames.cpp : dom/make_names.pl svg/svgtags.in svg/svgattrs.in perl -I $(WebCore)/bindings/scripts $else WMLElementFactory.cpp : echo > $@ WMLNames.cpp : echo > $@ endif # -------- # MathML tag and attribute names, and element factory MathMLElementFactory.cpp MathMLNames.cpp : dom/make_names.pl mathml/mathtags.in mathml/mathattrs.in perl -I $(WebCore)/bindings/scripts $sort $(dir $(1)))) $(WebCore)/bindings/scripts/generate-bindings.pl # JS bindings generator IDL_INCLUDES = dom fileapi html css page notifications xml svg IDL_COMMON_ARGS = $(IDL_INCLUDES:%=--include %) --write-dependencies --outputDir . JS_BINDINGS_SCRIPTS = $(GENERATE_SCRIPTS) bindings/scripts/CodeGeneratorJS.pm JS%.h : %.idl $(JS_BINDINGS_SCRIPTS) $(call generator_script, $(JS_BINDINGS_SCRIPTS)) $(IDL_COMMON_ARGS) --defines "$(FEATURE_DEFINES) $(ADDITIONAL_IDL_DEFINES) LANGUAGE_JAVASCRIPT" --generator JS $$(FEATURE_DEFINES) LANGUAGE_JAVASCRIPT" --generator Inspector $$(FEATURE_DEFINES) $(ADDITIONAL_IDL_DEFINES) LANGUAGE_CPP" --generator CPP $ $@ # -------- ifneq ($(ACTION),installhdrs) all : WebCore.exp WebCore.LP64.exp WebCore.exp : $(BUILT_PRODUCTS_DIR)/WebCoreExportFileGenerator $^ > $@ # Switch NSRect, NSSize and NSPoint with their CG counterparts for the 64-bit exports file. WebCore.LP64.exp : WebCore.exp cat $^ | sed -e s/7_NSRect/6CGRect/ -e s/7_NSSize/6CGSize/ -e s/8_NSPoint/7CGPoint/ > $@ endif # installhdrs # -------- # Objective-C bindings DOM_BINDINGS_SCRIPTS = $(GENERATE_BINDING_SCRIPTS) bindings/scripts/CodeGeneratorObjC.pm DOM%.h : %.idl $(DOM_BINDINGS_SCRIPTS) bindings/objc/PublicDOMInterfaces.h $(call generator_script, $(DOM_BINDINGS_SCRIPTS)) $(IDL_COMMON_ARGS) --defines "$(FEATURE_DEFINES) $(ADDITIONAL_IDL_DEFINES) LANGUAGE_OBJECTIVE_C" --generator ObjC $/* This is a generated file. Do not edit. */" > $@ if [ -f $(SDKROOT)/System/Library/Frameworks/AppKit.framework/PrivateHeaders/NSScrollerImpPair_Private.h ]; then echo "#define USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER 1" >> $@; else echo >> $@; fi else HeaderDetection.h : echo > $@ endif
VPATH这个变量定义了Make在哪里寻找文件,使用VPATH有一个隐患: VPATH在每个目录中搜索所有的source文件,如果一个相同的文件名出现在不同的目录中, VPATH将第一个搜索到的文件作为结果,使用vpath就比VPATH更灵活些。不够webkit暂时没出这个问题,所以VPATH已经够用。后面很多规则没有指定路径,靠的就是这个VPATH,将路径展开交给了make工具。
DOM_CLASSES定义了一大堆要根据IDL文件生成的h和cpp文件列表,大概有450个,生成的文件在D:/tools/cygwin/home/xufan/WebKit/WebKitBuild/Debug_Cairo_CFLite/obj/WebCore/DerivedSources目录下。
JS_DOM_HEADERS将所有的DOM_CLASSES值加了JS前缀,并去除了其中的JSMediaQueryListListener.h JSEventListener.h JSEventTarget.h这几个文件。
WEB_DOM_HEADERS在编译选项中包括BUILDING_WX时,将所有的DOM_CLASSES值加了WebDOM前缀,并去除了其中的WebDOMXSLTProcessor.h WebDOMEventTarget.h。在cairo win32编译环境下,这个变量为空。
makefile的入口是all这条规则,all依赖于$(JS_DOM_HEADERS),$(WEB_DOM_HEADERS),JSJavaScriptCallFrame.h,CSSGrammar.cpp,CSSPropertyNames.h,CSSValueKeywords.h,ColorData.cpp,DocTypeStrings.cpp,HTMLElementFactory.cpp,HTMLEntityTable.cpp,HTMLNames.cpp,WMLElementFactory.cpp,WMLNames.cpp,JSSVGElementWrapperFactory.cpp,SVGElementFactory.cpp,SVGNames.cpp,UserAgentStyleSheets.h,XLinkNames.cpp,XMLNSNames.cpp,XMLNames.cpp,MathMLElementFactory.cpp,MathMLNames.cpp,XPathGrammar.cpp,tokenizer.cpp,HeaderDetection.h,下面就介绍makefile如何对这些文件进行处理。