Fix buildscript

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/16/head
trivernis 3 years ago
parent 6f95538834
commit 76a0b13e5b
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -40,7 +40,7 @@ checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0"
[[package]] [[package]]
name = "app" name = "app"
version = "1.0.0-rc.1" version = "1.0.0-rc.2"
dependencies = [ dependencies = [
"mediarepo-api", "mediarepo-api",
"serde", "serde",

@ -2,15 +2,15 @@
import shutil as shut import shutil as shut
import os import os
from lib import * from lib import *
import json
from clean import clean from clean import clean
from check import check_daemon_depends, check_ui_depends from check import check, check_daemon_tooling, check_ui_tooling
from typing import List
build_output = 'out' build_output = 'out'
verbose = False verbose = False
ffmpeg = False ffmpeg = False
install_deps = False install_tooling = False
windows = os.name == 'nt' windows = os.name == 'nt'
@ -18,18 +18,18 @@ windows = os.name == 'nt'
def main(): def main():
opts = parse_args() opts = parse_args()
global install_deps global install_tooling
global build_output global build_output
global verbose global verbose
global ffmpeg global ffmpeg
global install_deps global install_tooling
build_output = opts.output if opts.output else build_output build_output = opts.output if opts.output else build_output
verbose = opts.verbose verbose = opts.verbose
ffmpeg = opts.ffmpeg ffmpeg = opts.ffmpeg
install_deps = opts.install_deps install_tooling = opts.install_tooling
build(opts.component) build(opts.component, opts.bundles)
def parse_args(): def parse_args():
@ -39,30 +39,34 @@ def parse_args():
'component', type=str, nargs='?', default='all', choices=['daemon', 'ui', 'all']) 'component', type=str, nargs='?', default='all', choices=['daemon', 'ui', 'all'])
parser.add_argument( parser.add_argument(
'--verbose', action='store_true', help='Verbose build') '--verbose', action='store_true', help='Verbose build')
parser.add_argument('--install-deps', action='store_true',
help='Install dependencies')
parser.add_argument( parser.add_argument(
'--output', action='store', help='Build output directory') '--output', action='store', help='Build output directory')
parser.add_argument( parser.add_argument(
'--ffmpeg', action='store_true', help='Build with ffmpeg') '--ffmpeg', action='store_true', help='Build with ffmpeg')
parser.add_argument('--install-tooling',
action='store_true', help='Install tooling')
parser.add_argument('--bundles', nargs='+',
help='UI bundles to build')
args = parser.parse_args() args = parser.parse_args()
return args return args
def build(component: str): def build(component: str, bundles: List[str] = None):
'''Builds the selected component''' '''Builds the selected component'''
clean() clean()
create_output_dir() create_output_dir()
if component == 'daemon' or component == 'all': if component == 'all':
check_daemon_depends() check(install_tooling)
build_daemon() build_daemon()
elif component == 'ui' or component == 'all': build_ui(bundles)
check_ui_depends(install_deps) elif component == 'daemon':
build_ui() check_daemon_tooling(install_tooling)
else: build_daemon()
raise Exception('Unknown component: {}'.format(component)) elif component == 'ui':
check_ui_tooling()
build_ui(bundles)
print('Build complete') print('Build complete')
@ -82,9 +86,13 @@ def build_daemon():
store_artifact('mediarepo-daemon/target/release/mediarepo-daemon') store_artifact('mediarepo-daemon/target/release/mediarepo-daemon')
def build_ui(): def build_ui(bundles: List[str] = None):
'''Builds UI''' '''Builds UI'''
yarn('install', 'mediarepo-ui') yarn('install', 'mediarepo-ui')
if bundles is not None:
cargo('tauri build --bundles ' + ' '.join(bundles), 'mediarepo-ui')
else:
cargo('tauri build ', 'mediarepo-ui') cargo('tauri build ', 'mediarepo-ui')
if windows: if windows:

@ -10,31 +10,31 @@ windows = os.name == 'nt'
def main(): def main():
opts = parse_args() opts = parse_args()
check(opts.install_deps) check(opts.install)
def parse_args(): def parse_args():
'''Parses command line arguments''' '''Parses command line arguments'''
args = argparse.ArgumentParser(description='Build mediarepo') args = argparse.ArgumentParser(description='Build mediarepo')
args.add_argument('--install-deps', action='store_true', args.add_argument('--install', action='store_true',
help='Install dependencies that can be installed automatically') help='Install tools that can be installed automatically')
return args.parse_args() return args.parse_args()
def check(install_deps: bool = False): def check(install_tooling: bool = False):
'''Checks dependencies''' '''Checks dependencies'''
check_daemon_depends() check_daemon_tooling()
check_ui_depends(install_deps) check_ui_tooling(install_tooling)
print('All checks passed') print('All checks passed')
def check_daemon_depends(): def check_daemon_tooling():
'''Checks dependencies for daemon''' '''Checks dependencies for daemon'''
check_exec('clang') check_exec('clang')
check_exec('cargo') check_exec('cargo')
def check_ui_depends(install_deps: bool = False): def check_ui_tooling(install_tooling: bool = False):
'''Checks dependencies for UI''' '''Checks dependencies for UI'''
if not windows: if not windows:
@ -46,10 +46,10 @@ def check_ui_depends(install_deps: bool = False):
check_exec('cargo') check_exec('cargo')
check_exec('node') check_exec('node')
check_exec('npm') check_exec('npm')
check_yarn(install_deps) check_yarn(install_tooling)
check_ng(install_deps) check_ng(install_tooling)
if install_deps: if install_tooling:
install_tauri_cli(tauri_cli_version) install_tauri_cli(tauri_cli_version)

@ -21,7 +21,7 @@ def check_yarn(install: bool = False):
if the install flag is set''' if the install flag is set'''
if not check_exec('yarn'): if not check_exec('yarn'):
if install: if install:
npm('install yarn') npm('install -g yarn')
else: else:
raise Exception('yarn not found') raise Exception('yarn not found')

Loading…
Cancel
Save