#ifndef BASE_EMBED_H #define BASE_EMBED_H // NOTE: bake a file into the binary (fonts, help.txt) so the release build is one file. .incbin // works in gcc and clang on elf, coff and mach-o; the path is relative to the directory the // compiler runs in, which is the repo root for compile.sh, build.bat and build_macos.sh. // name points at the bytes, name##_end one past them; a 0 byte follows so text is terminated. #if PLATFORM_APPLE #define EMBED_SECTION ".section __TEXT,__const\n" #define EMBED_SYMBOL(name) "_" #name #elif PLATFORM_WINDOWS #define EMBED_SECTION ".section .rdata,\"dr\"\n" #define EMBED_SYMBOL(name) #name #else #define EMBED_SECTION ".section .rodata\n" #define EMBED_SYMBOL(name) #name #endif #define EMBED_FILE(name, path) \ extern "C" const u8 name[]; \ extern "C" const u8 name##_end[]; \ __asm__(EMBED_SECTION \ ".balign 16\n" \ ".globl " EMBED_SYMBOL(name) "\n" \ EMBED_SYMBOL(name) ":\n" \ ".incbin \"" path "\"\n" \ ".globl " EMBED_SYMBOL(name##_end) "\n" \ EMBED_SYMBOL(name##_end) ":\n" \ ".byte 0\n" \ ".text\n") #define EmbeddedString8(name) ToString8Size((u8 *)(name), (u64)((name##_end) - (name))) #endif // BASE_EMBED_H