From 9f8e5cebd6dbbb7546e8917e6c59284699a48d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 8 Oct 2019 00:03:06 +0300 Subject: [PATCH] windres-wrapper: Implement the -F/--target flag like GNU windres The values passed to this parameter aren't arch/vendor/os triples, but bfd target names. --- wrappers/windres-wrapper.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/wrappers/windres-wrapper.c b/wrappers/windres-wrapper.c index 3622289..435c826 100644 --- a/wrappers/windres-wrapper.c +++ b/wrappers/windres-wrapper.c @@ -156,7 +156,7 @@ int _tmain(int argc, TCHAR* argv[]) { if (!target) target = _T(DEFAULT_TARGET); - + const TCHAR *bfd_target = NULL; const TCHAR *input = _T("-"); const TCHAR *output = _T("/dev/stdout"); const TCHAR *input_format = _T("rc"); @@ -199,7 +199,7 @@ int _tmain(int argc, TCHAR* argv[]) { else OPTION("-o", "--output", output) else OPTION("-J", "--input-format", input_format) else OPTION("-O", "--output-format", output_format) - else OPTION("-F", "--target", target) + else OPTION("-F", "--target", bfd_target) else IF_MATCH_EITHER("-I", "--include-dir") { SEPARATE_ARG(includes[nb_includes++]); } else if (_tcsstart(argv[i], _T("--include-dir="))) { @@ -240,6 +240,16 @@ int _tmain(int argc, TCHAR* argv[]) { error(basename, _T("rip: `"TS"'"), argv[i]); } } + if (bfd_target) { + if (!_tcscmp(bfd_target, _T("pe-x86-64")) || + !_tcscmp(bfd_target, _T("pei-x86-64"))) + target = _T("x86_64-w64-mingw32"); + else if (!_tcscmp(bfd_target, _T("pe-i386")) || + !_tcscmp(bfd_target, _T("pei-x86-64"))) + target = _T("x86_64-w64-mingw32"); + else + error(basename, _T("unsupported target: `"TS"'"), bfd_target); + } TCHAR *arch = _tcsdup(target); TCHAR *dash = _tcschr(arch, '-');