~bl4ckb0ne/wxrc

876e0aa4e331001a866537de910fec303cb10869 — Simon Zeni 1 year, 3 months ago 0144128
meson: improve build
43 files changed, 94 insertions(+), 95 deletions(-)

M example/meson.build
M meson.build
M protocol/meson.build
R wxrc/config.c => src/config.c
R wxrc/config.h => src/config.h
R wxrc/controller.c => src/controller.c
R wxrc/controller.h => src/controller.h
R wxrc/display.c => src/display.c
R wxrc/display.h => src/display.h
R wxrc/hand-tracking.c => src/hand-tracking.c
R wxrc/hand-tracking.h => src/hand-tracking.h
R wxrc/input.c => src/input.c
R wxrc/input.h => src/input.h
R wxrc/main.c => src/main.c
R wxrc/mathutil.c => src/mathutil.c
R wxrc/mathutil.h => src/mathutil.h
R wxrc/meson.build => src/meson.build
R wxrc/model.c => src/model.c
R wxrc/model.h => src/model.h
R wxrc/openxr.c => src/openxr.c
R wxrc/openxr.h => src/openxr.h
R wxrc/render.c => src/render.c
R wxrc/render.h => src/render.h
R wxrc/seat.c => src/seat.c
R wxrc/seat.h => src/seat.h
R wxrc/server.c => src/server.c
R wxrc/server.h => src/server.h
R wxrc/shaders.c => src/shaders.c
R wxrc/shaders.h => src/shaders.h
R wxrc/stb_image.c => src/stb_image.c
R wxrc/stb_image.h => src/stb_image.h
R wxrc/surface.c => src/surface.c
R wxrc/surface.h => src/surface.h
R wxrc/tracing.h => src/tracing.h
R wxrc/xdg-surface.c => src/xdg-surface.c
R wxrc/xr-controller-v1.c => src/xr-controller-v1.c
R wxrc/xr-hand-v1.c => src/xr-hand-v1.c
R wxrc/xr-input-v1.h => src/xr-input-v1.h
R wxrc/xr-shell-v1.c => src/xr-shell-v1.c
R wxrc/xr-shell-v1.h => src/xr-shell-v1.h
R wxrc/xr-surface.c => src/xr-surface.c
R wxrc/xrutil.c => src/xrutil.c
R wxrc/xrutil.h => src/xrutil.h
M example/meson.build => example/meson.build +9 -3
@@ 8,20 8,26 @@ examples = {
	'cube': {
		'src': ['cube.c', 'xr-buffer.c', 'gl.c'],
		'dep': tracy,
		'proto': ['linux-dmabuf-unstable-v1', 'xr-shell-v1', 'xr-input-v1']
	},
	'gui': {
		'src': ['gui.c', 'shm-buffer.c'],
		'dep': [microui, pango, cairo, pangocairo],
		'proto': ['xdg-shell']
	}
	# TODO gltf
}

examples_dep = [math, cglm, glesv2, egl, gbm, libdrm, wayland_client,
	wxr_protocols]
examples_dep = [math, cglm, glesv2, egl, gbm, libdrm, wayland_client]

foreach name, info : examples
	protos = []
	foreach p : info.get('proto', [])
		protos += wl_protocols_client_src[p]
	endforeach

	executable(name,
		files(info.get('src'), 'xr-buffer.c', 'gl.c'),
		[info.get('src') + protos],
		dependencies: [examples_dep, info.get('dep', [])],
	)
endforeach

M meson.build => meson.build +42 -27
@@ 41,7 41,14 @@ add_project_arguments(cc.get_supported_arguments([
	'-Wno-unused-function',
]), language: 'c')

math = cc.find_library('m', required : false)
math = cc.find_library('m')

wlroots_version = ['>=0.16.0', '<0.17.0']
subproject('wlroots',
	default_options: ['examples=false'],
	required: false,
	version: wlroots_version,
)

cglm = dependency('cglm', fallback : 'cglm')
egl = dependency('egl')


@@ 49,11 56,11 @@ gbm = dependency('gbm')
glesv2 = dependency('glesv2')
libdrm = dependency('libdrm')
openxr = dependency('openxr')
pixman = dependency('pixman-1')
xkbcommon = dependency('xkbcommon')
wayland_client = dependency('wayland-client')
wayland_egl = dependency('wayland-egl')
wayland_server = dependency('wayland-server')
wayland_protocols = dependency('wayland-protocols')
wlroots = dependency('wlroots', version: wlroots_version)

# TODO find a better way to get GLES3
assert(cc.check_header('GLES3/gl32.h'))


