From 1c62c9d2aef8046ff10ded70e3c8cd5122c637cd Mon Sep 17 00:00:00 2001 From: Guilherme Janczak Date: Thu, 2 Jan 2025 17:25:12 +0000 Subject: [PATCH] make producing the Windows installer optional And fix up some comments along the way. --- docs/CHANGELOG-1.3.0.md | 1 + meson.build | 170 ++++++++++++++++++++-------------------- meson_options.txt | 4 +- 3 files changed, 91 insertions(+), 84 deletions(-) diff --git a/docs/CHANGELOG-1.3.0.md b/docs/CHANGELOG-1.3.0.md index 3f26571..8b9b0d6 100644 --- a/docs/CHANGELOG-1.3.0.md +++ b/docs/CHANGELOG-1.3.0.md @@ -12,4 +12,5 @@ Changes in dictpw 1.3.0: - Add a portable install option to the Windows installer - Add an option to add the program to $env:PATH on Windows - Windows on 32-bit ARM support (for how long?) +- Make building the Windows installer optional diff --git a/meson.build b/meson.build index 29f3207..700bfad 100644 --- a/meson.build +++ b/meson.build @@ -78,36 +78,15 @@ subdir('test') install_man('src/dictpw.1') -if host_machine.system() == 'windows' or host_machine.system() == 'cygwin' +if host_machine.system() != 'windows' and host_machine.system() == 'cygwin' + if not get_option('installer').auto() + error('The \'installer\' feature is only for Windows hosts.') + endif +else # Build a .txt version of the manual too. For producing the installer. - # Create groff IR version of the manual. - man_groff = custom_target('man_groff', - command: [find_program('groff'), '-mdoc', '-Tascii', - '-Z'], - input: [files('src/dictpw.1')], - feed: true, - output: ['dictpw.groff'], - capture: true) - # Convert groff to ASCII with Unix newlines. - # '-bcou' means "don't use ANSI escapes". - man_unix = custom_target('man_unix', - command: [find_program('grotty'), '-bcou'], - input: [man_groff], - feed: true, - output: ['dictpw.txt.unix'], - capture: true) - unix2dos = find_program('unix2dos') # Convert Unix newlines to DOS newlines. - man = custom_target('man', - command: [unix2dos], - input: [man_unix], - feed: true, - output: ['dictpw.txt'], - capture: true, - build_by_default: true) - # Put copies of the license and the README with DOS newlines in the build # directory too. license = custom_target('license', @@ -125,64 +104,89 @@ if host_machine.system() == 'windows' or host_machine.system() == 'cygwin' capture: true, build_by_default: true) - inst_cmd = [find_program('iscc'), - '-DBUILDDIR=' + meson.current_build_dir(), - '-Fsetup-dictpw', - '-DMESON', - '-DNAME=' + meson.project_name(), - '-DVERSION=' + meson.project_version(), - '-DURL=https://github.com/guijan/dictpw', - # Inno Setup's ExtractFileName (basename function) expects the - # Windows path separator ('\'), but Meson uses the Unix path - # separator ('/'), so create a basename now. - '-DEXEFILE=' + dictpw.full_path(), - '-DLICENSE=' + license.full_path(), - '-DMANFILE=' + man.full_path(), - '-DREADME=' + readme.full_path(),] - - fs = import('fs') - if libbsd_dep.found() and libbsd_dep.type_name() == 'internal' - inst_cmd += '-DLIBOBSD_LICENSE=subprojects/libobsd/LICENSE_libobsd.txt' - endif - # Programs built in Cygwin and MSYS2's MSYS environment are linked against - # a special DLL with their implementations of Unix inside, distribute it. - dll_copy = [] - if host_machine.system() == 'cygwin' - dlls = ['/usr/bin/msys-2.0.dll', '/bin/cygwin1.dll'] - found = false - foreach dll : dlls - if fs.is_file(dll) - dll_copy += fs.copyfile(dll) - inst_cmd += '-DMSYS_DLL=' + fs.name(dll) - found = true - break + if get_option('installer').allowed() + # Create groff IR version of the manual. + man_groff = custom_target('man_groff', + command: [find_program('groff'), '-mdoc', + '-Tascii', '-Z'], + input: [files('src/dictpw.1')], + feed: true, + output: ['dictpw.groff'], + capture: true) + # Convert groff to ASCII with Unix newlines. + # '-bcou' means "don't use ANSI escapes". + man_unix = custom_target('man_unix', + command: [find_program('grotty'), '-bcou'], + input: [man_groff], + feed: true, + output: ['dictpw.txt.unix'], + capture: true) + man = custom_target('man', + command: [unix2dos], + input: [man_unix], + feed: true, + output: ['dictpw.txt'], + capture: true, + build_by_default: true) + + inst_cmd = [find_program('iscc'), + '-DBUILDDIR=' + meson.current_build_dir(), + '-Fsetup-dictpw', + '-DMESON', + '-DNAME=' + meson.project_name(), + '-DVERSION=' + meson.project_version(), + '-DURL=https://github.com/guijan/dictpw', + '-DEXEFILE=' + dictpw.full_path(), + '-DLICENSE=' + license.full_path(), + '-DMANFILE=' + man.full_path(), + '-DREADME=' + readme.full_path()] + + fs = import('fs') + if libbsd_dep.found() and libbsd_dep.type_name() == 'internal' + # Meson doesn't have a way to pass files from subprojects, so we work + # around it by passing the filename of a known location. + inst_cmd += '-DLIBOBSD_LICENSE=subprojects/libobsd/LICENSE_libobsd.txt' + endif + # Cygwin and MSYS environment programs are linked against a special DLL + # with their implementations of Unix inside, distribute it. + dll_copy = [] + if host_machine.system() == 'cygwin' + dlls = ['/usr/bin/msys-2.0.dll', '/bin/cygwin1.dll'] + found = false + foreach dll : dlls + if fs.is_file(dll) + dll_copy += fs.copyfile(dll) + inst_cmd += '-DMSYS_DLL=' + fs.name(dll) + found = true + break + endif + endforeach + if not found + error('cygwin/msys2 DLL not found') endif - endforeach - if not found - error('cygwin/msys2 DLL not found') endif + # Mapping between: + # https://mesonbuild.com/Reference-tables.html + # https://jrsoftware.org/ishelp/index.php?topic=archidentifiers + meson_to_iscc_arch = { + 'arm': 'arm32compatible', + 'aarch64': 'arm64', + 'x86_64': 'x64compatible', + 'x86': 'x86compatible' + } + inst_cmd += '-DARCH=' + meson_to_iscc_arch[host_machine.cpu_family()] + if cc.get_id() == 'msvc' + # https://learn.microsoft.com/en-us/visualstudio/releases/2022/compatibility#build-apps-that-run-on-windows-clients + winmin = '6.1sp1' + else + # https://www.msys2.org/docs/windows_support/ + # Minimum package requirement, not minimum toolchain requirement, I'm not + # going to bother figuring out which is right, so use the highest one. + winmin = '6.3' + endif + inst_cmd += '-DWIN_MIN=' + winmin + run_target('installer', + command: inst_cmd + files('src/dictpw.iss'), + depends: [dictpw, man, license, readme, dll_copy]) endif - # Mapping between: - # https://mesonbuild.com/Reference-tables.html - # https://jrsoftware.org/ishelp/index.php?topic=archidentifiers - meson_to_iscc_arch = { - 'arm': 'arm32compatible', - 'aarch64': 'arm64', - 'x86_64': 'x64compatible', - 'x86': 'x86compatible' - } - inst_cmd += '-DARCH=' + meson_to_iscc_arch[host_machine.cpu_family()] - if cc.get_id() == 'msvc' - # https://learn.microsoft.com/en-us/visualstudio/releases/2022/compatibility#build-apps-that-run-on-windows-clients - winmin = '6.1sp1' - else - # https://www.msys2.org/docs/windows_support/ - # Minimum package requirement, not minimum toolchain requirement, I'm not - # going to bother figuring out which is right, so use the highest one. - winmin = '6.3' - endif - inst_cmd += '-DWIN_MIN=' + winmin - run_target('installer', - command: inst_cmd + files('src/dictpw.iss'), - depends: [dictpw, man, license, readme, dll_copy]) endif diff --git a/meson_options.txt b/meson_options.txt index 5cc203b..9bfd714 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Guilherme Janczak +# Copyright (c) 2022, 2025 Guilherme Janczak # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -14,6 +14,8 @@ option('dict', type: 'string', value: 'eff_large_wordlist.txt', description: 'Generate the dictionary from the specified file.') +option('installer', type: 'feature', + 'description: 'Build the installer on Windows') # Only for internal usage.