silnrsi / grcompiler

The SIL Graphite compiler builds a Graphite enabled font from a smart font description
http://graphite.sil.org
Other
7 stars 3 forks source link

SILGRAPHITE COMPILER

The SIL Graphite compiler builds a Graphite enabled font from a smart font description, written in GDL (Graphite Description Language) and a TrueType font by adding extra TrueType tables to it which the Graphite engine can interpret.

This project contains three executables: grcompiler, gdlpp, and GrcRegressionTest. This project also depends on the International Components for Unicode (ICU) library. ANTLR is used to generate the GDL parser, though most developers can use the provided generated files. (See the compiler/Grammar/Antlr folder.) LZ4 is also used to compress some TrueType tables.

GDLPP #include details

WARNING: On Windows, grcompiler v5.2 fixes a longstanding bug. File inclusion will now be relative to the including file. Users who previously did inclusion relative to the current working directory will see changes if the current working director differs from the location of the including file. (Previously on Windows, file inclusion was relative to the current working directory when the path to the including file was specified using backslashes.)

It's possible to specify a folder that gdlpp will use to find included files (such as stddef.gdh). Set the GDLPP_PREFS environment variable to -I<folder path>. There must be no space after I and no quote marks. Use DOS-style short path naming if the path contains spaces. On Linux, /usr/share/grcompiler (PKGDATADIR) will be first in the include paths searched. Typically stddef.gdh will be installed there.

BUILDING

The grcompiler can currently be built with several build systems. The primary cross-platform build system is CMake. We require CMake 3.11 or above. It will build all three executables and can run the regression tests.

CMake

For all platforms

  1. Create your build directory

    mkdir build
    cd build
  2. Generate project files for your build system
    You may need to specify the CMAKE_BUILD_TYPE as some Windows generators require it.

    cmake -DCMAKE_BUILD_TYPE=Release ..

    CMake will automatically detect your build system and generate a project for that. You may wish to specify a build system other than the automatically detected one -- for example, if you have multiple versions of Visual Studio installed or another toolchain, such as MinGW, you wish to build under. To do this pass the -G <generator name> option to the initial cmake configuration call. If you want to build for a specific platform, and your tool chain support this, you can pass the -A <platform-name> option. A common use is to allow you to choose between 32 or 64 bit builds:

    OS 32 bit 64 bit
    Linux x86 amd64
    Windows Win32 x64

    For example for Visual Studio 2019 64 bit:

    cmake -G "Visual Studio 16 2019" -DCMAKE_BUILD_TYPE=Release -A x64 ..

    or for MinGW:

    cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE:STRING=Release ..

    TIPS: You can get a list of generators CMakes supports with cmake --help.
    If you want to run cmake with different options, you should do so in an empty folder.
    See below if you want to use a specific version of ICU.

  3. Build grcompiler binaries

    cmake --build .

    When building using the Visual Studio generator you will need to append --config Debug or --config Release for your debug or release builds, respectively, to the above command.

    Depending on your chosen generator the next step varies.
    For MS Visual Studio projects you will need to run:
    cmake --build . --target RUN_TESTS --config Release
    but for all other generators:
    cmake --build . --target test
    will be sufficient.

  4. Installation

    cmake --build . --target install

    The step will copy files into a GNU style hierarchy rooted at CMAKE_INSTALL_PREFIX which can be added the the project generation command using -DCMAKE_INSTALL_PREFIX=<path to target dir>. This command only really makes sense on a Unix system or if build as a dependency as part of another Windows project.

  5. Rebuilds
    You can clean the project with:

    cmake --build . --target clean

    Or just delete the build directory and start again.

Linux specific details

On amd64 architecture if you wish build and test 32 bit binaries this is possible using the following cmake invocation:

CFLAGS=-m32 CXXFLAGS=-m32 cmake ..
cmake --build .
cmake --build test

You will need g++-multilib support.

It is possible to use clang to build and test grcompiler and gdlpp. Use this build command:

CC=clang CXX=clang++ cmake ..
cmake --build .

You will need libc++ and libc++-abi packages.

Windows specific details

TIPS:

Visual Studio 2017 added support for handling CMake projects. You can find more information and instructions at CMake projects in Visual Studio.

Currently, development with CMake in the Visual Studio IDE is not advised because the CMake configuration does not work properly with the Ninja code generator, which is invoked by default from within the IDE. Both File-Open-CMake... and File-Open Folder... currently fail. See issue #42. Opening the grcompiler.sln file generated on the command line (as above) works around this issue.

Older build systems

Please note that these older build systems are no longer being mainatained and will likely be removed soon.

For Unix style system with autotools

The grcompiler project can use GNU autobuild tools to manage building and installation, please see the INSTALL file for more details.

For Win32 older build tools

The CMake approach above is strongly encouraged.

The choice of 32- or 64-bit build tools and targets is made by building from the appropriate Visual Studio command prompt.

To build grcomiler release binaries, from the compiler folder:

nmake -f makefile.mak

To build grcompiler debug binaries:

nmake CFG=DEBUG -f makefile.mak

TIP: A debug build for ICU from source will be needed too (see below).

Cleaning up, to remove all .obj files without removing the binaries:

nmake -f makefile.mak clean

To remove the binaries as well:

nmake -f makefile.mak realclean

This deletes the libraries as well.

To build gdlpp, from the preprocessor folder:

nmake -f gdlpp.mak

To build GrcRegressionTest and run regression tests, from the test/GrcRegressionTest folder:

nmake -f Makefile.vc  
cd fonts  
nmake -f regtest.mak  

To use Visual Studio, setup a new makefile project and add commands for building, testing, and debugging using the makefiles indicated above.

DEPENDENCIES

ICU

The grcompiler executable has a hard build dependency on ICU. This dependency may be satisfied via a system supplied dev package as is common on Linux, or via a pre-built binary distribution archive available from the ICU4C project.

Linux

You should use your distributions package manager to install icu-dev package.

Windows