@@ 63,36 70,44 @@ scfg = subproject('libscfg', required: true).get_variable('scfg')
cgltf = subproject('cgltf', required: true).get_variable('cgltf')

# Only required when profiling
tracy_proj = subproject('tracy',
	default_options : ['warning_level=0', 'werror=false'],
	required: get_option('profiling'),
)
if tracy_proj.found()
	tracy = tracy_proj.get_variable('tracy_dep')
	if get_option('profiling')
		 add_project_arguments('-DTRACY_ENABLE', '-DTRACY_CALLSTACK',
			language : 'c')
	endif
if get_option('profiling')
	subproject('tracy',
		default_options : ['warning_level=0', 'werror=false'],
	)
	tracy = dependency('tracy',
		required: true,
		not_found_message: 'Tracy required for profiling',
	)
	add_project_arguments('-DTRACY_ENABLE', '-DTRACY_CALLSTACK',
		language : 'c')
else
	tracy = dependency('', required: false)
endif

# Try first to find wlroots as a subproject, then as a system dependency
wlroots_version = ['>=0.17.0', '<0.18.0']
wlroots_proj = subproject(
	'wlroots',
	default_options: ['examples=false'],
	required: false,
	version: wlroots_version,
)
if wlroots_proj.found()
	wlroots = wlroots_proj.get_variable('wlroots')
else
	wlroots = dependency('wlroots', version: wlroots_version)
endif
wxrc_files = []
wxrc_deps = [
	cglm,
	cgltf,
	egl,
	gbm,
	glesv2,
	openxr,
	pixman,
	scfg,
	wayland_client,
	wayland_server,
	wlroots,
	xkbcommon,
]

subdir('protocol')
subdir('wxrc')
subdir('src')

executable('wxrc',
	wxrc_files,
	dependencies: wxrc_deps,
	install: true,
)

if get_option('examples')
	subdir('example')

M protocol/meson.build => protocol/meson.build +37 -45
@@ 1,48 1,40 @@
wayland_protocols = dependency('wayland-protocols')
wl_protocols_dir = wayland_protocols.get_variable(pkgconfig: 'pkgdatadir')

wayland_scanner = find_program('wayland-scanner', native: true)

wayland_scanner_code = generator(
	wayland_scanner,
	output: '@BASENAME@-protocol.c',
	arguments: ['private-code', '@INPUT@', '@OUTPUT@'],
)

wayland_scanner_server = generator(
	wayland_scanner,
	output: '@BASENAME@-protocol.h',
	arguments: ['server-header', '@INPUT@', '@OUTPUT@'],
)

wayland_scanner_client = generator(
	wayland_scanner,
	output: '@BASENAME@-client-protocol.h',
	arguments: ['client-header', '@INPUT@', '@OUTPUT@'],
)

protocols = [
	[wl_protocols_dir, 'stable/xdg-shell/xdg-shell.xml'],
	[wl_protocols_dir, 'unstable/pointer-constraints/pointer-constraints-unstable-v1.xml'],
	[wl_protocols_dir, 'unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml'],
	['xr-shell-v1.xml'],
	['xr-input-v1.xml'],
]

protocol_src = []
protocol_headers = []

foreach p : protocols
	xml = join_paths(p)
	protocol_src += wayland_scanner_code.process(xml)
	protocol_headers += wayland_scanner_server.process(xml)
	protocol_headers += wayland_scanner_client.process(xml)
wayland_scanner = dependency('wayland-scanner')
wl_scanner = find_program(wayland_scanner.get_variable('wayland_scanner'))

protocols = {
	'xdg-shell': wl_protocols_dir / 'stable/xdg-shell/xdg-shell.xml',
	'pointer-constraint-unstable-v1': wl_protocols_dir / 'unstable/pointer-constraints/pointer-constraints-unstable-v1.xml',
	'linux-dmabuf-unstable-v1': wl_protocols_dir / 'unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml',
	'xr-shell-v1': 'xr-shell-v1.xml',
	'xr-input-v1': 'xr-input-v1.xml',
}

wl_protocols_client_src = {}

foreach name, path : protocols
	xml = join_paths(path)

	code = custom_target(name.underscorify() + '_c',
		input: path,
		output: '@BASENAME@-protocol.c',
		command: [wl_scanner, 'private-code', '@INPUT@', '@OUTPUT@'],
	)

	server_header = custom_target(name.underscorify() + '_server_h',
		input: path,
		output: '@BASENAME@-protocol.h',
		command: [wl_scanner, 'server-header', '@INPUT@', '@OUTPUT@'],
	)

	client_header = custom_target(name.underscorify() + '_client_h',
		input: path,
		output: '@BASENAME@-client-protocol.h',
		command: [wl_scanner, 'client-header', '@INPUT@', '@OUTPUT@'],
	)

	wxrc_files += [code, server_header]
	wl_protocols_client_src += { name: [code, client_header] }
