diff --git a/.github/workflows/parse_api.yml b/.github/workflows/parse_api.yml index c8665e1d4..ce7cb9f9a 100644 --- a/.github/workflows/parse_api.yml +++ b/.github/workflows/parse_api.yml @@ -32,6 +32,6 @@ jobs: set -x git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add tools/parser - git commit -m "Update raylib_api.* by CI" + git add tools/rlparser + git commit -m "rlparser: update raylib_api.* by CI" git push diff --git a/tools/parser/Makefile b/tools/parser/Makefile deleted file mode 100644 index ecfdb44ba..000000000 --- a/tools/parser/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -EXTENSION?=txt -FORMAT?=DEFAULT -.PHONY: all parse clean raylib_api - - -raylib_parser: raylib_parser.c - cc raylib_parser.c -o raylib_parser - -raylib_api: ../../src/raylib.h raylib_parser - FORMAT=DEFAULT EXTENSION=txt $(MAKE) raylib_api.txt - FORMAT=JSON EXTENSION=json $(MAKE) raylib_api.json - FORMAT=XML EXTENSION=xml $(MAKE) raylib_api.xml - FORMAT=LUA EXTENSION=lua $(MAKE) raylib_api.lua - -raylib_api.$(EXTENSION): ../../src/raylib.h raylib_parser - ./raylib_parser -i ../../src/raylib.h -o raylib_api.$(EXTENSION) -f $(FORMAT) -d RLAPI - -raymath_api.$(EXTENSION): ../../src/raymath.h raylib_parser - ./raylib_parser -i ../../src/raymath.h -o raymath_api.$(EXTENSION) -f $(FORMAT) -d RMAPI - -rlgl_api.$(EXTENSION): ../../src/rlgl.h raylib_parser - ./raylib_parser -i ../../src/rlgl.h -o rlgl_api.$(EXTENSION) -f $(FORMAT) -d RLAPI -t "RLGL IMPLEMENTATION" - -reasings_api.$(EXTENSION): ../../examples/others/reasings.h raylib_parser - ./raylib_parser -i ../../examples/others/reasings.h -o reasings_api.$(EXTENSION) -f $(FORMAT) -d EASEDEF - -raygui_api.$(EXTENSION): ../raygui.h raylib_parser - ./raylib_parser -i ../raygui.h -o raygui_api.$(EXTENSION) -f $(FORMAT) -d RAYGUIAPI -t "RAYGUI IMPLEMENTATION" - -parse: raylib_api.$(EXTENSION) raymath_api.$(EXTENSION) rlgl_api.$(EXTENSION) raygui_api.$(EXTENSION) - - -# `make parse` (and therefore `make all) requires -# rmem.h, physac.h and raygui.h to exist in the correct directory -# API files for individual headers can be created likeso, provided the relevant header exists: -# FORMAT=JSON EXTENSION=json make raygui_api.json -all: raylib_parser - FORMAT=DEFAULT EXTENSION=txt $(MAKE) parse - FORMAT=JSON EXTENSION=json $(MAKE) parse - FORMAT=XML EXTENSION=xml $(MAKE) parse - FORMAT=LUA EXTENSION=lua $(MAKE) parse - -clean: - rm -f raylib_parser *.json *.txt *.xml *.lua diff --git a/tools/parser/LICENSE b/tools/rlparser/LICENSE similarity index 100% rename from tools/parser/LICENSE rename to tools/rlparser/LICENSE diff --git a/tools/rlparser/Makefile b/tools/rlparser/Makefile new file mode 100644 index 000000000..a645f7f41 --- /dev/null +++ b/tools/rlparser/Makefile @@ -0,0 +1,118 @@ +EXTENSION?=txt +FORMAT?=DEFAULT +.PHONY: all parse clean raylib_api + +# Determine PLATFORM_OS +# No uname.exe on MinGW!, but OS=Windows_NT on Windows! +# ifeq ($(UNAME),Msys) -> Windows +ifeq ($(OS),Windows_NT) + PLATFORM_OS = WINDOWS +else + UNAMEOS = $(shell uname) + ifeq ($(UNAMEOS),Linux) + PLATFORM_OS = LINUX + endif + ifeq ($(UNAMEOS),FreeBSD) + PLATFORM_OS = BSD + endif + ifeq ($(UNAMEOS),OpenBSD) + PLATFORM_OS = BSD + endif + ifeq ($(UNAMEOS),NetBSD) + PLATFORM_OS = BSD + endif + ifeq ($(UNAMEOS),DragonFly) + PLATFORM_OS = BSD + endif + ifeq ($(UNAMEOS),Darwin) + PLATFORM_OS = OSX + endif +endif + +# Define default C compiler: CC +#------------------------------------------------------------------------------------------------ +CC = gcc +ifeq ($(PLATFORM_OS),OSX) + # OSX default compiler + CC = clang +endif +ifeq ($(PLATFORM_OS),BSD) + # FreeBSD, OpenBSD, NetBSD, DragonFly default compiler + CC = clang +endif + +# Define default make program: MAKE +#------------------------------------------------------------------------------------------------ +MAKE ?= make +ifeq ($(PLATFORM_OS),WINDOWS) + MAKE = mingw32-make +endif + +# Define compiler flags: CFLAGS +#------------------------------------------------------------------------------------------------ +CFLAGS = -Wall -std=c99 +#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes + +ifeq ($(BUILD_MODE),DEBUG) + CFLAGS += -g -D_DEBUG +else + ifeq ($(PLATFORM_OS),OSX) + CFLAGS += -O2 + else + CFLAGS += -s -O2 + endif +endif +ifeq ($(PLATFORM_OS),WINDOWS) + # NOTE: The resource .rc file contains windows executable icon and properties + CFLAGS += rlparser.rc.data +endif + +# Define processes to execute +#------------------------------------------------------------------------------------------------ +# rlparser compilation +rlparser: rlparser.c + $(CC) rlparser.c -o rlparser $(CFLAGS) + +# rlparser execution: [raylib.h] parse, generating some output files +raylib_api: ../../src/raylib.h rlparser + FORMAT=DEFAULT EXTENSION=txt $(MAKE) raylib_api.txt + FORMAT=JSON EXTENSION=json $(MAKE) raylib_api.json + FORMAT=XML EXTENSION=xml $(MAKE) raylib_api.xml + FORMAT=LUA EXTENSION=lua $(MAKE) raylib_api.lua + +# rlparser execution: [raylib.h] parse, generating some output files +raylib_api.$(EXTENSION): ../../src/raylib.h rlparser + ./rlparser -i ../../src/raylib.h -o raylib_api.$(EXTENSION) -f $(FORMAT) -d RLAPI + +# rlparser execution: [rlgl.h] parse, generating some output files +rlgl_api.$(EXTENSION): ../../src/rlgl.h rlparser + ./rlparser -i ../../src/rlgl.h -o rlgl_api.$(EXTENSION) -f $(FORMAT) -d RLAPI -t "RLGL IMPLEMENTATION" + +# rlparser execution: [raymath.h] parse, generating some output files +raymath_api.$(EXTENSION): ../../src/raymath.h rlparser + ./rlparser -i ../../src/raymath.h -o raymath_api.$(EXTENSION) -f $(FORMAT) -d RMAPI + +# rlparser execution: [reasings.h] parse, generating some output files +reasings_api.$(EXTENSION): ../../examples/others/reasings.h rlparser + ./rlparser -i ../../examples/others/reasings.h -o reasings_api.$(EXTENSION) -f $(FORMAT) -d EASEDEF + +# rlparser execution: [raygui.h] parse, generating some output files +raygui_api.$(EXTENSION): ../raygui.h rlparser + ./rlparser -i ../raygui.h -o raygui_api.$(EXTENSION) -f $(FORMAT) -d RAYGUIAPI -t "RAYGUI IMPLEMENTATION" + +# Target to generate required APIs output files +parse: raylib_api.$(EXTENSION) raymath_api.$(EXTENSION) rlgl_api.$(EXTENSION) raygui_api.$(EXTENSION) + +# "make parse" (and therefore "make all") requires +# raygui.h and reasings_api.h to exist in the correct directory +# API files for individual headers can be created likeso, provided the relevant header exists: +# FORMAT=JSON EXTENSION=json make raygui_api.json +all: rlparser + FORMAT=DEFAULT EXTENSION=txt $(MAKE) parse + FORMAT=JSON EXTENSION=json $(MAKE) parse + FORMAT=XML EXTENSION=xml $(MAKE) parse + FORMAT=LUA EXTENSION=lua $(MAKE) parse + +# Clean rlparser and generated output files +clean: + rm -f rlparser *.json *.txt *.xml *.lua diff --git a/tools/parser/README.md b/tools/rlparser/README.md similarity index 83% rename from tools/parser/README.md rename to tools/rlparser/README.md index 86cdfdd5b..0e4f9b739 100644 --- a/tools/parser/README.md +++ b/tools/rlparser/README.md @@ -1,4 +1,4 @@ -# raylib parser +# rlparser - raylib parser This parser scans [`raylib.h`](../src/raylib.h) to get information about `defines`, `structs`, `enums` and `functions`. All data is separated into parts, usually as strings. The following types are used for data: @@ -8,16 +8,16 @@ All data is separated into parts, usually as strings. The following types are us - `struct StructInfo` - `struct EnumInfo` -Check `raylib_parser.c` for details about those structs. +Check `rlparser.c` for details about those structs. ## Command Line ``` ////////////////////////////////////////////////////////////////////////////////// // // -// raylib API parser // +// rlparser - raylib header API parser // // // -// more info and bugs-report: github.com/raysan5/raylib/parser // +// more info and bugs-report: github.com/raysan5/raylib/tools/rlparser // // // // Copyright (c) 2021-2025 Ramon Santamaria (@raysan5) // // // @@ -25,7 +25,7 @@ Check `raylib_parser.c` for details about those structs. USAGE: - > raylib_parser [--help] [--input ] [--output ] [--format ] + > rlparser [--help] [--input ] [--output ] [--format ] OPTIONS: @@ -50,19 +50,19 @@ OPTIONS: EXAMPLES: - > raylib_parser --input raylib.h --output api.json + > rlparser --input raylib.h --output api.json Process to generate - > raylib_parser --output raylib_data.info --format XML + > rlparser --output raylib_data.info --format XML Process to generate as XML text data - > raylib_parser --input raymath.h --output raymath_data.info --format XML --define RMAPI + > rlparser --input raymath.h --output raymath_data.info --format XML --define RMAPI Process to generate as XML text data ``` ## Constraints -This parser is specifically designed to work with raylib.h, so, it has some constraints: +`rlparser` is specifically designed to work with `raylib.h`, so, it has some constraints: - Functions are expected as a single line with the following structure: ``` @@ -91,7 +91,7 @@ This parser is specifically designed to work with raylib.h, so, it has some cons ``` _NOTE: For enums, multiple options are supported:_ - + - If value is not provided, ( + 1) is assigned - Value description can be provided or not @@ -103,5 +103,7 @@ This parser **does not require `` library**, all data is parsed direct ### LICENSE: zlib/libpng -raylib-parser is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check [LICENSE](LICENSE) for further details. +raylib-parser is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. + +Check [LICENSE](LICENSE) for further details. diff --git a/tools/parser/output/raylib_api.json b/tools/rlparser/output/raylib_api.json similarity index 100% rename from tools/parser/output/raylib_api.json rename to tools/rlparser/output/raylib_api.json diff --git a/tools/parser/output/raylib_api.lua b/tools/rlparser/output/raylib_api.lua similarity index 100% rename from tools/parser/output/raylib_api.lua rename to tools/rlparser/output/raylib_api.lua diff --git a/tools/parser/output/raylib_api.txt b/tools/rlparser/output/raylib_api.txt similarity index 100% rename from tools/parser/output/raylib_api.txt rename to tools/rlparser/output/raylib_api.txt diff --git a/tools/parser/output/raylib_api.xml b/tools/rlparser/output/raylib_api.xml similarity index 100% rename from tools/parser/output/raylib_api.xml rename to tools/rlparser/output/raylib_api.xml diff --git a/tools/parser/raylib_parser.c b/tools/rlparser/rlparser.c similarity index 99% rename from tools/parser/raylib_parser.c rename to tools/rlparser/rlparser.c index 4b5fe1625..2432af4af 100644 --- a/tools/parser/raylib_parser.c +++ b/tools/rlparser/rlparser.c @@ -1,28 +1,28 @@ /********************************************************************************************** - raylib API parser + rlparser - raylib header API parser, extracts API information as separate tokens This parser scans raylib.h to get API information about defines, structs, aliases, enums, callbacks and functions. All data is divided into pieces, usually as strings. The following types are used for data: - - struct DefineInfo - struct StructInfo - struct AliasInfo - struct EnumInfo - struct FunctionInfo + + WARNING: This parser is specifically designed to work with raylib.h, and has some contraints + in that regards. Still, it can also work with other header files that follow same file structure + conventions as raylib.h: rlgl.h, raymath.h, raygui.h, reasings.h CONSTRAINTS: - This parser is specifically designed to work with raylib.h, so, it has some constraints: - Functions are expected as a single line with the following structure: - ( , ); - Be careful with functions broken into several lines, it breaks the process! + WARNING: Be careful with functions broken into several lines, it breaks the process! - Structures are expected as several lines with the following form: - typedef struct { ; @@ -31,7 +31,6 @@ } ; - Enums are expected as several lines with the following form: - typedef enum { = , @@ -45,7 +44,6 @@ - Value description can be provided or not OTHER NOTES: - - This parser could work with other C header files if mentioned constraints are followed. - This parser does not require library, all data is parsed directly from char buffers. diff --git a/tools/rlparser/rlparser.ico b/tools/rlparser/rlparser.ico new file mode 100644 index 000000000..37f2af6b6 Binary files /dev/null and b/tools/rlparser/rlparser.ico differ diff --git a/tools/rlparser/rlparser.rc b/tools/rlparser/rlparser.rc new file mode 100644 index 000000000..a5bb5b7ad --- /dev/null +++ b/tools/rlparser/rlparser.rc @@ -0,0 +1,24 @@ +IDI_APP_ICON ICON "rlparser.ico" +1 VERSIONINFO +FILEVERSION 5,5,0,0 +PRODUCTVERSION 5,5,0,0 +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" // English US + BEGIN + VALUE "CompanyName", "raylib technologies" + VALUE "FileDescription", "rlparser | raylib header API parser" + VALUE "FileVersion", "1.0" + VALUE "InternalName", "rlparser" + VALUE "LegalCopyright", "(c) 2025 Ramon Santamaria (@raysan5)" + VALUE "OriginalFilename", "rlparser" + VALUE "ProductName", "rlparser" + VALUE "ProductVersion", "1.0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 // English US + END +END \ No newline at end of file diff --git a/tools/rlparser/rlparser.rc.data b/tools/rlparser/rlparser.rc.data new file mode 100644 index 000000000..1b5cc0c02 Binary files /dev/null and b/tools/rlparser/rlparser.rc.data differ