Top Level Namespace
Defined Under Namespace
Modules: RGame Classes: Example
Constant Summary collapse
- SOURCE_DIRS =
The engine sources live in this directory rather than a top-level src/:
gem installunpacks the gem and runs this script, and an extension must be buildable from its own directory.They are grouped into subdirectories by subsystem (app, graphics, text, input, audio) plus ruby/ for the Ruby-facing glue and vendor/ for third-party code. mkmf's default is to compile every .c in the extension's own directory and nothing deeper, so the source list has to be spelled out — which is what $srcs and $VPATH below do.
$srcs — what to compile. mkmf names each object after the source's *basename*, so the .o files land flat in this directory no matter how deep the .c was. Basenames therefore have to be unique across the subdirectories; mkmf aborts with "source files duplication" if they ever aren't, so that rule enforces itself. $VPATH — where make looks for a source when a rule names it by basename. The generic `.c.o` rule mkmf emits does exactly that, so without this every object would come up as a missing prerequisite.vendor/ contributes only its
_impl.c translation units. The libraries themselves are #included by those files (stb_vorbis even ships as a .c), so compiling them separately would duplicate every symbol in them. %w[app graphics text input audio ruby].freeze
- VENDORED =
The vendored implementations, compiled with warnings off (see vendor/README.md). mkmf has no per-file flag setting, so the rules are appended to the Makefile it just wrote. An explicit rule for a specific target beats mkmf's generic .c.o suffix rule, so these are what get used for those objects and nothing else.
Written from one list rather than one block per library: a second hand-copied rule is how the first one drifts. They are explicit rules rather than a
%pattern because mkmf's Makefiles are meant to work with whatevermakethe platform has, and pattern rules are a GNU extension.-wcomes last on the command line and switches every warning back off, which is simpler and more robust than trying to subtract -Wall -Wextra from $(CFLAGS) — everything else about how the extension compiles stays identical. Each vendored library's implementation TU (_impl.c) and the file it instantiates. stb_vorbis is the odd one out: it ships as a .c, not a .h. { 'stb_image' => 'stb_image.h', 'stb_truetype' => 'stb_truetype.h', 'stb_vorbis' => 'stb_vorbis.c', 'miniaudio' => 'miniaudio.h' }.freeze