endforeach

lib_protocols = static_library('wxr-protocols',
	protocol_src + protocol_headers,
)

wxr_protocols = declare_dependency(
	link_with: lib_protocols,
	sources: protocol_headers,
)

R wxrc/config.c => src/config.c +0 -0
R wxrc/config.h => src/config.h +0 -0
R wxrc/controller.c => src/controller.c +0 -0
R wxrc/controller.h => src/controller.h +0 -0
R wxrc/display.c => src/display.c +0 -0
R wxrc/display.h => src/display.h +0 -0
R wxrc/hand-tracking.c => src/hand-tracking.c +0 -0
R wxrc/hand-tracking.h => src/hand-tracking.h +0 -0
R wxrc/input.c => src/input.c +0 -0
R wxrc/input.h => src/input.h +0 -0
R wxrc/main.c => src/main.c +0 -0
R wxrc/mathutil.c => src/mathutil.c +0 -0
R wxrc/mathutil.h => src/mathutil.h +0 -0
R wxrc/meson.build => src/meson.build +4 -18
@@ 1,4 1,4 @@
wxrc_src = files(
wxrc_files += files(
	'config.c',
	'controller.c',
	'display.c',


@@ 22,20 22,6 @@ wxrc_src = files(
	'xrutil.c',
)

wxrc_deps = [
	cglm,
	cgltf,
	egl,
	glesv2,
	openxr,
	scfg,
	tracy,
	wlroots,
	wxr_protocols,
]

executable('wxrc',
	wxrc_src,
	dependencies: wxrc_deps,
	install: true,
)
# For wayland backend only
# TODO disable if not running from wayland
wxrc_files += wl_protocols_client_src['pointer-constraint-unstable-v1']

R wxrc/model.c => src/model.c +0 -0
R wxrc/model.h => src/model.h +0 -0
R wxrc/openxr.c => src/openxr.c +0 -0
R wxrc/openxr.h => src/openxr.h +0 -0
R wxrc/render.c => src/render.c +0 -0
R wxrc/render.h => src/render.h +0 -0
R wxrc/seat.c => src/seat.c +0 -0
R wxrc/seat.h => src/seat.h +0 -0
R wxrc/server.c => src/server.c +1 -1
@@ 239,7 239,7 @@ wxrc_server_init(struct wxrc_server *server)

	server->wl_display = wl_display_create();
	server->wl_event_loop = wl_display_get_event_loop(server->wl_display);
	server->backend = wlr_backend_autocreate(server->wl_display, NULL);
	server->backend = wlr_backend_autocreate(server->wl_display);
	if (server->backend == NULL) {
		wlr_log(WLR_ERROR, "failed to create native backend");
		return false;

R wxrc/server.h => src/server.h +0 -0
R wxrc/shaders.c => src/shaders.c +0 -0
R wxrc/shaders.h => src/shaders.h +0 -0
R wxrc/stb_image.c => src/stb_image.c +0 -0
R wxrc/stb_image.h => src/stb_image.h +0 -0
R wxrc/surface.c => src/surface.c +0 -0
R wxrc/surface.h => src/surface.h +0 -0
R wxrc/tracing.h => src/tracing.h +0 -0
R wxrc/xdg-surface.c => src/xdg-surface.c +0 -0
R wxrc/xr-controller-v1.c => src/xr-controller-v1.c +0 -0
R wxrc/xr-hand-v1.c => src/xr-hand-v1.c +0 -0
R wxrc/xr-input-v1.h => src/xr-input-v1.h +0 -0
R wxrc/xr-shell-v1.c => src/xr-shell-v1.c +1 -1
@@ 43,7 43,7 @@ resource_destroy(struct wl_client *client, struct wl_resource *resource)

static bool
update_buffer(struct wlr_client_buffer **buffer, struct wlr_buffer **pending,
	const pixman_region32_t *damage)
	pixman_region32_t *damage)
{
	if (*pending == NULL) {
		/* NULL commit */

R wxrc/xr-shell-v1.h => src/xr-shell-v1.h +0 -0
R wxrc/xr-surface.c => src/xr-surface.c +0 -0
R wxrc/xrutil.c => src/xrutil.c +0 -0
R wxrc/xrutil.h => src/xrutil.h +0 -0