Skip to content

Commit e977ee7

Browse files
author
yournamem
committed
use meson to gate windows specific build things
1 parent 1f07318 commit e977ee7

File tree

10 files changed

+177
-19
lines changed

10 files changed

+177
-19
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ generate_stylesheets.sh
1010
.flatpak/
1111
.potrans
1212
.editorconfig
13-
oldpng/
13+
oldpng/
14+
deploy/

JortsInstaller.nsi

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
!include "MUI2.nsh"
2+
3+
Name Jorts
4+
5+
Outfile "JortsInstaller.exe"
6+
InstallDir "$LOCALAPPDATA\Programs\Jorts"
7+
#RequestExecutionLevel admin ; Request administrative privileges
8+
9+
# Set the title of the installer window
10+
Caption "Jorts Installer"
11+
12+
# Set the title and text on the welcome page
13+
!define MUI_WELCOMEPAGE_TITLE "Welcome to Jorts setup"
14+
!define MUI_WELCOMEPAGE_TEXT "This bitch will guide you through the installation of Jorts."
15+
!define MUI_ABORTWARNING
16+
!define MUI_ABORTWARNING_TEXT "Are you sure you want to cancel Jorts setup?"
17+
!define MUI_INSTFILESPAGE_TEXT "Please wait while Jorts is being installed."
18+
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
19+
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
20+
21+
!insertmacro MUI_PAGE_WELCOME
22+
!insertmacro MUI_PAGE_DIRECTORY
23+
!insertmacro MUI_PAGE_INSTFILES
24+
!insertmacro MUI_PAGE_FINISH
25+
!insertmacro MUI_UNPAGE_CONFIRM
26+
!insertmacro MUI_UNPAGE_INSTFILES
27+
!insertmacro MUI_UNPAGE_FINISH
28+
29+
!insertmacro MUI_LANGUAGE "English"
30+
31+
!macro GetCleanDir INPUTDIR
32+
; ATTENTION: USE ON YOUR OWN RISK!
33+
; Please report bugs here: http://stefan.bertels.org/
34+
!define Index_GetCleanDir 'GetCleanDir_Line${__LINE__}'
35+
Push $R0
36+
Push $R1
37+
StrCpy $R0 "${INPUTDIR}"
38+
StrCmp $R0 "" ${Index_GetCleanDir}-finish
39+
StrCpy $R1 "$R0" "" -1
40+
StrCmp "$R1" "\" ${Index_GetCleanDir}-finish
41+
StrCpy $R0 "$R0\"
42+
${Index_GetCleanDir}-finish:
43+
Pop $R1
44+
Exch $R0
45+
!undef Index_GetCleanDir
46+
!macroend
47+
48+
; ################################################################
49+
; similar to "RMDIR /r DIRECTORY", but does not remove DIRECTORY itself
50+
; example: !insertmacro RemoveFilesAndSubDirs "$INSTDIR"
51+
!macro RemoveFilesAndSubDirs DIRECTORY
52+
; ATTENTION: USE ON YOUR OWN RISK!
53+
; Please report bugs here: http://stefan.bertels.org/
54+
!define Index_RemoveFilesAndSubDirs 'RemoveFilesAndSubDirs_${__LINE__}'
55+
56+
Push $R0
57+
Push $R1
58+
Push $R2
59+
60+
!insertmacro GetCleanDir "${DIRECTORY}"
61+
Pop $R2
62+
FindFirst $R0 $R1 "$R2*.*"
63+
${Index_RemoveFilesAndSubDirs}-loop:
64+
StrCmp $R1 "" ${Index_RemoveFilesAndSubDirs}-done
65+
StrCmp $R1 "." ${Index_RemoveFilesAndSubDirs}-next
66+
StrCmp $R1 ".." ${Index_RemoveFilesAndSubDirs}-next
67+
IfFileExists "$R2$R1\*.*" ${Index_RemoveFilesAndSubDirs}-directory
68+
; file
69+
Delete "$R2$R1"
70+
goto ${Index_RemoveFilesAndSubDirs}-next
71+
${Index_RemoveFilesAndSubDirs}-directory:
72+
; directory
73+
RMDir /r "$R2$R1"
74+
${Index_RemoveFilesAndSubDirs}-next:
75+
FindNext $R0 $R1
76+
Goto ${Index_RemoveFilesAndSubDirs}-loop
77+
${Index_RemoveFilesAndSubDirs}-done:
78+
FindClose $R0
79+
80+
Pop $R2
81+
Pop $R1
82+
Pop $R0
83+
!undef Index_RemoveFilesAndSubDirs
84+
!macroend
85+
86+
Section "Install"
87+
SetOutPath "$INSTDIR"
88+
File /r "windows\deploy\*"
89+
CreateDirectory $SMPROGRAMS\Jorts
90+
91+
; Start menu
92+
CreateShortCut "$SMPROGRAMS\Jorts\Jorts.lnk" "$INSTDIR\bin\jorts.exe" "" "$INSTDIR\windows\jorts.ico" 0
93+
94+
; Autostart
95+
; CreateShortCut "$SMPROGRAMS\Startup\Jorts.lnk" "$INSTDIR\bin\jorts.exe" "" "$INSTDIR\windows\jorts.ico" 0
96+
97+
; Preferences
98+
CreateShortCut "$SMPROGRAMS\Jorts\Preferences of Jorts.lnk" "$INSTDIR\bin\jorts.exe" "--preferences" "$INSTDIR\windows\jorts.ico" 0
99+
100+
101+
102+
WriteRegStr HKCU "Software\Jorts" "" $INSTDIR
103+
WriteUninstaller "$INSTDIR\Uninstall.exe"
104+
105+
; Add to Add/Remove programs list
106+
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Jorts" "DisplayName" "Jorts"
107+
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Jorts" "UninstallString" "$INSTDIR\Uninstall.exe"
108+
SectionEnd
109+
110+
Section "Uninstall"
111+
112+
; Remove Start Menu shortcut
113+
Delete "$SMPROGRAMS\Jorts\Jorts.lnk"
114+
Delete "$SMPROGRAMS\Startup\Jorts.lnk"
115+
116+
; Remove uninstaller
117+
Delete "$INSTDIR\Uninstall.exe"
118+
119+
; Remove files and folders
120+
!insertmacro RemoveFilesAndSubDirs "$INSTDIR"
121+
122+
; Remove directories used
123+
RMDir $SMPROGRAMS\Jorts
124+
RMDir "$INSTDIR"
125+
126+
; Remove registry keys
127+
DeleteRegKey HKCU "Software\Jorts"
128+
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Jorts"
129+
130+
SectionEnd
131+

