mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-22 23:03:44 +02:00
Use Emscripten's CMake toolchain file when building for Emscripten
Emscripten overrides some of the default CMake modules because some of the default functions like `check_type_size()` are broken.
This commit is contained in:
parent
b93ab2b106
commit
0370010da3
5 changed files with 18 additions and 122 deletions
12
.github/workflows/autobuild.yml
vendored
12
.github/workflows/autobuild.yml
vendored
|
@ -1191,6 +1191,18 @@ jobs:
|
|||
|
||||
- name: Configure core
|
||||
run: |
|
||||
echo "[binaries]" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo "c = 'emcc'" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo "cpp = 'em++'" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo "ar = 'emar'" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo "[host_machine]" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo "system = 'emscripten'" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo "cpu_family = 'wasm32'" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo "cpu = 'wasm32'" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo "endian = 'little'" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo "[properties]" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo "cmake_toolchain_file = '$(em-config EMSCRIPTEN_ROOT)/cmake/Modules/Platform/Emscripten.cmake'" | tee -a ${{ runner.temp }}/cross.ini
|
||||
echo '--------------------------------------------------------------------------------'
|
||||
if [ '${{ matrix.threading }}' = 'threaded' ]
|
||||
then
|
||||
threaded=true
|
||||
|
|
|
@ -144,6 +144,7 @@ else ifeq ($(platform),emscripten)
|
|||
MKXPZ_CPU_FAMILY = wasm32
|
||||
MKXPZ_CPU = wasm32
|
||||
MKXPZ_ENDIAN = little
|
||||
MKXPZ_CMAKE_TOOLCHAIN_FILE = $(shell em-config EMSCRIPTEN_ROOT)/cmake/Modules/Platform/Emscripten.cmake
|
||||
# The build times out with LTO enabled
|
||||
MKXPZ_LTO = false
|
||||
else
|
||||
|
@ -227,6 +228,10 @@ endif
|
|||
echo "cpu_family = '$(MKXPZ_CPU_FAMILY)'" >> $(MKXPZ_CROSS_FILE)
|
||||
echo "cpu = '$(MKXPZ_CPU)'" >> $(MKXPZ_CROSS_FILE)
|
||||
echo "endian = '$(MKXPZ_ENDIAN)'" >> $(MKXPZ_CROSS_FILE)
|
||||
echo "[properties]" >> $(MKXPZ_CROSS_FILE)
|
||||
ifneq ($(MKXPZ_CMAKE_TOOLCHAIN_FILE),)
|
||||
echo "CMAKE_TOOLCHAIN_FILE = '$(MKXPZ_CMAKE_TOOLCHAIN_FILE)'" >> $(MKXPZ_CROSS_FILE)
|
||||
endif
|
||||
echo "[cmake]" >> $(MKXPZ_CROSS_FILE)
|
||||
ifneq ($(MKXPZ_ARCH_CMAKE),)
|
||||
echo "CMAKE_SYSTEM_PROCESSOR = '$(MKXPZ_ARCH_CMAKE)'" >> $(MKXPZ_CROSS_FILE)
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
[binaries]
|
||||
c = 'emcc'
|
||||
cpp = 'em++'
|
||||
ar = 'emar'
|
||||
cmake = ['emcmake', 'cmake']
|
||||
|
||||
[host_machine]
|
||||
system = 'emscripten'
|
||||
cpu_family = 'wasm32'
|
||||
cpu = 'wasm32'
|
||||
endian = 'little'
|
|
@ -4,4 +4,4 @@ url = https://github.com/madebr/mpg123
|
|||
revision = 45fbaaeb00072d689b9c2ac4b7d109343f30abee
|
||||
depth = 1
|
||||
patch_directory = mpg123
|
||||
diff_files = mpg123-intrinsics.patch, mpg123-libsyn123.patch, mpg123-offset.patch, mpg123-pic.patch, mpg123-signal.patch
|
||||
diff_files = mpg123-intrinsics.patch, mpg123-libsyn123.patch, mpg123-pic.patch, mpg123-signal.patch
|
||||
|
|
|
@ -1,110 +0,0 @@
|
|||
# Fixes a problem where the size of off_t is miscalculated on certain platforms.
|
||||
|
||||
--- a/src/libmpg123/lfs_wrap.c
|
||||
+++ b/src/libmpg123/lfs_wrap.c
|
||||
@@ -48,18 +48,22 @@
|
||||
#ifndef OFF_MAX
|
||||
#undef OFF_MIN
|
||||
#if SIZEOF_OFF_T == 4
|
||||
+#define REAL_SIZEOF_OFF_T 4
|
||||
#define OFF_MAX INT32_MAX
|
||||
#define OFF_MIN INT32_MIN
|
||||
-#elif SIZEOF_OFF_T == 8
|
||||
+#elif SIZEOF_OFF_T == 8 || (defined(__EMSCRIPTEN__) && SIZEOF_OFF_T == 0)
|
||||
+#define REAL_SIZEOF_OFF_T 8
|
||||
#define OFF_MAX INT64_MAX
|
||||
#define OFF_MIN INT64_MIN
|
||||
#else
|
||||
#error "Unexpected width of off_t."
|
||||
#endif
|
||||
+#else
|
||||
+#define REAL_SIZEOF_OFF_T SIZEOF_OFF_T
|
||||
#endif
|
||||
|
||||
// A paranoid check that someone did not define a wrong SIZEOF_OFF_T at configure time.
|
||||
-typedef unsigned char MPG123_STATIC_ASSERT[(SIZEOF_OFF_T == sizeof(off_t)) ? 1 : -1];
|
||||
+typedef unsigned char MPG123_STATIC_ASSERT[(REAL_SIZEOF_OFF_T == sizeof(off_t)) ? 1 : -1];
|
||||
|
||||
#include "../common/debug.h"
|
||||
|
||||
@@ -87,7 +91,7 @@ int attribute_align_arg mpg123_position64( mpg123_handle *fr, int64_t no, int64_
|
||||
struct wrap_data
|
||||
{
|
||||
/* Storage for small offset index table. */
|
||||
-#if SIZEOF_OFF_T == 4
|
||||
+#if REAL_SIZEOF_OFF_T == 4
|
||||
off_t *indextable;
|
||||
// And ironically, another big offset table for mpg123_set_index_32.
|
||||
// I wand to avoid having to change a line of code in the internals.
|
||||
@@ -153,7 +157,7 @@ void INT123_wrap_destroy(void *handle)
|
||||
if(!wh)
|
||||
return;
|
||||
wrap_io_cleanup(handle);
|
||||
-#if SIZEOF_OFF_T == 4
|
||||
+#if REAL_SIZEOF_OFF_T == 4
|
||||
if(wh->indextable != NULL)
|
||||
free(wh->indextable);
|
||||
if(wh->set_indextable != NULL)
|
||||
@@ -184,7 +188,7 @@ static struct wrap_data* wrap_get(mpg123_handle *mh, int force_alloc)
|
||||
return NULL;
|
||||
}
|
||||
whd = *whd_;
|
||||
-#if SIZEOF_OFF_T == 4
|
||||
+#if REAL_SIZEOF_OFF_T == 4
|
||||
whd->indextable = NULL;
|
||||
whd->set_indextable = NULL;
|
||||
#endif
|
||||
@@ -313,7 +317,7 @@ off_t attribute_align_arg mpg123_length(mpg123_handle *mh)
|
||||
// If the former, we create a copy of the index table.
|
||||
int attribute_align_arg mpg123_index(mpg123_handle *mh, off_t **offsets, off_t *step, size_t *fill)
|
||||
{
|
||||
-#if SIZEOF_OFF_T == 8
|
||||
+#if REAL_SIZEOF_OFF_T == 8
|
||||
return mpg123_index64(mh, (int64_t**)offsets, (int64_t*)step, fill);
|
||||
#else
|
||||
int err;
|
||||
@@ -354,7 +358,7 @@ int attribute_align_arg mpg123_index(mpg123_handle *mh, off_t **offsets, off_t *
|
||||
|
||||
int attribute_align_arg mpg123_set_index(mpg123_handle *mh, off_t *offsets, off_t step, size_t fill)
|
||||
{
|
||||
-#if SIZEOF_OFF_T == 8
|
||||
+#if REAL_SIZEOF_OFF_T == 8
|
||||
return mpg123_set_index64(mh, (int64_t*)offsets, (int64_t)step, fill);
|
||||
#else
|
||||
int err;
|
||||
@@ -410,7 +414,7 @@ int attribute_align_arg mpg123_position( mpg123_handle *mh, off_t INT123_frame_o
|
||||
|
||||
// _32 aliases only for native 32 bit off_t
|
||||
// Will compilers be smart enough to optimize away the extra function call?
|
||||
-#if SIZEOF_OFF_T == 4
|
||||
+#if REAL_SIZEOF_OFF_T == 4
|
||||
|
||||
// The open routines are trivial now. I only have differeing symbols suffixes
|
||||
// to keep legacy ABI.
|
||||
@@ -524,7 +528,7 @@ int attribute_align_arg mpg123_position_32( mpg123_handle *mh, off_t INT123_fram
|
||||
// _64 aliases if we either got some off64_t to work with or
|
||||
// if there is no explicit 64 bit API but off_t is just always
|
||||
// 64 bits.
|
||||
-#if defined(LFS_LARGEFILE_64) || (SIZEOF_OFF_T == 8)
|
||||
+#if defined(LFS_LARGEFILE_64) || (REAL_SIZEOF_OFF_T == 8)
|
||||
|
||||
#ifdef LFS_LARGEFILE_64
|
||||
#define OFF64 off64_t
|
||||
@@ -954,7 +958,7 @@ int attribute_align_arg mpg123_replace_reader_handle(mpg123_handle *mh, mpg123_s
|
||||
return MPG123_OK;
|
||||
}
|
||||
|
||||
-#if SIZEOF_OFF_T == 4
|
||||
+#if REAL_SIZEOF_OFF_T == 4
|
||||
int attribute_align_arg mpg123_replace_reader_32(mpg123_handle *mh, mpg123_ssize_t (*r_read) (int, void *, size_t), off_t (*r_lseek)(int, off_t, int) )
|
||||
{
|
||||
return mpg123_replace_reader(mh, r_read, r_lseek);
|
||||
@@ -1019,7 +1023,7 @@ int attribute_align_arg mpg123_replace_reader_handle_64(mpg123_handle *mh, mpg12
|
||||
return MPG123_OK;
|
||||
}
|
||||
|
||||
-#elif SIZEOF_OFF_T == 8
|
||||
+#elif REAL_SIZEOF_OFF_T == 8
|
||||
|
||||
// If 64 bit off_t is enforced, libmpg123.c already defines the _64 functions.
|
||||
#ifndef FORCED_OFF_64
|
Loading…
Add table
Reference in a new issue