Skip to content

Commit

Permalink
WIP: second backport stage
Browse files Browse the repository at this point in the history
This _might_ work, but I've not implemented all of the changes yet
  • Loading branch information
pkoscik committed Nov 23, 2023
1 parent d25ec91 commit 26e5bec
Showing 1 changed file with 16 additions and 23 deletions.
39 changes: 16 additions & 23 deletions scripts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,27 +393,19 @@ def try_build(board_name, board_path, sample_name, sample_path):
shutil.copyfile(path, f"build/{project_sample_name}/{project_sample_name}-config")


def get_full_name(yaml_filename):
if os.path.exists(yaml_filename):
with open(yaml_filename) as f:
board_data = yaml.load(f, Loader=yaml.FullLoader)
full_board_name = board_data['name']
if len(full_board_name) > 50:
full_board_name = re.sub(r'\(.*\)', '', full_board_name)
else:
full_board_name = ''
def get_full_name(yaml_data):
full_board_name = yaml_data['name']
if len(full_board_name) > 50:
full_board_name = re.sub(r'\(.*\)', '', full_board_name)
return full_board_name

def get_board_yaml_path(board_dir, board_name):
yamlpath = f'{board_dir}/{board_name}.yaml'

def get_board_yaml_path(board_name, board_path):
board_yaml = f'{config.project_path}/{board_path}/{board_name}.yaml'

# this hack is needed for pinetime_devkit0
if not os.path.exists(board_yaml):
board_yaml = f'{config.project_path}/{board_path}/{board_name.replace("_", "-")}.yaml'

return board_yaml
if not os.path.exists(yamlpath):
raise Exception(f"Could not find a YAML file for the board '{board_name}': {yamlpath}")

return yamlpath

def get_sample_yaml_path(sample_path):
return f'{config.project_path}/{sample_path}/sample.yaml'
Expand All @@ -424,6 +416,7 @@ def main(board_dir: str, board_name: str, sample_name: str) -> None:
Main function to build a Zephyr sample for a specific board and create relevant artifacts.
Parameters:
# XXX: todo!
board_name (str): The name of the board to build the Zephyr sample for
sample_name (str): The name of the sample being built
"""
Expand Down Expand Up @@ -458,22 +451,22 @@ def main(board_dir: str, board_name: str, sample_name: str) -> None:
os.makedirs(f"build/{project_sample_name}", exist_ok=True)

# Save logs
shutil.copyfile(run.log_file, f"build/{project_sample_name}/{project_sample_name}-zephyr.log")
shutil.copyfile(run.log_file, f"build/{project_sample_name}/{sample_name}-zephyr.log")

# Save original DTS
if run.dts_modified:
shutil.copyfile(run.dts_original, f"build/{project_sample_name}/{project_sample_name}.dts.orig")
shutil.copyfile(run.dts_original, f"build/{project_sample_name}/{sample_name}.dts.orig")

for key, path in artifacts.items():
if re.search("spdx.+", key):
filename = os.path.basename(path)
shutil.copyfile(path, f"build/{project_sample_name}/{project_sample_name}-{filename}")
shutil.copyfile(path, f"build/{project_sample_name}/{sample_name}-{filename}")
elif key == "elf":
shutil.copyfile(path, f"build/{project_sample_name}/{board_name}-zephyr-{sample_name}.elf")
shutil.copyfile(path, f"build/{project_sample_name}/{sample_name}.elf")
elif key == "dts":
shutil.copyfile(path, f"build/{project_sample_name}/{project_sample_name}.dts")
shutil.copyfile(path, f"build/{project_sample_name}/{sample_name}.dts")
elif key == "config":
shutil.copyfile(path, f"build/{project_sample_name}/{project_sample_name}-config")
shutil.copyfile(path, f"build/{project_sample_name}/{sample_name}-config")

format_args = {
"board_name": board_name,
Expand Down

0 comments on commit 26e5bec

Please sign in to comment.