glfw: reduce compilation units to bring iteration time down to ~90ms

This consistently shaves off about 40ms (~130ms -> ~90ms, 30% reduction) from build times when iterating.

On Windows, I suspect the result will be much greater due to slow filesystem perf there and the fact
that this reduces the # of files read.

This was originally brought to my attention as a possibility by @meshula in hexops/dawn#2, the way this
works is by reducing compilation units so that C headers only need to be read/parsed/interpreted once
rather than once per individual C source file we are compiling.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2021-12-10 04:41:39 -07:00 committed by Stephen Gutekanst
parent c552148d0b
commit 3ec74222e6
9 changed files with 57 additions and 103 deletions

View file

@ -293,7 +293,6 @@ pub const Hints = struct {
else => unreachable,
};
}
}
};

9
glfw/src/sources_all.c Normal file
View file

@ -0,0 +1,9 @@
// General sources
#include "monitor.c"
#include "init.c"
#include "vulkan.c"
#include "input.c"
#include "osmesa_context.c"
#include "egl_context.c"
#include "context.c"
#include "window.c"

6
glfw/src/sources_linux.c Normal file
View file

@ -0,0 +1,6 @@
#include "sources_all.c"
// General Linux-like sources
#include "posix_time.c"
#include "posix_thread.c"
#include "linux_joystick.c"

View file

@ -0,0 +1,4 @@
// General Linux-like sources
#include "wl_monitor.c"
#include "wl_window.c"
#include "wl_init.c"

View file

@ -0,0 +1,6 @@
// General Linux-like sources
#include "x11_init.c"
#include "x11_window.c"
#include "x11_monitor.c"
#include "xkb_unicode.c"
#include "glx_context.c"

5
glfw/src/sources_macos.c Normal file
View file

@ -0,0 +1,5 @@
#include "sources_all.c"
// MacOS-specific sources
#include "cocoa_time.c"
#include "posix_thread.c"

6
glfw/src/sources_macos.m Normal file
View file

@ -0,0 +1,6 @@
// MacOS-specific sources
#include "cocoa_joystick.m"
#include "cocoa_init.m"
#include "cocoa_window.m"
#include "cocoa_monitor.m"
#include "nsgl_context.m"

View file

@ -0,0 +1,10 @@
#include "sources_all.c"
// Windows-specific sources
#include "win32_thread.c"
#include "wgl_context.c"
#include "win32_init.c"
#include "win32_monitor.c"
#include "win32_time.c"
#include "win32_joystick.c"
#include "win32_window.c"