Google V8 JavaScrit 研究(1)

Google Chrome 是开源项目,V8自己单独也是一个开源项目,地址是http://code.google.com/p/v8/.
Check out 出来以后,直接打开tools\visualstudio\v8.sln 就可以编译了。官方用的是VS2005,我用的是2008。注意一点是,Google的很多开发会用Python(Google的三大语言,C++, Java, Python),V8也用到了。

Chrome和V8的VS solution file都用到了*.vsprops的文件。所以你看到solution中的每天project都不自己定义include path和library path,因为这都统一写在了vsprops文件中。

例如: tools\visualstudio\common.vsprops

<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet
 ProjectType="Visual C++"
 Version="8.00"
 Name="essential"
 OutputDirectory="$(SolutionDir)$(ConfigurationName)"
 IntermediateDirectory="$(SolutionDir)$(ConfigurationName)\obj\$(ProjectName)"
 CharacterSet="1"
 >
 <Tool
  Name="VCCLCompilerTool"
  AdditionalIncludeDirectories="$(ProjectDir)\..\..\src;$(IntDir)\DerivedSources"
  PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;_HAS_EXCEPTIONS=0;PCRE_STATIC;ENABLE_LOGGING_AND_PROFILING"
  MinimalRebuild="false"
  ExceptionHandling="0"
  RuntimeTypeInfo="false"
  WarningLevel="3"
  WarnAsError="true"
  Detect64BitPortabilityProblems="false"
  DebugInformationFormat="3"
  DisableSpecificWarnings="4355;4800"
  EnableFunctionLevelLinking="true"
 />
 <Tool
  Name="VCLibrarianTool"
  OutputFile="$(OutDir)\lib\$(ProjectName).lib"
 />
 <Tool
  Name="VCLinkerTool"
  GenerateDebugInformation="true"
  MapFileName="$(OutDir)\$(TargetName).map"
  ImportLibrary="$(OutDir)\lib\$(TargetName).lib"
  TargetMachine="1"
  FixedBaseAddress="1"
  AdditionalOptions="/IGNORE:4221 /NXCOMPAT"
 />
</VisualStudioPropertySheet>

一开始我不明白$(SolutionDir)的位置。它其实是*.sln所在的path. 所以当你自己创建solution文件的时候,要和例子中的solution文件在相同的路径结构中。当自己设计一个项目的时候,当确定了文件目录结构以后,就可以用这种方法来组织。

VisualStudio还有几种方式

1. 设置project的dependency,这种方式能解决lib的问题,但不能解决include path的问题。
2. 在项目的project setting中设置reference lib,同理这也不可以解决include path.
3. 在VS options 设置C++ include path, 这一般用于系统lib的path.
4. 在源代码中用相对路径,例如..\..\include,但这限制了文件的层次结构。

看来*.vsprops还是一个不错的选择。

原文地址:https://www.cnblogs.com/Chrome/p/1290310.html