Browse Source

mingw-w64-meson: added to repo

Signed-off-by: Steven Noonan <steven@uplinklabs.net>
master
Steven Noonan 1 year ago
parent
commit
fbccd1e891
Signed by: steven GPG Key ID: 408EEB508ED0CD4D
  1. 43
      mingw-w64-meson/PKGBUILD
  2. 33
      mingw-w64-meson/meson-mingw-wrapper
  3. 77
      mingw-w64-meson/toolchain_generator.py

43
mingw-w64-meson/PKGBUILD

@ -0,0 +1,43 @@
# Maintainer: drakkan <nicola.murino at gmail dot com>
pkgname=mingw-w64-meson
pkgver=1
pkgrel=19
arch=('any')
pkgdesc="Meson wrapper for MinGW (mingw-w64)"
depends=('meson' 'mingw-w64-gcc' 'mingw-w64-pkg-config')
makedepends=('mingw-w64-environment')
optdepends=('mingw-w64-wine: Set NEED_WINE env variable in your PKGBUILD to use wine support in meson'
'mingw-w64-cmake')
license=("GPL")
url="http://fedoraproject.org/wiki/MinGW"
source=("toolchain_generator.py"
"meson-mingw-wrapper")
sha256sums=('a598c4f27b4a03063c5515ee2ffb7213ea969f6c64d88979f55c0542729b6b80'
'c91f2bbcafad7b742f13c6bd46324a03b70066b348621ce6a20f4a05005985ef')
_architectures="i686-w64-mingw32 x86_64-w64-mingw32"
build() {
for _arch in ${_architectures}; do
unset CPPFLAGS
unset CFLAGS
unset CXXFLAGS
unset LDFLAGS
source mingw-env ${_arch}
python toolchain_generator.py --arch ${_arch} --output-file toolchain-${_arch}.meson
python toolchain_generator.py --arch ${_arch} --output-file toolchain-${_arch}-wine.meson --need-exe-wrapper
sed "s|@TRIPLE@|${_arch}|g;" meson-mingw-wrapper > ${_arch}-meson
done
}
package() {
install -d "${pkgdir}"/usr/bin
install -d "${pkgdir}"/usr/share/mingw
install -m 755 "${srcdir}/toolchain_generator.py" "$pkgdir/usr/bin/meson-cross-file-generator"
for _arch in ${_architectures}; do
install -m 755 "${srcdir}/${_arch}-meson" "$pkgdir/usr/bin/${_arch}-meson"
install -m 644 toolchain-${_arch}.meson "${pkgdir}"/usr/share/mingw/
install -m 644 toolchain-${_arch}-wine.meson "${pkgdir}"/usr/share/mingw/
done
}
# vim: ts=2 sw=2 et:

33
mingw-w64-meson/meson-mingw-wrapper

@ -0,0 +1,33 @@
#!/bin/sh
if [ -z ${CROSS_FILE} ]
then
if [ -z ${NEED_WINE} ]
then
CROSS_FILE=/usr/share/mingw/toolchain-@TRIPLE@.meson
else
CROSS_FILE=/usr/share/mingw/toolchain-@TRIPLE@-wine.meson
fi
fi
exec meson setup \
--prefix /usr/@TRIPLE@ \
--libdir /usr/@TRIPLE@/lib \
--libexecdir /usr/@TRIPLE@/lib \
--bindir /usr/@TRIPLE@/bin \
--sbindir /usr/@TRIPLE@/bin \
--includedir /usr/@TRIPLE@/include \
--datadir /usr/@TRIPLE@/share \
--mandir /usr/@TRIPLE@/share/man \
--infodir /usr/@TRIPLE@/share/info \
--localedir /usr/@TRIPLE@/share/locale \
--sysconfdir /usr/@TRIPLE@/etc \
--localstatedir /var \
--sharedstatedir /var/lib \
--buildtype release \
--wrap-mode nofallback \
-D b_lto=true \
-D strip=true \
--cross-file ${CROSS_FILE} \
--default-library shared \
"$@"

77
mingw-w64-meson/toolchain_generator.py

@ -0,0 +1,77 @@
#!/usr/bin/env python
import argparse
import configparser
import os
class CrossFileGenerator:
def __init__(self, arch, output_file, need_exe_wrapper):
self.arch = arch
self.output_file = output_file
self.need_exe_wrapper = need_exe_wrapper
self.cflags = os.environ['CFLAGS'] if 'CFLAGS' in os.environ else ''
self.cxxflags = os.environ["CXXFLAGS"] if 'CXXFLAGS' in os.environ else ''
self.ldflags = os.environ["LDFLAGS"] if 'LDFLAGS' in os.environ else ''
if self.arch == 'i686-w64-mingw32':
self.cpu_family = "x86"
self.processor = 'i686'
else:
self.cpu_family = 'x86_64'
self.processor = 'x86_64'
def generate(self):
config = configparser.ConfigParser()
config['binaries'] = self.get_binaries_section()
config['properties'] = self.get_properties_section()
config['host_machine'] = self.get_host_machine_section()
with open(self.output_file, 'w') as configfile:
config.write(configfile)
def get_binaries_section(self):
binaries = {'c':"'{}-gcc'".format(self.arch),
'cpp':"'{}-g++'".format(self.arch),
'fortran':"'{}-gfortran'".format(self.arch),
'ar':"'{}-gcc-ar'".format(self.arch),
'pkgconfig':"'{}-pkg-config'".format(self.arch),
'ranlib':"'{}-gcc-ranlib'".format(self.arch),
'strip':"'{}-strip'".format(self.arch),
'windres':"'{}-windres'".format(self.arch),
'cmake':"'{}-cmake'".format(self.arch),
}
if self.need_exe_wrapper:
binaries.update({'exe_wrapper':"'{}-wine'".format(self.arch)})
return binaries
def get_properties_section(self):
return {'root':"'{}'".format(self.arch),
'sys_root':"'/usr/{}'".format(self.arch),
'c_args':[f for f in self.cflags.split(" ") if f],
'cpp_args':[f for f in self.cxxflags.split(" ") if f],
'c_link_args':[f for f in self.ldflags.split(" ") if f],
'cpp_link_args':[f for f in self.ldflags.split(" ") if f],
'needs_exe_wrapper':'true'
}
def get_host_machine_section(self):
return {'system':"'windows'",
'cpu_family':"'{}'".format(self.cpu_family),
'cpu':"'{}'".format(self.processor),
'endian':"'little'"
}
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Generate a meson cross file using CFLAGS/CXXFLAGS/LDFLAGS from env vars',
add_help=False)
required = parser.add_argument_group('required arguments')
optional = parser.add_argument_group('optional arguments')
required.add_argument('--arch', type=str, required=True, choices=['i686-w64-mingw32', 'x86_64-w64-mingw32'],
help='Architecture to use for cross file generation')
required.add_argument('--output-file', type=str, required=True, help='Write the generated cross file to this path')
optional.add_argument('-h', '--help', action='help', default=argparse.SUPPRESS,
help='show this help message and exit')
optional.add_argument("--need-exe-wrapper", dest='need_exe_wrapper', action='store_true', help="Add wine as exe wrapper")
args = parser.parse_args()
generator = CrossFileGenerator(args.arch, args.output_file, args.need_exe_wrapper)
generator.generate()
Loading…
Cancel
Save