from SCons.Errors import StopError Import("core_env") update_env = core_env.Clone( toolpath=[core_env["FBT_SCRIPT_DIR"].Dir("fbt_tools")], tools=["python3"], ) print("Updating SDK...") ufbt_state = update_env["UFBT_STATE"] update_args = [ "--ufbt-dir", f'"{update_env["UFBT_STATE_DIR"]}"', ] if branch_name := GetOption("sdk_branch"): update_args.extend(["--branch", branch_name]) elif channel_name := GetOption("sdk_channel"): update_args.extend(["--channel", channel_name]) elif branch_name := ufbt_state.get("branch", None): update_args.extend(["--branch", branch_name]) elif channel_name := ufbt_state.get("channel", None): update_args.extend(["--channel", channel_name]) else: raise StopError("No branch or channel specified for SDK update") if hw_target := GetOption("sdk_target"): update_args.extend(["--hw-target", hw_target]) else: update_args.extend(["--hw-target", ufbt_state["hw_target"]]) update_env.Replace(UPDATE_ARGS=update_args) result = update_env.Execute( update_env.subst('$PYTHON3 "$UFBT_BOOTSTRAP_SCRIPT" $UPDATE_ARGS'), ) Exit(result)