Adding launcher code to the src dir.
This commit is contained in:
parent
904c61ff3f
commit
c9088d8c45
14
meson.build
14
meson.build
|
@ -2,8 +2,10 @@ project('me.sergiotarxz.recuento', 'vala')
|
|||
compiler = meson.get_compiler('c')
|
||||
ws = '/'
|
||||
|
||||
is_windows = false
|
||||
if compiler.has_header('windows.h')
|
||||
ws = '\\\\'
|
||||
is_windows = true
|
||||
endif
|
||||
|
||||
vapidir = meson.project_source_root() / 'vapi'
|
||||
|
@ -20,6 +22,10 @@ sources = [
|
|||
'src/main.vala',
|
||||
]
|
||||
|
||||
launcher_sources = [
|
||||
'src/windows/launcher.c',
|
||||
]
|
||||
|
||||
datadir_unix = get_option('prefix') + '/' + get_option('datadir')
|
||||
datadir = get_option('prefix') + ws + get_option('datadir')
|
||||
|
||||
|
@ -40,9 +46,17 @@ foreach i : preloaded_images_files
|
|||
)
|
||||
endforeach
|
||||
|
||||
if is_windows
|
||||
executable('recuento_launcher_windows',
|
||||
launcher_sources,
|
||||
win_subsystem: 'windows',
|
||||
)
|
||||
endif
|
||||
|
||||
executable('recuento',
|
||||
sources,
|
||||
dependencies : recuentodeps,
|
||||
install : true,
|
||||
win_subsystem: 'windows',
|
||||
)
|
||||
|
||||
|
|
30
package.pl
30
package.pl
|
@ -14,7 +14,7 @@ my $resources = $recuento_inner->child('resources');
|
|||
$resources->mkpath;
|
||||
copy_recursive('/usr/x86_64-w64-mingw32/usr/bin/*.{exe,dll,EXE,DLL}', $recuento_inner);
|
||||
copy_recursive('/usr/x86_64-w64-mingw32/usr/share/recuento/', $resources);
|
||||
compile_and_add_launcher ($destdir);
|
||||
move_launcher ($recuento_inner, $destdir);
|
||||
make_config ($destdir);
|
||||
make_share ($destdir);
|
||||
|
||||
|
@ -62,29 +62,11 @@ gtk-font-name=LiberationSans 20
|
|||
EOF
|
||||
}
|
||||
|
||||
sub compile_and_add_launcher {
|
||||
sub move_launcher {
|
||||
my $recuento_inner = shift;
|
||||
my $recuento = shift;
|
||||
my $c_tmp_dir = Path::Tiny->tempdir;
|
||||
my $filename = 'Recuento';
|
||||
my $c = 'Recuento.c';
|
||||
my $c_contents = <<'EOF';
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <windows.h>
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR pCmdLine, int nCmdShow) {
|
||||
char* argument_list[] = { _fullpath(NULL, "recuento\\\\recuento.exe", 3000), NULL };
|
||||
_putenv_s("DATADIR_RECUENTO", "recuento\\\\resources/");
|
||||
_putenv_s("GSETTINGS_SCHEMA_DIR", "share\\\\glib-2.0\\\\schemas");
|
||||
int return_value = execvp(argument_list[0], argument_list);
|
||||
if (return_value == -1)
|
||||
printf ("%s\n", strerror(errno));
|
||||
}
|
||||
EOF
|
||||
my $c_file = $c_tmp_dir->child($c);
|
||||
$c_file->spew($c_contents);
|
||||
system qw@/usr/bin/x86_64-w64-mingw32-gcc@, '-Wl,--subsystem,windows',
|
||||
qw@-mwindows@, $c_file, qw@-o@, $recuento->child($filename);
|
||||
my $filename = 'Recuento.exe';
|
||||
system 'cp', $recuento_inner->child('recuento_launcher_windows'), $recuento->child($filename);
|
||||
}
|
||||
sub copy_recursive {
|
||||
my $source = shift;
|
||||
|
@ -96,5 +78,5 @@ sub compress_7z {
|
|||
my $zip_output = path($0)->parent->child('recuento.7z')->absolute;
|
||||
$zip_output->remove if -e $zip_output;
|
||||
my $pushd = pushd $destdir;
|
||||
system qw/7z a -t7z -r /,$zip_output, '.';
|
||||
system qw/7z a -t7z -m0=LZMA2:d64k:fb32 -ms=8m -mmt=4 -mx=1 -r /,$zip_output, '.';
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <windows.h>
|
||||
|
||||
int
|
||||
WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR pCmdLine, int nCmdShow)
|
||||
{
|
||||
char* argument_list[] = { _fullpath(NULL, "recuento\\\\recuento.exe", 3000), NULL };
|
||||
_putenv_s("DATADIR_RECUENTO", "recuento\\\\resources/");
|
||||
_putenv_s("GSETTINGS_SCHEMA_DIR", "share\\\\glib-2.0\\\\schemas");
|
||||
int return_value = execvp(argument_list[0], argument_list);
|
||||
if (return_value == -1)
|
||||
printf ("%s\n", strerror(errno));
|
||||
}
|
Loading…
Reference in New Issue