Compare commits

...

2 Commits

Author SHA1 Message Date
49ee551b9b
Use LocalAppData for thumbnails on Windows 2023-06-26 02:11:12 +02:00
089c90004b
Produce a basic Windows installer package
We're very early adopters of msitools' new UI feature,
so this doesn't work on MSYS2 directly yet due to an old version.
2023-06-26 02:10:31 +02:00
6 changed files with 125 additions and 3 deletions

View File

@ -65,14 +65,15 @@ Windows
~~~~~~~
'fiv' can be cross-compiled for Windows, provided that you install a bunch of
dependencies listed at the beginning of 'msys2-configure.sh',
plus rsvg-convert from librsvg2, and icotool from icoutils.
plus rsvg-convert from librsvg2, icotool from icoutils, and msitools ≥ 0.102.
Beware that the build will take up about a gigabyte of disk space.
$ sh -e msys2-configure.sh builddir
$ meson install -C builddir
If everything succeeds, you will find a portable build of the application
in the 'builddir/package' subdirectory. No installer is provided yet.
in the 'builddir/package' subdirectory, and a very basic MSI installation
package in 'builddir'.
Faster colour management
^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -100,7 +100,16 @@ mark_thumbnail_lq(cairo_surface_t *surface)
static gchar *
fiv_thumbnail_get_root(void)
{
#ifdef G_OS_WIN32
// We can do better than GLib with FOLDERID_InternetCache,
// and we don't want to place .cache directly in the user's home.
// TODO(p): Register this thumbnail path using the installer:
// https://learn.microsoft.com/en-us/windows/win32/lwef/disk-cleanup
gchar *cache_dir =
g_build_filename(g_get_user_data_dir(), PROJECT_NAME, NULL);
#else
gchar *cache_dir = get_xdg_home_dir("XDG_CACHE_HOME", ".cache");
#endif
gchar *thumbnails_dir = g_build_filename(cache_dir, "thumbnails", NULL);
g_free(cache_dir);
return thumbnails_dir;

69
fiv.wxs.in Normal file
View File

@ -0,0 +1,69 @@
<?xml version='1.0' encoding='utf-8'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
<?define FullName = "@ProjectName@ @ProjectVersion@" ?>
<?if $(sys.BUILDARCH) = x64 ?>
<?define ProgramFilesFolder = "ProgramFiles64Folder" ?>
<?else?>
<?define ProgramFilesFolder = "ProgramFilesFolder" ?>
<?endif?>
<Product Id='*'
Name='$(var.FullName)'
UpgradeCode='a3e64e2d-4310-4c5f-8562-bb0e0b3e0a53'
Language='1033'
Codepage='1252'
Version='@ProjectVersion@'
Manufacturer='Premysl Eric Janouch'>
<Package Id='*'
Keywords='Installer,Image,Viewer'
Description='$(var.FullName) Installer'
Manufacturer='Premysl Eric Janouch'
InstallerVersion='200'
Compressed='yes'
Languages='1033'
SummaryCodepage='1252' />
<Media Id='1' Cabinet='data.cab' EmbedCab='yes' />
<Icon Id='fiv.ico' SourceFile='fiv.ico' />
<Property Id='ARPPRODUCTICON' Value='fiv.ico' />
<Property Id='ARPURLINFOABOUT' Value='https://git.janouch.name/p/fiv' />
<UIRef Id='WixUI_Minimal' />
<!-- This isn't supported by msitools, but is necessary for WiX.
<WixVariable Id='WixUILicenseRtf' Value='License.rtf' />
-->
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='$(var.ProgramFilesFolder)' Name='Files'>
<Directory Id='INSTALLDIR' Name='$(var.FullName)' />
</Directory>
<Directory Id='ProgramMenuFolder' Name='Programs'>
<Directory Id='ProgramMenuDir' Name='$(var.FullName)'>
<Component Id='ProgramMenuDir' Guid='*'>
<Shortcut Id='ProgramsMenuShortcut'
Name='@ProjectName@'
Target='[INSTALLDIR]\fiv.exe'
WorkingDirectory='INSTALLDIR'
Arguments='"%USERPROFILE%"'
Icon='fiv.ico' />
<RemoveFolder Id='ProgramMenuDir' On='uninstall' />
<RegistryValue Root='HKCU'
Key='Software\[Manufacturer]\[ProductName]'
Type='string'
Value=''
KeyPath='yes' />
</Component>
</Directory>
</Directory>
<Directory Id='DesktopFolder' Name='Desktop' />
</Directory>
<Feature Id='Complete' Level='1'>
<ComponentGroupRef Id='CG.fiv' />
<ComponentRef Id='ProgramMenuDir' />
</Feature>
</Product>
</Wix>

View File

@ -338,6 +338,19 @@ elif meson.is_cross_build()
msys2_root = meson.get_external_property('msys2_root')
meson.add_install_script('msys2-install.sh', msys2_root)
# TODO: If we used DESTDIR instead of the prefix, this could probably
# be a custom target that invokes "meson install --destdir $(pwd)/package"
# through "meson compile -C builddir msi". Try it out, also in MSYS2.
meson.add_install_script('msys2-package.sh', host_machine.cpu())
configure_file(
input : 'fiv.wxs.in',
output : 'fiv.wxs',
configuration : configuration_data({
'ProjectName' : meson.project_name(),
'ProjectVersion' : meson.project_version(),
}),
)
# This is the minimum to run targets from msys2-configure.sh builds.
meson.add_devenv({
'WINEPATH' : msys2_root / 'bin',

View File

@ -19,7 +19,7 @@ then
wine64() { "$@"; }
awk() { command awk -v RS='\r?\n' "$@"; }
pacman -S --needed libarchive $pkg-ca-certificates $pkg-gcc $pkg-icoutils \
$pkg-librsvg $pkg-meson $pkg-pkgconf
$pkg-librsvg $pkg-meson $pkg-msitools $pkg-pkgconf
fi
status() {

30
msys2-package.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/sh -e
export LC_ALL=C.UTF-8
cd "$MESON_BUILD_ROOT"
txt2rtf() {
iconv -f utf-8 -t ascii//translit "$@" | awk 'BEGIN {
print "{\\rtf1\\ansi\\ansicpg1252\\deff0{\\fonttbl{\\f0 Tahoma;}}"
print "\\f0\\fs24{\\pard\\sa240"
} {
gsub(/\\/, "\\\\"); gsub(/{/, "\\{"); gsub(/}/, "\\}")
if (!$0) { print "\\par}{\\pard\\sa240"; prefix = "" }
else { print prefix $0; prefix = " " }
} END {
print "\\par}}"
}'
}
# We're being passed host_machine.cpu(), which will be either x86 or x86_64.
[ "$1" = "x86" ] && arch=x86 || arch=x64
wxs=fiv.wxs files=fiv-files.wxs msi=fiv.msi
txt2rtf "$MESON_SOURCE_ROOT/LICENSE" > License.rtf
find "$MESON_INSTALL_DESTDIR_PREFIX" -type f \
| wixl-heat --prefix "$MESON_INSTALL_DESTDIR_PREFIX/" \
--directory-ref INSTALLDIR --component-group CG.fiv \
--var var.SourceDir > "$files"
wixl --verbose --arch "$arch" -D SourceDir="$MESON_INSTALL_DESTDIR_PREFIX" \
--ext ui --output "$msi" "$wxs" "$files"