Skip to content

Commit 798937b

Browse files
committed
remove debug build and add more builds
1 parent e913237 commit 798937b

File tree

6 files changed

+42
-51
lines changed

6 files changed

+42
-51
lines changed

.github/workflows/workflow.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,27 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
os: [ubuntu-22.04, macos-latest, windows-latest]
13-
buildtype: [debug, release]
13+
buildtype: [release]
14+
arch: [x64]
15+
include:
16+
- os: windows-latest
17+
buildtype: release
18+
arch: x86
19+
- os: windows-latest
20+
buildtype: release
21+
arch: x86
22+
- os: windows-latest
23+
buildtype: release
24+
arch: arm64
25+
- os: windows-latest
26+
buildtype: release
27+
arch: arm64
28+
- os: macos-latest
29+
buildtype: release
30+
arch: x86_64
31+
- os: macos-latest
32+
buildtype: release
33+
arch: x86_64
1434

1535
runs-on: ${{ matrix.os }}
1636

@@ -27,13 +47,13 @@ jobs:
2747
build-cache: true
2848

2949
- name: Configure
30-
run: xmake config -m ${{ matrix.buildtype }} -y -vv
50+
run: xmake config -a ${{ matrix.arch }} -m ${{ matrix.buildtype }} -y -vv
3151

3252
- name: Build
3353
run: xmake build -y -vv
3454

3555
- name: Upload artifacts
3656
uses: actions/upload-artifact@v4
3757
with:
38-
name: ${{ matrix.os }}-${{ matrix.buildtype }}
58+
name: ${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.buildtype }}
3959
path: build/*/*/${{ matrix.buildtype }}/

grngame/assets/embedded_asset.c

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -81,50 +81,9 @@ static void embed_callback(const char *path, void *userdata)
8181
fprintf(ctx->out, "// asset: %s = %s\n\n", path, var_name);
8282

8383
char entry[1024];
84-
85-
// 1. Full path
8684
snprintf(entry, sizeof(entry), " {\"%s\", %s, %s_size},\n", path, var_name, var_name);
87-
strcat(ctx->registry, entry);
88-
89-
// 2. Base name (e.g. "music.wav")
90-
snprintf(entry, sizeof(entry), " {\"%s\", %s, %s_size},\n", base, var_name, var_name);
91-
if (!strstr(ctx->registry, entry)) {
92-
strcat(ctx->registry, entry);
93-
}
9485

95-
// 3. Stem for audio and images (e.g. "music")
96-
if (FileIsLoadableAudio(path) || FileIsLoadableImage(path))
97-
{
98-
char *stem = FileStem(path);
99-
if (stem)
100-
{
101-
snprintf(entry, sizeof(entry), " {\"%s\", %s, %s_size},\n", stem, var_name, var_name);
102-
if (!strstr(ctx->registry, entry)) {
103-
strcat(ctx->registry, entry);
104-
}
105-
free(stem);
106-
}
107-
}
108-
109-
// 4. Std paths directly
110-
const char *std_pos = strstr(path, "std/");
111-
if (std_pos)
112-
{
113-
snprintf(entry, sizeof(entry), " {\"%s\", %s, %s_size},\n", std_pos, var_name, var_name);
114-
if (!strstr(ctx->registry, entry)) {
115-
strcat(ctx->registry, entry);
116-
}
117-
118-
char no_ext[512];
119-
snprintf(no_ext, sizeof(no_ext), "%s", std_pos);
120-
char *ext_ptr = strrchr(no_ext, '.');
121-
if (ext_ptr) *ext_ptr = '\0';
122-
123-
snprintf(entry, sizeof(entry), " {\"%s\", %s, %s_size},\n", no_ext, var_name, var_name);
124-
if (!strstr(ctx->registry, entry)) {
125-
strcat(ctx->registry, entry);
126-
}
127-
}
86+
strcat(ctx->registry, entry);
12887
}
12988

13089
void create_embedded_structure(int num_dirs, const char **dirs, const char *output_header)

grngame/assets/load.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ bool LoadSoundFile(const char *file)
5353

