Skip to content
Snippets Groups Projects
Commit b68b605c authored by Kateryna Kostiuk's avatar Kateryna Kostiuk
Browse files

build: add parameter for architecture

This patch introduces a parameter to specify the build architecture.
Currently, this affects only macOS builds. By default, it targets
the host architecture.

Change-Id: I32a610d69069e910bea19864fab6ffbfcb849dbd
parent 9f123095
Branches
No related tags found
No related merge requests found
...@@ -34,16 +34,14 @@ elif [ "${PLATFORM}" = "Darwin" ]; then ...@@ -34,16 +34,14 @@ elif [ "${PLATFORM}" = "Darwin" ]; then
PLATFORM="darwin" PLATFORM="darwin"
SO_FILE_NAME="lib${PLUGIN_NAME}.dylib" SO_FILE_NAME="lib${PLUGIN_NAME}.dylib"
alias nproc='sysctl -n hw.logicalcpu' alias nproc='sysctl -n hw.logicalcpu'
CONTRIB_PLATFORM_CURT=${ARCH}-apple
CONTRIB_PLATFORM_EXTRA=$(uname -r) CONTRIB_PLATFORM_EXTRA=$(uname -r)
echo "Building with ${PLATFORM}" echo "Building with ${PLATFORM}"
fi fi
while getopts t:c:p:d OPT; do while getopts t:c:p:d:a: OPT; do
case "$OPT" in case "$OPT" in
d) d)
DEBUG=true DEBUG=true
export __DEBUG__=true
;; ;;
t) t)
PLATFORM="${OPTARG}" PLATFORM="${OPTARG}"
...@@ -53,13 +51,19 @@ while getopts t:c:p:d OPT; do ...@@ -53,13 +51,19 @@ while getopts t:c:p:d OPT; do
;; ;;
p) p)
;; ;;
a)
ARCH="${OPTARG}" # Override the default ARCH value if provided
;;
\?) \?)
exit 1 exit 1
;; ;;
esac esac
done done
#cp -r ffmpeg ${CONTRIB_PATH}/src/ if [ "${PLATFORM}" = "darwin" ]; then
CONTRIB_PLATFORM_CURT=${ARCH}-apple
fi
cp -r ../contrib/mp3lame ${CONTRIB_PATH}/src/ cp -r ../contrib/mp3lame ${CONTRIB_PATH}/src/
if [ "${PLATFORM}" = "linux-gnu" ] || [ "${PLATFORM}" = "redhat-linux" ] if [ "${PLATFORM}" = "linux-gnu" ] || [ "${PLATFORM}" = "redhat-linux" ]
...@@ -130,13 +134,15 @@ then ...@@ -130,13 +134,15 @@ then
EXTRA_DEBUG_LIBRARIES="-lyaml-cpp -lmp3lame" EXTRA_DEBUG_LIBRARIES="-lyaml-cpp -lmp3lame"
EXTRA_DEFINES="-D__DEBUG__" EXTRA_DEFINES="-D__DEBUG__"
else else
python3 ./../SDK/jplManipulation.py --preassemble --plugin=${PLUGIN_NAME} python3 ./../SDK/jplManipulation.py --preassemble --plugin=${PLUGIN_NAME} --arch="${ARCH}"
CLANG_OPTS="-O3 -shared" CLANG_OPTS="-O3 -shared"
OUTPUT="build-local/jpl/lib/${CONTRIB_PLATFORM}/${SO_FILE_NAME}" OUTPUT="build-local/jpl/lib/${CONTRIB_PLATFORM}/${SO_FILE_NAME}"
fi fi
ARCH_OPT=" -arch ${ARCH}"
# Compile # Compile
clang++ -std=c++17 -fPIC ${CLANG_OPTS} \ clang++ -std=c++17 -fPIC ${CLANG_OPTS} ${ARCH_OPT}\
-Wl,-no_compact_unwind -Wl,-framework,CoreFoundation \ -Wl,-no_compact_unwind -Wl,-framework,CoreFoundation \
-Wl,-framework,Security -Wl,-framework,VideoToolbox \ -Wl,-framework,Security -Wl,-framework,VideoToolbox \
-Wl,-framework,CoreMedia -Wl,-framework,CoreVideo \ -Wl,-framework,CoreMedia -Wl,-framework,CoreVideo \
...@@ -299,8 +305,12 @@ then ...@@ -299,8 +305,12 @@ then
fi fi
if [ ! ${DEBUG} ]; then if [ ! ${DEBUG} ]; then
if [ "${PLATFORM}" = "darwin" ]; then
python3 ./../SDK/jplManipulation.py --assemble --plugin=${PLUGIN_NAME} --distribution=${PLATFORM} --extraPath=${EXTRAPATH} --arch="${ARCH}"
else
python3 ./../SDK/jplManipulation.py --assemble --plugin=${PLUGIN_NAME} --distribution=${PLATFORM} --extraPath=${EXTRAPATH} python3 ./../SDK/jplManipulation.py --assemble --plugin=${PLUGIN_NAME} --distribution=${PLATFORM} --extraPath=${EXTRAPATH}
fi fi
fi
cd ${CONTRIB_PATH}/src/ffmpeg/ cd ${CONTRIB_PATH}/src/ffmpeg/
# ffmpeg build configuration files were changed during plugin build # ffmpeg build configuration files were changed during plugin build
# this git checkout will remove these changes # this git checkout will remove these changes
......
...@@ -31,12 +31,11 @@ if [ "${PLATFORM}" = "Linux" ]; then ...@@ -31,12 +31,11 @@ if [ "${PLATFORM}" = "Linux" ]; then
echo "Building with ${PLATFORM}" echo "Building with ${PLATFORM}"
elif [ "${PLATFORM}" = "Darwin" ]; then elif [ "${PLATFORM}" = "Darwin" ]; then
SO_FILE_NAME="lib${PLUGIN_NAME}.dylib" SO_FILE_NAME="lib${PLUGIN_NAME}.dylib"
CONTRIB_PLATFORM_CURT=${ARCH}-apple
CONTRIB_PLATFORM_EXTRA=$(uname -r) CONTRIB_PLATFORM_EXTRA=$(uname -r)
echo "Building with ${PLATFORM}" echo "Building with ${PLATFORM}"
fi fi
while getopts t:c:p:d OPT; do while getopts t:c:p:d:a: OPT; do
case "$OPT" in case "$OPT" in
d) d)
DEBUG=true DEBUG=true
...@@ -49,18 +48,26 @@ while getopts t:c:p:d OPT; do ...@@ -49,18 +48,26 @@ while getopts t:c:p:d OPT; do
;; ;;
p) p)
;; ;;
a)
ARCH="${OPTARG}" # Override the default ARCH value if provided
;;
\?) \?)
exit 1 exit 1
;; ;;
esac esac
done done
if [ "${PLATFORM}" = "Darwin" ]; then
CONTRIB_PLATFORM_CURT=${ARCH}-apple
fi
if [ "${PLATFORM}" = "linux-gnu" ] || [ "${PLATFORM}" = "redhat-linux" ] || [ "${PLATFORM}" = "Darwin" ] if [ "${PLATFORM}" = "linux-gnu" ] || [ "${PLATFORM}" = "redhat-linux" ] || [ "${PLATFORM}" = "Darwin" ]
then then
CONTRIB_PLATFORM=${CONTRIB_PLATFORM_CURT}-${PLATFORM} CONTRIB_PLATFORM=${CONTRIB_PLATFORM_CURT}-${PLATFORM}
OUTPUTFOLDER=${CONTRIB_PLATFORM} OUTPUTFOLDER=${CONTRIB_PLATFORM}
if [ "${PLATFORM}" = "Darwin" ]; then if [ "${PLATFORM}" = "Darwin" ]; then
CONTRIB_PLATFORM=${CONTRIB_PLATFORM}${CONTRIB_PLATFORM_EXTRA} CONTRIB_PLATFORM=${CONTRIB_PLATFORM}${CONTRIB_PLATFORM_EXTRA}
ARCH_OPT=" -arch ${ARCH}"
fi fi
if [ ${DEBUG} ]; then if [ ${DEBUG} ]; then
...@@ -69,13 +76,13 @@ then ...@@ -69,13 +76,13 @@ then
EXTRA_DEBUG_LIBRARIES="-lyaml-cpp" EXTRA_DEBUG_LIBRARIES="-lyaml-cpp"
EXTRA_DEFINES="-D__DEBUG__" EXTRA_DEFINES="-D__DEBUG__"
else else
python3 ./../SDK/jplManipulation.py --preassemble --plugin=${PLUGIN_NAME} python3 ./../SDK/jplManipulation.py --preassemble --plugin=${PLUGIN_NAME} --arch=${ARCH}
CLANG_OPTS="-O3 -shared" CLANG_OPTS="-O3 -shared"
OUTPUT="build-local/jpl/lib/${OUTPUTFOLDER}/${SO_FILE_NAME}" OUTPUT="build-local/jpl/lib/${OUTPUTFOLDER}/${SO_FILE_NAME}"
fi fi
# Compile # Compile
clang++ -std=c++17 -fPIC ${CLANG_OPTS} \ clang++ -std=c++17 -fPIC ${CLANG_OPTS} ${ARCH_OPT} \
-Wl,-rpath,"\${ORIGIN}" \ -Wl,-rpath,"\${ORIGIN}" \
-Wall -Wextra \ -Wall -Wextra \
-Wno-unused-parameter \ -Wno-unused-parameter \
...@@ -212,5 +219,9 @@ then ...@@ -212,5 +219,9 @@ then
fi fi
if [ ! ${DEBUG} ]; then if [ ! ${DEBUG} ]; then
if [ "${PLATFORM}" = "Darwin" ]; then
python3 ./../SDK/jplManipulation.py --assemble --plugin=${PLUGIN_NAME} --distribution=${PLATFORM} --extraPath=${EXTRAPATH} --arch="${ARCH}"
else
python3 ./../SDK/jplManipulation.py --assemble --plugin=${PLUGIN_NAME} --distribution=${PLATFORM} --extraPath=${EXTRAPATH} python3 ./../SDK/jplManipulation.py --assemble --plugin=${PLUGIN_NAME} --distribution=${PLATFORM} --extraPath=${EXTRAPATH}
fi fi
fi
...@@ -39,7 +39,6 @@ elif [ "${PLATFORM}" = "Darwin" ]; then ...@@ -39,7 +39,6 @@ elif [ "${PLATFORM}" = "Darwin" ]; then
PLATFORM="darwin" PLATFORM="darwin"
SO_FILE_NAME="lib${PLUGIN_NAME}.dylib" SO_FILE_NAME="lib${PLUGIN_NAME}.dylib"
alias nproc='sysctl -n hw.logicalcpu' alias nproc='sysctl -n hw.logicalcpu'
CONTRIB_PLATFORM_CURT=${ARCH}-apple
CONTRIB_PLATFORM_EXTRA=$(uname -r) CONTRIB_PLATFORM_EXTRA=$(uname -r)
echo "Building with ${PLATFORM}" echo "Building with ${PLATFORM}"
fi fi
...@@ -52,7 +51,7 @@ elif [ "${PROCESSOR}" = "NVIDIA" ]; then ...@@ -52,7 +51,7 @@ elif [ "${PROCESSOR}" = "NVIDIA" ]; then
PREFERENCESFILENAME="${PREFERENCESFILENAME}-accel" PREFERENCESFILENAME="${PREFERENCESFILENAME}-accel"
fi fi
while getopts t:c:p:d OPT; do while getopts t:c:p:d:a: OPT; do
case "$OPT" in case "$OPT" in
d) d)
DEBUG=true DEBUG=true
...@@ -68,13 +67,19 @@ while getopts t:c:p:d OPT; do ...@@ -68,13 +67,19 @@ while getopts t:c:p:d OPT; do
;; ;;
p) p)
;; ;;
a)
ARCH="${OPTARG}" # Override the default ARCH value if provided
;;
\?) \?)
exit 1 exit 1
;; ;;
esac esac
done done
#cp -r ffmpeg ${CONTRIB_PATH}/src/ if [ "${PLATFORM}" = "darwin" ]; then
CONTRIB_PLATFORM_CURT=${ARCH}-apple
fi
cp -r ../contrib/rav1e ${CONTRIB_PATH}/src/ cp -r ../contrib/rav1e ${CONTRIB_PATH}/src/
if [ "${PLATFORM}" = "linux-gnu" ] || [ "${PLATFORM}" = "redhat-linux" ] if [ "${PLATFORM}" = "linux-gnu" ] || [ "${PLATFORM}" = "redhat-linux" ]
...@@ -182,13 +187,19 @@ then ...@@ -182,13 +187,19 @@ then
EXTRA_DEBUG_LIBRARIES="-lyaml-cpp -lrav1e" EXTRA_DEBUG_LIBRARIES="-lyaml-cpp -lrav1e"
EXTRA_DEFINES="-D__DEBUG__" EXTRA_DEFINES="-D__DEBUG__"
else else
python3 ./../SDK/jplManipulation.py --preassemble --plugin=${PLUGIN_NAME} python3 ./../SDK/jplManipulation.py --preassemble --plugin=${PLUGIN_NAME} --arch="${ARCH}"
CLANG_OPTS="-O3 -shared" CLANG_OPTS="-O3 -shared"
OUTPUT="build-local/jpl/lib/${CONTRIB_PLATFORM}/${SO_FILE_NAME}" OUTPUT="build-local/jpl/lib/${CONTRIB_PLATFORM}/${SO_FILE_NAME}"
fi fi
ARCH_OPT=" -arch ${ARCH}"
# Update the install name of libonnxruntime.dylib from "@rpath/libonnxruntime.1.16.2.dylib"
# to "@rpath/libonnxruntime.dylib" before any linking occurs.
install_name_tool -id "@rpath/libonnxruntime.dylib" "${ONNX_PATH}/lib/onnxruntime/${ONNX_LIBS}/libonnxruntime.dylib"
# Compile # Compile
clang++ -std=c++17 -fPIC ${CLANG_OPTS} \ clang++ -std=c++17 -fPIC ${CLANG_OPTS} ${ARCH_OPT} \
-Wl,-no_compact_unwind -Wl,-framework,CoreFoundation \ -Wl,-no_compact_unwind -Wl,-framework,CoreFoundation \
-Wl,-framework,Security -Wl,-framework,VideoToolbox \ -Wl,-framework,Security -Wl,-framework,VideoToolbox \
-Wl,-framework,CoreMedia -Wl,-framework,CoreVideo \ -Wl,-framework,CoreMedia -Wl,-framework,CoreVideo \
...@@ -225,6 +236,7 @@ then ...@@ -225,6 +236,7 @@ then
-lopencv_imgproc \ -lopencv_imgproc \
-lopencv_core \ -lopencv_core \
-lonnxruntime \ -lonnxruntime \
-lswresample \
-lspeex \ -lspeex \
-lopus \ -lopus \
${EXTRA_DEBUG_LIBRARIES} \ ${EXTRA_DEBUG_LIBRARIES} \
...@@ -234,17 +246,17 @@ then ...@@ -234,17 +246,17 @@ then
mkdir -p "./data/model" mkdir -p "./data/model"
cp "./modelSRC/mModel.onnx" "./data/model/mModel.onnx" cp "./modelSRC/mModel.onnx" "./data/model/mModel.onnx"
cp "${ONNX_PATH}/lib/onnxruntime/${ONNX_LIBS}/libonnxruntime.dylib" "libonnxruntime.dylib" cp "${ONNX_PATH}/lib/onnxruntime/${ONNX_LIBS}/libonnxruntime.dylib" "libonnxruntime.dylib"
install_name_tool -id "@loader_path/libonnxruntime.1.12.0.dylib" "libonnxruntime.dylib" install_name_tool -id "@loader_path/libonnxruntime.dylib" "libonnxruntime.dylib"
install_name_tool -id "@loader_path/${PLUGIN_NAME}" "${OUTPUT}" install_name_tool -id "@loader_path/${PLUGIN_NAME}" "${OUTPUT}"
else else
mkdir -p "./build-local/jpl/data/model" mkdir -p "./build-local/jpl/data/model"
cp "./modelSRC/mModel.onnx" "./build-local/jpl/data/model/mModel.onnx" cp "./modelSRC/mModel.onnx" "./build-local/jpl/data/model/mModel.onnx"
cp "./${PREFERENCESFILENAME}.json" "./build-local/jpl/data/preferences.json" cp "./${PREFERENCESFILENAME}.json" "./build-local/jpl/data/preferences.json"
cp "${ONNX_PATH}/lib/onnxruntime/${ONNX_LIBS}/libonnxruntime.dylib" "build-local/jpl/lib/${CONTRIB_PLATFORM}/libonnxruntime.dylib" cp "${ONNX_PATH}/lib/onnxruntime/${ONNX_LIBS}/libonnxruntime.dylib" "build-local/jpl/lib/${CONTRIB_PLATFORM}/libonnxruntime.dylib"
install_name_tool -id "@loader_path/libonnxruntime.1.12.0.dylib" "build-local/jpl/lib/${CONTRIB_PLATFORM}/libonnxruntime.dylib" install_name_tool -id "@loader_path/libonnxruntime.dylib" "build-local/jpl/lib/${CONTRIB_PLATFORM}/libonnxruntime.dylib"
install_name_tool -id "@loader_path/${SO_FILE_NAME}" "${OUTPUT}" install_name_tool -id "@loader_path/${SO_FILE_NAME}" "${OUTPUT}"
fi fi
install_name_tool -change "@rpath/libonnxruntime.1.12.0.dylib" "@loader_path/libonnxruntime.dylib" "${OUTPUT}" install_name_tool -change "@rpath/libonnxruntime.dylib" "@loader_path/libonnxruntime.dylib" "${OUTPUT}"
if [ -n "${APPLE_SIGN_CERTIFICATE}" ]; then if [ -n "${APPLE_SIGN_CERTIFICATE}" ]; then
codesign --force --verify --timestamp -o runtime --sign "${APPLE_SIGN_CERTIFICATE}" "build-local/jpl/lib/${CONTRIB_PLATFORM}/libonnxruntime.dylib" codesign --force --verify --timestamp -o runtime --sign "${APPLE_SIGN_CERTIFICATE}" "build-local/jpl/lib/${CONTRIB_PLATFORM}/libonnxruntime.dylib"
...@@ -413,8 +425,12 @@ then ...@@ -413,8 +425,12 @@ then
fi fi
if [ ! ${DEBUG} ]; then if [ ! ${DEBUG} ]; then
if [ "${PLATFORM}" = "darwin" ]; then
python3 ./../SDK/jplManipulation.py --assemble --plugin=${PLUGIN_NAME} --distribution=${PLATFORM} --extraPath=${EXTRAPATH} --arch="${ARCH}"
else
python3 ./../SDK/jplManipulation.py --assemble --plugin=${PLUGIN_NAME} --distribution=${PLATFORM} --extraPath=${EXTRAPATH} python3 ./../SDK/jplManipulation.py --assemble --plugin=${PLUGIN_NAME} --distribution=${PLATFORM} --extraPath=${EXTRAPATH}
fi fi
fi
cd ${CONTRIB_PATH}/src/ffmpeg/ cd ${CONTRIB_PATH}/src/ffmpeg/
# ffmpeg build configuration files were changed during plugin build # ffmpeg build configuration files were changed during plugin build
# this git checkout will remove these changes # this git checkout will remove these changes
......
...@@ -118,7 +118,7 @@ def onerror(func, path, exc_info): ...@@ -118,7 +118,7 @@ def onerror(func, path, exc_info):
raise raise
def preAssemble(pluginName, distribution=''): def preAssemble(pluginName, distribution='', arch=''):
localSystem = getSystem() localSystem = getSystem()
osBuildPath = "build-local" osBuildPath = "build-local"
...@@ -126,7 +126,7 @@ def preAssemble(pluginName, distribution=''): ...@@ -126,7 +126,7 @@ def preAssemble(pluginName, distribution=''):
if (distribution != 'android'): if (distribution != 'android'):
distribution = "x86_64-linux-gnu" distribution = "x86_64-linux-gnu"
elif localSystem == OS_IDS["Darwin"]: elif localSystem == OS_IDS["Darwin"]:
distribution = "x86_64-apple-Darwin" distribution = f"{arch}-apple-Darwin"
elif localSystem == OS_IDS["Windows"]: elif localSystem == OS_IDS["Windows"]:
distribution = "x64-windows" distribution = "x64-windows"
osBuildPath = "msvc" osBuildPath = "msvc"
...@@ -161,7 +161,7 @@ def preAssemble(pluginName, distribution=''): ...@@ -161,7 +161,7 @@ def preAssemble(pluginName, distribution=''):
os.chdir(f"./{osBuildPath}") os.chdir(f"./{osBuildPath}")
def assemble(pluginName, extraPath='', distribution=''): def assemble(pluginName, extraPath='', distribution='', arch=''):
extraPath = '/' + extraPath extraPath = '/' + extraPath
localSystem = getSystem() localSystem = getSystem()
root = os.path.dirname(os.path.abspath(__file__)) + "/.." root = os.path.dirname(os.path.abspath(__file__)) + "/.."
...@@ -171,7 +171,7 @@ def assemble(pluginName, extraPath='', distribution=''): ...@@ -171,7 +171,7 @@ def assemble(pluginName, extraPath='', distribution=''):
if (distribution != 'android'): if (distribution != 'android'):
distribution = "x86_64-linux-gnu" distribution = "x86_64-linux-gnu"
elif localSystem == OS_IDS["Darwin"]: elif localSystem == OS_IDS["Darwin"]:
distribution = "x86_64-apple-Darwin" distribution = f"{arch}-apple-Darwin"
elif localSystem == OS_IDS["Windows"]: elif localSystem == OS_IDS["Windows"]:
distribution = "x64-windows" distribution = "x64-windows"
osBuildPath = 'msvc' osBuildPath = 'msvc'
...@@ -215,6 +215,8 @@ def parser(): ...@@ -215,6 +215,8 @@ def parser():
help='output intermediate Path') help='output intermediate Path')
parser.add_argument('--distribution', type=str, default='', parser.add_argument('--distribution', type=str, default='',
help="GNU/Linux or Windows, leave empty. Android, type android") help="GNU/Linux or Windows, leave empty. Android, type android")
parser.add_argument('--arch', type=str,
help='Specify the architecture (x86_64, arm64).')
# to build or not to build # to build or not to build
parser.add_argument('--build', action='store_true') parser.add_argument('--build', action='store_true')
...@@ -242,11 +244,11 @@ def main(): ...@@ -242,11 +244,11 @@ def main():
args = parser() args = parser()
if args.preassemble: if args.preassemble:
preAssemble(args.plugin, args.distribution) preAssemble(args.plugin, args.distribution, args.arch)
if (args.build): if (args.build):
build(args.plugin) build(args.plugin)
if (args.assemble): if (args.assemble):
assemble(args.plugin, args.extraPath, args.distribution) assemble(args.plugin, args.extraPath, args.distribution, args.arch)
if (args.merge): if (args.merge):
JPLStructure(args.path, args.output) JPLStructure(args.path, args.output)
......
...@@ -34,12 +34,11 @@ elif [ "${PLATFORM}" = "Darwin" ]; then ...@@ -34,12 +34,11 @@ elif [ "${PLATFORM}" = "Darwin" ]; then
PLATFORM="darwin" PLATFORM="darwin"
SO_FILE_NAME="lib${PLUGIN_NAME}.dylib" SO_FILE_NAME="lib${PLUGIN_NAME}.dylib"
alias nproc="sysctl -n hw.logicalcpu" alias nproc="sysctl -n hw.logicalcpu"
CONTRIB_PLATFORM_CURT=${ARCH}-apple
CONTRIB_PLATFORM_EXTRA=$(uname -r) CONTRIB_PLATFORM_EXTRA=$(uname -r)
echo "Building with ${PLATFORM}" echo "Building with ${PLATFORM}"
fi fi
while getopts t:c:p:d OPT; do while getopts t:c:p:d:a: OPT; do
case "$OPT" in case "$OPT" in
d) d)
DEBUG=true DEBUG=true
...@@ -53,13 +52,19 @@ while getopts t:c:p:d OPT; do ...@@ -53,13 +52,19 @@ while getopts t:c:p:d OPT; do
;; ;;
p) p)
;; ;;
a)
ARCH="${OPTARG}" # Override the default ARCH value if provided
;;
\?) \?)
exit 1 exit 1
;; ;;
esac esac
done done
#cp -r ffmpeg ${CONTRIB_PATH}/src/ if [ "${PLATFORM}" = "darwin" ]; then
CONTRIB_PLATFORM_CURT=${ARCH}-apple
fi
cp -r ../contrib/rav1e ${CONTRIB_PATH}/src/ cp -r ../contrib/rav1e ${CONTRIB_PATH}/src/
if [ "${PLATFORM}" = "linux-gnu" ] || [ "${PLATFORM}" = "redhat-linux" ] if [ "${PLATFORM}" = "linux-gnu" ] || [ "${PLATFORM}" = "redhat-linux" ]
...@@ -124,20 +129,21 @@ then ...@@ -124,20 +129,21 @@ then
elif [ "${PLATFORM}" = "darwin" ] elif [ "${PLATFORM}" = "darwin" ]
then then
CONTRIB_PLATFORM=${CONTRIB_PLATFORM_CURT}-${PLATFORM} CONTRIB_PLATFORM=${CONTRIB_PLATFORM_CURT}-${PLATFORM}
if [ ${DEBUG} ]; then if [ ${DEBUG} ]; then
OUTPUT="${PLUGIN_NAME}" OUTPUT="${PLUGIN_NAME}"
CLANG_OPTS="-g -fsanitize=address" CLANG_OPTS="-g -fsanitize=address"
EXTRA_DEBUG_LIBRARIES="-lyaml-cpp -lrav1e" EXTRA_DEBUG_LIBRARIES="-lyaml-cpp -lrav1e"
EXTRA_DEFINES="-D__DEBUG__" EXTRA_DEFINES="-D__DEBUG__"
else else
python3 ./../SDK/jplManipulation.py --preassemble --plugin=${PLUGIN_NAME} python3 ./../SDK/jplManipulation.py --preassemble --plugin=${PLUGIN_NAME} --arch="${ARCH}"
CLANG_OPTS="-O3 -shared" CLANG_OPTS="-O3 -shared"
OUTPUT="build-local/jpl/lib/${CONTRIB_PLATFORM}/${SO_FILE_NAME}" OUTPUT="build-local/jpl/lib/${CONTRIB_PLATFORM}/${SO_FILE_NAME}"
fi fi
ARCH_OPT=" -arch ${ARCH}"
# Compile # Compile
clang++ -std=c++17 -fPIC ${CLANG_OPTS} \ clang++ -std=c++17 -fPIC ${CLANG_OPTS} ${ARCH_OPT} \
-Wl,-no_compact_unwind -Wl,-framework,CoreFoundation \ -Wl,-no_compact_unwind -Wl,-framework,CoreFoundation \
-Wl,-framework,Security -Wl,-framework,VideoToolbox \ -Wl,-framework,Security -Wl,-framework,VideoToolbox \
-Wl,-framework,CoreMedia -Wl,-framework,CoreVideo \ -Wl,-framework,CoreMedia -Wl,-framework,CoreVideo \
...@@ -164,11 +170,11 @@ then ...@@ -164,11 +170,11 @@ then
-lavformat \ -lavformat \
-lavcodec \ -lavcodec \
-lavutil \ -lavutil \
-lswresample \
-lvpx -lx264 -lbz2 -liconv -lz \ -lvpx -lx264 -lbz2 -liconv -lz \
-lspeex \ -lspeex \
-lopus \ -lopus \
"/usr/local/opt/libpng/lib/libpng.a" \ -lfreetype \
"/usr/local/opt/freetype/lib/libfreetype.a" \
${EXTRA_DEBUG_LIBRARIES} \ ${EXTRA_DEBUG_LIBRARIES} \
-o "${OUTPUT}" -o "${OUTPUT}"
...@@ -302,7 +308,14 @@ then ...@@ -302,7 +308,14 @@ then
done done
fi fi
if [ ! ${DEBUG} ]; then
if [ "${PLATFORM}" = "darwin" ]; then
python3 ./../SDK/jplManipulation.py --assemble --plugin=${PLUGIN_NAME} --distribution=${PLATFORM} --extraPath=${EXTRAPATH} --arch="${ARCH}"
else
python3 ./../SDK/jplManipulation.py --assemble --plugin=${PLUGIN_NAME} --distribution=${PLATFORM} --extraPath=${EXTRAPATH} python3 ./../SDK/jplManipulation.py --assemble --plugin=${PLUGIN_NAME} --distribution=${PLATFORM} --extraPath=${EXTRAPATH}
fi
fi
cd ${CONTRIB_PATH}/src/ffmpeg/ cd ${CONTRIB_PATH}/src/ffmpeg/
# ffmpeg build configuration files were changed during plugin build # ffmpeg build configuration files were changed during plugin build
# this git checkout will remove these changes # this git checkout will remove these changes
......
...@@ -41,7 +41,7 @@ elif [ "${PLATFORM}" = "Darwin" ]; then ...@@ -41,7 +41,7 @@ elif [ "${PLATFORM}" = "Darwin" ]; then
echo "Building with ${PLATFORM}" echo "Building with ${PLATFORM}"
fi fi
while getopts t:c:p:d OPT; do while getopts t:c:p:d:a: OPT; do
case "$OPT" in case "$OPT" in
d) d)
DEBUG=true DEBUG=true
...@@ -55,12 +55,19 @@ while getopts t:c:p:d OPT; do ...@@ -55,12 +55,19 @@ while getopts t:c:p:d OPT; do
;; ;;
p) p)
;; ;;
a)
ARCH="${OPTARG}" # Override the default ARCH value if provided
;;
\?) \?)
exit 1 exit 1
;; ;;
esac esac
done done
if [ "${PLATFORM}" = "darwin" ]; then
CONTRIB_PLATFORM_CURT=${ARCH}-apple
fi
if [ -z "${PROCESSOR}" ]; then if [ -z "${PROCESSOR}" ]; then
PROCESSOR="CPU" PROCESSOR="CPU"
echo "PROCESSOR not provided, building with ${PROCESSOR}" echo "PROCESSOR not provided, building with ${PROCESSOR}"
...@@ -170,10 +177,6 @@ then ...@@ -170,10 +177,6 @@ then
elif [ "${PLATFORM}" = "darwin" ] elif [ "${PLATFORM}" = "darwin" ]
then then
if [ -f "${CONTRIB_BUILD_PATH}/.ffmpeg" ]; then
rm "${CONTRIB_BUILD_PATH}/.ffmpeg"
rm -rf "${CONTRIB_BUILD_PATH}/ffmpeg"
fi
if [ -f "${CONTRIB_BUILD_PATH}/.whispercpp" ]; then if [ -f "${CONTRIB_BUILD_PATH}/.whispercpp" ]; then
rm "${CONTRIB_BUILD_PATH}/.whispercpp" rm "${CONTRIB_BUILD_PATH}/.whispercpp"
rm -rf "${CONTRIB_BUILD_PATH}/whispercpp" rm -rf "${CONTRIB_BUILD_PATH}/whispercpp"
...@@ -191,13 +194,15 @@ then ...@@ -191,13 +194,15 @@ then
EXTRA_DEBUG_LIBRARIES="-lyaml-cpp -lrav1e" EXTRA_DEBUG_LIBRARIES="-lyaml-cpp -lrav1e"
EXTRA_DEFINES="-D__DEBUG__" EXTRA_DEFINES="-D__DEBUG__"
else else
python3 ./../SDK/jplManipulation.py --preassemble --plugin=${PLUGIN_NAME} python3 ./../SDK/jplManipulation.py --preassemble --plugin=${PLUGIN_NAME} --arch="${ARCH}"
CLANG_OPTS="-O3 -g -shared" CLANG_OPTS="-O3 -g -shared"
OUTPUT="build-local/jpl/lib/${CONTRIB_PLATFORM}/${SO_FILE_NAME}" OUTPUT="build-local/jpl/lib/${CONTRIB_PLATFORM}/${SO_FILE_NAME}"
fi fi
ARCH_OPT=" -arch ${ARCH}"
# Compile # Compile
clang++ -std=c++17 -fPIC ${CLANG_OPTS} \ clang++ -std=c++17 -fPIC ${CLANG_OPTS} ${ARCH_OPT} \
-Wl,-no_compact_unwind -Wl,-framework,CoreFoundation \ -Wl,-no_compact_unwind -Wl,-framework,CoreFoundation \
-Wl,-framework,Security -Wl,-framework,VideoToolbox \ -Wl,-framework,Security -Wl,-framework,VideoToolbox \
-Wl,-framework,CoreMedia -Wl,-framework,CoreVideo \ -Wl,-framework,CoreMedia -Wl,-framework,CoreVideo \
...@@ -230,13 +235,12 @@ then ...@@ -230,13 +235,12 @@ then
-lavformat \ -lavformat \
-lavcodec \ -lavcodec \
-lavutil \ -lavutil \
-lfreetype \
-lvpx -lx264 -lbz2 -liconv -lz \ -lvpx -lx264 -lbz2 -liconv -lz \
"${CONTRIB_PATH}/${CONTRIB_PLATFORM}${CONTRIB_PLATFORM_EXTRA}/lib/libspeex.a" \ "${CONTRIB_PATH}/${CONTRIB_PLATFORM}${CONTRIB_PLATFORM_EXTRA}/lib/libspeex.a" \
"${CONTRIB_PATH}/${CONTRIB_PLATFORM}${CONTRIB_PLATFORM_EXTRA}/lib/libopus.a" \ "${CONTRIB_PATH}/${CONTRIB_PLATFORM}${CONTRIB_PLATFORM_EXTRA}/lib/libopus.a" \
-lfmt \ -lfmt \
-lwhisper \ -lwhisper \
"/usr/local/opt/libpng/lib/libpng.a" \
"/usr/local/opt/freetype/lib/libfreetype.a" \
${EXTRA_DEBUG_LIBRARIES} \ ${EXTRA_DEBUG_LIBRARIES} \
-o "${OUTPUT}" -o "${OUTPUT}"
...@@ -382,8 +386,12 @@ then ...@@ -382,8 +386,12 @@ then
fi fi
if [ ! ${DEBUG} ]; then if [ ! ${DEBUG} ]; then
if [ "${PLATFORM}" = "darwin" ]; then
python3 ./../SDK/jplManipulation.py --assemble --plugin=${PLUGIN_NAME} --distribution=${PLATFORM} --extraPath=${EXTRAPATH} --arch="${ARCH}"
else
python3 ./../SDK/jplManipulation.py --assemble --plugin=${PLUGIN_NAME} --distribution=${PLATFORM} --extraPath=${EXTRAPATH} python3 ./../SDK/jplManipulation.py --assemble --plugin=${PLUGIN_NAME} --distribution=${PLATFORM} --extraPath=${EXTRAPATH}
fi fi
fi
cd ${CONTRIB_PATH}/src/ffmpeg/ cd ${CONTRIB_PATH}/src/ffmpeg/
# ffmpeg build configuration files were changed during plugin build # ffmpeg build configuration files were changed during plugin build
......
...@@ -5,6 +5,10 @@ WHISPERCPP_GITURL := https://github.com/ggerganov/whisper.cpp.git ...@@ -5,6 +5,10 @@ WHISPERCPP_GITURL := https://github.com/ggerganov/whisper.cpp.git
WCONFIG := -DBUILD_SHARED_LIBS=OFF \ WCONFIG := -DBUILD_SHARED_LIBS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON
ifdef HAVE_MACOSX
WCONFIG += -DCMAKE_OSX_ARCHITECTURES=${ARCH}
endif
$(TARBALLS)/whispercpp-$(WHISPERCPP_HASH).tar.xz: $(TARBALLS)/whispercpp-$(WHISPERCPP_HASH).tar.xz:
$(call download_git,$(WHISPERCPP_GITURL),master,$(WHISPERCPP_HASH)) $(call download_git,$(WHISPERCPP_GITURL),master,$(WHISPERCPP_HASH))
......
...@@ -47,6 +47,8 @@ def parse(): ...@@ -47,6 +47,8 @@ def parse():
help='Runtime plugin CPU/GPU setting.') help='Runtime plugin CPU/GPU setting.')
parser.add_argument('--buildOptions', default='', type=str, parser.add_argument('--buildOptions', default='', type=str,
help="Type all build optionsto pass to package.json 'defines' property.\nThis argument consider that you're using cmake.") help="Type all build optionsto pass to package.json 'defines' property.\nThis argument consider that you're using cmake.")
parser.add_argument('--arch', type=str, default=None,
help='Specify the architecture (arm64 or x86_64).')
dist = choose_distribution() dist = choose_distribution()
...@@ -93,6 +95,10 @@ def validate_args(parsed_args): ...@@ -93,6 +95,10 @@ def validate_args(parsed_args):
if (parsed_args.buildOptions): if (parsed_args.buildOptions):
parsed_args.buildOptions = parsed_args.buildOptions.split(',') parsed_args.buildOptions = parsed_args.buildOptions.split(',')
valid_archs = ['arm64', 'x86_64', None]
if parsed_args.arch not in valid_archs:
sys.exit(f"Invalid architecture: {parsed_args.arch}. Must be one of {valid_archs}")
def choose_distribution(): def choose_distribution():
system = platform.system().lower() system = platform.system().lower()
...@@ -113,7 +119,7 @@ def choose_distribution(): ...@@ -113,7 +119,7 @@ def choose_distribution():
return 'Unknown' return 'Unknown'
def buildPlugin(pluginPath, processor, distribution, buildOptions=''): def buildPlugin(pluginPath, processor, distribution, arch, buildOptions=''):
if distribution == WIN32_DISTRIBUTION_NAME: if distribution == WIN32_DISTRIBUTION_NAME:
if (buildOptions): if (buildOptions):
with open(f"{pluginPath}/package.json") as f: with open(f"{pluginPath}/package.json") as f:
...@@ -150,6 +156,9 @@ def buildPlugin(pluginPath, processor, distribution, buildOptions=''): ...@@ -150,6 +156,9 @@ def buildPlugin(pluginPath, processor, distribution, buildOptions=''):
install_args.append(processor) install_args.append(processor)
install_args.append('-p') install_args.append('-p')
install_args.append(str(multiprocessing.cpu_count())) install_args.append(str(multiprocessing.cpu_count()))
if arch:
install_args.append('-a')
install_args.append(arch)
subprocess.check_call(['chmod', '+x', pluginPath + "/build.sh"]) subprocess.check_call(['chmod', '+x', pluginPath + "/build.sh"])
return subprocess.run([pluginPath + "/build.sh"] + return subprocess.run([pluginPath + "/build.sh"] +
...@@ -166,6 +175,7 @@ def main(): ...@@ -166,6 +175,7 @@ def main():
currentDir + "/" + plugin, currentDir + "/" + plugin,
args.processor[i], args.processor[i],
args.distribution, args.distribution,
args.arch,
args.buildOptions) args.buildOptions)
......
...@@ -32,5 +32,10 @@ ifdef HAVE_ANDROID ...@@ -32,5 +32,10 @@ ifdef HAVE_ANDROID
cd $< && $(HOSTVARS) ./configure $(FTCONFIG) cd $< && $(HOSTVARS) ./configure $(FTCONFIG)
cd $< && $(MAKE) cd $< && $(MAKE)
cd $< && $(MAKE) install cd $< && $(MAKE) install
else ifdef HAVE_MACOSX
cd $< && $(HOSTVARS) sh autogen.sh
cd $< && $(HOSTVARS) ./configure $(FTCONFIG)
cd $< && $(MAKE)
cd $< && $(MAKE) install
endif endif
touch $@ touch $@
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment