1
0
Fork 0
Commit graph

9 commits

Author SHA1 Message Date
Scott Giese
a9365cd34e Embedded Resources: Fix for Ninja 1.9
Refactor to break circular references.
New custom target generates the resource files.
FGFS and Test_Suite targets declare a dependency to the generated files.
2019-12-26 01:26:44 -06:00
Florent Rougon
9054a51dd3 fgrcc: use octal escape sequences instead of hexadecimal ones
Octal escape sequences can be as short as 2 bytes (\0, ..., \7),
therefore they allow one to generate shorter files than hex escapes, for
the same resource contents. The line lengths won't be as even, but this
is purely cosmetic, virtually no one will ever read the resource data
string literals, so this is quite a negligible drawback compared to the
advantage of using less space in the Git repository every time resource
files are committed.
2018-01-19 08:12:24 +01:00
Florent Rougon
83fef08a04 Use common definition of simgear::enumValue() from <simgear/sg_inlines.h>
This avoids code duplication.
2017-11-19 08:23:14 +01:00
Florent Rougon
41045f3bf3 Remove XLIFF files from this repository
It was finally decided that the XLIFF files will live in FGData (cf.
<https://sourceforge.net/p/flightgear/mailman/message/35996085/> and
earlier messages in the same thread).
2017-08-18 11:22:47 +02:00
Florent Rougon
553212df1a fgrcc: use correct C++ variable names in generated C++ files
Use base 26 numbering with letter-only digits for resource indices in
the C++ files generated by fgrcc. This is needed because, for instance,
'resource10' appears not to be a valid C++ variable name, mpfff...
2017-08-03 11:14:19 +02:00
Florent Rougon
9c0dee2e9f Add XLIFF 1.2 translation files and register them as embedded resources
Translations/en_US/FlightGear-nonQt.xlf is for a proper English
translation, where for instance "found %n airport(s)" would have two
plural forms, "found %n airport" and "found %n airports" (most
non-plural strings can be taken verbatim from the default translation,
and at this point there is no plural form at all yet).

As they are registered here, the files will have virtual paths such as:

  /Translations/de/FlightGear-nonQt.xlf
  /Translations/en_US/FlightGear-nonQt.xlf
  etc.

for the EmbeddedResourceManager ('/' being the default virtual prefix).
2017-08-01 09:38:44 +02:00
Florent Rougon
b2cc191bc6 Integrate the EmbeddedResourceManager into FlightGear
${CMAKE_SOURCE_DIR}/src/EmbeddedResources/FlightGear-resources.xml
(currently empty) is automatically "compiled" into
${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.[ch]xx by
fgrcc inside the build directory. These files are incorporated into the
FlightGear build (FlightGear-resources.cxx is linked into FlightGear).

When the XML embedded resource declaration file added here,
FlightGear-resources.xml, is compiled, fgrcc is passed the
--root=${CMAKE_SOURCE_DIR} option, so that files referred to in
FlightGear-resources.xml are looked up relatively to the root directory
of the FlightGear repository. One could use a second XML embedded
resource declaration file compiled with a different --root option to
grab files from FGData, for instance. I would name such a file
FGData-resources.xml to be consistent with the current naming scheme.

Note: this --root option applies to the paths of real files. Don't
      confuse it with the 'prefix' attribute of <qresource> elements
      inside XML resource declaration files (such as
      FlightGear-resources.xml), which applies to the virtual path of
      each resource defined beneath.

The commands in src/Main/CMakeLists.txt ensure that
FlightGear-resources.xml is recompiled with fgrcc whenever it is
changed, and obviously also when FlightGear-resources.cxx or
FlightGear-resources.hxx is missing. However, CMake doesn't know how to
parse fgrcc XML resource declaration files, therefore when a resource is
modified but the XML file it is declared in is not (here,
FlightGear-resources.xml), you have to trigger yourself a recompilation
of the XML resource declaration file to see the new resource contents
inside FlightGear. The easiest ways to do so are:
  - either update the timestamp of the XML resource declaration file;
  - or remove one or both of the generated files
    (FlightGear-resources.cxx and FlightGear-resources.hxx here).

The EmbeddedResourceManager is created in fgMainInit() just after
Options::processOptions() set the language that was either requested by
the user or obtained from the system (locales). Resources from
FlightGear-resources.cxx are added to it, after which
EmbeddedResourceManager::selectLocale() is called with the user's
preferred locale (obtained with FGLocale::getPreferredLanguage()).

Upon reset (fgStartNewReset()), EmbeddedResourceManager::selectLocale()
is called in a similar way after Options::processOptions(), however in
this case the EmbeddedResourceManager instance doesn't have to be
recreated.
2017-06-11 18:57:58 +02:00
Florent Rougon
ed9f985f92 Fix warnings in fgrcc.cxx
The braces fix is apparently needed to avoid warnings due to a compiler
bug, or at least missing feature (cf. [1] and [2]). The other one in
std::accumulate() seems legitimate.

[1] http://en.cppreference.com/w/cpp/container/array
[2] https://stackoverflow.com/questions/14178264/c11-correct-stdarray-initialization
2017-06-11 18:52:45 +02:00
Florent Rougon
42821d6a63 Embedded resources: add a resource compiler (fgrcc)
For more info, run 'fgrcc --help' and/or read the presentation at [1]
(will be probably added to $FG_ROOT/Docs at some later point).

[1] https://sourceforge.net/p/flightgear/mailman/message/35870025/
2017-06-11 17:46:32 +02:00