5454
int32 ret;
5555
khiter_t k = kh_put(SoundMap, sound_map, key, &ret);
56+
if (UNLIKELY(ret == 0))
57+
{
58+
free((char *)kh_key(sound_map, k));
59+
kh_key(sound_map, k) = key;
60+
WavStream_destroy(kh_value(sound_map, k));
61+
}
5662
kh_value(sound_map, k) = stream;
5763
return true;
5864
}
@@ -97,6 +103,12 @@ bool LoadTextureFile(const char *file)
97103

98104
int32 ret;
99105
khiter_t k = kh_put(TextureMap, texture_map, key, &ret);
106+
if (ret == 0)
107+
{
108+
free((char *)kh_key(texture_map, k));
109+
kh_key(texture_map, k) = key;
110+
SDL_DestroyTexture(kh_value(texture_map, k).texture);
111+
}
100112
Texture tex = {.texture = texture, .w = (int16)w, .h = (int16)h};
101113
kh_value(texture_map, k) = tex;
102114
return true;
@@ -107,10 +119,12 @@ bool UnloadSoundFile(const char *file)
107119
khash_t(SoundMap) *sound_map = g_app.asset_manager.sound_map;
108120
char *key = FileStem(file);
109121
khiter_t k = kh_get(SoundMap, sound_map, key);
122+
free(key);
110123
if (k == kh_end(sound_map))
111124
return false;
112125

113126
WavStream_destroy(kh_value(sound_map, k));
127+
free((char *)kh_key(sound_map, k));
114128
kh_del(SoundMap, sound_map, k);
115129
return true;
116130
}
@@ -120,10 +134,12 @@ bool UnloadTextureFile(const char *file)
120134
khash_t(TextureMap) *texture_map = g_app.asset_manager.texture_map;
121135
char *key = FileStem(file);
122136
khiter_t k = kh_get(TextureMap, texture_map, key);
137+
free(key);
123138
if (k == kh_end(texture_map))
124139
return false;
125140

126141
SDL_DestroyTexture(kh_value(texture_map, k).texture);
142+
free((char *)kh_key(texture_map, k));
127143
kh_del(TextureMap, texture_map, k);
128144
return true;
129145
}

grngame/bindings/wren/wren_engine.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,17 @@ bool WrenEngine::LoadMainScript(const char *main_script_name)
7777
{
7878
std::string main_source;
7979

80-
// 1. Try to load from embedded assets first
8180
const EmbeddedAsset *asset = nullptr;
8281
if (g_app.info.embedded_assets)
8382
{
8483
std::string name_with_ext = std::string(main_script_name) + ".wren";
8584
for (int i = 0; g_app.info.embedded_assets[i].name != NULL; i++)
8685
{
87-
// First pass, exactly "main.wren", avoids matching "main.das" fallback
8886
if (std::strcmp(g_app.info.embedded_assets[i].name, name_with_ext.c_str()) == 0)
8987
{
9088
asset = &g_app.info.embedded_assets[i];
9189
break;
9290
}
93-
// Fallback match exactly "main"
9491
if (std::strcmp(g_app.info.embedded_assets[i].name, main_script_name) == 0 && !asset)
9592
{
9693
asset = &g_app.info.embedded_assets[i];
@@ -105,7 +102,6 @@ bool WrenEngine::LoadMainScript(const char *main_script_name)
105102
}
106103
else
107104
{
108-
// 2. Try to load from disk
109105
const std::filesystem::path path_of_script = BuildModulePath(main_script_name, ".wren");
110106
if (!ReadTextFile(path_of_script, main_source))
111107
{

wren_test/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ int main()
1313
AppInfo app;
1414
app.name = "Tests";
1515
app.version = "1.0.1";
16-
app.fps = 80;
16+
app.fps = 500;
1717
app.window_width = 200;
1818
app.window_height = 200;
1919
app.window_universe_height = 200;

xmake.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ target("WrenTest")
167167
add_files("wren_test/main.c")
168168
add_deps("GrnGame")
169169
add_deps("Embedded")
170-
--add_defines("GRN_EMBED_ASSETS")
170+
add_defines("GRN_EMBED_ASSETS")
171171

172172
before_build(function(target)
173173
local embedded_exe = target:dep("Embedded"):targetfile()

0 commit comments

Comments
 (0)