Skip to content

Commit

Permalink
Put wayland-thing in a single compile-unit
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Mar 17, 2022
1 parent 4b42ce6 commit 2e494f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Tools/kmake
13 changes: 11 additions & 2 deletions kfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,18 +338,21 @@ else if (platform === Platform.Linux || platform === Platform.FreeBSD) {

const child_process = require('child_process');

let chfiles = [];

function wl_protocol(protocol, file) {
chfiles.push(file);
const backend_path = path.resolve(waylandDir);
const protocol_path = path.resolve('/usr/share/wayland-protocols', protocol);
if (child_process.spawnSync('wayland-scanner', ['private-code', protocol_path, path.resolve(backend_path, file + '.c')]).status !== 0) {
if (child_process.spawnSync('wayland-scanner', ['private-code', protocol_path, path.resolve(backend_path, file + '.c.h')]).status !== 0) {
log.error('Failed to generate wayland protocol files for' + protocol);
}
if (child_process.spawnSync('wayland-scanner', ['client-header', protocol_path, path.resolve(backend_path, file + '.h')]).status !== 0) {
log.error('Failed to generate wayland protocol header for' + protocol);
}
}

if (child_process.spawnSync('wayland-scanner', ['private-code', '/usr/share/wayland/wayland.xml', path.resolve(waylandDir, 'wayland-protocol.c')]).status !== 0) {
if (child_process.spawnSync('wayland-scanner', ['private-code', '/usr/share/wayland/wayland.xml', path.resolve(waylandDir, 'wayland-protocol.c.h')]).status !== 0) {
log.error('Failed to generate wayland protocol files for /usr/share/wayland/wayland.xml');
}
if (child_process.spawnSync('wayland-scanner', ['client-header', '/usr/share/wayland/wayland.xml', path.resolve(waylandDir, 'wayland-protocol.h')]).status !== 0) {
Expand All @@ -362,6 +365,12 @@ else if (platform === Platform.Linux || platform === Platform.FreeBSD) {
wl_protocol('unstable/pointer-constraints/pointer-constraints-unstable-v1.xml', 'wayland-pointer-constraint');
wl_protocol('unstable/relative-pointer/relative-pointer-unstable-v1.xml', 'wayland-relative-pointer');

let cfile = '#include "wayland-protocol.c.h"\n';
for (const chfile of chfiles) {
cfile += '#include "' + chfile + '.c.h"\n';
}
fs.writeFileSync(path.resolve(waylandDir, 'waylandunit.c'), cfile);

project.addIncludeDir(path.join(targetDirectory, 'wayland'));
project.addFile(path.resolve(waylandDir, '**'));
}
Expand Down

0 comments on commit 2e494f2

Please sign in to comment.