raylib-spinel 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0f47d0b3e4ab6bcea3834e6fcb32f4cb699100b77878e98fcbd5050e4b4e561d
4
+ data.tar.gz: 941a7d8c46999e45cea32a200bdfef32e59a7517b6db5cf3652fc441ffd5c2c1
5
+ SHA512:
6
+ metadata.gz: 0f5544c09a04d1dc813bc731f61594deb292502f0d3dddcdba63b075a7310db2627881ea20d8c35b6d5ca7690b3a4ce1d36609176307d8a74e7cea8bcc4c9f9d
7
+ data.tar.gz: a7a7b714df6829090a3b4f491c2bee2afe877bf682a94d778f6f7423f181567793cafce8c3dfe8ffce12d6d1b7c81712f2647bc43318f8b030cb11fe6e3b9363
data/LICENSE.md ADDED
@@ -0,0 +1,16 @@
1
+ Copyright (c) 2026 Nelson Jovel
2
+
3
+ This software is provided "as-is", without any express or implied warranty. In no event
4
+ will the authors be held liable for any damages arising from the use of this software.
5
+
6
+ Permission is granted to anyone to use this software for any purpose, including commercial
7
+ applications, and to alter it and redistribute it freely, subject to the following restrictions:
8
+
9
+ 1. The origin of this software must not be misrepresented; you must not claim that you
10
+ wrote the original software. If you use this software in a product, an acknowledgment
11
+ in the product documentation would be appreciated but is not required.
12
+
13
+ 2. Altered source versions must be plainly marked as such, and must not be misrepresented
14
+ as being the original software.
15
+
16
+ 3. This notice may not be removed or altered from any source distribution.
data/README.md ADDED
@@ -0,0 +1,135 @@
1
+ # raylib-spinel
2
+
3
+ `require "raylib"` for games built with the
4
+ [Spinel AOT compiler](https://github.com/rebuilt/spinel-crystalizer), and an
5
+ MRI gem that runs the same game under CRuby unchanged.
6
+
7
+ One game, two engines:
8
+
9
+ - **Spinel (AOT):** this package provides the whole raylib-bindings API
10
+ surface — raylib, raymath, rlgl, rcamera, raygui, physac — as FFI
11
+ declarations plus C adapters that `spin` compiles into your binary.
12
+ - **CRuby (MRI):** the gem delegates to the
13
+ [raylib-bindings](https://rubygems.org/gems/raylib-bindings) gem, so the
14
+ same source runs interpreted with no changes.
15
+
16
+ ## Quick start (CRuby)
17
+
18
+ ```bash
19
+ gem install raylib-spinel
20
+ ```
21
+
22
+ ```ruby
23
+ require "raylib-spinel"
24
+
25
+ include Raylib
26
+
27
+ Raylib.InitWindow(1280, 720, "raylib [text] example - Hello World")
28
+ Raylib.EnableCursor()
29
+ WHITE_TEXT_COLOR = Color.from_u8(255, 255, 255, 255)
30
+ BLACK_TEXT_COLOR = Color.from_u8(0, 0, 0, 255)
31
+ until Raylib.WindowShouldClose
32
+ Raylib.BeginDrawing
33
+ Raylib.ClearBackground(BLACK_TEXT_COLOR)
34
+ Raylib.DrawFPS(10, 90)
35
+
36
+ Raylib.DrawText("Hello World", 10, 10, 20, WHITE_TEXT_COLOR)
37
+ Raylib.EndDrawing
38
+
39
+ # Break instead of CloseWindow here: closing mid-frame leaves update/draw
40
+ # running against a dead GL context; teardown happens after the loop.
41
+ break if Raylib.IsKeyDown(Raylib::KEY_Q)
42
+ end
43
+
44
+ Raylib.CloseWindow()
45
+ ```
46
+
47
+ `Raylib.WindowShouldClose` answers a real boolean on both engines — write
48
+ `until Raylib.WindowShouldClose`, not `== 1` (a Spinel `:bool` and an FFI
49
+ `:bool` both give `true`/`false`, never an Integer).
50
+
51
+ No system raylib is needed: raylib-bindings ships prebuilt binaries, and
52
+ raylib-spinel's loader calls `Raylib.load_lib` on them by absolute path.
53
+ The prebuilt library dlopens OpenGL/GLX/X11 from the operating system
54
+ (stock packages everywhere; on NixOS, from a shell like the sibling
55
+ hello_raylib checkout's flake). Bundler users: add `gem "raylib-spinel"`
56
+ to the Gemfile.
57
+
58
+ ## Quick start (Spinel)
59
+
60
+ ```bash
61
+ spin new myapp # scaffold: spin.toml, bin/myapp.rb, test/, .gitignore
62
+ cd myapp
63
+ spin add raylib --git https://github.com/rebuilt/raylib-spinel
64
+ # or a local checkout: spin add raylib --path ../raylib-spinel
65
+
66
+ spin run # compile bin/myapp.rb and run it
67
+ ```
68
+
69
+ `spin` compiles the eight carried C adapters against the raylib headers
70
+ `pkg-config --cflags raylib` names (`[native] pkg_config` in spin.toml),
71
+ then links `-lraylib`.
72
+
73
+ ## Existing raylib-bindings projects
74
+
75
+ Projects written against the MRI `raylib-bindings` gem need no source
76
+ changes: point spin at this package and keep `require "raylib"`. That entry
77
+ loads the full gem surface (raylib, raymath, rlgl, rcamera, raygui, physac),
78
+ the bundled `ffi` package, and the include-able instance methods, and the
79
+ gem's `Raylib.load_lib` / `Raylib.setup_symbols` calls are accepted as
80
+ no-ops.
81
+
82
+ ```bash
83
+ cd my_existing_game
84
+ spin add raylib --git https://github.com/rebuilt/raylib-spinel
85
+ spin run my_game # `require "raylib"` resolves to this package
86
+ ```
87
+
88
+ ## Where libraylib comes from at run time
89
+
90
+ - **CRuby:** raylib-bindings' bundled binaries, loaded by absolute path
91
+ (see the quick start above).
92
+ - **Spinel:** the link needs a `libraylib` the linker can find
93
+ (pkg-config's `-L`, or a system install), and the produced binary needs
94
+ the library again at run time. The program link carries
95
+ `-Wl,-rpath,'$ORIGIN/../raylib'` (lib/raylib_ffi.rb), so a known-good
96
+ `libraylib.so` vendored into a `raylib/` sibling of the binary always
97
+ wins — that is how the sibling hello_raylib checkout ships the gem's
98
+ build. A distro's runtime-only raylib package is often not enough on its
99
+ own: the loader probes the *unversioned* `libraylib.so`, which
100
+ runtime-only packages frequently do not ship. A source `make install`
101
+ does put one in /usr/local/lib, and nixpkgs' raylib does too.
102
+
103
+ ## Development: generators, audits, corpus
104
+
105
+ The Spinel surface is generated from the gem's API JSON; the generators keep
106
+ the shim layer honest:
107
+
108
+ ```bash
109
+ python3 tools/gen_raylib_ffi.py # ffi_func/wrapper surface + rl_* shims
110
+ python3 tools/gen_handle_class_c.py # handle-class views + Class.size (sizeof)
111
+ python3 tools/gen_raylib_include.py # include-able instance delegators
112
+ python3 tools/wrap_handle_producers.py # wrap Load*/Gen* into view objects
113
+ ```
114
+
115
+ Handle classes are GC views (`rl_<X>`: cls_id / payload pointer / owner). Every
116
+ shim parameter naming a handle class, by value or by pointer, must unwrap it
117
+ (`*RL_TEX(t)`, `RL_IMG(i)`); only flat buffers stay raw. Two audits enforce
118
+ that and are safe to run any time:
119
+
120
+ ```bash
121
+ python3 tools/check_shim_unwraps.py # shims + direct decls + undefined symbols
122
+ python3 tools/fix_pointer_handle_shims.py --check # single-struct pointer params unwrapped
123
+ ruby tools/check_duplicate_methods.rb # one definition per module function
124
+ ```
125
+
126
+ Verification: `spin test` (headless, MRI-differential expectations) and
127
+ `python3 tools/run_gem_corpus.py` (synthetic programs run under CRuby +
128
+ raylib-bindings and under Spinel, then diffed; the raylib-bindings examples
129
+ with the loader line replaced are compiled to record coverage). The runner
130
+ links the gem's libraylib under its SONAME: the system build creates incomplete
131
+ FBOs, which shows up as all-zero render-texture readbacks.
132
+
133
+ Packaging (what each channel ships, and the consumer matrix that proves a
134
+ stranger's install works) is measured in `PACKAGING.md`; `ruby
135
+ tools/publish_readiness.rb` re-runs the measurement.