Skip to content

castle-engine/castle-fpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

128 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FPC (Free Pascal Compiler) builds (for Castle Game Engine and other usage)

Build FPC Free Pascal Compiler so that we can easily distribute it together with Castle Game Engine downloads.

This repo includes:

Features:

  • As much as possible is within the bash script logic and you can just run build_fpc on your machine to test it works. So it's not only for CI/CD.

  • The resulting FPC version can be:

    • "best stable" version (3.2.2 or 3.2.3 now, depending on the platform).
    • "last tested unstable" version (3.3.1 from a commit hash FPC_UNSTABLE_COMMIT in script).
  • The resulting FPC is a trivial ZIP, for all platforms, easy to unpack and repack into a larger installer.

  • The resulting FPC build is released as snapshot release. Scripts (from other CI/CD workflows) can download this FPC trivially too, just

    wget https://github.com/castle-engine/castle-fpc/releases/download/snapshot/fpc-"${OS}"-"${CPU}".zip
    
  • When using this FPC, be sure to specify proper options. See section "You also need fpc.cfg or otherwise pass some command-line options to FPC" below and see repo castle-lazarus for example usage.

  • Auto-tested. We actually execute the build compiler on test_program.lpr to make sure it works.

While the primary use-case is that people download Castle Game Engine bundled with FPC and use it, you can also

  • directly download the FPC build from snapshot release and use it.

  • You can also just run build_fpc script yourself, to build FPC for your platform. It's a regular bash script and we put effort that it "just works" on all platforms. All you need is a basic set of Unix tools (on Windows, make sure you have MSys2/Cygwin installed).

Note: You also need fpc.cfg or otherwise pass some command-line options to FPC

The FPC packaged as ZIP here doesn't ship with any configuration file (fpc.cfg). You need to create fpc.cfg yourself, or otherwise make sure to always pass the appropriate minimal command-line options listed below. You must pass these options, at least to let the FPC find its standard units. When using through Castle Game Engine, you don't need to worry about it, our build tool calculates and passes appropriate options (without storing them in any config file, so you can still move around the CGE+FPC installation directory anywhere you want).

A minimal FPC configuration file (you would place this in file like fpc.cfg alongside fpc.exe on Windows, or in $HOME/.fpc.cfg on Unix) should contain this:

# Point to FPC standard units.
# Note that FPC will replace the $FPCTARGET itself.
# You only need to replace the <directory-....> part with correct (absolute,
# so it works everywhere) path.
-Fu<directory-where-you-extracted-FPC-ZIP>/fpc/units/$FPCTARGET/*

#ifdef DARWIN
# Add macOS specific flags, otherwise linking on newer macOS versions fails.
# See "utils_calculate_fpc_opts" function in "build_utilities" script
# for full detection and reason behind these flags.
-XR/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
-Fl/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib
-FD/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
-WM10.15
#endif

Our build_fpc script auto-tests that these options allow to build programs, so we are sure these options are good.

Why

Goal: Provide ready precompiled FPC to later be included ("bundled") with the CGE download.

For:

  • This "bundled FPC in CGE download" is for people who don't want to use FPC outside of CGE.

  • Maybe they are new to Pascal, maybe they are new to FPC, maybe they just "want something that works with CGE as easily as possible" and don't care about having specific FPC version etc.

  • It is important that CGE works as "out of the box" as it can, to be friendly to new users. Part of this is that you can "just download Castle Game Engine, create new project from template, hit F9 and it builds and runs".

Note that we don't fork FPC here.

How

  • We want a binary FPC build, as a simple zip, for major platforms supported by CGE.

  • This repository contains GitHub Actions workflows (see inside .github subdirectory) to build FPC for major CGE supported platforms.

    See the snapshot release assets for a list of available OS/CPU combinations.

  • FPC is build, installed and packaged to a simple zip. Later, this zip is included in CGE binary download (this is handled during CGE build).

  • Note: We don't use binary downloads from https://sourceforge.net/projects/lazarus/files/ , for various reasons they are not good enough.

    E.g. for Windows they only contain FPC in exe (installer) format. They don't provide zip for Linux.

    We also don't use binary downloads from https://sourceforge.net/projects/freepascal/ .They don't provide Win64 compiler (only Win32, unexpected by most users).

    We also need to use FPC 3.2.3 (fixed branch) on some platforms. We can decide about it here, and later CGE build process can just take the version from this repo as "best stable version".

    We also want to test FPC 3.3.1 from a commit hash we define here.

    Building FPC ourselves, as a simple zip for all platforms we need, is simplest.

Note: We have also repo where we build Lazarus, https://github.com/castle-engine/castle-lazarus . But it has more limited use-case now (as we don't bundle Lazarus with CGE).

Future

  • This may be extended to include cross-compilers. In particular

    • between Linux/x86_64 and Windows/x86_64
    • to Android (Android/Arm, Android/Aarch64), from all other platforms.

About

FPC (Free Pascal Compiler) version that is easy to distribute together with CGE

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors