Skip to content

Commit

Permalink
build: move completions to separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
emersion authored and bl4ckb0ne committed Nov 28, 2022
1 parent dca0bb5 commit a358d67
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 55 deletions.
57 changes: 57 additions & 0 deletions completions/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
if get_option('zsh-completions')
zsh_files = files(
'zsh/_sway',
'zsh/_swaymsg',
)
zsh_install_dir = join_paths(datadir, 'zsh', 'site-functions')

install_data(zsh_files, install_dir: zsh_install_dir)
endif

if get_option('bash-completions')
bash_comp = dependency('bash-completion', required: false)

bash_files = files(
'bash/sway',
'bash/swaymsg',
)

if get_option('swaybar')
bash_files += files('bash/swaybar')
endif

if bash_comp.found()
bash_install_dir = bash_comp.get_variable(
pkgconfig: 'completionsdir',
pkgconfig_define: ['datadir', datadir]
)
else
bash_install_dir = join_paths(datadir, 'bash-completion', 'completions')
endif

install_data(bash_files, install_dir: bash_install_dir)
endif

if get_option('fish-completions')
fish_comp = dependency('fish', required: false)

fish_files = files(
'fish/sway.fish',
'fish/swaymsg.fish',
)

if get_option('swaynag')
fish_files += files('fish/swaynag.fish')
endif

if fish_comp.found()
fish_install_dir = fish_comp.get_variable(
pkgconfig: 'completionsdir',
pkgconfig_define: ['datadir', datadir]
)
else
fish_install_dir = join_paths(datadir, 'fish', 'vendor_completions.d')
endif

install_data(fish_files, install_dir: fish_install_dir)
endif
56 changes: 1 addition & 55 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ xcb = dependency('xcb', required: get_option('xwayland'))
drm_full = dependency('libdrm') # only needed for drm_fourcc.h
drm = drm_full.partial_dependency(compile_args: true, includes: true)
libudev = wlroots_features['libinput_backend'] ? dependency('libudev') : null_dep
bash_comp = dependency('bash-completion', required: false)
fish_comp = dependency('fish', required: false)
math = cc.find_library('m')
rt = cc.find_library('rt')
xcb_icccm = dependency('xcb-icccm', required: get_option('xwayland'))
Expand Down Expand Up @@ -266,59 +264,7 @@ if get_option('default-wallpaper')
install_data(wallpaper_files, install_dir: wallpaper_install_dir)
endif

if get_option('zsh-completions')
zsh_files = files(
'completions/zsh/_sway',
'completions/zsh/_swaymsg',
)
zsh_install_dir = join_paths(datadir, 'zsh', 'site-functions')

install_data(zsh_files, install_dir: zsh_install_dir)
endif

if get_option('bash-completions')
bash_files = files(
'completions/bash/sway',
'completions/bash/swaymsg',
)

if get_option('swaybar')
bash_files += files('completions/bash/swaybar')
endif

if bash_comp.found()
bash_install_dir = bash_comp.get_variable(
pkgconfig: 'completionsdir',
pkgconfig_define: ['datadir', datadir]
)
else
bash_install_dir = join_paths(datadir, 'bash-completion', 'completions')
endif

install_data(bash_files, install_dir: bash_install_dir)
endif

if get_option('fish-completions')
fish_files = files(
'completions/fish/sway.fish',
'completions/fish/swaymsg.fish',
)

if get_option('swaynag')
fish_files += files('completions/fish/swaynag.fish')
endif

if fish_comp.found()
fish_install_dir = fish_comp.get_variable(
pkgconfig: 'completionsdir',
pkgconfig_define: ['datadir', datadir]
)
else
fish_install_dir = join_paths(datadir, 'fish', 'vendor_completions.d')
endif

install_data(fish_files, install_dir: fish_install_dir)
endif
subdir('completions')

summary({
'xwayland': have_xwayland,
Expand Down

0 comments on commit a358d67

Please sign in to comment.