[FL-2832] fbt: more fixes & improvements (#1854)
* github: bundling debug folder with scripts; docs: fixes & updates; fbt: added FAP_EXAMPLES variable to enable building example apps. Disabled by default. fbt: added TERM to list of proxied environment variables * fbt: better help output; disabled implicit_deps_unchanged; added color to import validator reports * fbt: moved debug configuration to separate tool * fbt: proper dependency tracker for SDK source file; renamed linker script for external apps * fbt: fixed debug elf path * fbt: packaging sdk archive * scripts: fixed sconsdist.py * fbt: reworked sdk packing; docs: updates * docs: info on cli target; linter fixes * fbt: moved main code to scripts folder * scripts: packing update into .tgz * fbt, scripts: reworked copro_dist to build .tgz * scripts: fixed naming for archived updater package * Scripts: fix ぐるぐる回る Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from flipper.app import App
|
||||
from os.path import join, exists
|
||||
from os import makedirs
|
||||
from os.path import join, exists, relpath
|
||||
from os import makedirs, walk
|
||||
from update import Main as UpdateMain
|
||||
import shutil
|
||||
import zipfile
|
||||
import tarfile
|
||||
|
||||
|
||||
class ProjectDir:
|
||||
@@ -17,6 +19,8 @@ class ProjectDir:
|
||||
|
||||
|
||||
class Main(App):
|
||||
DIST_FILE_PREFIX = "flipper-z-"
|
||||
|
||||
def init(self):
|
||||
self.subparsers = self.parser.add_subparsers(help="sub-command help")
|
||||
|
||||
@@ -45,9 +49,13 @@ class Main(App):
|
||||
def get_project_filename(self, project, filetype):
|
||||
# Temporary fix
|
||||
project_name = project.project
|
||||
if project_name == "firmware" and filetype != "elf":
|
||||
project_name = "full"
|
||||
return f"flipper-z-{self.target}-{project_name}-{self.args.suffix}.{filetype}"
|
||||
if project_name == "firmware":
|
||||
if filetype == "zip":
|
||||
project_name = "sdk"
|
||||
elif filetype != "elf":
|
||||
project_name = "full"
|
||||
|
||||
return f"{self.DIST_FILE_PREFIX}{self.target}-{project_name}-{self.args.suffix}.{filetype}"
|
||||
|
||||
def get_dist_filepath(self, filename):
|
||||
return join(self.output_dir_path, filename)
|
||||
@@ -56,10 +64,28 @@ class Main(App):
|
||||
obj_directory = join("build", project.dir)
|
||||
|
||||
for filetype in ("elf", "bin", "dfu", "json"):
|
||||
shutil.copyfile(
|
||||
join(obj_directory, f"{project.project}.{filetype}"),
|
||||
self.get_dist_filepath(self.get_project_filename(project, filetype)),
|
||||
)
|
||||
if exists(src_file := join(obj_directory, f"{project.project}.{filetype}")):
|
||||
shutil.copyfile(
|
||||
src_file,
|
||||
self.get_dist_filepath(
|
||||
self.get_project_filename(project, filetype)
|
||||
),
|
||||
)
|
||||
if exists(sdk_folder := join(obj_directory, "sdk")):
|
||||
with zipfile.ZipFile(
|
||||
self.get_dist_filepath(self.get_project_filename(project, "zip")),
|
||||
"w",
|
||||
zipfile.ZIP_DEFLATED,
|
||||
) as zf:
|
||||
for root, dirs, files in walk(sdk_folder):
|
||||
for file in files:
|
||||
zf.write(
|
||||
join(root, file),
|
||||
relpath(
|
||||
join(root, file),
|
||||
sdk_folder,
|
||||
),
|
||||
)
|
||||
|
||||
def copy(self):
|
||||
self.projects = dict(
|
||||
@@ -103,9 +129,8 @@ class Main(App):
|
||||
)
|
||||
|
||||
if self.args.version:
|
||||
bundle_dir = join(
|
||||
self.output_dir_path, f"{self.target}-update-{self.args.suffix}"
|
||||
)
|
||||
bundle_dir_name = f"{self.target}-update-{self.args.suffix}"
|
||||
bundle_dir = join(self.output_dir_path, bundle_dir_name)
|
||||
bundle_args = [
|
||||
"generate",
|
||||
"-d",
|
||||
@@ -131,10 +156,24 @@ class Main(App):
|
||||
)
|
||||
)
|
||||
bundle_args.extend(self.other_args)
|
||||
self.logger.info(
|
||||
f"Use this directory to self-update your Flipper:\n\t{bundle_dir}"
|
||||
)
|
||||
return UpdateMain(no_exit=True)(bundle_args)
|
||||
|
||||
if (bundle_result := UpdateMain(no_exit=True)(bundle_args)) == 0:
|
||||
self.logger.info(
|
||||
f"Use this directory to self-update your Flipper:\n\t{bundle_dir}"
|
||||
)
|
||||
|
||||
# Create tgz archive
|
||||
with tarfile.open(
|
||||
join(
|
||||
self.output_dir_path,
|
||||
f"{self.DIST_FILE_PREFIX}{bundle_dir_name}.tgz",
|
||||
),
|
||||
"w:gz",
|
||||
compresslevel=9,
|
||||
) as tar:
|
||||
tar.add(bundle_dir, arcname=bundle_dir_name)
|
||||
|
||||
return bundle_result
|
||||
|
||||
return 0
|
||||
|
||||
|
Reference in New Issue
Block a user