Debian Codegraph @

tools/rexm/README.md

raw symbols SCIP
1
2 # `rexm` - raylib examples manager
3
4 rexm is a raylib support tool to help to manage the raylib examples collection.
5
6 ## Why do we need a tool to manage raylib examples?
7
8 raylib has a big collection of examples to learn how to use the library. It started with just a few examples and it has grown to +160 in the last 12 years, with many of those examples contributed by the community (~50%).
9
10 **Managing those examples has become a considerable amount of work.** Some years ago an [examples template](https://github.com/raysan5/raylib/blob/master/examples/examples_template.c) was created to standarize examples format and contents, it simplified the review process but implementing a new example is not enough; adding/modifying an new example from the collection implies a series of actions:
11
12 - Create the example `.c` code file, **following provided [examples template](https://github.com/raysan5/raylib/blob/master/examples/examples_template.c) guidelines**.
13 - Make sure example header lists all required metadata information
14 - Make sure example follows required structure and sections
15 - Copy required resources into `resource` directory, make sure they are based in a permissive license
16 - Create a screenshot for the example, illustrating main functionality.
17 - Add example to several raylib build systems:
18 - Examples `Makefile`: multi-platform build configuration
19 - Examples `Makefile.Web`: specific Web building configuration
20 - raylib Visual Studio 2022 solution: Include a separate project with example, in correct category
21 - Add example to examples `README.md` table, in corerct category
22 - Compile example for Web and upload to `raylib.com` open-source repository
23 - Update `raylib.com` webpage to include example running on real-time
24
25 All the following files need to be require to be review every time an examples is added or modified:
26
27 ```
28 - Add: raylib/examples/<category>/<category>_example_name.c
29 - Add: raylib/examples/<category>/<category>_example_name.png
30 - Add: raylib/examples/<category>/resources/..
31 - Edit: raylib/examples/Makefile
32 - Edit: raylib/examples/Makefile.Web
33 - Add: raylib/projects/VS2022/examples/<category>_example_name.vcxproj
34 - Edit: raylib/projects/VS2022/raylib.sln
35 - Edit: raylib/examples/README.md
36 - Edit: raylib.com/common/examples.js
37 - Generate: raylib.com/examples/<category>/<category>_example_name.html
38 - Generate: raylib.com/examples/<category>/<category>_example_name.data
39 - Generate: raylib.com/examples/<category>/<category>_example_name.wasm
40 - Generate: raylib.com/examples/<category>/<category>_example_name.js
41 ```
42
43 This process has been done manually for many years and required a lot of time, it was also very prone to errors, like missing some edits or adding typos.
44
45 Finally I decided to automatize the process and create a pipeline to `add`, `rename`, `remove`, `validate` and `build` examples automatically edited. Additionally I decided to a `validation` process to verify the integrity of all the required files and even fix some of the potential issues.
46
47 ## `rexm` supported commands
48
49 The following commands are supported by `rexm` to manage examples:
50
51 ```
52 help : Provides command-line usage information
53 create <new_example_name> : Creates an empty example, from internal template
54 add <example_name> : Add existing example, category extracted from name
55 Supported categories: core, shapes, textures, text, models
56 rename <old_examples_name> <new_example_name> : Rename an existing example
57 remove <example_name> : Remove an existing example
58 build <example_name> : Build example for Desktop and Web platforms
59 validate : Validate examples collection, generates report
60 update : Validate and update examples collection, generates report
61 ```
62
63 ## `rexm` examples **validation** and **update**
64
65 Two commands have been added to `rexm` to validate all the examples, checking if the examples follow all requirements and all the files needed are available, that way the examples review has been automated, generating complete tables on examples status.
66
67 As we were able to detect possible examples errors and inconsistencies, an additional command was implemented to **update** all examples with inconsistencies.
68
69 ## `rexm` technology used
70
71 Usually this kind of pipelines are implemented with high-level scripting languages like Python due to all the functionality already provided, specially useful for files/paths management or text files editing but those languages also require the interpreter available to run. I decided to follow a less common route, implementing the tool directly in C, the language I use for raylib and all my tools.
72
73 C standard library does not provide a lot of the high-level functionality required for files and text management but here is where raylib came to the rescue. raylib already contained some functions to work with the file system and to manage text, so I decided to implement the required additional ones to use raylib on pipelines building.
74
75 The main benefit of using C and raylib is that the pipeline can be created in C and it can be build int an independent multi-platform dependency-free executable tool; it also open the door for a possible expansion into a UI interface, if required in the future.
76
77 As mentioned, implementing the pipeline in C with raylib required some additional support functions to be added, to simplify some tasks and align with functionality provided by high-level languages; but it was not dramatic and the truth is that the development process just flowed smoothly.
78
79 Some of the support functions implemented:
80
81 ```c
82 // File management functions
83 int FileRename(const char *fileName, const char *fileRename); // Rename file (if exists)
84 int FileRemove(const char *fileName); // Remove file (if exists)
85 int FileCopy(const char *srcPath, const char *dstPath); // Copy file from one path to another, dstPath created if it doesn't exist
86 int FileMove(const char *srcPath, const char *dstPath); // Move file from one directory to another, dstPath created if it doesn't exist
87 int FileTextReplace(const char *fileName, const char *search, const char *replacement); // Replace text in an existing file
88 iint FileTextFindIndex(const char *fileName, const char *search); // Find text in existing file
89
90 // Text management functions
91 char **LoadTextLines(const char *text, int *count); // Load text lines from text block, separate by '\n'
92 void UnloadTextLines(char **text); // Unload text lines
93 const char *TextRemoveSpaces(const char *text); // Remove text spaces, concat words
94 char *GetTextBetween(const char *text, const char *begin, const char *end); // Get text between two strings
95 char *TextReplace(const char *text, const char *search, const char *replacement); // Replace text string
96 char *TextReplaceBetween(const char *text, const char *begin, const char *end, const char *replacement); // Replace text between two specific strings
97 ```
98
99 **These functions have been added to raylib main library.**
100
101 ## License
102
103 `rexm` is an **open source** project, licensed under an unmodified [zlib/libpng license](LICENSE)
104
105 *Copyright (c) 2025-2026 Ramon Santamaria ([@raysan5](https://github.com/raysan5))*