Skip to content

Commit

Permalink
Updated to use Meson options instead of hard-coded bin dir.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlynxZhou committed May 16, 2022
1 parent 845924e commit ae93b97
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@
*.su

build/
.cache/
2 changes: 1 addition & 1 deletion dists/flipclock.desktop → dists/flipclock.desktop.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Name=FlipClock
Comment=A flip clock screensaver supported by SDL2.
Icon=flipclock
Exec=flipclock
TryExec=/usr/bin/flipclock
TryExec=@package_bindir@/flipclock
StartupNotify=false
Terminal=false
Categories=Game
35 changes: 22 additions & 13 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,28 @@ if get_option('debug') == true
endif

conf_data = configuration_data()
conf_data.set('install_prefix', get_option('prefix'))
conf_data.set('project_version', meson.project_version())
conf_data.set('package_bindir', get_option('prefix') / get_option('bindir'))
conf_data.set('package_datadir', get_option('prefix') / get_option('datadir'))

configure_file(
input: 'srcs/config-meson.h.in',
output: 'config.h',
configuration: conf_data
)

# Don't install desktop entry for Windows.
if host_machine.system() == 'linux'
configure_file(
input: 'dists/flipclock.desktop.in',
output: 'flipclock.desktop',
configuration: conf_data,
install: true,
# If a relative path is given, meson will put it under prefix so we don't need to put `get_option('prefix')` manually here.
install_dir: get_option('datadir') / 'applications'
)
endif

sources = files(
'srcs/main.c',
'srcs/getarg.c',
Expand All @@ -51,8 +64,8 @@ if host_machine.system() == 'linux'
c_args: c_args,
dependencies: dependencies,
include_directories: include_directories,
install: true,
install_dir: get_option('prefix') / 'bin'
install: true
# By default, meson install binary to `get_option('prefix') / get_option('bindir')`, so we can omit `install_dir` here.
)

install_data(
Expand All @@ -67,10 +80,6 @@ if host_machine.system() == 'linux'
'dists' / 'flipclock.png',
install_dir: get_option('datadir') / 'pixmaps'
)
install_data(
'dists' / 'flipclock.desktop',
install_dir: get_option('datadir') / 'applications'
)
elif host_machine.system() == 'windows'
if get_option('debug') == true
executable(
Expand All @@ -80,7 +89,7 @@ elif host_machine.system() == 'windows'
dependencies: dependencies,
include_directories: include_directories,
install: true,
install_dir: get_option('prefix') / meson.project_name(),
install_dir: meson.project_name(),
name_suffix: 'scr',
win_subsystem: 'console'
)
Expand All @@ -92,26 +101,26 @@ elif host_machine.system() == 'windows'
dependencies: dependencies,
include_directories: include_directories,
install: true,
install_dir: get_option('prefix') / meson.project_name(),
install_dir: meson.project_name(),
name_suffix: 'scr',
win_subsystem: 'windows'
)
endif

install_data(
'LICENSE',
install_dir: get_option('prefix') / meson.project_name()
install_dir: meson.project_name()
)
install_data(
'dists' / 'flipclock.ttf',
install_dir: get_option('prefix') / meson.project_name()
install_dir: meson.project_name()
)
install_data(
'dists' / 'COPYING',
install_dir: get_option('prefix') / meson.project_name()
install_dir: meson.project_name()
)
install_data(
'dists' / '请先读我.txt',
install_dir: get_option('prefix') / meson.project_name()
install_dir: meson.project_name()
)
endif
3 changes: 2 additions & 1 deletion srcs/config-meson.h.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef __CONFIG_H__

#define INSTALL_PREFIX "@install_prefix@"
#define PROJECT_VERSION "@project_version@"
#define PACKAGE_BINDIR "@package_bindir@"
#define PACKAGE_DATADIR "@package_datadir@"

#endif
2 changes: 1 addition & 1 deletion srcs/flipclock.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ void flipclock_open_fonts(struct flipclock *app, int clock_index)
// Directly under `app/src/main/assets` for Android APP.
char *font_path = "flipclock.ttf";
#elif defined(__linux__)
char *font_path = INSTALL_PREFIX "/share/fonts/flipclock.ttf";
char *font_path = PACKAGE_DATADIR "/fonts/flipclock.ttf";
#endif
LOG_DEBUG("Using font_path `%s`.\n", font_path);
app->clocks[clock_index].fonts.time = TTF_OpenFont(
Expand Down

0 comments on commit ae93b97

Please sign in to comment.