def collect_env(args): PROJ_DIR = look_for_proj_dir(os.path.abspath(__file__), 'pubspec.yaml') RUST_PROJ_DIR = os.path.join(PROJ_DIR, 'rust') RUST_ASSETS_DIR = os.path.join(RUST_PROJ_DIR, 'assets') TOML_FILE = os.path.join(RUST_PROJ_DIR, 'Cargo.toml') META = toml.loads(open(TOML_FILE).read()) NAME = META['package']['name'] VERSION = META['package']['version'] DESCRIPTION = META['package']['description'] DEBUG = not args.release RELEASE = args.release WORKSPACE = get_workspace_dir(RUST_PROJ_DIR) if WORKSPACE is not None: # cargo put outputs in workspace target directory TARGET_DIR = os.path.join(WORKSPACE, 'target') else: TARGET_DIR = os.path.join(RUST_PROJ_DIR, 'target') OUTPUT_DIR = os.path.join(TARGET_DIR, 'debug' if DEBUG else 'release') FLUTTER_CONFIG = META['package']['metadata']['flutter'] IDENTIFIER = FLUTTER_CONFIG[ 'identifier'] if 'identifier' in FLUTTER_CONFIG else 'one.juju.flutter-app' FLUTTER_LIB_VER = META['package']['metadata']['flutter']['version'] FLUTTER_ASSETS = os.path.join(os.path.dirname(RUST_PROJ_DIR), 'build', 'flutter_assets') return locals()
def get_config(): try: proj_dir = look_for_proj_dir(os.path.abspath(__file__), 'pubspec.yaml') name = input('What\'s the name of the project?\n') lib_name = name.replace('-', '_') tmplfile_path = os.path.join(proj_dir, '.tmplfiles') try: with open(tmplfile_path) as f: tmplfiles = [] for line in f.readlines(): line = line.strip() if os.path.isdir(os.path.join(proj_dir, line)): line = os.path.join(line, '*') tmplfiles.append(line) except: tmplfiles = [] return { "name": name, "lib_name": lib_name, # underlined version of name "proj_dir": proj_dir, "tmplfiles": tmplfiles, "tmplfile_path": tmplfile_path } except KeyboardInterrupt: return None
def get_config(): try: proj_dir = look_for_proj_dir(os.path.abspath(__file__), 'pubspec.yaml') name = input('What\'s the name of the project?\n') lib_name = name.replace('-', '_') try: with open(os.path.join(proj_dir, '.initignore')) as f: ignore_list = [] for line in f.readlines(): ignore = line.strip() if os.path.isdir(os.path.join(proj_dir, ignore)): ignore = os.path.join(ignore, '*') ignore_list.append(ignore) except: ignore_list = [] return { "name": name, "lib_name": lib_name, # underlined version of name "proj_dir": proj_dir, "ignore_list": ignore_list } except KeyboardInterrupt: return None
def run(): proj_dir = look_for_proj_dir(os.path.abspath(__file__), 'pubspec.yaml') tmplfile_path = os.path.join(proj_dir, '.tmplfiles') first_run = os.path.isfile(tmplfile_path) if first_run: print('🔮 Creating files') tmpl_proj(proj_dir) # remove tmplfile, useless now os.remove(tmplfile_path) print('🧩 Installing build dependencies') install_py_deps(proj_dir) print('🔮 Downloading flutter-engine') download_flutter_engine() print('🍭 Done! Happy coding.')
def collect_env(args): PROJ_DIR = look_for_proj_dir(os.path.abspath(__file__), 'pubspec.yaml') RUST_PROJ_DIR = os.path.join(PROJ_DIR, 'rust') RUST_ASSETS_DIR = os.path.join(RUST_PROJ_DIR, 'assets') TOML_FILE = os.path.join(RUST_PROJ_DIR, 'Cargo.toml') META = toml.loads(open(TOML_FILE).read()) CONFIG = toml.loads(open(os.path.join(RUST_PROJ_DIR, 'build.toml')).read()) NAME = META['package']['name'] VERSION = META['package']['version'] DESCRIPTION = META['package']['description'] DEBUG = not args.release RELEASE = args.release TARGET_DIR = os.path.join(RUST_PROJ_DIR, 'target') WORKSPACE = get_workspace_dir(RUST_PROJ_DIR) WORKSPACE_TARGET_DIR = os.path.join(WORKSPACE, 'target') if WORKSPACE else None OUTPUT_DIR = os.path.join(TARGET_DIR, 'debug' if DEBUG else 'release') FLUTTER_LIB_VER = get_flutter_version() FLUTTER_ASSETS = os.path.join(os.path.dirname(RUST_PROJ_DIR), 'build', 'flutter_assets') return locals()
import re import subprocess import signal import sys import threading from lib import look_for_proj_dir def signal_handler(signal, frame): sys.exit(0) signal.signal(signal.SIGINT, signal_handler) FLUTTER = 'flutter.bat' if sys.platform == 'win32' else 'flutter' PROJ_DIR = look_for_proj_dir(os.path.abspath(__file__), 'pubspec.yaml') RUST_PROJ_DIR = os.path.join(PROJ_DIR, 'rust') class CargoThread(threading.Thread): def __init__(self): super().__init__() self.observatory_port = '' self.observatory_open = threading.Event() def run(self): self.proc = subprocess.Popen(['cargo', 'run'], stdout=subprocess.PIPE, cwd=RUST_PROJ_DIR) while True: