myxce/src/frontend/apiserver/meson.build

64 lines
2.1 KiB
Meson

# frontend/apiserver — Go REST API server with CGO backend integration.
#
# CGO is required for two reasons:
# 1. pam_linux.go: dlopen/dlsym for PAM (handled by -ldl in the source file)
# 2. backend/clib.go: libxce C client library for IPC with the controller
#
# Include/link flags for libxce and its transitive deps are gathered from
# pkg-config and injected into CGO_CFLAGS/CGO_LDFLAGS so the go_build script
# can substitute path placeholders before invoking go build.
cgo_cflags = ''
cgo_ldflags = ''
if with_debug
cgo_cflags += '-fsanitize=address -g -DWITH_DEBUG=1 '
cgo_ldflags += '-fsanitize=address -g '
endif
# Deps whose cflags/ldflags must be passed into CGO (transitive libxce deps).
apiserver_cgo_deps = [
librtti_dep,
c_capnproto_dep,
ssl_dep,
tinylog_dep,
math_dep,
rt_dep,
]
foreach dep : apiserver_cgo_deps
cf = run_command(pkgconfig, '--cflags', dep.name(), check: false)
if cf.returncode() == 0
cgo_cflags += ' ' + cf.stdout().strip()
endif
lf = run_command(pkgconfig, '--libs', dep.name(), check: false)
if lf.returncode() == 0
cgo_ldflags += ' ' + lf.stdout().strip()
endif
endforeach
# Add the source and build-directory include paths with meson placeholders.
# The go_build script resolves @CURRENT_SOURCE_DIR@ and @BUILD_ROOT@ at build time.
cgo_cflags += ' -I@CURRENT_SOURCE_DIR@/../../include -I@BUILD_ROOT@/lib'
cgo_ldflags += ' -L@BUILD_ROOT@/lib -lxce'
go_env = environment()
go_env.set('CGO_CFLAGS', cgo_cflags)
go_env.set('CGO_LDFLAGS', cgo_ldflags)
go_env.set('BUILDTYPE', get_option('buildtype'))
go_env.set('FIX_ENVARS', 'CGO_CFLAGS CGO_LDFLAGS')
go_env.set('ENVARS', 'CURRENT_SOURCE_DIR BUILD_ROOT')
go_env.set('DEPENDENCIES','thread math')
custom_target('apiserver',
input: 'cmd/main.go',
output: 'xce_apiserver',
command: [env_program,
'CURRENT_SOURCE_DIR="@CURRENT_SOURCE_DIR@"',
'BUILD_ROOT="@BUILD_ROOT@"',
go_build_program,
'@INPUT@', '@OUTPUT@'],
env: go_env,
depends: [libxce],
install: true,
install_dir: get_option('prefix') / 'bin')