mirror of
https://github.com/thepigeongenerator/mcaselector-lite.git
synced 2025-12-17 06:05:44 +01:00
fix: using the linker for generating a .o file is a feature for only GNU ld.
Now utilising a process to generate a .c file using `xxd`, and compiling those to object files.
This commit is contained in:
2
.github/workflows/ci.yaml
vendored
2
.github/workflows/ci.yaml
vendored
@@ -25,7 +25,7 @@ jobs:
|
|||||||
if: runner.os == 'Linux'
|
if: runner.os == 'Linux'
|
||||||
run: |
|
run: |
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install -y libwayland-dev libxkbcommon-dev xorg-dev cmake
|
sudo apt install -y libwayland-dev libxkbcommon-dev xorg-dev cmake xxd
|
||||||
|
|
||||||
- uses: actions/cache@v4
|
- uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
|
|||||||
11
Makefile
11
Makefile
@@ -72,10 +72,15 @@ bin/TEST_$(NAME): $(TOBJ) $(filter-out obj/src/main.o,$(OBJ))
|
|||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
@$(LD) -o $@ $^ $(LDFLAGS) $(LDLIBS)
|
@$(LD) -o $@ $^ $(LDFLAGS) $(LDLIBS)
|
||||||
|
|
||||||
obj/res/%.o: res/%
|
obj/res/%.c: res/%
|
||||||
$(info [LD] $@)
|
$(info [XXD] $@)
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
@$(LD) -r -b binary -o $@ $<
|
@xxd -i -n $(patsubst res/%,%,$<) $< $@
|
||||||
|
|
||||||
|
obj/res/%.o: obj/res/%.c
|
||||||
|
$(info [CC] $@)
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
@$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
|
||||||
|
|
||||||
obj/%.o: %.c
|
obj/%.o: %.c
|
||||||
$(info [CC] $@)
|
$(info [CC] $@)
|
||||||
|
|||||||
@@ -8,20 +8,14 @@
|
|||||||
|
|
||||||
#include "../error.h"
|
#include "../error.h"
|
||||||
|
|
||||||
#define NAM_S(name) _binary_res_##name##_start // name of a start variable
|
|
||||||
#define NAM_E(name) _binary_res_##name##_end // name of an end variable
|
|
||||||
|
|
||||||
// macro for generating the variable declarations
|
|
||||||
#define DEF_GLSL(name) \
|
|
||||||
extern const char NAM_S(name)[]; \
|
|
||||||
extern const char NAM_E(name)[]
|
|
||||||
|
|
||||||
// NOTE: we are currently just sucking up the memory costs for ease. We can either include the source files themselves. Or use compression, where I'd prefer the latter for ease of installation.
|
// NOTE: we are currently just sucking up the memory costs for ease. We can either include the source files themselves. Or use compression, where I'd prefer the latter for ease of installation.
|
||||||
// NOLINTBEGIN (bugprone-reserved-identifier)
|
extern const char sh_vert_glsl[];
|
||||||
DEF_GLSL(sh_vert_glsl);
|
extern const char sh_frag_glsl[];
|
||||||
DEF_GLSL(sh_frag_glsl);
|
extern const char sh_geom_glsl[];
|
||||||
DEF_GLSL(sh_geom_glsl);
|
extern const uint sh_vert_glsl_len;
|
||||||
// NOLINTEND
|
extern const uint sh_frag_glsl_len;
|
||||||
|
extern const uint sh_geom_glsl_len;
|
||||||
|
|
||||||
/* compile a shader */
|
/* compile a shader */
|
||||||
static GLuint shader_compile(GLenum type, const char *src, size_t len) {
|
static GLuint shader_compile(GLenum type, const char *src, size_t len) {
|
||||||
@@ -42,11 +36,10 @@ static GLuint shader_compile(GLenum type, const char *src, size_t len) {
|
|||||||
return shader;
|
return shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define COMPILE_NAME(_type, _name) shader_compile(_type, NAM_S(_name), (uintptr_t)NAM_E(_name) - (uintptr_t)NAM_S(_name))
|
|
||||||
int shader_init(GLuint pipe) {
|
int shader_init(GLuint pipe) {
|
||||||
GLuint vs = COMPILE_NAME(GL_VERTEX_SHADER, sh_vert_glsl);
|
GLuint vs = shader_compile(GL_VERTEX_SHADER, sh_vert_glsl, sh_vert_glsl_len);
|
||||||
GLuint fs = COMPILE_NAME(GL_FRAGMENT_SHADER, sh_frag_glsl);
|
GLuint fs = shader_compile(GL_FRAGMENT_SHADER, sh_frag_glsl, sh_frag_glsl_len);
|
||||||
GLuint gs = COMPILE_NAME(GL_GEOMETRY_SHADER, sh_geom_glsl);
|
GLuint gs = shader_compile(GL_GEOMETRY_SHADER, sh_geom_glsl, sh_geom_glsl_len);
|
||||||
|
|
||||||
glAttachShader(pipe, vs);
|
glAttachShader(pipe, vs);
|
||||||
glAttachShader(pipe, fs);
|
glAttachShader(pipe, fs);
|
||||||
|
|||||||
Reference in New Issue
Block a user