We are using `ctpp2c` when building kiwix-lib to compile embedded resources.
As `ctpp2c` will be used in the host machine, it always need to be
compiled for the host (native).
But we still want tho ctpp2 library compiled for the target platform.
As we don't want handle the conflict between two dynamic lib with the same
name but for two different platforms, we build ctpp2c statically.
"PIE" option is for executable and we don't build a executable.
Using a combination of "pie", "pic", shared and static libraries makes the
compilation of `kiwix-lib` fails with a "undefined symbol main".
Removing the pie option solve the problem.
The `cross_path_only` option used in `cmake` and `meson` builder where
mainly here to avoid kiwix-build to set the env with `CC` and `CXX`
variable set.
This is needed as `cmake` and `meson` will find the correct compiler
from the cross-config file.
However, even for them, we need to set some environment variables
(especially PKG_CONFIG_LIBDIR)
So we need another level a configuration to be able to set a cross_env
without setting the compiler's env variables.
Those option should be set by build system, not by kiwix-build.
Moreover, this impact other libraries (as icu) and generate pretty big
library binaries.
On android platform, we load the ICU data as external data, not embeded
in the kiwix-lib.
So we need to generate correctly the dat file and use it in kiwix-android.
We don't need all the ICU data and we need to reduce binaries' size
(Especially for android where we have a limit of 50Mo per APK).
By removing unwanted ICU data, we reduce a lot the data size and so
the final binaries' size.
There is also some "problems" to compile the `ja.txt` collfiles,
the "resource compiler" crashes.
As we don't need it, we also remove it.
ICU doesn't provide data sources in their release archives but directly
pre-compiled data.
As we need to compile ourselves our data to remove unwanted data, we need
to get the sources directly from the SVN.
The custom app to build must be specified as an option when running
kiwix-build.
In the same way, the zim file to download must be specified in the
`info.json` (`zim_url` key) or given as option.
Cmake use the 'Windows' name to detect we are building to Windows but
meson use the lowered 'windows' string.
So we need to lower the system declared in the cross-env when generating
the meson cross_file.
The target (`platform_info.build`) is not enough to get a correct
cross_env. For android apk, the target is always "android" but we want
different cross_env depending of the target arch.
The `platform_info` already know for which arch we are building so
let's make platform_info generate the cross_env directly.
Travis fails if we try to build a lot of targets in the same job because
of quota limit. By removing intermediate build files, we limit our disk
usage.
Previous script (from kiwix repository) created a APK with all architecture embeded.
Now, we generated a APK per architecture. It simplify the build process and
generate smaller APKs.
It seems that last meson version (0.40.0) do not pass cross compilation
extra_args to compiler when checking for headers.
Thus, the kiwix-lib check for ctpp2 headers fails because the WIN32
define is not present. So kiwix-lib is compiled without CTPP2 but
kiwix-tool compile as if kiwix-lib where compile with CTPP2 and fails.
By making CTPP2 headers check for `__WINGW32__` we workaround this problem.
I don't know if this is a bug in meson, ctpp2 or kiwix-lib but this small
fix allow to compile correctly with last meson version.