[gimp/wip/Jehan/installer-to-windows-store: 9/9] data: fix gimp-release file on Windows.




commit 8ed13c01e8415038e0ad616f10fc9ab92ff2fa9f
Author: Jehan <jehan girinstud io>
Date:   Tue Jun 7 15:56:25 2022 +0200

    data: fix gimp-release file on Windows.
    
    The '\n' newline is transformed into a space (0x20) when building
    natively on Windows. And unfortunately g_key_file_load_from_file() does
    not like this.
    
    The autotools rule work properly according to my tests.
    
    Note that at first, I thought it was a LF vs. CRLF issue, and tried to
    special-case Windows, but I realized it's just that 'echo' command
    seemingly transform newlines unexpectedly in its Windows form. I didn't
    want to waste too much time experimenting alternative calls, especially
    as I have to test through CI (so each test is very costly, time-wise).
    Instead I go the alternative way of using a pre-generated conf file.

 data/gimp-release.in |  2 ++
 data/meson.build     | 24 +++++++-----------------
 2 files changed, 9 insertions(+), 17 deletions(-)
---
diff --git a/data/gimp-release.in b/data/gimp-release.in
new file mode 100644
index 0000000000..904317aef3
--- /dev/null
+++ b/data/gimp-release.in
@@ -0,0 +1,2 @@
+[package]
+revision=@REVISION@
diff --git a/data/meson.build b/data/meson.build
index a9bfe63882..0733682cde 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -15,22 +15,12 @@ meson.add_install_script('sh', '-c',
   'mkdir -p $MESON_INSTALL_DESTDIR_PREFIX/@0@'.format(gimpdatadir / 'fonts')
 )
 
-# It's crappy, but is a combination of meson not transforming \n into
-# Windows CRLF for us (which might not be considered a bug) and GLib's
-# g_key_file_load_from_file() API apparently not able to work with Unix
-# newlines LF-only while on Windows.
-if platform_windows
-  nl='\r\n'
-else
-  nl='\n'
-endif
+release_conf = configuration_data()
+release_conf.set('REVISION', get_option('revision'))
 
-custom_target('gimp-release',
-  output: [ 'gimp-release' ],
-  command: [
-    'echo', ['[package]' + nl + 'revision=@0@'.format(get_option('revision'))]
-  ],
-  capture: true,
-  install: true,
-  install_dir: gimpdatadir,
+gimp_release = 'gimp-release'
+configure_file(
+  input : gimp_release + '.in',
+  output: gimp_release,
+  configuration: release_conf,
 )


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]