Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice of creating Delphi package for different Delphi IDEs

I maintain an open source Delphi Library. I want to have one minimal project file for all Delphi XE series compilers. Ideally, I need a tool that will create one project file for XE6, and that will strip all redundant information and create corresponding project files for XE-XE5 automatically. Is there any smart way to achieve that?

Here is my current project file, which contains much redundant information. For instance, it contains a dummy configuration for Android/iOS etc, but my project is targeting traditional Windows apps. If I manually remove this information, it will come back when the project changes. Also, I know the value of DebugInformation was boolean in XE4, but integer in XE5.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <ProjectGuid>{1118D87C-9E72-4D93-9098-E70AD237493A}</ProjectGuid>
        <MainSource>dutil_rtl.dpk</MainSource>
        <ProjectVersion>15.1</ProjectVersion>
        <FrameworkType>None</FrameworkType>
        <Base>True</Base>
        <Config Condition="'$(Config)'==''">Release</Config>
        <Platform Condition="'$(Platform)'==''">Win32</Platform>
        <TargetedPlatforms>3</TargetedPlatforms>
        <AppType>Package</AppType>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
        <Base>true</Base>
    </PropertyGroup>
    <PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Base)'=='true') or '$(Base_Win32)'!=''">
        <Base_Win32>true</Base_Win32>
        <CfgParent>Base</CfgParent>
        <Base>true</Base>
    </PropertyGroup>
    <PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Base)'=='true') or '$(Base_Win64)'!=''">
        <Base_Win64>true</Base_Win64>
        <CfgParent>Base</CfgParent>
        <Base>true</Base>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_1)'!=''">
        <Cfg_1>true</Cfg_1>
        <CfgParent>Base</CfgParent>
        <Base>true</Base>
    </PropertyGroup>
    <PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win32)'!=''">
        <Cfg_1_Win32>true</Cfg_1_Win32>
        <CfgParent>Cfg_1</CfgParent>
        <Cfg_1>true</Cfg_1>
        <Base>true</Base>
    </PropertyGroup>
    <PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win64)'!=''">
        <Cfg_1_Win64>true</Cfg_1_Win64>
        <CfgParent>Cfg_1</CfgParent>
        <Cfg_1>true</Cfg_1>
        <Base>true</Base>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_2)'!=''">
        <Cfg_2>true</Cfg_2>
        <CfgParent>Base</CfgParent>
        <Base>true</Base>
    </PropertyGroup>
    <PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win32)'!=''">
        <Cfg_2_Win32>true</Cfg_2_Win32>
        <CfgParent>Cfg_2</CfgParent>
        <Cfg_2>true</Cfg_2>
        <Base>true</Base>
    </PropertyGroup>
    <PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win64)'!=''">
        <Cfg_2_Win64>true</Cfg_2_Win64>
        <CfgParent>Cfg_2</CfgParent>
        <Cfg_2>true</Cfg_2>
        <Base>true</Base>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Base)'!=''">
        <VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
        <VerInfo_Locale>1033</VerInfo_Locale>
        <DCC_DUPLICATE_CTOR_DTOR>false</DCC_DUPLICATE_CTOR_DTOR>
        <GenPackage>true</GenPackage>
        <GenDll>true</GenDll>
        <RuntimeOnlyPackage>true</RuntimeOnlyPackage>
        <DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace)</DCC_Namespace>
        <DCC_DcuOutput>..\lib\$(Platform)\$(Config)</DCC_DcuOutput>
        <DCC_ExeOutput>.\$(Platform)\$(Config)</DCC_ExeOutput>
        <DCC_E>false</DCC_E>
        <DCC_N>false</DCC_N>
        <DCC_S>false</DCC_S>
        <DCC_F>false</DCC_F>
        <DCC_K>false</DCC_K>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Base_Win32)'!=''">
        <DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
        <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Base_Win64)'!=''">
        <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
        <DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace)</DCC_Namespace>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Cfg_1)'!=''">
        <DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
        <DCC_Optimize>false</DCC_Optimize>
        <DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
        <DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>
        <DCC_RemoteDebug>true</DCC_RemoteDebug>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
        <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
        <DCC_RemoteDebug>false</DCC_RemoteDebug>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
        <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Cfg_2)'!=''">
        <DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
        <DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
        <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
        <DCC_DebugInformation>false</DCC_DebugInformation>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
        <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Cfg_2_Win64)'!=''">
        <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
    </PropertyGroup>
    <ItemGroup>
        <DelphiCompile Include="$(MainSource)">
            <MainSource>MainSource</MainSource>
        </DelphiCompile>
        <DCCReference Include="rtl.dcp"/>
        <DCCReference Include="..\src\dutil.core.Exception.pas"/>
        <DCCReference Include="..\src\dutil.core.NonRefCountedInterfacedObject.pas"/>
        <DCCReference Include="..\src\dutil.io.device.File_.pas"/>
        <DCCReference Include="..\src\dutil.io.device.TempFile.pas"/>
        <DCCReference Include="..\src\dutil.io.FileVersion.pas"/>
        <DCCReference Include="..\src\dutil.sys.win32.MessageWindowThread.pas"/>
        <DCCReference Include="..\src\dutil.sys.win32.Platform.pas"/>
        <DCCReference Include="..\src\dutil.sys.win32.Process.pas"/>
        <DCCReference Include="..\src\dutil.sys.win32.registry.Reader.pas"/>
        <DCCReference Include="..\src\dutil.sys.win32.registry.Validation.pas"/>
        <DCCReference Include="..\src\dutil.sys.win32.registry.Writer.pas"/>
        <DCCReference Include="..\src\dutil.sys.win32.SpecialPath.pas"/>
        <DCCReference Include="..\src\dutil.sys.win32.SubclassingWindow.pas"/>
        <DCCReference Include="..\src\dutil.text.arg.Arg.pas"/>
        <DCCReference Include="..\src\dutil.text.arg.Arguments.pas"/>
        <DCCReference Include="..\src\dutil.text.arg.Builder.pas"/>
        <DCCReference Include="..\src\dutil.text.Convert.pas"/>
        <DCCReference Include="..\src\dutil.text.json.Json.pas"/>
        <DCCReference Include="..\src\dutil.text.json.Reader.pas"/>
        <DCCReference Include="..\src\dutil.text.json.Validation.pas"/>
        <DCCReference Include="..\src\dutil.text.Util.pas"/>
        <DCCReference Include="..\src\dutil.text.xml.Validation.pas"/>
        <DCCReference Include="..\src\dutil.time.Time.pas"/>
        <DCCReference Include="..\src\dutil.util.concurrent.BlockingQueue.pas"/>
        <DCCReference Include="..\src\dutil.util.concurrent.FailSafeThread.pas"/>
        <DCCReference Include="..\src\dutil.util.concurrent.Result.pas"/>
        <DCCReference Include="..\src\dutil.util.concurrent.Timer.pas"/>
        <DCCReference Include="..\src\dutil.util.concurrent.TimerImpl.pas"/>
        <DCCReference Include="..\src\dutil.util.concurrent.TimerQueue.pas"/>
        <DCCReference Include="..\src\dutil.util.container.DynArray.pas"/>
        <DCCReference Include="..\src\dutil.util.digest.Crc32.pas"/>
        <BuildConfiguration Include="Release">
            <Key>Cfg_2</Key>
            <CfgParent>Base</CfgParent>
        </BuildConfiguration>
        <BuildConfiguration Include="Base">
            <Key>Base</Key>
        </BuildConfiguration>
        <BuildConfiguration Include="Debug">
            <Key>Cfg_1</Key>
            <CfgParent>Base</CfgParent>
        </BuildConfiguration>
    </ItemGroup>
    <ProjectExtensions>
        <Borland.Personality>Delphi.Personality.12</Borland.Personality>
        <Borland.ProjectType>Package</Borland.ProjectType>
        <BorlandProject>
            <Delphi.Personality>
                <VersionInfo>
                    <VersionInfo Name="IncludeVerInfo">True</VersionInfo>
                    <VersionInfo Name="AutoIncBuild">False</VersionInfo>
                    <VersionInfo Name="MajorVer">1</VersionInfo>
                    <VersionInfo Name="MinorVer">0</VersionInfo>
                    <VersionInfo Name="Release">0</VersionInfo>
                    <VersionInfo Name="Build">0</VersionInfo>
                    <VersionInfo Name="Debug">False</VersionInfo>
                    <VersionInfo Name="PreRelease">False</VersionInfo>
                    <VersionInfo Name="Special">False</VersionInfo>
                    <VersionInfo Name="Private">False</VersionInfo>
                    <VersionInfo Name="DLL">False</VersionInfo>
                    <VersionInfo Name="Locale">1033</VersionInfo>
                    <VersionInfo Name="CodePage">1252</VersionInfo>
                </VersionInfo>
                <VersionInfoKeys>
                    <VersionInfoKeys Name="CompanyName"/>
                    <VersionInfoKeys Name="FileDescription"/>
                    <VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
                    <VersionInfoKeys Name="InternalName"/>
                    <VersionInfoKeys Name="LegalCopyright"/>
                    <VersionInfoKeys Name="LegalTrademarks"/>
                    <VersionInfoKeys Name="OriginalFilename"/>
                    <VersionInfoKeys Name="ProductName"/>
                    <VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
                    <VersionInfoKeys Name="Comments"/>
                </VersionInfoKeys>
                <Source>
                    <Source Name="MainSource">dutil_rtl.dpk</Source>
                </Source>
                <Excluded_Packages>
                    <Excluded_Packages Name="$(BDSBIN)\dcloffice2k190.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
                    <Excluded_Packages Name="$(BDSBIN)\dclofficexp190.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
                </Excluded_Packages>
            </Delphi.Personality>
            <Deployment/>
            <Platforms>
                <Platform value="iOSDevice">False</Platform>
                <Platform value="iOSSimulator">False</Platform>
                <Platform value="Win32">True</Platform>
                <Platform value="Win64">True</Platform>
            </Platforms>
        </BorlandProject>
        <ProjectFileVersion>12</ProjectFileVersion>
    </ProjectExtensions>
    <Import Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')" Project="$(BDS)\Bin\CodeGear.Delphi.Targets"/>
    <Import Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')" Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj"/>
</Project>
like image 772
stanleyxu2005 Avatar asked Jan 11 '23 13:01

stanleyxu2005


1 Answers

A single project file may have worked in the old days when everything was based on DPR/DPK files only, but since DPROJ files were introduced a single project will not work anymore. That is because a DPROJ file contains version info, and in some cases node structures, that are different between IDE releases. If you opened a DPROJ in a newer IDE and the file contained an older version/structure, the IDE would upgrade the project. If you then saved the changes to the same file, it would not work in older IDEs anymore.

If you look at any of the major third-party component packages, they maintain different projects for each IDE release, for this reason. You will need to do the same.

like image 57
Remy Lebeau Avatar answered Jan 20 '23 21:01

Remy Lebeau