繁体   English   中英

使用Jenkins的多个Delphi版本:库路径

[英]Multiple Delphi versions using Jenkins: library paths

我们正在考虑将我们的构建机器从FinalBuilder迁移到Jenkins,以适应我们扩展公司的其余部分。

我注意到的一个问题是,虽然Finalbuilder能够从构建机器上当前的Delphi安装中提取当前库路径,但Jenkins依赖于.dproj文件中包含的信息。

由于已知的.dproj文件中的路径问题非常特定于用户机器,我们目前不会将它们提交到我们的存储库,依赖于Delphi根据需要重新创建它们。 当构建机器首先依赖于完整的MSBUILD脚本时,这显然不会很好。

我们使用了相当多的第三方组件(仅DevExpress套件就有超过100个单元),因此在.dpr中包含和维护所有.pas文件的完整路径并不是一个真正的选择。

有没有人有一个久经考验的解决方案呢?

我对选项的看法是:

  • 为每个构建设置%PATH% - 为相关版本添加当前的Delphi库(这将运行到%PATH%长度限制吗?)
  • 使用命令行参数将正确的库路径传递给MSBUILD(这可能吗?)
  • 用编译器指令在源文件中以某种方式包含搜索路径(这可能吗?)
  • 使用预编译步骤创建新的.dproj文件(类似于http://delphi-divining.blogspot.co.uk/2012/10/dprojmaker-tool-to-create-delphi.html但它需要是命令行)

编辑:第五个想法:

  • 我们可以为每个项目使用dproj.local文件,存储在单独的存储库中(或在单独的路径中)并复制到构建机器预构建吗? 这将允许构建机器路径安全地存储远离凌乱的提交。

您需要将.dproj文件提交给源代码管理。

您遇到的问题是您的配置不完整。 任何构建系统都应该能够使用源代码控制中的文件来构建项目,这是确保构建正确二进制文件的唯一方法。

你有很多选择来完成这项工作

  1. 您可以在Delphi IDE中使用环境变量,例如, %ROOTFOLDER%可以在一台机器上设置为C:\\ Development \\ MyDelphiProjects而在另一台机器上设置为C:\\ Dev,只要该路径上的所有内容都相同即可。 每个开发人员和构建计算机都可以设置所需的路径。 您也可能需要用于bpl路径的变量。
  2. 在客户端计算机上实施相同的结构。 真的有多难让我们所有的开发者以C:\\ Development \\ Delphi作为他们的根?
  3. 确保所有搜索路径都是相对的。 这可以工作,但总会有异常导致问题,所以我从来没有设法让它工作。

我们在之前的公司中使用过选项1并且它工作非常成功,设置起来有点痛苦但是一旦设置就可以确保您的构建是正确的。

当我选择Jenkins作为“构建”环境时,我遇到了同样的问题。 解决方案是使用内部构建任务的MSBuild脚本。 因此,在Jenkins中,不是直接构建项目,而是构建此脚本,为您提供更多选项,包括指定项目路径的选项(您可以覆盖默认的IDE路径)。 我明天会发这样的剧本。

因此,在Jenkins配置MSBuild时,您必须指定msbuild文件,它将是Build.xml 对于命令行参数,我只使用/ v - verbosity和/ t - target name。

构建脚本如下所示:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <Target Name="Compile" DependsOnTargets="CompileApp" />

  <PropertyGroup>
    <ExeOutputName>App.exe</ExeOutputName>
    <ExeOutputPath>x:\exe</ExeOutputPath>
    <DcuOutputPath>x:\dcu</DcuOutputPath>

    <ForConfig>Release</ForConfig>
    <ForPlatform>Win32</ForPlatform>
  </PropertyGroup>

  <Target Name="ResolveOutputPath">
    <MakeDir Directories="$(ExeOutputPath)" />
    <MakeDir Directories="$(DcuOutputPath)" />
    <Delete Files="$(ExeOutputPath)\$(ExeOutputName)" />
    <Delete Files="$(DcuOutputPath)\*.*" />
  </Target>

  <ItemGroup>
    <AppUnitSearchPathItem Include="$(BDS)\lib\$(ForPlatform)\$(ForConfig)" />
    <AppUnitSearchPathItem Include="C:\Users\builder\Documents\tmssoftware\TMS Component Pack" />
    <AppUnitSearchPathItem Include="C:\Program Files (x86)\RemObjects Software\RemObjects SDK for Delphi\Dcu\$(ForPlatform)" />
    <AppUnitSearchPathItem Include="C:\Program Files (x86)\RemObjects Software\RemObjects SDK for Delphi\Source" />
    <AppUnitSearchPathItem Include="C:\Program Files (x86)\RemObjects Software\RemObjects SDK for Delphi\Source\CodeGen" />
    <AppUnitSearchPathItem Include="C:\Program Files (x86)\RemObjects Software\RemObjects SDK for Delphi\Source\DataSnap" />
    <AppUnitSearchPathItem Include="C:\Program Files (x86)\RemObjects Software\RemObjects SDK for Delphi\Source\ZLib" />
    <AppUnitSearchPathItem Include="C:\Program Files (x86)\RemObjects Software\RemObjects SDK for Delphi\Source\Synapse" />
    <AppUnitSearchPathItem Include="C:\Program Files (x86)\Embarcadero\RAD Studio\12.0\Components\EhLib\Lib\$(ForPlatform)\$(ForConfig)" />
    ...
  </ItemGroup> 

  <ItemGroup>
    <AppDefinesItem Include="App" />
    <!-- AppDefinesItem Include="CompilerDirective" -->
  </ItemGroup>

  <ItemGroup>
    <AppPropertiesItem Include="DCC_ExeOutput=$(ExeOutputPath)" />
    <AppPropertiesItem Include="DCC_DcuOutput=$(DcuOutputPath)" />
    <AppPropertiesItem Include="DCC_BuildAllUnits=true" />
    <AppPropertiesItem Include="DCC_Optimize=true" />
    <AppPropertiesItem Include="DCC_DebugInformation=0" />
    <AppPropertiesItem Include="DCC_PentiumSafeDivide=true" />
    <AppPropertiesItem Include="DCC_RangeChecking=true" />
    <AppPropertiesItem Include="DCC_IntegerOverflowCheck=true" />
    <AppPropertiesItem Include="DCC_WriteableConstants=true" />
    <AppPropertiesItem Include="DCC_IOChecking=true" />
    <AppPropertiesItem Include="DCC_AssertionsAtRuntime=false" />
    <AppPropertiesItem Include="DCC_Warnings=true" />
    <AppPropertiesItem Include="DCC_MapFile=3" />
    <AppPropertiesItem Include="DCC_ConsoleTarget=false" />
  </ItemGroup>

  <Target Name="CompileApp" DependsOnTargets="ResolveOutputPath">
    <PropertyGroup>
      <AppUnitSearchPath>@(AppUnitSearchPathItem)</AppUnitSearchPath>
      <AppDefines>@(AppDefinesItem)</AppDefines>
    </PropertyGroup>

    <ItemGroup>
      <AppProperties Include="Config=$(ForConfig)" />
      <AppProperties Include="Platform=$(ForPlatform)" />
      <!-- AppProperties Include="LibraryPath=$(AppUnitSearchPath)" -->
      <AppProperties Include="DelphiLibraryPath=$(AppUnitSearchPath)" />
      <AppProperties Include="UnitSearchPath=$(AppUnitSearchPath)" />
      <AppProperties Include="ResourcePath=$(AppUnitSearchPath)" />
      <AppProperties Include="IncludePath=$(AppUnitSearchPath)" />
      <AppProperties Include="ObjPath=$(AppUnitSearchPath)" />
      <AppProperties Include="DCC_Define=$(AppDefines)" />
      <AppProperties Include="@(AppPropertiesItem)" />
    </ItemGroup>

    <MSBuild Projects="App.dproj" Properties="@(AppProperties)" />
  </Target>
</Project>

这里缺少的是版本控制部分,可以使用资源模板从这个脚本完成...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM