shed local vendors: stb + kb_text_shape + file_utils now ship with sx
The local vendors/ copies existed because the old modules/ffi/stb*.sx resolved C paths CWD-relative, forcing every consumer to carry identically-named copies. sx now ships these as proper library vendors (#import "vendors/<name>/<name>.sx"), so the copies and the retired ffi module imports both go. Verified: sx build --target ios-sim bundles M3te.app; tools/run_tests.sh 23/23.
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
#import "modules/std.sx";
|
||||
#import "modules/math";
|
||||
#import "modules/ffi/opengl.sx";
|
||||
#import "modules/ffi/stb.sx";
|
||||
#import "vendors/stb_image/stb_image.sx";
|
||||
#import "modules/gpu/types.sx";
|
||||
#import "modules/gpu/api.sx";
|
||||
#import "modules/ui/types.sx";
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#import "modules/std.sx";
|
||||
#import "modules/math";
|
||||
#import "modules/ffi/opengl.sx";
|
||||
#import "modules/ffi/stb.sx";
|
||||
#import "vendors/stb_image/stb_image.sx";
|
||||
#import "modules/gpu/types.sx";
|
||||
#import "modules/gpu/api.sx";
|
||||
#import "modules/ui/types.sx";
|
||||
|
||||
6
main.sx
6
main.sx
@@ -4,8 +4,10 @@
|
||||
#import "modules/ffi/opengl.sx";
|
||||
#import "modules/ffi/sdl3.sx";
|
||||
#import "modules/math";
|
||||
#import "modules/ffi/stb.sx";
|
||||
#import "modules/ffi/stb_truetype.sx";
|
||||
#import "vendors/stb_image/stb_image.sx";
|
||||
#import "vendors/stb_truetype/stb_truetype.sx";
|
||||
#import "vendors/kb_text_shape/kb_text_shape.sx";
|
||||
#import "vendors/file_utils/file_utils.sx";
|
||||
#import "modules/gpu/api.sx";
|
||||
#import "modules/gpu/types.sx";
|
||||
#import "modules/gpu/metal.sx";
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
// never hits this — its loops run over 64 board cells, not millions of pixels.
|
||||
#import "modules/std.sx";
|
||||
#import "modules/math";
|
||||
#import "modules/ffi/stb.sx";
|
||||
#import "vendors/stb_image/stb_image.sx";
|
||||
|
||||
SRC_PATH :: "/Users/agra/Downloads/m3te_particle.png";
|
||||
OUT_PATH :: "assets/fx/particle.png";
|
||||
|
||||
55
vendors/file_utils/file_utils.c
vendored
55
vendors/file_utils/file_utils.c
vendored
@@ -1,55 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <android/asset_manager.h>
|
||||
|
||||
// Caller-installed AAssetManager pointer. Chess's android_main extracts
|
||||
// it from `app->activity->assetManager` (via sx-side platform module's
|
||||
// `g_android_asset_manager` global) and feeds it here once at startup.
|
||||
// Until the setter has been called, Android falls through to fopen —
|
||||
// gives a predictable "file not found" rather than a NULL-deref.
|
||||
static AAssetManager* g_aam = NULL;
|
||||
|
||||
void sx_android_set_asset_manager(void* m) {
|
||||
g_aam = (AAssetManager*)m;
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned char* read_file_bytes(const char* path, int* out_size) {
|
||||
#ifdef __ANDROID__
|
||||
if (g_aam != NULL) {
|
||||
// AAssetManager paths are relative to the APK's `assets/`
|
||||
// directory. Strip a leading "assets/" so callers can use the
|
||||
// same paths across iOS/macOS/Android (those platforms read
|
||||
// assets via `assets/...` rooted in the bundle or CWD).
|
||||
const char* lookup = path;
|
||||
if (strncmp(path, "assets/", 7) == 0) {
|
||||
lookup = path + 7;
|
||||
}
|
||||
AAsset* a = AAssetManager_open(g_aam, lookup, AASSET_MODE_BUFFER);
|
||||
if (a != NULL) {
|
||||
off_t n = AAsset_getLength(a);
|
||||
*out_size = (int)n;
|
||||
unsigned char* buf = (unsigned char*)malloc((size_t)n);
|
||||
if (buf != NULL) {
|
||||
memcpy(buf, AAsset_getBuffer(a), (size_t)n);
|
||||
}
|
||||
AAsset_close(a);
|
||||
return buf;
|
||||
}
|
||||
// Falls through to fopen — useful when assets land in the data
|
||||
// dir via extraction or app updates.
|
||||
}
|
||||
#endif
|
||||
FILE* f = fopen(path, "rb");
|
||||
if (!f) return 0;
|
||||
fseek(f, 0, SEEK_END);
|
||||
*out_size = (int)ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
unsigned char* buf = (unsigned char*)malloc(*out_size);
|
||||
fread(buf, 1, *out_size, f);
|
||||
fclose(f);
|
||||
return buf;
|
||||
}
|
||||
13
vendors/file_utils/file_utils.h
vendored
13
vendors/file_utils/file_utils.h
vendored
@@ -1,13 +0,0 @@
|
||||
#ifndef FILE_UTILS_H
|
||||
#define FILE_UTILS_H
|
||||
|
||||
unsigned char* read_file_bytes(const char* path, int* out_size);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
// Install the AAssetManager that `read_file_bytes` consults for paths
|
||||
// rooted inside the APK. Caller is responsible for passing the manager
|
||||
// from `ANativeActivity->assetManager` before any read_file_bytes call.
|
||||
void sx_android_set_asset_manager(void* m);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
19
vendors/kb_text_shape/kb/LICENSE
vendored
19
vendors/kb_text_shape/kb/LICENSE
vendored
@@ -1,19 +0,0 @@
|
||||
zlib License
|
||||
|
||||
(C) Copyright 2024-2025 Jimmy Lefevre
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
30737
vendors/kb_text_shape/kb/kb_text_shape.h
vendored
30737
vendors/kb_text_shape/kb/kb_text_shape.h
vendored
File diff suppressed because it is too large
Load Diff
2
vendors/kb_text_shape/kb_text_shape_impl.c
vendored
2
vendors/kb_text_shape/kb_text_shape_impl.c
vendored
@@ -1,2 +0,0 @@
|
||||
#define KB_TEXT_SHAPE_IMPLEMENTATION
|
||||
#include "kb/kb_text_shape.h"
|
||||
15
vendors/kb_text_shape/kbts_api.h
vendored
15
vendors/kb_text_shape/kbts_api.h
vendored
@@ -1,15 +0,0 @@
|
||||
// Minimal API declarations for SX import.
|
||||
// Only the functions/types we actually use — avoids parsing the full 30k-line header.
|
||||
|
||||
typedef struct kbts_shape_context kbts_shape_context;
|
||||
typedef struct kbts_font kbts_font;
|
||||
|
||||
kbts_shape_context *kbts_CreateShapeContext(void *Allocator, void *AllocatorData);
|
||||
void kbts_DestroyShapeContext(kbts_shape_context *Context);
|
||||
kbts_font *kbts_ShapePushFontFromMemory(kbts_shape_context *Context, void *Memory, int Size, int FontIndex);
|
||||
void kbts_GetFontInfo2(kbts_font *Font, void *Info);
|
||||
void kbts_ShapeBegin(kbts_shape_context *Context, unsigned int ParagraphDirection, unsigned int Language);
|
||||
void kbts_ShapeUtf8(kbts_shape_context *Context, const char *Utf8, int Length, unsigned int UserIdGenerationMode);
|
||||
void kbts_ShapeEnd(kbts_shape_context *Context);
|
||||
int kbts_ShapeRun(kbts_shape_context *Context, void *Run);
|
||||
int kbts_GlyphIteratorNext(void *It, void **Glyph);
|
||||
7988
vendors/stb_image/stb_image.h
vendored
7988
vendors/stb_image/stb_image.h
vendored
File diff suppressed because it is too large
Load Diff
2
vendors/stb_image/stb_image_impl.c
vendored
2
vendors/stb_image/stb_image_impl.c
vendored
@@ -1,2 +0,0 @@
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "stb_image.h"
|
||||
1724
vendors/stb_image/stb_image_write.h
vendored
1724
vendors/stb_image/stb_image_write.h
vendored
File diff suppressed because it is too large
Load Diff
2
vendors/stb_image/stb_image_write_impl.c
vendored
2
vendors/stb_image/stb_image_write_impl.c
vendored
@@ -1,2 +0,0 @@
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "stb_image_write.h"
|
||||
5079
vendors/stb_truetype/stb_truetype.h
vendored
5079
vendors/stb_truetype/stb_truetype.h
vendored
File diff suppressed because it is too large
Load Diff
2
vendors/stb_truetype/stb_truetype_impl.c
vendored
2
vendors/stb_truetype/stb_truetype_impl.c
vendored
@@ -1,2 +0,0 @@
|
||||
#define STB_TRUETYPE_IMPLEMENTATION
|
||||
#include "stb_truetype.h"
|
||||
Reference in New Issue
Block a user