Initial stab at supporting ninja and meson builds
Currently unused.
This commit is contained in:
parent
f6f35debb8
commit
a13bf95a78
@ -88,6 +88,75 @@ termux_setup_golang() {
|
||||
( cd "$TERMUX_COMMON_CACHEDIR"; tar xf "$TERMUX_BUILDGO_TAR"; mv go "$TERMUX_BUILDGO_FOLDER"; rm "$TERMUX_BUILDGO_TAR" )
|
||||
}
|
||||
|
||||
# Utility function for cmake-built packages to setup a current ninja.
|
||||
termux_setup_ninja() {
|
||||
local NINJA_VERSION=1.7.2
|
||||
local NINJA_FOLDER=$TERMUX_COMMON_CACHEDIR/ninja-$NINJA_VERSION
|
||||
if [ ! -x $NINJA_FOLDER/ninja ]; then
|
||||
mkdir -p $NINJA_FOLDER
|
||||
local NINJA_ZIP_FILE=$TERMUX_PKG_TMPDIR/ninja-$NINJA_VERSION.zip
|
||||
termux_download https://github.com/ninja-build/ninja/releases/download/v$NINJA_VERSION/ninja-linux.zip \
|
||||
$NINJA_ZIP_FILE \
|
||||
38fa8cfb9c1632a5cdf7a32fe1a7c5aa89e96c1d492c28624f4cc018e68458b9
|
||||
unzip $NINJA_ZIP_FILE -d $NINJA_FOLDER
|
||||
fi
|
||||
export PATH=$NINJA_FOLDER:$PATH
|
||||
}
|
||||
|
||||
# Utility function for cmake-built packages to setup a current meson.
|
||||
termux_setup_meson() {
|
||||
termux_setup_ninja
|
||||
local MESON_VERSION=0.41.2
|
||||
local MESON_FOLDER=$TERMUX_COMMON_CACHEDIR/meson-$MESON_VERSION
|
||||
if [ ! -d "$MESON_FOLDER" ]; then
|
||||
local MESON_TAR_NAME=meson-$MESON_VERSION.tar.gz
|
||||
local MESON_TAR_FILE=$TERMUX_PKG_TMPDIR/$MESON_TAR_NAME
|
||||
termux_download \
|
||||
https://github.com/mesonbuild/meson/releases/download/$MESON_VERSION/meson-$MESON_VERSION.tar.gz \
|
||||
$MESON_TAR_FILE \
|
||||
074dd24fd068be0893e2e45bcc35c919d8e12777e9d6a7efdf72d4dc300867ca
|
||||
tar xf "$MESON_TAR_FILE" -C "$TERMUX_COMMON_CACHEDIR"
|
||||
(cd $MESON_FOLDER && patch -p1 < $TERMUX_SCRIPTDIR/scripts/meson-android.patch)
|
||||
fi
|
||||
TERMUX_MESON="$MESON_FOLDER/meson.py"
|
||||
TERMUX_MESON_CROSSFILE=$TERMUX_COMMON_CACHEDIR/meson-crossfile-v1.txt
|
||||
if [ ! -f $TERMUX_MESON_CROSSFILE ]; then
|
||||
local MESON_CPU MESON_CPU_FAMILY
|
||||
if [ $TERMUX_ARCH = "arm" ]; then
|
||||
MESON_CPU_FAMILY="arm"
|
||||
MESON_CPU="armv7"
|
||||
elif [ $TERMUX_ARCH = "i686" ]; then
|
||||
MESON_CPU_FAMILY="x86"
|
||||
MESON_CPU="i686"
|
||||
elif [ $TERMUX_ARCH = "x86_64" ]; then
|
||||
MESON_CPU_FAMILY="x86_64"
|
||||
MESON_CPU="x86_64"
|
||||
elif [ $TERMUX_ARCH = "aarch64" ]; then
|
||||
MESON_CPU_FAMILY="arm"
|
||||
MESON_CPU="aarch64"
|
||||
else
|
||||
termux_error_exit "Unsupported arch: $TERMUX_ARCH"
|
||||
fi
|
||||
|
||||
cat > $TERMUX_MESON_CROSSFILE <<-HERE
|
||||
[binaries]
|
||||
ar = '$AR'
|
||||
c = '$CC'
|
||||
cpp = '$CXX'
|
||||
ld = '$LD'
|
||||
pkg-config = '$PKG_CONFIG'
|
||||
strip = '$STRIP'
|
||||
[properties]
|
||||
needs_exe_wrapper = true
|
||||
[host_machine]
|
||||
cpu_family = '$MESON_CPU_FAMILY'
|
||||
cpu = '$MESON_CPU'
|
||||
endian = 'little'
|
||||
system = 'android'
|
||||
HERE
|
||||
fi
|
||||
}
|
||||
|
||||
# Utility function for cmake-built packages to setup a current cmake.
|
||||
termux_setup_cmake() {
|
||||
local TERMUX_CMAKE_MAJORVESION=3.9
|
||||
@ -819,11 +888,26 @@ termux_step_configure_cmake () {
|
||||
$TERMUX_PKG_EXTRA_CONFIGURE_ARGS $TOOLCHAIN_ARGS
|
||||
}
|
||||
|
||||
termux_step_configure_meson () {
|
||||
termux_setup_meson
|
||||
CC=gcc CXX=g++ $TERMUX_MESON \
|
||||
$TERMUX_PKG_SRCDIR \
|
||||
$TERMUX_PKG_BUILDDIR \
|
||||
--cross-file $TERMUX_MESON_CROSSFILE \
|
||||
--prefix $TERMUX_PREFIX \
|
||||
--libdir lib \
|
||||
--buildtype minsize \
|
||||
--strip \
|
||||
$TERMUX_PKG_EXTRA_CONFIGURE_ARGS
|
||||
}
|
||||
|
||||
termux_step_configure () {
|
||||
if [ "$TERMUX_PKG_FORCE_CMAKE" == 'no' ] && [ -f "$TERMUX_PKG_SRCDIR/configure" ]; then
|
||||
termux_step_configure_autotools
|
||||
elif [ -f "$TERMUX_PKG_SRCDIR/CMakeLists.txt" ]; then
|
||||
termux_step_configure_cmake
|
||||
elif [ -f "$TERMUX_PKG_SRCDIR/meson.build" ]; then
|
||||
termux_step_configure_meson
|
||||
fi
|
||||
}
|
||||
|
||||
@ -850,6 +934,8 @@ termux_step_make_install() {
|
||||
else
|
||||
make -j 1 ${TERMUX_PKG_EXTRA_MAKE_ARGS} ${TERMUX_PKG_MAKE_INSTALL_TARGET}
|
||||
fi
|
||||
elif test -f build.ninja; then
|
||||
ninja install
|
||||
fi
|
||||
}
|
||||
|
||||
|
103
scripts/meson-android.patch
Normal file
103
scripts/meson-android.patch
Normal file
@ -0,0 +1,103 @@
|
||||
diff -u -r ../meson-0.41.2/mesonbuild/build.py ./mesonbuild/build.py
|
||||
--- ../meson-0.41.2/mesonbuild/build.py 2017-07-19 11:39:22.000000000 +0200
|
||||
+++ ./mesonbuild/build.py 2017-07-29 00:28:05.082804622 +0200
|
||||
@@ -21,7 +21,7 @@
|
||||
from .mesonlib import File, MesonException
|
||||
from .mesonlib import flatten, typeslistify, stringlistify, classify_unity_sources
|
||||
from .mesonlib import get_filenames_templates_dict, substitute_values
|
||||
-from .environment import for_windows, for_darwin, for_cygwin
|
||||
+from .environment import for_windows, for_darwin, for_cygwin, for_android
|
||||
from .compilers import is_object, clike_langs, sort_clike, lang_suffixes
|
||||
|
||||
known_basic_kwargs = {'install': True,
|
||||
@@ -1164,6 +1164,7 @@
|
||||
if not hasattr(self, 'suffix'):
|
||||
self.suffix = None
|
||||
self.basic_filename_tpl = '{0.prefix}{0.name}.{0.suffix}'
|
||||
+ self.is_cross = is_cross
|
||||
self.determine_filenames(is_cross, environment)
|
||||
|
||||
def determine_filenames(self, is_cross, env):
|
||||
@@ -1272,25 +1273,26 @@
|
||||
|
||||
def process_kwargs(self, kwargs, environment):
|
||||
super().process_kwargs(kwargs, environment)
|
||||
- # Shared library version
|
||||
- if 'version' in kwargs:
|
||||
- self.ltversion = kwargs['version']
|
||||
- if not isinstance(self.ltversion, str):
|
||||
- raise InvalidArguments('Shared library version needs to be a string, not ' + type(self.ltversion).__name__)
|
||||
- if not re.fullmatch(r'[0-9]+(\.[0-9]+){0,2}', self.ltversion):
|
||||
- raise InvalidArguments('Invalid Shared library version "{0}". Must be of the form X.Y.Z where all three are numbers. Y and Z are optional.'.format(self.ltversion))
|
||||
- # Try to extract/deduce the soversion
|
||||
- if 'soversion' in kwargs:
|
||||
- self.soversion = kwargs['soversion']
|
||||
- if isinstance(self.soversion, int):
|
||||
- self.soversion = str(self.soversion)
|
||||
- if not isinstance(self.soversion, str):
|
||||
- raise InvalidArguments('Shared library soversion is not a string or integer.')
|
||||
- elif self.ltversion:
|
||||
- # library version is defined, get the soversion from that
|
||||
- # We replicate what Autotools does here and take the first
|
||||
- # number of the version by default.
|
||||
- self.soversion = self.ltversion.split('.')[0]
|
||||
+ if not for_android(self.is_cross, environment):
|
||||
+ # Shared library version
|
||||
+ if 'version' in kwargs:
|
||||
+ self.ltversion = kwargs['version']
|
||||
+ if not isinstance(self.ltversion, str):
|
||||
+ raise InvalidArguments('Shared library version needs to be a string, not ' + type(self.ltversion).__name__)
|
||||
+ if not re.fullmatch(r'[0-9]+(\.[0-9]+){0,2}', self.ltversion):
|
||||
+ raise InvalidArguments('Invalid Shared library version "{0}". Must be of the form X.Y.Z where all three are numbers. Y and Z are optional.'.format(self.ltversion))
|
||||
+ # Try to extract/deduce the soversion
|
||||
+ if 'soversion' in kwargs:
|
||||
+ self.soversion = kwargs['soversion']
|
||||
+ if isinstance(self.soversion, int):
|
||||
+ self.soversion = str(self.soversion)
|
||||
+ if not isinstance(self.soversion, str):
|
||||
+ raise InvalidArguments('Shared library soversion is not a string or integer.')
|
||||
+ elif self.ltversion:
|
||||
+ # library version is defined, get the soversion from that
|
||||
+ # We replicate what Autotools does here and take the first
|
||||
+ # number of the version by default.
|
||||
+ self.soversion = self.ltversion.split('.')[0]
|
||||
# Visual Studio module-definitions file
|
||||
if 'vs_module_defs' in kwargs:
|
||||
path = kwargs['vs_module_defs']
|
||||
diff -u -r ../meson-0.41.2/mesonbuild/environment.py ./mesonbuild/environment.py
|
||||
--- ../meson-0.41.2/mesonbuild/environment.py 2017-07-19 11:39:22.000000000 +0200
|
||||
+++ ./mesonbuild/environment.py 2017-07-29 00:08:12.592115029 +0200
|
||||
@@ -212,6 +212,17 @@
|
||||
return env.cross_info.config['host_machine']['system'] == 'darwin'
|
||||
return False
|
||||
|
||||
+def for_android(is_cross, env):
|
||||
+ """
|
||||
+ Host machine is Android?
|
||||
+
|
||||
+ Note: 'host' is the machine on which compiled binaries will run
|
||||
+ """
|
||||
+ if not is_cross:
|
||||
+ return mesonlib.is_android()
|
||||
+ elif env.cross_info.has_host():
|
||||
+ return env.cross_info.config['host_machine']['system'] == 'android'
|
||||
+ return False
|
||||
|
||||
def search_version(text):
|
||||
# Usually of the type 4.1.4 but compiler output may contain
|
||||
diff -u -r ../meson-0.41.2/mesonbuild/mesonlib.py ./mesonbuild/mesonlib.py
|
||||
--- ../meson-0.41.2/mesonbuild/mesonlib.py 2017-07-19 11:39:22.000000000 +0200
|
||||
+++ ./mesonbuild/mesonlib.py 2017-07-29 00:08:27.543948195 +0200
|
||||
@@ -219,6 +219,12 @@
|
||||
def is_linux():
|
||||
return platform.system().lower() == 'linux'
|
||||
|
||||
+def is_android():
|
||||
+ import sysconfig
|
||||
+ # Taken from Lib/test/support/__init__.py of the python source:
|
||||
+ _ANDROID_API_LEVEL = sysconfig.get_config_var('ANDROID_API_LEVEL')
|
||||
+ return _ANDROID_API_LEVEL is not None and _ANDROID_API_LEVEL > 0
|
||||
+
|
||||
def is_windows():
|
||||
platname = platform.system().lower()
|
||||
return platname == 'windows' or 'mingw' in platname
|
Loading…
Reference in New Issue
Block a user