webkit在win32下的编译规则(三)

这篇博客详细解析了WebKit在Win32环境下编译的过程,包括Pre-build event的设置,JavaScriptCorePreBuild.cmd脚本的作用,以及一系列vsprops文件如FeatureDefinesCairo.vsprops、common.vsprops、release.vsprops、WinCairo.vsprops和WTFCommon.vsprops在编译配置中的功能。这些文件定义了版本信息、特性开关、编译选项、依赖库等关键信息,影响着整个WebKit工程的构建过程。
摘要由CSDN通过智能技术生成

首先来看WTF这个project,这个project的Pre-build event如下:

   1: REM Do not edit from the Visual Studio IDE! Customize via a $(ProjectName)PreBuild.cmd file.
   2: if not exist "$(ProjectDir)$(ProjectName)PreBuild.cmd" exit /b
   3:  
   4: set CONFIGURATIONBUILDDIR=$(ConfigurationBuildDir)
   5: set CONFIGURATIONNAME=$(ConfigurationName)
   6: set INPUTDIR=$(InputDir)
   7: set INPUTFILENAME=$(InputFileName)
   8: set INPUTPATH=$(InputPath)
   9: set INTDIR=$(IntDir)
  10: set LIBRARYCONFIGSUFFIX=$(LibraryConfigSuffix)
  11: set OUTDIR=$(OutDir)
  12: set PLATFORMNAME=$(PlatformName)
  13: set PROJECTDIR=$(ProjectDir)
  14: set PROJECTFILENAME=$(ProjectFileName)
  15: set PROJECTNAME=$(ProjectName)
  16: set PROJECTPATH=$(ProjectPath)
  17: set SOLUTIONDIR=$(SolutionDir)
  18: set SOLUTIONFILENAME=$(SolutionFileName)
  19: set SOLUTIONNAME=$(SolutionName)
  20: set SOLUTIONPATH=$(SolutionPath)
  21: set TARGETDIR=$(TargetDir)
  22: set TARGETEXT=$(TargetExt)
  23: set TARGETFILENAME=$(TargetFileName)
  24: set TARGETPATH=$(TargetPath)
  25: set WEBKITCONFIGSUFFIX=$(WebKitConfigSuffix)
  26: set WEBKITDLLCONFIGSUFFIX=$(WebKitDLLConfigSuffix)
  27:  
  28: REM If any of the above variables didn't exist previously and
  29: REM were set to an empty string, set will set the errorlevel to 1,
  30: REM which will cause the project-specific script to think the build
  31: REM has failed. This cmd /c call will clear the errorlevel.
  32: cmd /c
  33:  
  34: "$(ProjectDir)$(ProjectName)PreBuild.cmd"

这些脚本首先利用vs自带的一些内置变量来设置环境变量,然后调用"$(ProjectDir)$(ProjectName)PreBuild.cmd"这个脚本,展开后的路径是D:/tools/cygwin/home/xufan/WebKit/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCorePreBuild.cmd。从上面的28-31行可以看出,cmd /c的主要作用是为了清除errorlevel。JavaScriptCorePreBuild.cmd这个脚本的内容如下:

   1: %SystemDrive%/cygwin/bin/which.exe bash
   2: if errorlevel 1 set PATH=%SystemDrive%/cygwin/bin;%PATH%
   3: cmd /c
   4: if exist "%CONFIGURATIONBUILDDIR%/buildfailed" grep XX%PROJECTNAME%XX "%CONFIGURATIONBUILDDIR%/buildfailed"
   5: if errorlevel 1 exit 1
   6: echo XX%PROJECTNAME%XX > "%CONFIGURATIONBUILDDIR%/buildfailed"
   7:  
   8: bash "%WEBKITLIBRARIESDIR%/tools/scripts/auto-version.sh" "%INTDIR%"

JavaScriptCorePreBuild.cmd首先检查前面的编译有没有问题,如果没有问题,就会调用D:/tools/cygwin/home/xufan/WebKit/WebKitLibraries/win/tools/scripts/auto-version.sh这个perl脚本,内容如下:

   1: #!/usr/bin/bash
   2:  
   3: # Copyright (C) 2007, 2009 Apple Inc.  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:  
  27: # Trim any trailing /r or /n from the given variable.
  28: chomp()
  29: {
   
  30:     local old_value=$(eval echo "/$$1");
  31:     local value=$(echo "$old_value" | sed 's/[/r/n]*$//')
  32:     eval $1=/$value;
  33: }
  34:  
  35: if [[ -n "$WEBKITLIBRARIESDIR" ]]; then
  36:     FALLBACK_VERSION_PATH=`cygpath -u "$WEBKITLIBRARIESDIR//tools//scripts//VERSION"`
  37:     FALLBACK_VERSION=$(cat "$FALLBACK_VERSION_PATH");
  38:  
  39:     COPYRIGHT_END_YEAR_PATH=`cygpath -u "$WEBKITLIBRARIESDIR//tools//scripts//COPYRIGHT-END-YEAR"`
  40:     COPYRIGHT_END_YEAR=$(cat "$COPYRIGHT_END_YEAR_PATH");
  41:     chomp COPYRIGHT_END_YEAR
  42: fi
  43:  
  44: OUTPUT_FILE=$(cygpath -u "$1")/include/autoversion.h
  45: mkdir -p "$(dirname "$OUTPUT_FILE")"
  46:  
  47: # Take the initial version number from RC_PROJECTSOURCEVERSION if it
  48: # exists, otherwise fall back to the version number stored in the source.
  49: ENVIRONMENT_VERSION="$RC_PROJECTSOURCEVERSION";
  50: PROPOSED_VERSION=${ENVIRONMENT_VERSION:-$FALLBACK_VERSION}
  51: chomp PROPOSED_VERSION
  52:  
  53: # Split out the three components of the dotted version number.  We pad
  54: # the input with trailing dots to handle the case where the input version
  55: # has fewer components than we expect.
  56: BUILD_MAJOR_VERSION=$(echo "$PROPOSED_VERSION.." | cut -d '.' -f 1)
  57: BUILD_MINOR_VERSION=$(echo "$PROPOSED_VERSION.." | cut -d '.' -f 2)
  58: BUILD_TINY_VERSION=$(echo "$PROPOSED_VERSION.." | cut -d '.' -f 3)
  59:  
  60: # Cut the major component down to three characters by dropping any
  61: # extra leading digits, then adjust the major version portion of the
  62: # version string to match.
  63: CHARACTERS_TO_DROP=$(( ${#BUILD_MAJOR_VERSION} > 3 ? ${#BUILD_MAJOR_VERSION} - 3 : 0 ))
  64: BUILD_MAJOR_VERSION=${BUILD_MAJOR_VERSION:$CHARACTERS_TO_DROP}
  65: PROPOSED_VERSION=${PROPOSED_VERSION:$CHARACTERS_TO_DROP}
  66:  
  67: # Have the minor and tiny components default to zero if not present.
  68: BUILD_MINOR_VERSION=${BUILD_MINOR_VERSION:-0}
  69: BUILD_TINY_VERSION=${BUILD_TINY_VERSION:-0}
  70:  
  71: # Split the first component further by using the first digit for the
  72: # major version and the remaining two characters as the minor version.
  73: # The minor version is shifted down to the tiny version, with the tiny
  74: # version becoming the variant version.
  75: MAJOR_VERSION=${BUILD_MAJOR_VERSION:0:1}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值