diff options
author | Nicola Murino | 2019-12-08 12:03:14 +0100 |
---|---|---|
committer | Nicola Murino | 2019-12-08 12:03:14 +0100 |
commit | dd344c749391da36d80b58ee17b6b123f9169468 (patch) | |
tree | 0a2d883eb4426a55e47da5434bf99bbc0f5d65d0 | |
parent | 53faa09ac862c1164f2a071b7914f24569a00cff (diff) | |
download | aur-dd344c749391da36d80b58ee17b6b123f9169468.tar.gz |
use *flags from mingw-w64-environment
-rw-r--r-- | .SRCINFO | 7 | ||||
-rw-r--r-- | PKGBUILD | 22 | ||||
-rw-r--r-- | toolchain-mingw.meson | 25 | ||||
-rwxr-xr-x | toolchain_generator.py | 76 |
4 files changed, 91 insertions, 39 deletions
@@ -1,18 +1,19 @@ pkgbase = mingw-w64-meson pkgdesc = Meson wrapper for MinGW (mingw-w64) pkgver = 1 - pkgrel = 16 + pkgrel = 17 url = http://fedoraproject.org/wiki/MinGW arch = any license = GPL + makedepends = mingw-w64-environment depends = meson depends = mingw-w64-gcc depends = mingw-w64-pkg-config optdepends = mingw-w64-wine: Set NEED_WINE env variable in your PKGBUILD to use wine support in meson optdepends = mingw-w64-cmake - source = toolchain-mingw.meson + source = toolchain_generator.py source = meson-mingw-wrapper - sha256sums = a611b990aff3b6755f1f61a3724ec94ad629c68a662b1a3863d03e8efc6d1100 + sha256sums = e7635c6cbb1c4c99fc41910083febfb3d0f7d4b6995537a2fb7ab55322ee2910 sha256sums = c91f2bbcafad7b742f13c6bd46324a03b70066b348621ce6a20f4a05005985ef pkgname = mingw-w64-meson @@ -1,30 +1,30 @@ # Maintainer: drakkan <nicola.murino at gmail dot com> pkgname=mingw-w64-meson pkgver=1 -pkgrel=16 +pkgrel=17 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-mingw.meson" +source=("toolchain_generator.py" "meson-mingw-wrapper") -sha256sums=('a611b990aff3b6755f1f61a3724ec94ad629c68a662b1a3863d03e8efc6d1100' +sha256sums=('e7635c6cbb1c4c99fc41910083febfb3d0f7d4b6995537a2fb7ab55322ee2910' 'c91f2bbcafad7b742f13c6bd46324a03b70066b348621ce6a20f4a05005985ef') _architectures="i686-w64-mingw32 x86_64-w64-mingw32" build() { for _arch in ${_architectures}; do - if [ ${_arch} = "i686-w64-mingw32" ]; then - _cpu_family="x86" - else - _cpu_family="x86_64" - fi - sed "s|@TRIPLE@|${_arch}|g;s|@PROCESSOR@|${_arch::-12}|g;s|@CPU_FAMILY@|${_cpu_family}|g" toolchain-mingw.meson > toolchain-${_arch}.meson - sed "s|@TRIPLE@|${_arch}|g;s|@PROCESSOR@|${_arch::-12}|g;s|@CPU_FAMILY@|${_cpu_family}|g" toolchain-mingw.meson > toolchain-${_arch}-wine.meson - sed -i '/^exe_wrapper/ d' toolchain-${_arch}.meson + 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 } diff --git a/toolchain-mingw.meson b/toolchain-mingw.meson deleted file mode 100644 index 9689f59a34d5..000000000000 --- a/toolchain-mingw.meson +++ /dev/null @@ -1,25 +0,0 @@ -[binaries] -c = '@TRIPLE@-gcc' -cpp = '@TRIPLE@-g++' -fortran = '@TRIPLE@-gfortran' -ar = '@TRIPLE@-gcc-ar' -pkgconfig = '@TRIPLE@-pkg-config' -ranlib = '@TRIPLE@-gcc-ranlib' -strip = '@TRIPLE@-strip' -windres = '@TRIPLE@-windres' -exe_wrapper = '@TRIPLE@-wine' -cmake = '@TRIPLE@-cmake' - -[properties] -root = '@TRIPLE@' -c_args = ['-D_FORTIFY_SOURCE=2', '-O2', '-pipe', '-fno-plt', '-fexceptions', '--param=ssp-buffer-size=4'] -cpp_args = ['-D_FORTIFY_SOURCE=2', '-O2', '-pipe', '-fno-plt', '-fexceptions', '--param=ssp-buffer-size=4'] -c_link_args = ['-Wl,-O1,--sort-common,--as-needed', '-fstack-protector'] -cpp_link_args = ['-Wl,-O1,--sort-common,--as-needed', '-fstack-protector'] -needs_exe_wrapper = true - -[host_machine] -system = 'windows' -cpu_family = '@CPU_FAMILY@' -cpu = '@PROCESSOR@' -endian = 'little' diff --git a/toolchain_generator.py b/toolchain_generator.py new file mode 100755 index 000000000000..0ef4e5e9dab0 --- /dev/null +++ b/toolchain_generator.py @@ -0,0 +1,76 @@ +#!/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"] + self.cxxflags = os.environ["CXXFLAGS"] + self.ldflags = os.environ["LDFLAGS"] + 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), + '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 exec wrapper") + args = parser.parse_args() + generator = CrossFileGenerator(args.arch, args.output_file, args.need_exe_wrapper) + generator.generate() |