Skip to content

Commit d7a83a1

Browse files
committed
REVIEWED: RENAMED: Renamed tool raylib_parser to rlparser
The tool can work with other libraries following `raylib.h` structure, keeping the `raylib_parser` name could be missleading. Also added an icon an reviewed Makefile an CI.
1 parent f0ffdb3 commit d7a83a1

File tree

13 files changed

+163
-65
lines changed

13 files changed

+163
-65
lines changed

.github/workflows/parse_api.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ jobs:
3232
set -x
3333
git config user.name "github-actions[bot]"
3434
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
35-
git add tools/parser
36-
git commit -m "Update raylib_api.* by CI"
35+
git add tools/rlparser
36+
git commit -m "rlparser: update raylib_api.* by CI"
3737
git push

tools/parser/Makefile

Lines changed: 0 additions & 44 deletions
This file was deleted.
File renamed without changes.

tools/rlparser/Makefile

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
EXTENSION?=txt
2+
FORMAT?=DEFAULT
3+
.PHONY: all parse clean raylib_api
4+
5+
# Determine PLATFORM_OS
6+
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
7+
# ifeq ($(UNAME),Msys) -> Windows
8+
ifeq ($(OS),Windows_NT)
9+
PLATFORM_OS = WINDOWS
10+
else
11+
UNAMEOS = $(shell uname)
12+
ifeq ($(UNAMEOS),Linux)
13+
PLATFORM_OS = LINUX
14+
endif
15+
ifeq ($(UNAMEOS),FreeBSD)
16+
PLATFORM_OS = BSD
17+
endif
18+
ifeq ($(UNAMEOS),OpenBSD)
19+
PLATFORM_OS = BSD
20+
endif
21+
ifeq ($(UNAMEOS),NetBSD)
22+
PLATFORM_OS = BSD
23+
endif
24+
ifeq ($(UNAMEOS),DragonFly)
25+
PLATFORM_OS = BSD
26+
endif
27+
ifeq ($(UNAMEOS),Darwin)
28+
PLATFORM_OS = OSX
29+
endif
30+
endif
31+
32+
# Define default C compiler: CC
33+
#------------------------------------------------------------------------------------------------
34+
CC = gcc
35+
ifeq ($(PLATFORM_OS),OSX)
36+
# OSX default compiler
37+
CC = clang
38+
endif
39+
ifeq ($(PLATFORM_OS),BSD)
40+
# FreeBSD, OpenBSD, NetBSD, DragonFly default compiler
41+
CC = clang
42+
endif
43+
44+
# Define default make program: MAKE
45+
#------------------------------------------------------------------------------------------------
46+
MAKE ?= make
47+
ifeq ($(PLATFORM_OS),WINDOWS)
48+
MAKE = mingw32-make
49+
endif
50+
51+
# Define compiler flags: CFLAGS
52+
#------------------------------------------------------------------------------------------------
53+
CFLAGS = -Wall -std=c99
54+
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
55+
56+
ifeq ($(BUILD_MODE),DEBUG)
57+
CFLAGS += -g -D_DEBUG
58+
else
59+
ifeq ($(PLATFORM_OS),OSX)
60+
CFLAGS += -O2
61+
else
62+
CFLAGS += -s -O2
63+
endif
64+
endif
65+
ifeq ($(PLATFORM_OS),WINDOWS)
66+
# NOTE: The resource .rc file contains windows executable icon and properties
67+
CFLAGS += rlparser.rc.data
68+
endif
69+
70+
# Define processes to execute
71+
#------------------------------------------------------------------------------------------------
72+
# rlparser compilation
73+
rlparser: rlparser.c
74+
$(CC) rlparser.c -o rlparser $(CFLAGS)
75+
76+
# rlparser execution: [raylib.h] parse, generating some output files
77+
raylib_api: ../../src/raylib.h rlparser
78+
FORMAT=DEFAULT EXTENSION=txt $(MAKE) raylib_api.txt
79+
FORMAT=JSON EXTENSION=json $(MAKE) raylib_api.json
80+
FORMAT=XML EXTENSION=xml $(MAKE) raylib_api.xml
81+
FORMAT=LUA EXTENSION=lua $(MAKE) raylib_api.lua
82+
83+
# rlparser execution: [raylib.h] parse, generating some output files
84+
raylib_api.$(EXTENSION): ../../src/raylib.h rlparser
85+
./rlparser -i ../../src/raylib.h -o raylib_api.$(EXTENSION) -f $(FORMAT) -d RLAPI
86+
87+
# rlparser execution: [rlgl.h] parse, generating some output files
88+
rlgl_api.$(EXTENSION): ../../src/rlgl.h rlparser
89+
./rlparser -i ../../src/rlgl.h -o rlgl_api.$(EXTENSION) -f $(FORMAT) -d RLAPI -t "RLGL IMPLEMENTATION"
90+
91+
# rlparser execution: [raymath.h] parse, generating some output files
92+
raymath_api.$(EXTENSION): ../../src/raymath.h rlparser
93+
./rlparser -i ../../src/raymath.h -o raymath_api.$(EXTENSION) -f $(FORMAT) -d RMAPI
94+
95+
# rlparser execution: [reasings.h] parse, generating some output files
96+
reasings_api.$(EXTENSION): ../../examples/others/reasings.h rlparser
97+
./rlparser -i ../../examples/others/reasings.h -o reasings_api.$(EXTENSION) -f $(FORMAT) -d EASEDEF
98+
99+
# rlparser execution: [raygui.h] parse, generating some output files
100+
raygui_api.$(EXTENSION): ../raygui.h rlparser
101+
./rlparser -i ../raygui.h -o raygui_api.$(EXTENSION) -f $(FORMAT) -d RAYGUIAPI -t "RAYGUI IMPLEMENTATION"
102+
103+
# Target to generate required APIs output files
104+
parse: raylib_api.$(EXTENSION) raymath_api.$(EXTENSION) rlgl_api.$(EXTENSION) raygui_api.$(EXTENSION)
105+
106+
# "make parse" (and therefore "make all") requires
107+
# raygui.h and reasings_api.h to exist in the correct directory
108+
# API files for individual headers can be created likeso, provided the relevant header exists:
109+
# FORMAT=JSON EXTENSION=json make raygui_api.json
110+
all: rlparser
111+
FORMAT=DEFAULT EXTENSION=txt $(MAKE) parse
112+
FORMAT=JSON EXTENSION=json $(MAKE) parse
113+
FORMAT=XML EXTENSION=xml $(MAKE) parse
114+
FORMAT=LUA EXTENSION=lua $(MAKE) parse
115+
116+
# Clean rlparser and generated output files
117+
clean:
118+
rm -f rlparser *.json *.txt *.xml *.lua