data/meson.build

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ i18n.merge_file(
1616
install_dir: get_option('datadir') / 'applications'
1717
)
1818

19+
20+
# metainfo confuses windows
21+
if not windows
22+
1923
#Translate and install our .metainfo file
2024
i18n.merge_file(
2125
input: 'jorts.metainfo.xml.in',
@@ -25,6 +29,7 @@ i18n.merge_file(
2529
install_dir: get_option('datadir') / 'metainfo'
2630
)
2731

32+
endif
2833

2934
#======== ICONS ========
3035

meson.build

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ else
2020
vala_flags = ['--define', 'DEFAULT']
2121
endif
2222

23-
add_project_arguments(vala_flags, language: 'vala')
23+
windows = get_option('windows')
24+
if windows
25+
vala_flags += ['--define', 'WINDOWS']
26+
endif
2427

28+
add_project_arguments(vala_flags, language: 'vala')
2529

2630
#================================
2731
# Import the stylesheet
@@ -49,10 +53,11 @@ dependencies = [
4953
dependency('json-glib-1.0'),
5054
dependency('gee-0.8'),
5155
dependency('gtk4'),
52-
dependency('libportal')
5356
]
5457

55-
58+
if not windows
59+
dependencies += dependency('libportal')
60+
endif
5661

5762
#================================
5863

meson_options.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,9 @@ option('variant',
33
choices : ['default', 'pride', 'halloween'],
44
value : ['default'],
55
description : 'The name of the seasonal icon and style to use. Only the first value is chosen.'
6+
)
7+
option('windows',
8+
type : 'boolean',
9+
value : true,
10+
description : 'Whether we build for windows'
611
)

src/Views/PreferencesView.vala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
/****************************************************/
8585
/* Autostart Request */
8686
/****************************************************/
87+
#if !WINDOWS
8788

8889
Xdp.Portal portal = new Xdp.Portal ();
8990
GenericArray<weak string> cmd = new GenericArray<weak string> ();
@@ -148,7 +149,7 @@
148149
autostart_box.append (autostart_label);
149150
autostart_box.append (both_buttons);
150151
settingsbox.append (autostart_box);
151-
152+
#endif
152153
/*************************************************/
153154
// Bar at the bottom
154155
var actionbar = new Gtk.CenterBox () {

src/meson.build

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ sources = files (
55

66
'Utils' / 'ZoomConvert.vala',
77
'Utils' / 'Random.vala',
8-
'Utils' / 'Libportal.vala',
98

109
'Services' / 'Constants.vala',
1110
'Services' / 'Storage.vala',
@@ -31,6 +30,10 @@ sources = files (
3130
'Application.vala',
3231
)
3332

33+
if not windows
34+
sources += files('Utils' / 'Libportal.vala')
35+
endif
36+
3437
#================================
3538
# Let's define our executable
3639
executable(
@@ -39,5 +42,6 @@ executable(
3942
config_file,
4043
sources,
4144
dependencies: dependencies,
45+
win_subsystem: 'windows',
4246
install : true
4347
)

windows/deploy.sh

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
# Run app from base directory, not ./windows
55
# Write path UNIX-style ("/"). Script will invert the slash where relevant.
66
app_name="Jorts"
7-
build_dir="../builddir"
7+
build_dir="builddir"
88
theme_name="io.elementary.stylesheet.blueberry"
9-
font_path="font"
9+
font_path="windows/fonts"
1010

11-
deploy_dir="deploy"
12-
exe_name="jorts.exe"
13-
icon_file="jorts.ico"
14-
icon_file_install="install.ico"
15-
icon_file_uninstall="uninstall.ico"
11+
deploy_dir="windows/deploy"
12+
exe_name="io.github.ellie_commons.jorts.exe"
13+
icon_file="windows/jorts.ico"
14+
icon_file_install="windows/install.ico"
15+
icon_file_uninstall="windows/uninstall.ico"
1616

1717
#PRE MESON
1818
#Skip refresh package
@@ -44,12 +44,13 @@ done
4444
# Copy other required things for Gtk to work nicely
4545
echo "Copying other necessary files..."
4646
cp /mingw64/bin/gdbus.exe ${deploy_dir}/bin/gdbus.exe
47-
cp -r /mingw64/etc/gtk-3.0 ${deploy_dir}/etc/gtk-3.0
48-
cp -r /mingw64/etc/gtk-4.0 ${deploy_dir}/etc/gtk-4.0
47+
#cp -r /mingw64/etc/gtk-3.0 ${deploy_dir}/etc/gtk-3.0
48+
#cp -r /mingw64/etc/gtk-4.0 ${deploy_dir}/etc/gtk-4.0
4949
cp -r /mingw64/etc/fonts ${deploy_dir}/etc/fonts
5050

5151
# Redacted Script
52-
cp -r ${font_path} ${deploy_dir}/etc/fonts/${font_path}
52+
mkdir ${deploy_dir}/etc/fonts/redactedscript
53+
cp -r ${font_path} ${deploy_dir}/etc/fonts/redactedscript/
5354

5455
mkdir -p ${deploy_dir}/lib/gdk-pixbuf-2.0/2.10.0
5556
cp -r /mingw64/lib/gdk-pixbuf-2.0/2.10.0 ${deploy_dir}/lib/gdk-pixbuf-2.0
@@ -173,8 +174,6 @@ Section "Install"
173174
174175
; Preferences
175176
CreateShortCut "\$SMPROGRAMS\\${app_name}\\Preferences of ${app_name}.lnk" "\$INSTDIR\bin\\${exe_name}" "--preferences" "\$INSTDIR\\${icon_file/\//\\}" 0
176-
177-
178177
179178
WriteRegStr HKCU "Software\\${app_name}" "" \$INSTDIR
180179
WriteUninstaller "\$INSTDIR\Uninstall.exe"
84.1 KB
Binary file not shown.
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
#!/bin/bash
22

3+
# cd /c/Documents and Settings/TC/Desktop/jorts
34

4-
pacman -S mingw-w64-ucrt-x86_64-{gtk4,vala,granite7,ninja,meson,nsis}
5+
pacman -S mingw-w64-ucrt-x86_64-{gtk4,vala,granite7,ninja,meson,nsis,gcc}
56
pacman -S mingw-w64-libgee mingw-w64-gsettings-desktop-schemas
7+
pacman -S mingw-w64-x86_64-desktop-file-utils
8+
pacman -S mingw-w64-x86_64-gtk-elementary-theme mingw-w64-x86_64-elementary-icon-theme
9+
10+
# No its not redundant
11+
pacman -S meson gcc ninja
12+
pacman -S pacman -S –mmingw-w64-ucrt-x86_64-vala mingw-w64-x86_64-vala
613

714
wget https://github.com/christiannaths/redacted-font/raw/63e542017bab347ba9be54d7d99b99d4754c3d97/RedactedScript/fonts/ttf/RedactedScript-Regular.ttf -O font/RedactedScript-Regular.ttf

0 commit comments

Comments
 (0)