2025-07-30 14:54:59 +08:00
|
|
|
|
project('mango', ['c', 'cpp'],
|
2025-10-21 22:59:14 +08:00
|
|
|
|
version : '0.10.3',
|
2025-02-03 23:18:47 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
subdir('protocols')
|
|
|
|
|
|
|
2025-02-25 20:06:20 +08:00
|
|
|
|
is_nixos = false
|
|
|
|
|
|
os_release = run_command('cat', '/etc/os-release', check: false)
|
|
|
|
|
|
if os_release.returncode() == 0
|
|
|
|
|
|
if os_release.stdout().contains('ID=nixos')
|
|
|
|
|
|
is_nixos = true
|
|
|
|
|
|
endif
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
2025-02-25 13:04:54 +08:00
|
|
|
|
prefix = get_option('prefix')
|
|
|
|
|
|
sysconfdir = get_option('sysconfdir')
|
|
|
|
|
|
|
|
|
|
|
|
# 如果 sysconfdir 以 prefix 开头,去掉 prefix
|
2025-02-25 20:06:20 +08:00
|
|
|
|
if sysconfdir.startswith(prefix) and not is_nixos
|
2025-02-25 13:04:54 +08:00
|
|
|
|
sysconfdir = sysconfdir.substring(prefix.length())
|
2025-02-25 20:06:20 +08:00
|
|
|
|
# 确保 sysconfdir 是绝对路径
|
|
|
|
|
|
if not sysconfdir.startswith('/')
|
|
|
|
|
|
sysconfdir = '/' + sysconfdir
|
|
|
|
|
|
endif
|
2025-02-25 13:04:54 +08:00
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
# 打印调试信息,确认 sysconfdir 的值
|
2025-02-25 20:06:20 +08:00
|
|
|
|
# message('prefix: ' + prefix)
|
|
|
|
|
|
# message('sysconfdir: ' + sysconfdir)
|
2025-02-04 13:36:44 +08:00
|
|
|
|
|
2025-02-03 23:18:47 +08:00
|
|
|
|
cc = meson.get_compiler('c')
|
|
|
|
|
|
libm = cc.find_library('m')
|
|
|
|
|
|
xcb = dependency('xcb', required : get_option('xwayland'))
|
|
|
|
|
|
xlibs = dependency('xcb-icccm', required : get_option('xwayland'))
|
|
|
|
|
|
wayland_server_dep = dependency('wayland-server')
|
2025-06-25 11:05:57 +08:00
|
|
|
|
wlroots_dep = dependency('wlroots-0.19',version: '>=0.19.0')
|
2025-02-03 23:18:47 +08:00
|
|
|
|
xkbcommon_dep = dependency('xkbcommon')
|
|
|
|
|
|
libinput_dep = dependency('libinput')
|
|
|
|
|
|
libwayland_client_dep = dependency('wayland-client')
|
2025-05-18 18:26:06 +08:00
|
|
|
|
pcre2_dep = dependency('libpcre2-8')
|
2025-06-25 11:05:57 +08:00
|
|
|
|
libscenefx_dep = dependency('scenefx-0.4',version: '>=0.4.1')
|
2025-06-14 09:29:12 +08:00
|
|
|
|
|
2025-02-03 23:18:47 +08:00
|
|
|
|
|
2025-10-12 17:46:37 +08:00
|
|
|
|
# 获取版本信息
|
2025-02-25 13:04:54 +08:00
|
|
|
|
git = find_program('git', required : false)
|
2025-10-12 17:46:37 +08:00
|
|
|
|
is_git_repo = false
|
|
|
|
|
|
|
|
|
|
|
|
# 检查当前目录是否是 Git 仓库
|
2025-02-25 13:04:54 +08:00
|
|
|
|
if git.found()
|
2025-10-12 17:46:37 +08:00
|
|
|
|
git_status = run_command(git, 'rev-parse', '--is-inside-work-tree', check : false)
|
|
|
|
|
|
if git_status.returncode() == 0 and git_status.stdout().strip() == 'true'
|
|
|
|
|
|
is_git_repo = true
|
|
|
|
|
|
endif
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
if is_git_repo
|
|
|
|
|
|
# 如果是 Git 目录,获取 Commit Hash 和最新的 tag
|
2025-04-04 19:51:24 +08:00
|
|
|
|
commit_hash = run_command(git, 'rev-parse', '--short', 'HEAD', check : false).stdout().strip()
|
|
|
|
|
|
latest_tag = run_command(git, 'describe', '--tags', '--abbrev=0', check : false).stdout().strip()
|
2025-10-12 17:46:37 +08:00
|
|
|
|
version_with_hash = '@0@(@1@)'.format(latest_tag, commit_hash)
|
2025-02-25 13:04:54 +08:00
|
|
|
|
else
|
2025-10-12 17:46:37 +08:00
|
|
|
|
# 如果不是 Git 目录,使用项目版本号和 "release" 字符串
|
|
|
|
|
|
commit_hash = 'release'
|
|
|
|
|
|
latest_tag = meson.project_version()
|
|
|
|
|
|
version_with_hash = '@0@(@1@)'.format(latest_tag, commit_hash)
|
2025-02-25 13:04:54 +08:00
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
# 定义编译参数
|
2025-02-03 23:18:47 +08:00
|
|
|
|
c_args = [
|
|
|
|
|
|
'-g',
|
|
|
|
|
|
'-Wno-unused-function',
|
|
|
|
|
|
'-DWLR_USE_UNSTABLE',
|
|
|
|
|
|
'-D_POSIX_C_SOURCE=200809L',
|
2025-08-06 11:49:04 +08:00
|
|
|
|
'-DVERSION="@0@"'.format(version_with_hash),
|
|
|
|
|
|
'-DSYSCONFDIR="@0@"'.format('/etc'),
|
2025-02-03 23:18:47 +08:00
|
|
|
|
]
|
|
|
|
|
|
|
2025-08-06 11:49:04 +08:00
|
|
|
|
# 仅在 debug 选项启用时添加调试参数
|
|
|
|
|
|
if get_option('asan')
|
|
|
|
|
|
c_args += [
|
|
|
|
|
|
'-fsanitize=address',
|
|
|
|
|
|
'-fno-omit-frame-pointer',
|
|
|
|
|
|
'-fno-optimize-sibling-calls'
|
|
|
|
|
|
]
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
2025-02-03 23:18:47 +08:00
|
|
|
|
if xcb.found() and xlibs.found()
|
|
|
|
|
|
c_args += '-DXWAYLAND'
|
2025-02-25 13:04:54 +08:00
|
|
|
|
endif
|
2025-02-03 23:18:47 +08:00
|
|
|
|
|
2025-08-06 11:49:04 +08:00
|
|
|
|
# 链接参数(根据 debug 状态添加 ASAN)
|
|
|
|
|
|
link_args = []
|
|
|
|
|
|
if get_option('asan')
|
|
|
|
|
|
link_args += '-fsanitize=address'
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
2025-07-30 14:54:59 +08:00
|
|
|
|
executable('mango',
|
|
|
|
|
|
'src/mango.c',
|
2025-04-28 09:19:26 +08:00
|
|
|
|
'src/common/util.c',
|
2025-08-26 15:59:35 +08:00
|
|
|
|
'src/ext-protocol/wlr_ext_workspace_v1.c',
|
2025-02-03 23:18:47 +08:00
|
|
|
|
wayland_sources,
|
|
|
|
|
|
dependencies : [
|
|
|
|
|
|
libm,
|
|
|
|
|
|
xcb,
|
|
|
|
|
|
xlibs,
|
2025-06-14 09:29:12 +08:00
|
|
|
|
libscenefx_dep,
|
2025-02-03 23:18:47 +08:00
|
|
|
|
wayland_server_dep,
|
|
|
|
|
|
wlroots_dep,
|
|
|
|
|
|
xkbcommon_dep,
|
|
|
|
|
|
libinput_dep,
|
|
|
|
|
|
libwayland_client_dep,
|
2025-05-18 18:26:06 +08:00
|
|
|
|
pcre2_dep,
|
2025-02-03 23:18:47 +08:00
|
|
|
|
],
|
|
|
|
|
|
install : true,
|
2025-08-06 11:49:04 +08:00
|
|
|
|
c_args : c_args,
|
|
|
|
|
|
link_args : link_args,
|
2025-02-03 23:18:47 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
2025-10-19 18:09:34 +08:00
|
|
|
|
# build mmsg
|
|
|
|
|
|
dwl_ipc_protocol = 'protocols/dwl-ipc-unstable-v2.xml'
|
2025-10-19 19:04:25 +08:00
|
|
|
|
|
|
|
|
|
|
wayland_scanner_client_header = generator(
|
|
|
|
|
|
wayland_scanner,
|
|
|
|
|
|
output: '@BASENAME@-protocol.h',
|
|
|
|
|
|
arguments: ['client-header', '@INPUT@', '@OUTPUT@']
|
2025-10-19 18:09:34 +08:00
|
|
|
|
)
|
2025-10-19 19:04:25 +08:00
|
|
|
|
|
|
|
|
|
|
wayland_scanner_private_code = generator(
|
|
|
|
|
|
wayland_scanner,
|
|
|
|
|
|
output: '@BASENAME@-protocol.c',
|
|
|
|
|
|
arguments: ['private-code', '@INPUT@', '@OUTPUT@']
|
2025-10-19 18:09:34 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
2025-10-19 19:04:25 +08:00
|
|
|
|
# 在 mmsg 目标中使用生成器
|
2025-10-19 18:09:34 +08:00
|
|
|
|
executable('mmsg',
|
|
|
|
|
|
'mmsg/mmsg.c',
|
2025-10-19 19:04:25 +08:00
|
|
|
|
wayland_scanner_private_code.process(dwl_ipc_protocol),
|
|
|
|
|
|
wayland_scanner_client_header.process(dwl_ipc_protocol),
|
2025-10-19 18:09:34 +08:00
|
|
|
|
dependencies: [
|
|
|
|
|
|
libwayland_client_dep
|
|
|
|
|
|
],
|
|
|
|
|
|
install: true,
|
|
|
|
|
|
c_args: [
|
|
|
|
|
|
'-g',
|
|
|
|
|
|
'-Wno-unused-function',
|
|
|
|
|
|
],
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2025-02-04 07:17:44 +08:00
|
|
|
|
desktop_install_dir = join_paths(prefix, 'share/wayland-sessions')
|
2025-07-30 14:54:59 +08:00
|
|
|
|
install_data('mango.desktop', install_dir : desktop_install_dir)
|
2025-10-18 12:43:03 +08:00
|
|
|
|
install_data('config.conf', install_dir : join_paths(sysconfdir, 'mango'))
|