mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-30 10:43:02 +02:00
Remove dependency on xxd
This commit is contained in:
parent
ecc5cb5de3
commit
20f806abef
6 changed files with 40 additions and 36 deletions
|
@ -29,8 +29,8 @@
|
|||
#include "core.h"
|
||||
#include "wasi.h"
|
||||
|
||||
extern unsigned char mkxp_retro_dist_zip[];
|
||||
extern unsigned int mkxp_retro_dist_zip_len;
|
||||
extern const uint8_t mkxp_retro_dist_zip[];
|
||||
extern const size_t mkxp_retro_dist_zip_len;
|
||||
|
||||
namespace mkxp_retro {
|
||||
retro_log_printf_t log_printf;
|
||||
|
|
|
@ -13,7 +13,6 @@ AUTORECONF ?= autoreconf
|
|||
CURL ?= curl
|
||||
GIT ?= git
|
||||
ZIP ?= zip
|
||||
XXD ?= xxd
|
||||
SED ?= sed
|
||||
GREP ?= grep
|
||||
CC ?= cc
|
||||
|
@ -44,20 +43,18 @@ WASI_RANLIB := $(WASI_SDK)/bin/llvm-ranlib
|
|||
NATIVE_TOOLCHAIN := CC=$(CC) CXX=$(CXX) LD=$(LD) AR=$(AR) RANLIB=$(RANLIB)
|
||||
WASI_TOOLCHAIN := CC=$(WASI_CC) CXX=$(WASI_CXX) LD=$(WASI_LD) AR=$(WASI_AR) RANLIB=$(WASI_RANLIB)
|
||||
|
||||
all default: deps ruby-dist ruby-bindings
|
||||
all default: ruby-dist ruby-bindings
|
||||
|
||||
ruby-dist: $(OUTDIR)/mkxp-retro-dist.zip.cpp $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby.h $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby-impl.h $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_0.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_1.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_2.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_3.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_4.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_5.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_6.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_7.c
|
||||
ruby-dist: $(OUTDIR)/mkxp-retro-dist.zip $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby.h $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby-impl.h $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_0.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_1.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_2.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_3.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_4.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_5.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_6.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_7.c
|
||||
|
||||
ruby-bindings: $(OUTDIR)/mkxp-sandbox-bindgen.cpp $(OUTDIR)/mkxp-sandbox-bindgen.h
|
||||
|
||||
deps: $(OUTDIR)/GMGSx.sf2.cpp
|
||||
|
||||
clean: clean-ruby-dist clean-ruby-bindings clean-deps
|
||||
clean: clean-ruby-dist clean-ruby-bindings
|
||||
rm -rf $(LIBDIR)/*
|
||||
rm -rf $(DOWNLOADS)/*
|
||||
|
||||
clean-ruby-dist:
|
||||
rm -f $(OUTDIR)/mkxp-retro-dist.zip.cpp
|
||||
rm -f $(OUTDIR)/mkxp-retro-dist.zip
|
||||
rm -rf $(LIBDIR)/mkxp-retro-ruby
|
||||
|
||||
clean-ruby-bindings:
|
||||
|
@ -66,13 +63,6 @@ clean-ruby-bindings:
|
|||
rm -f $(LIBDIR)/tags.c
|
||||
rm -f $(LIBDIR)/tags
|
||||
|
||||
clean-deps:
|
||||
rm -f $(OUTDIR)/GMGSx.sf2.cpp
|
||||
|
||||
$(OUTDIR)/GMGSx.sf2.cpp: GMGSx.sf2
|
||||
mkdir -p $(OUTDIR)
|
||||
$(XXD) -i GMGSx.sf2 $(OUTDIR)/GMGSx.sf2.cpp
|
||||
|
||||
# Cross Ruby (targets WASI)
|
||||
|
||||
$(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby.h $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby-impl.h $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_0.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_1.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_2.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_3.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_4.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_5.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_6.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_7.c &: $(LIBDIR)/mkxp-retro-dist/bin/ruby
|
||||
|
@ -81,18 +71,14 @@ $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby.h $(OUTDIR)/mkxp-retro-ruby/mkxp-retro
|
|||
# Find all the function types declared using `FUNC_TYPE_DECL_EXTERN_T` and redeclare them as macros to fix the "initializer element is not constant" compilation error that occurs when using GCC versions earlier than 8.1.0
|
||||
rm -f $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby-func-types.h
|
||||
for func_type in $$($(GREP) -r 'FUNC_TYPE_DECL_EXTERN_T *([^()]*)' $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby-impl.h | $(GREP) -v '# *define' | $(SED) -e 's/FUNC_TYPE_DECL_EXTERN_T *( *\(.*\) *).*/\1/'); do \
|
||||
echo "#define $$func_type \"$$($(XXD) -c 0 -l 32 -p /dev/urandom | $(SED) -e 's/.\{2\}/\\x&/g')\"" >> $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby-func-types.h; \
|
||||
echo "#define $$func_type \"$$(od -N 32 -x /dev/urandom | cut -b 9- | tr -d ' \n' | $(SED) -e 's/.\{2\}/\\x&/g')\"" >> $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby-func-types.h; \
|
||||
done
|
||||
$(SED) -i 's/ *# *define * FUNC_TYPE_DECL_EXTERN_T *([^()]).*/#define FUNC_TYPE_DECL_EXTERN_T(x)/g' $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby-impl.h
|
||||
$(SED) -i 's/ *# *define * FUNC_TYPE_EXTERN_T *([^()]).*/#define FUNC_TYPE_EXTERN_T(x) const char _mkxp_unused_##x[]/g' $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby-impl.h
|
||||
$(SED) -i 's/ *# *define * FUNC_TYPE_T *([^()]).*/#define FUNC_TYPE_T(x) static const char _mkxp_unused_##x[]/g' $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby-impl.h
|
||||
$(SED) -i 's/__has_builtin *([^()]*)/0/g' $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby-impl.h
|
||||
|
||||
$(OUTDIR)/mkxp-retro-dist.zip.cpp: $(LIBDIR)/mkxp-retro-dist.zip
|
||||
mkdir -p $(OUTDIR)
|
||||
cd $(LIBDIR) && $(XXD) -i mkxp-retro-dist.zip $(OUTDIR)/mkxp-retro-dist.zip.cpp
|
||||
|
||||
$(LIBDIR)/mkxp-retro-dist.zip: $(LIBDIR)/mkxp-retro-dist/bin/ruby
|
||||
$(OUTDIR)/mkxp-retro-dist.zip: $(LIBDIR)/mkxp-retro-dist/bin/ruby
|
||||
rm -rf $(LIBDIR)/_mkxp-retro-dist
|
||||
cp -r $(LIBDIR)/mkxp-retro-dist $(LIBDIR)/_mkxp-retro-dist
|
||||
rm $(LIBDIR)/_mkxp-retro-dist/bin/ruby
|
||||
|
@ -101,8 +87,8 @@ $(LIBDIR)/mkxp-retro-dist.zip: $(LIBDIR)/mkxp-retro-dist/bin/ruby
|
|||
rm -r $(LIBDIR)/_mkxp-retro-dist/share
|
||||
rm -r $(LIBDIR)/_mkxp-retro-dist/lib/ruby/gems/$(RUBY_VERSION).0/cache/*
|
||||
echo '# This is a Ruby script that does nothing. We make Ruby load this file on startup just because Ruby needs to load a script on startup for some reason.' > $(LIBDIR)/_mkxp-retro-dist/bin/mkxp-z
|
||||
rm -f $(LIBDIR)/mkxp-retro-dist.zip
|
||||
cd $(LIBDIR)/_mkxp-retro-dist && $(ZIP) -r $(LIBDIR)/mkxp-retro-dist.zip *
|
||||
rm -f $(OUTDIR)/mkxp-retro-dist.zip
|
||||
cd $(LIBDIR)/_mkxp-retro-dist && $(ZIP) -r $(OUTDIR)/mkxp-retro-dist.zip *
|
||||
rm -r $(LIBDIR)/_mkxp-retro-dist
|
||||
|
||||
$(LIBDIR)/mkxp-retro-dist/bin/ruby: $(DOWNLOADS)/crossruby/Makefile ruby-bindings.h
|
||||
|
|
|
@ -6,12 +6,12 @@ All the files produced by this stage are platform-agnostic, so you can run this
|
|||
|
||||
Required software:
|
||||
* C and C++ compilers
|
||||
* Make
|
||||
* GNU Make
|
||||
* GNU Autotools
|
||||
* GNU Bison
|
||||
* [Git](https://git-scm.com)
|
||||
* [xxd](https://github.com/vim/vim/blob/master/runtime/doc/xxd.man)
|
||||
* [curl](https://curl.se)
|
||||
* [Info-ZIP Zip](https://infozip.sourceforge.net/Zip.html) (the `zip` package found in many package managers)
|
||||
* [Info-ZIP's Zip](https://infozip.sourceforge.net/Zip.html) (the `zip` package found in many package managers)
|
||||
* [WASI SDK](https://github.com/WebAssembly/wasi-sdk) (currently you need WASI SDK version 21; later versions don't work yet)
|
||||
* [Binaryen](https://github.com/WebAssembly/binaryen)
|
||||
* [WABT](https://github.com/WebAssembly/wabt)
|
||||
|
|
26
meson.build
26
meson.build
|
@ -12,8 +12,6 @@ if not is_libretro and host_system == 'darwin'
|
|||
error('This Meson project no longer supports macOS. Please use the Xcode project instead.')
|
||||
endif
|
||||
|
||||
git_hash = run_command('git', 'rev-parse', '--short', 'HEAD').stdout().strip()
|
||||
|
||||
compilers = {'c': meson.get_compiler('c'), 'cpp': meson.get_compiler('cpp')}
|
||||
|
||||
global_sources = []
|
||||
|
@ -567,9 +565,29 @@ if is_libretro
|
|||
'binding-sandbox/wasi.cpp',
|
||||
'binding-sandbox/wasm-rt.cpp',
|
||||
'binding/module_rpg.cpp',
|
||||
libretro_stage1_path / 'GMGSx.sf2.cpp',
|
||||
libretro_stage1_path / 'mkxp-sandbox-bindgen.cpp',
|
||||
libretro_stage1_path / 'mkxp-retro-dist.zip.cpp',
|
||||
custom_target(
|
||||
'GMGSx',
|
||||
input: 'assets/GMGSx.sf2',
|
||||
output: 'GMGSx.sf2.cpp',
|
||||
command: [
|
||||
embedtool,
|
||||
'@INPUT@',
|
||||
'@OUTPUT@',
|
||||
'mkxp_gmgsx_sf2',
|
||||
],
|
||||
),
|
||||
custom_target(
|
||||
'mkxp-retro-dist',
|
||||
input: libretro_stage1_path / 'mkxp-retro-dist.zip',
|
||||
output: 'mkxp-retro-dist.zip.cpp',
|
||||
command: [
|
||||
embedtool,
|
||||
'@INPUT@',
|
||||
'@OUTPUT@',
|
||||
'mkxp_retro_dist_zip',
|
||||
],
|
||||
),
|
||||
libretro_stage1_path / 'mkxp-retro-ruby/mkxp-retro-ruby_0.c',
|
||||
libretro_stage1_path / 'mkxp-retro-ruby/mkxp-retro-ruby_1.c',
|
||||
libretro_stage1_path / 'mkxp-retro-ruby/mkxp-retro-ruby_2.c',
|
||||
|
|
10
src/core.cpp
10
src/core.cpp
|
@ -54,8 +54,8 @@ static inline void *malloc_align(size_t alignment, size_t size) {
|
|||
#endif
|
||||
}
|
||||
|
||||
extern unsigned char GMGSx_sf2[];
|
||||
extern unsigned int GMGSx_sf2_len;
|
||||
extern const uint8_t mkxp_gmgsx_sf2[];
|
||||
extern const size_t mkxp_gmgsx_sf2_len;
|
||||
|
||||
static ALCdevice *al_device = NULL;
|
||||
static ALCcontext *al_context = NULL;
|
||||
|
@ -227,8 +227,8 @@ static bool init_sandbox() {
|
|||
return std::calloc(1, sizeof(long));
|
||||
},
|
||||
.fread = [](void *buf, int count, void *handle) {
|
||||
assert(*(long *)handle + count < GMGSx_sf2_len);
|
||||
std::memcpy(buf, GMGSx_sf2 + *(long *)handle, count);
|
||||
assert(*(long *)handle + count < mkxp_gmgsx_sf2_len);
|
||||
std::memcpy(buf, mkxp_gmgsx_sf2 + *(long *)handle, count);
|
||||
*(long *)handle += count;
|
||||
return (int)FLUID_OK;
|
||||
},
|
||||
|
@ -238,7 +238,7 @@ static bool init_sandbox() {
|
|||
*(long *)handle += offset;
|
||||
break;
|
||||
case SEEK_END:
|
||||
*(long *)handle = GMGSx_sf2_len + offset;
|
||||
*(long *)handle = mkxp_gmgsx_sf2_len + offset;
|
||||
break;
|
||||
default:
|
||||
*(long *)handle = offset;
|
||||
|
|
Loading…
Add table
Reference in a new issue