Skip to content

Commit

Permalink
Merge pull request #177 from carstene1ns/feature/icu-cross
Browse files Browse the repository at this point in the history
Do not copy ICU for cross build
  • Loading branch information
Ghabry committed Jun 10, 2024
2 parents 1d6d0b2 + 8291596 commit 04e4952
Show file tree
Hide file tree
Showing 27 changed files with 436 additions and 560 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@
*.pl
*.cache
.DS_Store
meson-cross.txt
44 changes: 25 additions & 19 deletions 3ds/2_build_toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ test_ccache

# Toolchain available?
test_dkp "devkitARM"
export PATH=$DEVKITARM/bin:$DEVKITPRO/tools/bin:$PATH

# Extra tools available?
if test_tool bannertool && test_tool makerom && test_tool 3dstool; then
: # nothing
else
msg "The following tools need to be installed to allow building .cia"
msg "bundles or creating custom banners:"
msg " https://github.com/dnasdw/3dstool"
#msg " https://github.com/Steveice10/bannertool"
msg " https://github.com/carstene1ns/3ds-bannertool"
msg " https://github.com/profi200/Project_CTR"
fi
require_tool tex3ds
require_tool 3dsxtool

if [ ! -f .patches-applied ]; then
echo "Patching libraries"
Expand All @@ -25,6 +40,7 @@ if [ ! -f .patches-applied ]; then
# Fix pixman
(cd $PIXMAN_DIR
patch -Np1 < $SCRIPT_DIR/../shared/extra/pixman-no-tls.patch
patch -Np1 < $SCRIPT_DIR/pixman-fix-types.patch
)

# Fix mpg123
Expand All @@ -33,23 +49,19 @@ if [ ! -f .patches-applied ]; then
autoreconf -fi
)

# Fix tremor
patch -d $TREMOR_DIR -Np1 < $SCRIPT_DIR/tremor-fix-types.patch

# Fix opus (remove when next version is out)
(cd $OPUS_DIR
patch -Np1 < $SCRIPT_DIR/opus-fix-types.patch
)
patch -d $OPUS_DIR -Np1 < $SCRIPT_DIR/opus-fix-types.patch

# Fix opusfile
(cd $OPUSFILE_DIR
patch -Np1 < $SCRIPT_DIR/../shared/extra/opusfile-devkit.patch
)
patch -d $OPUSFILE_DIR -Np1 < $SCRIPT_DIR/../shared/extra/opusfile-devkit.patch

# Fix lhasa
(cd $LHASA_DIR
patch -Np1 < $SCRIPT_DIR/../shared/extra/lhasa.patch
)
patch -d $LHASA_DIR -Np1 < $SCRIPT_DIR/../shared/extra/lhasa.patch

# Fix icu build
cp -rup icu icu-native
patch -Np0 < $SCRIPT_DIR/icu-3ds.patch

touch .patches-applied
Expand All @@ -59,8 +71,6 @@ cd $WORKSPACE

echo "Preparing toolchain"

export PATH=$DEVKITARM/bin:$PATH

export PLATFORM_PREFIX=$WORKSPACE
export TARGET_HOST=arm-none-eabi
unset PKG_CONFIG_PATH
Expand All @@ -70,10 +80,6 @@ export MAKEFLAGS="-j${nproc:-2}"
function set_build_flags {
export CC="$TARGET_HOST-gcc"
export CXX="$TARGET_HOST-g++"
if [ "$ENABLE_CCACHE" ]; then
export CC="ccache $CC"
export CXX="ccache $CXX"
fi
ARCH_FLAGS="-march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft -mword-relocations"
export CFLAGS="-g0 -O2 $ARCH_FLAGS -ffunction-sections -fdata-sections"
export CXXFLAGS="$CFLAGS"
Expand All @@ -82,15 +88,15 @@ function set_build_flags {
export LIBS="-lctru"
export CMAKE_SYSTEM_NAME="Generic"

$SCRIPT_DIR/../shared/mk-meson-cross.sh 3ds > meson-cross.txt
make_meson_cross 3ds > meson-cross.txt
}

install_lib_icu_native

set_build_flags

install_lib_zlib
install_lib $LIBPNG_DIR $LIBPNG_ARGS
install_lib_cmake $ZLIB_DIR $ZLIB_ARGS
install_lib_cmake $LIBPNG_DIR $LIBPNG_ARGS
install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=ON
#install_lib_meson $HARFBUZZ_DIR $HARFBUZZ_ARGS
#install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=OFF
Expand Down
2 changes: 0 additions & 2 deletions 3ds/3_cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ headermsg "Cleaning up library build folders and other stuff..."

cleanup

rm -f meson-cross.txt

echo " -> done"
19 changes: 16 additions & 3 deletions 3ds/opus-fix-types.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
diff '--color=auto' -Naur opus-1.5.1-orig/src/opus_private.h opus-1.5.1/src/opus_private.h
--- opus-1.5.1-orig/src/opus_private.h 2024-01-26 06:17:36.000000000 +0100
+++ opus-1.5.1/src/opus_private.h 2024-03-29 12:35:28.073702694 +0100
diff --color -Nur opus-1.5.1.orig/src/opus_private.h opus-1.5.1/src/opus_private.h
--- opus-1.5.1.orig/src/opus_private.h 2024-01-26 06:17:36.000000000 +0100
+++ opus-1.5.1/src/opus_private.h 2024-06-07 19:15:48.414257500 +0200
@@ -214,7 +214,7 @@

opus_int32 opus_packet_extensions_parse(const unsigned char *data, opus_int32 len, opus_extension_data *extensions, opus_int32 *nb_extensions);
Expand All @@ -10,3 +10,16 @@ diff '--color=auto' -Naur opus-1.5.1-orig/src/opus_private.h opus-1.5.1/src/opus

opus_int32 opus_packet_extensions_count(const unsigned char *data, opus_int32 len);

diff --color -Nur opus-1.5.1.orig/src/repacketizer.c opus-1.5.1/src/repacketizer.c
--- opus-1.5.1.orig/src/repacketizer.c 2024-02-20 21:05:04.000000000 +0100
+++ opus-1.5.1/src/repacketizer.c 2024-06-07 19:33:17.139842439 +0200
@@ -155,7 +155,8 @@
/* incorporate any extensions from the repacketizer padding */
for (i=begin;i<end;i++)
{
- int frame_ext_count, j;
+ opus_int32 frame_ext_count;
+ int j;
frame_ext_count = total_ext_count - ext_count;
int ret = opus_packet_extensions_parse(rp->paddings[i], rp->padding_len[i],
&all_extensions[ext_count], &frame_ext_count);
35 changes: 35 additions & 0 deletions 3ds/pixman-fix-types.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
diff --color -Nur pixman-0.43.4.orig/pixman/pixman.h pixman-0.43.4/pixman/pixman.h
--- pixman-0.43.4.orig/pixman/pixman.h 2024-02-29 17:13:20.000000000 +0100
+++ pixman-0.43.4/pixman/pixman.h 2024-06-07 18:28:33.819563120 +0200
@@ -120,7 +120,7 @@
typedef uint32_t pixman_fixed_1_31_t;
typedef uint32_t pixman_fixed_1_16_t;
typedef int32_t pixman_fixed_16_16_t;
-typedef pixman_fixed_16_16_t pixman_fixed_t;
+typedef int pixman_fixed_t;

#define pixman_fixed_e ((pixman_fixed_t) 1)
#define pixman_fixed_1 (pixman_int_to_fixed(1))
@@ -632,7 +632,7 @@

struct pixman_box32
{
- int32_t x1, y1, x2, y2;
+ int x1, y1, x2, y2;
};

struct pixman_region32
diff --color -Nur pixman-0.43.4.orig/pixman/pixman-inlines.h pixman-0.43.4/pixman/pixman-inlines.h
--- pixman-0.43.4.orig/pixman/pixman-inlines.h 2024-02-29 17:13:20.000000000 +0100
+++ pixman-0.43.4/pixman/pixman-inlines.h 2024-06-07 18:19:58.620034383 +0200
@@ -792,8 +792,8 @@
int32_t * right_tz,
int32_t * right_pad)
{
- int width1 = *width, left_pad1, right_pad1;
- int width2 = *width, left_pad2, right_pad2;
+ int32_t width1 = *width, left_pad1, right_pad1;
+ int32_t width2 = *width, left_pad2, right_pad2;

pad_repeat_get_scanline_bounds (source_image_width, vx, unit_x,
&width1, &left_pad1, &right_pad1);
31 changes: 31 additions & 0 deletions 3ds/tremor-fix-types.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--- tremor.orig/sharedbook.c 2018-03-19 21:08:57.000000000 +0100
+++ tremor-7c30a66346199f3f09017a09567c6c8a3a0eedc8/sharedbook.c 2024-06-07 19:26:43.278590551 +0200
@@ -218,12 +218,11 @@
quantvals=_book_maptype1_quantvals(b);
for(j=0;j<b->entries;j++){
if((sparsemap && b->lengthlist[j]) || !sparsemap){
- ogg_int32_t last=0;
- int lastpoint=0;
+ ogg_int32_t last=0, lastpoint=0;
int indexdiv=1;
for(k=0;k<b->dim;k++){
int index= (j/indexdiv)%quantvals;
- int point=0;
+ ogg_int32_t point=0;
int val=VFLOAT_MULTI(delta,delpoint,
abs(b->quantlist[index]),&point);

@@ -253,11 +252,10 @@
case 2:
for(j=0;j<b->entries;j++){
if((sparsemap && b->lengthlist[j]) || !sparsemap){
- ogg_int32_t last=0;
- int lastpoint=0;
+ ogg_int32_t last=0, lastpoint=0;

for(k=0;k<b->dim;k++){
- int point=0;
+ ogg_int32_t point=0;
int val=VFLOAT_MULTI(delta,delpoint,
abs(b->quantlist[j*b->dim+k]),&point);

14 changes: 3 additions & 11 deletions android/2_build_toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ source $SCRIPT_DIR/../shared/import.sh
os=`uname`
if [ $os = "Darwin" ] ; then
nproc=$(getconf _NPROCESSORS_ONLN)
CP_ARGS="-r"
NDK_ARCH="darwin-x86_64"
else
nproc=$(nproc)
CP_ARGS="-rup"
NDK_ARCH="linux-x86_64"
fi

Expand All @@ -28,8 +26,6 @@ if [ ! -f .patches-applied ]; then

patches_common

cp $CP_ARGS icu icu-native

# pixman: hardcode cpufeatures (crashes armeabi-v7a)
(cd $PIXMAN_DIR
patch -Np1 < ../pixman-cpufeatures.patch
Expand Down Expand Up @@ -97,16 +93,12 @@ function build() {
export TARGET_HOST="$4"
export CC="clang -target ${TARGET_HOST}${TARGET_API}"
export CXX="clang++ -target ${TARGET_HOST}${TARGET_API}"
if [ "$ENABLE_CCACHE" ]; then
export CC="ccache $CC"
export CXX="ccache $CXX"
fi

mkdir -p $PLATFORM_PREFIX
$SCRIPT_DIR/../shared/mk-meson-cross.sh "${TARGET_HOST}${TARGET_API}" > $PLATFORM_PREFIX/meson-cross.txt
make_meson_cross "${TARGET_HOST}${TARGET_API}" > $PLATFORM_PREFIX/meson-cross.txt

install_lib_zlib
install_lib $LIBPNG_DIR $LIBPNG_ARGS
install_lib_cmake $ZLIB_DIR $ZLIB_ARGS
install_lib_cmake $LIBPNG_DIR $LIBPNG_ARGS
install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=ON
install_lib_meson $HARFBUZZ_DIR $HARFBUZZ_ARGS
install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=OFF
Expand Down
9 changes: 3 additions & 6 deletions emscripten/2_build_toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ source $SCRIPT_DIR/../shared/import.sh
os=`uname`
if [ $os = "Darwin" ] ; then
nproc=$(getconf _NPROCESSORS_ONLN)
CP_ARGS="-r"
else
nproc=$(nproc)
CP_ARGS="-rup"
fi

# no ccache support currently with em* wrappers
Expand Down Expand Up @@ -44,8 +42,6 @@ if [ ! -f .patches-applied ]; then
)
fi

cp $CP_ARGS icu icu-native

touch .patches-applied
fi

Expand All @@ -68,6 +64,7 @@ function set_build_flags {
export EM_CFLAGS="-Wno-warn-absolute-paths"
export EMCC_CFLAGS="$EM_CFLAGS"
export EM_PKG_CONFIG_PATH="$PLATFORM_PREFIX/lib/pkgconfig"
export CMAKE_EXTRA_ARGS="-DCMAKE_FIND_ROOT_PATH=$PLATFORM_PREFIX"

# force mmap support in mpg123 (actually unused, but needed for building)
export ac_cv_func_mmap_fixed_mapped=yes
Expand Down Expand Up @@ -96,8 +93,8 @@ if [ $os = "Darwin" ] ; then
export TARGET_HOST="asmjs-unknown-emscripten"
fi

install_lib_zlib
install_lib $LIBPNG_DIR $LIBPNG_ARGS
install_lib_cmake $ZLIB_DIR $ZLIB_ARGS
install_lib_cmake $LIBPNG_DIR $LIBPNG_ARGS
install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=ON
install_lib_meson $HARFBUZZ_DIR $HARFBUZZ_ARGS
install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=OFF -DCMAKE_FIND_ROOT_PATH=$PLATFORM_PREFIX
Expand Down
1 change: 0 additions & 1 deletion emscripten/3_cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ headermsg "Cleaning up library build folders and other stuff..."
cleanup

rm -rf SDL2/
rm -f meson-cross.txt

echo " -> done"
12 changes: 3 additions & 9 deletions ios/2_build_toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ if [ ! -f .patches-applied ]; then

patches_common

cp -rp icu icu-native

touch .patches-applied
fi

Expand All @@ -43,10 +41,6 @@ function set_build_flags {
export CC="$CLANG $ARCH"
export CXX="$CLANGXX $ARCH"
export OBJC="$CLANG $ARCH"
if [ "$ENABLE_CCACHE" ]; then
export CC="ccache $CC"
export CXX="ccache $CXX"
fi
export CFLAGS="-g -O2 -miphoneos-version-min=9.0 -isysroot $SDKPATH $3"
export CXXFLAGS=$CFLAGS
# ICU include is required for arm64
Expand All @@ -58,14 +52,14 @@ function set_build_flags {
export TARGET_HOST="$2"

mkdir -p $PLATFORM_PREFIX
$SCRIPT_DIR/../shared/mk-meson-cross.sh "${TARGET_HOST}" > $PLATFORM_PREFIX/meson-cross.txt
make_meson_cross "${TARGET_HOST}" > $PLATFORM_PREFIX/meson-cross.txt
}

function build() {
cd "$WORKSPACE"

install_lib_zlib
install_lib $LIBPNG_DIR $LIBPNG_ARGS
install_lib_cmake $ZLIB_DIR $ZLIB_ARGS
install_lib_cmake $LIBPNG_DIR $LIBPNG_ARGS
install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=ON
install_lib_meson $HARFBUZZ_DIR $HARFBUZZ_ARGS
install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=OFF
Expand Down
15 changes: 9 additions & 6 deletions linux-static/2_build_toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,23 @@ echo "Preparing toolchain"

export PLATFORM_PREFIX=$WORKSPACE

if test_tool clang && test_tool clang++; then
export CC=clang
export CXX=clang++
elif test_tool gcc && test_tool g++; then
export CC=gcc
export CXX=g++
fi
export CFLAGS="-Os -g0 -fPIC -ffunction-sections -fdata-sections"
export CXXFLAGS=$CFLAGS
export CPPFLAGS="-I$PLATFORM_PREFIX/include"
export LDFLAGS="-fPIC -L$PLATFORM_PREFIX/lib"
export MAKEFLAGS="-j${nproc:-2}"
export PKG_CONFIG_PATH=$WORKSPACE/lib/pkgconfig
export PKG_CONFIG_LIBDIR=$PKG_CONFIG_PATH
if [ "$ENABLE_CCACHE" ]; then
export CC="ccache gcc"
export CXX="ccache g++"
fi

install_lib_zlib
install_lib $LIBPNG_DIR $LIBPNG_ARGS
install_lib_cmake $ZLIB_DIR $ZLIB_ARGS
install_lib_cmake $LIBPNG_DIR $LIBPNG_ARGS
install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=ON
install_lib_meson $HARFBUZZ_DIR $HARFBUZZ_ARGS
install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=OFF
Expand Down
12 changes: 3 additions & 9 deletions macos/2_build_toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ if [ ! -f .patches-applied ]; then

patches_common

cp -rp icu icu-native

touch .patches-applied
fi

Expand All @@ -42,10 +40,6 @@ function set_build_flags() {
export PATH=$PLATFORM_PREFIX/bin:$PATH
export CC="$CLANG $ARCH"
export CXX="$CLANGXX $ARCH"
if [ "$ENABLE_CCACHE" ]; then
export CC="ccache $CC"
export CXX="ccache $CXX"
fi
export CFLAGS="-g -O2 -mmacosx-version-min=10.9 -isysroot $SDKPATH $3"
export CXXFLAGS=$CFLAGS
# ICU include is required for arm64
Expand All @@ -59,14 +53,14 @@ function set_build_flags() {
export TARGET_HOST="$2"

mkdir -p $PLATFORM_PREFIX
$SCRIPT_DIR/../shared/mk-meson-cross.sh "${TARGET_HOST}" > $PLATFORM_PREFIX/meson-cross.txt
make_meson_cross "${TARGET_HOST}" > $PLATFORM_PREFIX/meson-cross.txt
}

function build() {
cd "$WORKSPACE"

install_lib_zlib
install_lib $LIBPNG_DIR $LIBPNG_ARGS
install_lib_cmake $ZLIB_DIR $ZLIB_ARGS
install_lib_cmake $LIBPNG_DIR $LIBPNG_ARGS
install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=ON
install_lib_meson $HARFBUZZ_DIR $HARFBUZZ_ARGS
install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=OFF
Expand Down
Loading

0 comments on commit 04e4952

Please sign in to comment.