tools/parser/README.md renamed to tools/rlparser/README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# raylib parser
1+
# rlparser - raylib parser
22

33
This parser scans [`raylib.h`](../src/raylib.h) to get information about `defines`, `structs`, `enums` and `functions`.
44
All data is separated into parts, usually as strings. The following types are used for data:
@@ -8,24 +8,24 @@ All data is separated into parts, usually as strings. The following types are us
88
- `struct StructInfo`
99
- `struct EnumInfo`
1010

11-
Check `raylib_parser.c` for details about those structs.
11+
Check `rlparser.c` for details about those structs.
1212

1313
## Command Line
1414

1515
```
1616
//////////////////////////////////////////////////////////////////////////////////
1717
// //
18-
// raylib API parser //
18+
// rlparser - raylib header API parser //
1919
// //
20-
// more info and bugs-report: github.com/raysan5/raylib/parser //
20+
// more info and bugs-report: github.com/raysan5/raylib/tools/rlparser //
2121
// //
2222
// Copyright (c) 2021-2025 Ramon Santamaria (@raysan5) //
2323
// //
2424
//////////////////////////////////////////////////////////////////////////////////
2525
2626
USAGE:
2727
28-
> raylib_parser [--help] [--input <filename.h>] [--output <filename.ext>] [--format <type>]
28+
> rlparser [--help] [--input <filename.h>] [--output <filename.ext>] [--format <type>]
2929
3030
OPTIONS:
3131
@@ -50,19 +50,19 @@ OPTIONS:
5050
5151
EXAMPLES:
5252
53-
> raylib_parser --input raylib.h --output api.json
53+
> rlparser --input raylib.h --output api.json
5454
Process <raylib.h> to generate <api.json>
5555
56-
> raylib_parser --output raylib_data.info --format XML
56+
> rlparser --output raylib_data.info --format XML
5757
Process <raylib.h> to generate <raylib_data.info> as XML text data
5858
59-
> raylib_parser --input raymath.h --output raymath_data.info --format XML --define RMAPI
59+
> rlparser --input raymath.h --output raymath_data.info --format XML --define RMAPI
6060
Process <raymath.h> to generate <raymath_data.info> as XML text data
6161
```
6262

