Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What project options to use for open source Delphi packages?

I've written some Delphi code I would like to share on GitHub. All code is contained in runtime and designtime packages as required. There are many "Project Options" to set for each project. (Output directories, search paths, compilation options, etc.) I've managed to find some default options that work well for my situation but reading other Q&As here it's clear there are multiple ways of working.

What project options should be used to allow the open source packages to easily be incorporated into individual projects?

Delphi Project Options

I've recently started using NodeJS. The NPM package manager makes it super easy to use third-party packages in a project. Packages are installed with one simple command on the command line. Packages will automatically install any required dependencies.

PS: Feel free to edit this question if you would like to add extra things to consider.

like image 204
Shannon Matthews Avatar asked Feb 10 '15 06:02

Shannon Matthews


1 Answers

Let's say you have this structure

  • MyComponent
    • Packages
      • DelphiXE7
        • Package2.dpr
    • source
    • bin
      • Delphi XE7

then set

  • Search Path

    ..\..\..\source

  • Unit output directory

    ..\..\..\bin\Delphi XE7\$(Platform)\$(Config)

After compilation for all supported platforms and both Release and Debug you will have this structure in the bin directory

  • MyComponent
    • Packages
      • DelphiXE7
        • Package2.dpr
    • source
    • bin
      • Delphi XE7
        • Android
          • Release
          • Debug
        • Win32
          • Release
          • Debug
        • Win64
          • Release
          • Debug

For installation you have to setup some path inside the IDE.

  • Environment

    MYCOMPONENT => [root path to the files]

  • Library

    Repeat that for all supported platforms

    • Library Path

      $(MYCOMPONENT)\bin\Delphi XE7\$(Platform)\Release

    • Search Path

      $(MYCOMPONENT)\source

    • Debug-DCU-Path

      $(MYCOMPONENT)\bin\Delphi XE7\$(Platform)\Debug

If there are some language related units there is also a place to add (see Library - translated)

This ensures, that you have full debug feature (with Use Debug-DCU option set) and on release you have no debug code in your application.


Just a sidenote on libraries you should not want to install because you only use them in some projects.

Simply use the Optionset combined with a environment variable.

Here my SuperObject.optionset ($(USRLIB) points to a directory, where I collect all common used source code. And $(USRLIB)\ext is the place for all of the external libraries).

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <DCC_UnitSearchPath>$(USRLIB)\ext\superobject;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
    </PropertyGroup>
    <ProjectExtensions>
        <Borland.Personality>Delphi.Personality.12</Borland.Personality>
        <Borland.ProjectType>OptionSet</Borland.ProjectType>
        <BorlandProject>
            <Delphi.Personality/>
        </BorlandProject>
        <ProjectFileVersion>12</ProjectFileVersion>
    </ProjectExtensions>
</Project>

To use the superobject library I simply add the optionset to the project (right mouse click on build configuration) and everything is fine.

like image 169
Sir Rufo Avatar answered Nov 06 '22 11:11

Sir Rufo