|
|
@ -1,11 +1,24 @@
|
|
|
|
|
|
|
|
#!/bin/env python3
|
|
|
|
import shutil as shut
|
|
|
|
import shutil as shut
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tauri_cli_version = '1.0.0-rc.5'
|
|
|
|
build_output = 'out'
|
|
|
|
build_output = 'out'
|
|
|
|
|
|
|
|
verbose = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
windows = os.name == 'nt'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def exec(cmd: str, dir: str = None) -> str:
|
|
|
|
|
|
|
|
print('Running: {}'.format(cmd))
|
|
|
|
|
|
|
|
child = subprocess.run(cmd, shell=True, cwd=dir)
|
|
|
|
|
|
|
|
child.check_returncode()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_exec(name: str):
|
|
|
|
def check_exec(name: str):
|
|
|
|
print('Checking {}...'.format(name))
|
|
|
|
print('Checking {}...'.format(name))
|
|
|
|
|
|
|
|
|
|
|
|
if shut.which(name) is None:
|
|
|
|
if shut.which(name) is None:
|
|
|
|
raise Exception('{} not found'.format(name))
|
|
|
|
raise Exception('{} not found'.format(name))
|
|
|
|
exec(name + ' --version')
|
|
|
|
exec(name + ' --version')
|
|
|
@ -13,63 +26,68 @@ def check_exec(name: str):
|
|
|
|
|
|
|
|
|
|
|
|
def check_yarn():
|
|
|
|
def check_yarn():
|
|
|
|
print('Checking yarn...')
|
|
|
|
print('Checking yarn...')
|
|
|
|
|
|
|
|
|
|
|
|
if shut.which('yarn') is None:
|
|
|
|
if shut.which('yarn') is None:
|
|
|
|
print('installing yarn...')
|
|
|
|
print('installing yarn...')
|
|
|
|
exec('npm install -g yarn')
|
|
|
|
npm('install -g yarn')
|
|
|
|
check_exec('yarn')
|
|
|
|
check_exec('yarn')
|
|
|
|
exec('yarn --version')
|
|
|
|
exec('yarn --version')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_ng():
|
|
|
|
def check_ng():
|
|
|
|
print('Checking ng...')
|
|
|
|
print('Checking ng...')
|
|
|
|
|
|
|
|
|
|
|
|
if shut.which('ng') is None:
|
|
|
|
if shut.which('ng') is None:
|
|
|
|
print('installing ng...')
|
|
|
|
print('installing ng...')
|
|
|
|
exec('npm install -g @angular/cli')
|
|
|
|
npm('install -g @angular/cli')
|
|
|
|
check_exec('ng')
|
|
|
|
check_exec('ng')
|
|
|
|
exec('ng --version')
|
|
|
|
exec('ng --version')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def exec(cmd: str, dir: str = None) -> str:
|
|
|
|
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
child = subprocess.run(cmd, shell=True, cwd=dir)
|
|
|
|
|
|
|
|
child.check_returncode()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def store_artifact(path: str):
|
|
|
|
def store_artifact(path: str):
|
|
|
|
print('Storing {}'.format(path))
|
|
|
|
print('Storing {}'.format(path))
|
|
|
|
if os.path.isdir(path):
|
|
|
|
if os.path.isdir(path):
|
|
|
|
shut.copytree(path, os.path.join(build_output, os.path.basename(path)), dirs_exist_ok=True)
|
|
|
|
shut.copytree(path, os.path.join(
|
|
|
|
|
|
|
|
build_output, os.path.basename(path)), dirs_exist_ok=True)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
shut.copy(path, build_output)
|
|
|
|
shut.copy(path, build_output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cargo(cmd: str, dir: str = None) -> str:
|
|
|
|
def cargo(cmd: str, dir: str = None):
|
|
|
|
print('cargo {}'.format(cmd))
|
|
|
|
if verbose:
|
|
|
|
exec('cargo {}'.format(cmd), dir)
|
|
|
|
exec('cargo {} --verbose'.format(cmd), dir)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
exec('cargo {}'.format(cmd), dir)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def npm(cmd: str, dir: str = None):
|
|
|
|
|
|
|
|
exec('npm {}'.format(cmd), dir)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def yarn(cmd: str, dir: str = None):
|
|
|
|
def yarn(cmd: str, dir: str = None):
|
|
|
|
print('yarn {}'.format(cmd))
|
|
|
|
|
|
|
|
exec('yarn {}'.format(cmd), dir)
|
|
|
|
exec('yarn {}'.format(cmd), dir)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def build_daemon():
|
|
|
|
def build_daemon():
|
|
|
|
|
|
|
|
'''Builds daemon'''
|
|
|
|
cargo('fetch', 'mediarepo-daemon')
|
|
|
|
cargo('fetch', 'mediarepo-daemon')
|
|
|
|
cargo('build --release --frozen --verbose', 'mediarepo-daemon')
|
|
|
|
cargo('build --release --frozen', 'mediarepo-daemon')
|
|
|
|
|
|
|
|
|
|
|
|
if os.name == 'nt':
|
|
|
|
if windows:
|
|
|
|
store_artifact('mediarepo-daemon/target/release/mediarepo-daemon.exe')
|
|
|
|
store_artifact('mediarepo-daemon/target/release/mediarepo-daemon.exe')
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
store_artifact('mediarepo-daemon/target/release/mediarepo-daemon')
|
|
|
|
store_artifact('mediarepo-daemon/target/release/mediarepo-daemon')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def build_ui():
|
|
|
|
def build_ui():
|
|
|
|
cargo('install tauri-cli --version ^1.0.0-rc.4')
|
|
|
|
'''Builds UI'''
|
|
|
|
|
|
|
|
cargo('install tauri-cli --version ^{}'.format(tauri_cli_version))
|
|
|
|
yarn('install', 'mediarepo-ui')
|
|
|
|
yarn('install', 'mediarepo-ui')
|
|
|
|
cargo('tauri build --verbose', 'mediarepo-ui')
|
|
|
|
cargo('tauri build', 'mediarepo-ui')
|
|
|
|
|
|
|
|
|
|
|
|
if os.name == 'nt':
|
|
|
|
if windows:
|
|
|
|
store_artifact('mediarepo-ui/src-tauri/target/release/mediarepo-ui.exe')
|
|
|
|
store_artifact(
|
|
|
|
|
|
|
|
'mediarepo-ui/src-tauri/target/release/mediarepo-ui.exe')
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
store_artifact('mediarepo-ui/src-tauri/target/release/mediarepo-ui')
|
|
|
|
store_artifact('mediarepo-ui/src-tauri/target/release/mediarepo-ui')
|
|
|
|
|
|
|
|
|
|
|
@ -77,11 +95,13 @@ def build_ui():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_daemon():
|
|
|
|
def check_daemon():
|
|
|
|
|
|
|
|
'''Checks dependencies for daemon'''
|
|
|
|
check_exec('clang')
|
|
|
|
check_exec('clang')
|
|
|
|
check_exec('cargo')
|
|
|
|
check_exec('cargo')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_ui():
|
|
|
|
def check_ui():
|
|
|
|
|
|
|
|
'''Checks dependencies for UI'''
|
|
|
|
check_exec('clang')
|
|
|
|
check_exec('clang')
|
|
|
|
check_exec('cargo')
|
|
|
|
check_exec('cargo')
|
|
|
|
check_exec('wget')
|
|
|
|
check_exec('wget')
|
|
|
@ -92,24 +112,29 @@ def check_ui():
|
|
|
|
check_yarn()
|
|
|
|
check_yarn()
|
|
|
|
check_ng()
|
|
|
|
check_ng()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check():
|
|
|
|
def check():
|
|
|
|
|
|
|
|
'''Checks dependencies'''
|
|
|
|
check_daemon()
|
|
|
|
check_daemon()
|
|
|
|
check_ui()
|
|
|
|
check_ui()
|
|
|
|
print('All checks passed')
|
|
|
|
print('All checks passed')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_output_dir():
|
|
|
|
def create_output_dir():
|
|
|
|
|
|
|
|
'''Creates build output directory'''
|
|
|
|
if not os.path.exists(build_output):
|
|
|
|
if not os.path.exists(build_output):
|
|
|
|
os.mkdir(build_output)
|
|
|
|
os.mkdir(build_output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def clean():
|
|
|
|
def clean():
|
|
|
|
|
|
|
|
'''Removes build output'''
|
|
|
|
if os.path.exists(build_output):
|
|
|
|
if os.path.exists(build_output):
|
|
|
|
shut.rmtree(build_output)
|
|
|
|
shut.rmtree(build_output)
|
|
|
|
print('Cleaned')
|
|
|
|
print('Cleaned')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def build(daemon=True, ui=True):
|
|
|
|
def build(daemon=True, ui=True):
|
|
|
|
|
|
|
|
'''Builds both daemon and UI'''
|
|
|
|
clean()
|
|
|
|
clean()
|
|
|
|
create_output_dir()
|
|
|
|
create_output_dir()
|
|
|
|
|
|
|
|
|
|
|
@ -133,8 +158,13 @@ def parse_args():
|
|
|
|
subparsers.add_parser('check')
|
|
|
|
subparsers.add_parser('check')
|
|
|
|
|
|
|
|
|
|
|
|
build_parser = subparsers.add_parser('build')
|
|
|
|
build_parser = subparsers.add_parser('build')
|
|
|
|
build_parser.add_argument('--daemon', action='store_true', help='Build daemon')
|
|
|
|
build_parser.add_argument(
|
|
|
|
|
|
|
|
'--daemon', action='store_true', help='Build daemon')
|
|
|
|
build_parser.add_argument('--ui', action='store_true', help='Build UI')
|
|
|
|
build_parser.add_argument('--ui', action='store_true', help='Build UI')
|
|
|
|
|
|
|
|
build_parser.add_argument(
|
|
|
|
|
|
|
|
'--verbose', action='store_true', help='Verbose build')
|
|
|
|
|
|
|
|
build_parser.add_argument(
|
|
|
|
|
|
|
|
'--output', action='store', help='Build output directory')
|
|
|
|
|
|
|
|
|
|
|
|
subparsers.add_parser('clean')
|
|
|
|
subparsers.add_parser('clean')
|
|
|
|
args = parser.parse_args()
|
|
|
|
args = parser.parse_args()
|
|
|
@ -143,9 +173,14 @@ def parse_args():
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|
opts = parse_args()
|
|
|
|
opts = parse_args()
|
|
|
|
print(opts)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if opts.command == 'build':
|
|
|
|
if opts.command == 'build':
|
|
|
|
|
|
|
|
global build_output
|
|
|
|
|
|
|
|
build_output = opts.output if opts.output else build_output
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
global verbose
|
|
|
|
|
|
|
|
verbose = opts.verbose
|
|
|
|
|
|
|
|
|
|
|
|
if opts.daemon:
|
|
|
|
if opts.daemon:
|
|
|
|
build(True, False)
|
|
|
|
build(True, False)
|
|
|
|
elif opts.ui:
|
|
|
|
elif opts.ui:
|
|
|
|