6363
## Constraints
6464

65-
This parser is specifically designed to work with raylib.h, so, it has some constraints:
65+
`rlparser` is specifically designed to work with `raylib.h`, so, it has some constraints:
6666

6767
- Functions are expected as a single line with the following structure:
6868
```
@@ -91,7 +91,7 @@ This parser is specifically designed to work with raylib.h, so, it has some cons
9191
```
9292

9393
_NOTE: For enums, multiple options are supported:_
94-
94+
9595
- If value is not provided, (<valueInteger[i -1]> + 1) is assigned
9696
- Value description can be provided or not
9797

@@ -103,5 +103,7 @@ This parser **does not require `<string.h>` library**, all data is parsed direct
103103

104104
### LICENSE: zlib/libpng
105105

106-
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.
106+
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.
107+
108+
Check [LICENSE](LICENSE) for further details.
107109

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tools/parser/raylib_parser.c renamed to tools/rlparser/rlparser.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
/**********************************************************************************************
22
3-
raylib API parser
3+
rlparser - raylib header API parser, extracts API information as separate tokens
44
55
This parser scans raylib.h to get API information about defines, structs, aliases, enums, callbacks and functions.
66
All data is divided into pieces, usually as strings. The following types are used for data:
7-
87
- struct DefineInfo
98
- struct StructInfo
109
- struct AliasInfo
1110
- struct EnumInfo
1211
- struct FunctionInfo
12+
13+
WARNING: This parser is specifically designed to work with raylib.h, and has some contraints
14+
in that regards. Still, it can also work with other header files that follow same file structure
15+
conventions as raylib.h: rlgl.h, raymath.h, raygui.h, reasings.h
1316
1417
CONSTRAINTS:
15-
1618
This parser is specifically designed to work with raylib.h, so, it has some constraints:
1719
1820
- Functions are expected as a single line with the following structure:
19-
2021
<retType> <name>(<paramType[0]> <paramName[0]>, <paramType[1]> <paramName[1]>); <desc>
2122
22-
Be careful with functions broken into several lines, it breaks the process!
23+
WARNING: Be careful with functions broken into several lines, it breaks the process!
2324
2425
- Structures are expected as several lines with the following form:
25-
2626
<desc>
2727
typedef struct <name> {
2828
<fieldType[0]> <fieldName[0]>; <fieldDesc[0]>
@@ -31,7 +31,6 @@
3131
} <name>;
3232
3333
- Enums are expected as several lines with the following form:
34-
3534
<desc>
3635
typedef enum {
3736
<valueName[0]> = <valueInteger[0]>, <valueDesc[0]>
@@ -45,7 +44,6 @@
4544
- Value description can be provided or not
4645
4746
OTHER NOTES:
48-
4947
- This parser could work with other C header files if mentioned constraints are followed.
5048
- This parser does not require <string.h> library, all data is parsed directly from char buffers.
5149

0 commit comments

Comments
 (0)