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

add script to build dependencies

Now it only builds dependencies for macOS.

Change-Id: I0b79a52da39f564d4e485697f5fb1d81a88b8c68
parent 4a9a69aa
Branches
No related tags found
No related merge requests found
#!/usr/bin/env python3
#
# Copyright (C) 2023 Savoir-faire Linux Inc.
#
# Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Creates packaging targets for a distribution and architecture.
# This helps reduce the length of the top Makefile.
#
# This script must unify the Plugins build for
# every project and Operational System
import subprocess
import os
import platform
import argparse
def exec_cmd(command):
process = subprocess.Popen(command, shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = process.communicate()
if process.returncode != 0:
print(f"Error executing command: {err.decode().strip()}")
else:
print(out.decode().strip())
def get_mac_host_parameter(arch):
if not arch:
arch = platform.machine()
system = platform.uname().release
return f"{arch}-apple-darwin{system}"
def run_for_mac(arch=None, projects=None, with_onnx=False):
host_param = get_mac_host_parameter(arch)
if "WaterMark" in projects or "WhisperTranscript" in projects:
os.environ["WITH_FREETYPE"] = '1'
opencv_flag = "--enable-opencv" if projects == "GreenScreen" else "--disable-opencv"
onnx_flag = "--enable-onnx" if with_onnx else "--disable-onnx"
cmd = f"""
cd ../daemon/contrib
mkdir -p native
cd native
../bootstrap --host={host_param} --enable-minizip --enable-ffmpeg --enable-opus --enable-speex \
{onnx_flag} --disable-argon2 --disable-asio --enable-fmt --disable-gcrypt \
--disable-gmp --disable-gnutls --disable-gpg-error --disable-gsm \
--disable-http_parser --disable-iconv --disable-jack --disable-jsoncpp \
--disable-libarchive --disable-libressl --disable-msgpack --disable-natpmp \
--disable-nettle {opencv_flag} --enable-opendht --disable-pjproject \
--disable-portaudio --disable-restinio --disable-secp256k1 --disable-speexdsp \
--disable-upnp --disable-uuid --disable-yaml-cpp --disable-zlib --disable-dhtnet \
--disable-webrtc-audio-processing
make list
export PATH=/usr/local/bin:$PATH
export BATCH_MODE=1
make -j$(sysctl -n hw.ncpu)
"""
exec_cmd(cmd)
def copy_contrib():
cmd = """
cp -r freetype ../daemon/contrib/src/
cp -r mp3lame ../daemon/contrib/src/
cp -r rav1e ../daemon/contrib/src/
"""
exec_cmd(cmd)
def parse_arguments():
parser = argparse.ArgumentParser(description="Script to build plugins contributions.")
parser.add_argument('--arch', type=str, choices=['arm64', 'x86_64'],
help="Specify the architecture (arm64 or x86_64)")
parser.add_argument('--projects', type=str,
help='Select plugins to build dependencies for.')
parser.add_argument('--with-onnx', action='store_true',
help="Enable ONNX if set.")
return parser.parse_args()
if __name__ == "__main__":
os_system = platform.system()
args = parse_arguments()
if os_system == "Darwin":
copy_contrib()
run_for_mac(args.arch, args.projects, args.with_onnx)
else:
print("Unsupported operating system.")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment