File: make_lib_opusfile.sh

package info (click to toggle)
ddnet 19.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 68,960 kB
  • sloc: cpp: 195,050; ansic: 58,572; python: 5,568; asm: 946; sh: 941; java: 366; xml: 206; makefile: 31
file content (79 lines) | stat: -rwxr-xr-x 1,899 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash

ANDROID_HOME=~/Android/Sdk
ANDROID_NDK="$(find "$ANDROID_HOME/ndk" -maxdepth 1 | sort -n | tail -1)"

export MAKEFLAGS=-j32

export CXXFLAGS="$3"
export CFLAGS="$3"
export CPPFLAGS="$4"
export LDFLAGS="$4"

export ANDROID_NDK_ROOT="$ANDROID_NDK"

function make_opusfile() {
	_EXISTS_PROJECT=0
	if [ -d "$1" ]; then
		_EXISTS_PROJECT=1
	else
		mkdir "$1"
	fi
	(
		cd "$1" || exit 1
		if [[ "$_EXISTS_PROJECT" == 0 ]]; then
			#not nice but doesn't matter
			cp -R ../../ogg/include .
			cp -R ../../opus/include .
			cp -R ../../ogg/"$2"/include/ogg/* include/ogg/
			cp ../../ogg/"$2"/libogg.a libogg.a
			cp ../../opus/"$2"/libopus.a libopus.a
		fi

		TMP_COMPILER=""
		TMP_AR=""
		if [[ "${5}" == "android" ]]; then
			TMP_COMPILER="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/$3$4-clang"
			TMP_AR="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"
		elif [[ "${5}" == "webasm" ]]; then
			TMP_COMPILER="emcc"
			TMP_AR="emar"
		fi

		${TMP_COMPILER} \
			-c \
			-fPIC \
			-I"${PWD}"/../include \
			-I"${PWD}"/include \
			../src/opusfile.c \
			../src/info.c \
			../src/internal.c
		${TMP_COMPILER} \
			-c \
			-fPIC \
			-I"${PWD}"/../include \
			-I"${PWD}"/include \
			-include stdio.h \
			../src/stream.c
		${TMP_AR} \
			rvs \
			libopusfile.a \
			opusfile.o \
			info.o \
			stream.o \
			internal.o
	)
}

function compile_all_opusfile() {
	if [[ "${2}" == "android" ]]; then
		make_opusfile build_"$2"_arm build_"$2"_arm armv7a-linux-androideabi "$1" "$2"
		make_opusfile build_"$2"_arm64 build_"$2"_arm64 aarch64-linux-android "$1" "$2"
		make_opusfile build_"$2"_x86 build_"$2"_x86 i686-linux-android "$1" "$2"
		make_opusfile build_"$2"_x86_64 build_"$2"_x86_64 x86_64-linux-android "$1" "$2"
	elif [[ "${2}" == "webasm" ]]; then
		make_opusfile build_"$2"_wasm build_"$2"_wasm "" "$1" "$2"
	fi
}

compile_all_opusfile "$1" "$2"