接下来看JavaScriptCore这个工程,这个工程继承的project property sheet如下:
../../../../WebKitLibraries/win/tools/vsprops/FeatureDefinesCairo.vsprops
../../../../WebKitLibraries/win/tools/vsprops/common.vsprops
../../../../WebKitLibraries/win/tools/vsprops/debug.vsprops
../../../../WebKitLibraries/win/tools/vsprops/debug_wincairo.vsprops
./JavaScriptCoreCommon.vsprops
./JavaScriptCoreCFLite.vsprops
上面的前面4个与WTF工程一样,就不介绍了。
JavaScriptCoreCommon.vsprops主要用于设置javascriptcore依赖的头文件目录和库文件,文件内容如下:
xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet
ProjectType="Visual C++"
Version="8.00"
Name="JavaScriptCoreCommon"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""$(ConfigurationBuildDir)/obj/JavaScriptCore/DerivedSources/";../../;../../API/;../../parser/;../../bytecompiler/;../../jit/;../../runtime/;../../bytecode/;../../interpreter/;../../wtf/;../../profiler;../../assembler/;../../debugger/;../../collector/handles/;"$(WebKitLibrariesDir)/include";"$(WebKitLibrariesDir)/include/private";"$(ConfigurationBuildDir)/include";"$(ConfigurationBuildDir)/include/JavaScriptCore";"$(ConfigurationBuildDir)/include/private";"$(WebKitLibrariesDir)/include/pthreads""
PreprocessorDefinitions="__STD_C"
ForcedIncludeFiles="ICUVersion.h"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="gdi32.lib oleaut32.lib winmm.lib libicuin$(LibraryConfigSuffix).lib libicuuc$(LibraryConfigSuffix).lib pthreadVC2$(LibraryConfigSuffix).lib WTF$(WebKitConfigSuffix).lib"
OutputFile="$(OutDir)/$(ProjectName)$(WebKitDLLConfigSuffix).dll"
AdditionalLibraryDirectories=""$(IntDir)/lib""
ModuleDefinitionFile="JavaScriptCore.def"
/>
VisualStudioPropertySheet>
xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet
ProjectType="Visual C++"
Version="8.00"
Name="JavaScriptCoreCFLite"
>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="CFLite$(WebKitConfigSuffix).lib"
/>
VisualStudioPropertySheet>
CFlite是Apple 的基础组件,苹果开源了Core Foundation的部分内容,可以到http://opensource.apple.com/source/下载。但webkit依赖的cflite苹果并没有公开全,不过网上有开源版本OpenCFLite(http://sourceforge.net/projects/opencflite/)。还有另外一个版本,请参考:http://www.yonsm.net/read.php?507 。
JavaScriptCore这个工程的pre-build event脚本如下:
REM Do not edit from the Visual Studio IDE! Customize via a $(ProjectName)PreBuild.cmd file. if not exist "$(ProjectDir)$(ProjectName)PreBuild.cmd" exit /b set CONFIGURATIONBUILDDIR=$(ConfigurationBuildDir) set CONFIGURATIONNAME=$(ConfigurationName) set INPUTDIR=$(InputDir) set INPUTFILENAME=$(InputFileName) set INPUTPATH=$(InputPath) set INTDIR=$(IntDir) set LIBRARYCONFIGSUFFIX=$(LibraryConfigSuffix) set OUTDIR=$(OutDir) set PLATFORMNAME=$(PlatformName) set PROJECTDIR=$(ProjectDir) set PROJECTFILENAME=$(ProjectFileName) set PROJECTNAME=$(ProjectName) set PROJECTPATH=$(ProjectPath) set SOLUTIONDIR=$(SolutionDir) set SOLUTIONFILENAME=$(SolutionFileName) set SOLUTIONNAME=$(SolutionName) set SOLUTIONPATH=$(SolutionPath) set TARGETDIR=$(TargetDir) set TARGETEXT=$(TargetExt) set TARGETFILENAME=$(TargetFileName) set TARGETPATH=$(TargetPath) set WEBKITCONFIGSUFFIX=$(WebKitConfigSuffix) set WEBKITDLLCONFIGSUFFIX=$(WebKitDLLConfigSuffix) REM If any of the above variables didn't exist previously and REM were set to an empty string, set will set the errorlevel to 1, REM which will cause the project-specific script to think the build REM has failed. This cmd /c call will clear the errorlevel. cmd /c "$(ProjectDir)$(ProjectName)PreBuild.cmd"
主要是调用JavaScriptCorePreBuild.cmd这个文件,JavaScriptCorePreBuild.cmd这个文件内容如下:
%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" bash "%WEBKITLIBRARIESDIR%/tools/scripts/auto-version.sh" "%INTDIR%"
在编译JavaScriptCore这个工程时,cl.exe所使用的参数展开后如下:
/Od /I "C:/cygwin/home/xufan/WebKit/WebKitBuild/Debug_Cairo_CFLite/obj/JavaScriptCore/DerivedSources//" /I "../../" /I "../../API/" /I "../../parser/" /I "../../bytecompiler/" /I "../../jit/" /I "../../runtime/" /I "../../bytecode/" /I "../../interpreter/" /I "../../wtf/" /I "../../profiler" /I "../../assembler/" /I "../../debugger/" /I "../../collector/handles/" /I "C:/cygwin/home/xufan/WebKit/WebKitLibraries/win/include" /I "C:/cygwin/home/xufan/WebKit/WebKitLibraries/win/include/private" /I "C:/cygwin/home/xufan/WebKit/WebKitBuild/Debug_Cairo_CFLite/include" /I "C:/cygwin/home/xufan/WebKit/WebKitBuild/Debug_Cairo_CFLite/include/JavaScriptCore" /I "C:/cygwin/home/xufan/WebKit/WebKitBuild/Debug_Cairo_CFLite/include/private" /I "C:/cygwin/home/xufan/WebKit/WebKitLibraries/win/include/pthreads" /I "C:/cygwin/home/xufan/WebKit/WebKitLibraries/win/include/cairo" /D "__STD_C" /D "WIN32" /D "_WINDOWS" /D "WINVER=0x502" /D "_WIN32_WINNT=0x502" /D "_WIN32_IE=0x603" /D "_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1" /D "__PRODUCTION__=0" /D "_HAS_EXCEPTIONS=0" /D "BUILDING_JavaScriptCore" /D "ENABLE_CHANNEL_MESSAGING" /D "ENABLE_DATABASE" /D "ENABLE_DATALIST" /D "ENABLE_DOM_STORAGE" /D "ENABLE_EVENTSOURCE" /D "ENABLE_FILTERS" /D "ENABLE_ICONDATABASE" /D "ENABLE_JAVASCRIPT_DEBUGGER" /D "ENABLE_METER_TAG" /D "ENABLE_OFFLINE_WEB_APPLICATIONS" /D "ENABLE_SHARED_WORKERS" /D "ENABLE_SVG" /D "ENABLE_SVG_ANIMATION" /D "ENABLE_SVG_AS_IMAGE" /D "ENABLE_SVG_FONTS" /D "ENABLE_SVG_FOREIGN_OBJECT" /D "ENABLE_SVG_USE" /D "ENABLE_WEB_SOCKETS" /D "ENABLE_WORKERS" /D "ENABLE_XPATH" /D "ENABLE_XSLT" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /Gm /RTC1 /MTd /GR- /Fo"C:/cygwin/home/xufan/WebKit/WebKitBuild/Debug_Cairo_CFLite/obj/JavaScriptCore//" /Fd"C:/cygwin/home/xufan/WebKit/WebKitBuild/Debug_Cairo_CFLite/obj/JavaScriptCore/vc80.pdb" /W4 /nologo /c /Zi /TP /wd4018 /wd4068 /wd4099 /wd4100 /wd4127 /wd4138 /wd4180 /wd4189 /wd4201 /wd4244 /wd4251 /wd4275 /wd4288 /wd4291 /wd4305 /wd4344 /wd4355 /wd4389 /wd4503 /wd4505 /wd4510 /wd4512 /wd4610 /wd4706 /wd4800 /wd4951 /wd4952 /wd4996 /wd6011 /wd6031 /wd6211 /wd6246 /wd6255 /wd6387 /FI "ICUVersion.h" /errorReport:prompt /GS
里面的类似于/D "ENABLE_SVG"的宏定义就是用于开启webkit的相关特性的,在cpp里面的一般用这种写法来判断是否开启:
#if ENABLE(SVG) #include "XLinkNames.h" #include "SVGNames.h" #endif
/* ==== PLATFORM handles OS, operating environment, graphics API, and CPU. This macro will be phased out in favor of platform adaptation macros, policy decision macros, and top-level port definitions. ==== */ #define PLATFORM(WTF_FEATURE) (defined WTF_PLATFORM_##WTF_FEATURE && WTF_PLATFORM_##WTF_FEATURE) /* ==== Platform adaptation macros: these describe properties of the target environment. ==== */ /* COMPILER() - the compiler being used to build the project */ #define COMPILER(WTF_FEATURE) (defined WTF_COMPILER_##WTF_FEATURE && WTF_COMPILER_##WTF_FEATURE) /* CPU() - the target CPU architecture */ #define CPU(WTF_FEATURE) (defined WTF_CPU_##WTF_FEATURE && WTF_CPU_##WTF_FEATURE) /* HAVE() - specific system features (headers, functions or similar) that are present or not */ #define HAVE(WTF_FEATURE) (defined HAVE_##WTF_FEATURE && HAVE_##WTF_FEATURE) /* OS() - underlying operating system; only to be used for mandated low-level services like virtual memory, not to choose a GUI toolkit */ #define OS(WTF_FEATURE) (defined WTF_OS_##WTF_FEATURE && WTF_OS_##WTF_FEATURE) /* ==== Policy decision macros: these define policy choices for a particular port. ==== */ /* USE() - use a particular third-party library or optional OS service */ #define USE(WTF_FEATURE) (defined WTF_USE_##WTF_FEATURE && WTF_USE_##WTF_FEATURE) /* ENABLE() - turn on a specific feature of WebKit */ #define ENABLE(WTF_FEATURE) (defined ENABLE_##WTF_FEATURE && ENABLE_##WTF_FEATURE)
Platform.h还定义了其他很多跟平台相关的宏,这些宏在移植webkit到其他平台(例如arm)时要特别注意。
JavaScriptCore这个工程的link参数如下:
/OUT:"C:/cygwin/home/xufan/WebKit/WebKitBuild/Debug_Cairo_CFLite/bin/JavaScriptCore_debug.dll" /INCREMENTAL /NOLOGO /LIBPATH:"C:/cygwin/home/xufan/WebKit/WebKitBuild/Debug_Cairo_CFLite/obj/JavaScriptCore/lib" /LIBPATH:"C:/cygwin/home/xufan/WebKit/WebKitLibraries/win/lib" /LIBPATH:"C:/cygwin/home/xufan/WebKit/WebKitBuild/Debug_Cairo_CFLite/lib" /DLL /MANIFEST /MANIFESTFILE:"C:/cygwin/home/xufan/WebKit/WebKitBuild/Debug_Cairo_CFLite/obj/JavaScriptCore/JavaScriptCore_debug.dll.intermediate.manifest" /DEF:"JavaScriptCore.def" /DEBUG /PDB:"c:/cygwin/home/xufan/WebKit/WebKitBuild/Debug_Cairo_CFLite/bin/JavaScriptCore_debug.pdb" /SUBSYSTEM:WINDOWS /IMPLIB:"C:/cygwin/home/xufan/WebKit/WebKitBuild/Debug_Cairo_CFLite/lib/JavaScriptCore_debug.lib" /MACHINE:X86 /ERRORREPORT:PROMPT CFLite_debug.lib gdi32.lib oleaut32.lib winmm.lib libicuin.lib libicuuc.lib pthreadVC2.lib WTF_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /SAFESEH /FIXED:NO /dynamicbase /ignore:4221
JavaScriptCore这个工程最终编译成JavaScriptCore.dll(或JavaScriptCore_debug.dll),这个dll到处和如下函数供jsc,webcore等工程使用(c:/cygwin/home/xufan/WebKit/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def,这里面的很多函数可以到苹果的网站http://developer.apple.com/library/mac/#documentation/Carbon/Reference/WebKit_JavaScriptCore_Ref/index.html看帮助):
WTF::CString::CString(char const *) WTF::CString::CString(char const *,unsigned int) WTF::Collator::Collator(char const *) JSC::DateInstance::DateInstance(class JSC::ExecState *,double) JSC::DateInstance::DateInstance(class JSC::ExecState *,class WTF::NonNullPassRefPtr<class JSC::Structure>,double) JSC::DefaultGCActivityCallback::DefaultGCActivityCallback(class JSC::Heap *) JSC::JSLock::DropAllLocks::DropAllLocks(enum JSC::JSLockBehavior) JSC::DynamicGlobalObjectScope::DynamicGlobalObjectScope(class JSC::ExecState *,class JSC::JSGlobalObject *) JSC::InternalFunction::InternalFunction(class JSC::JSGlobalData *,class JSC::JSGlobalObject *,class WTF::NonNullPassRefPtr<class JSC::Structure>,class JSC::Identifier const &) JSC::JSArray::JSArray(class JSC::JSGlobalData &,class WTF::NonNullPassRefPtr<class JSC::Structure>,class JSC::ArgList const &) JSC::JSArray::JSArray(class WTF::NonNullPassRefPtr<class JSC::Structure>) JSC::JSByteArray::JSByteArray(class JSC::ExecState *,class WTF::NonNullPassRefPtr<class JSC::Structure>,class WTF::ByteArray *) JSC::JSFunction::JSFunction(class JSC::ExecState *,class JSC::JSGlobalObject *,class WTF::NonNullPassRefPtr<class JSC::Structure>,int,class JSC::Identifier const &,__int64 (*)(class JSC::ExecState *)) JSC::JSObjectWithGlobalObject::JSObjectWithGlobalObject(class JSC::JSGlobalObject *,class WTF::NonNullPassRefPtr<class JSC::Structure>) JSC::JSString::JSString(enum JSC::JSString::VPtrStealingHackType) JSC::JSString::JSString(class JSC::ExecState *,