blob: 2b8e9df408ec10ac6d163305664a31a8f112cfef [file]
#!/usr/bin/env python3
# Copyright 2026 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
import os
import sys
def main():
exec_dir = os.path.dirname(sys.argv[0])
runfiles_dir = os.path.join(exec_dir, "{app_name}.runfiles")
if "RUNFILES_DIR" in os.environ:
runfiles_dir = os.environ["RUNFILES_DIR"]
yaml_path = "{runners_yaml}"
binary_path = "{binary}"
flash_bin_path = "{flash_bin}"
abs_yaml = os.path.join(runfiles_dir, yaml_path)
abs_binary = os.path.join(runfiles_dir, binary_path)
abs_flash_bin = os.path.join(runfiles_dir, flash_bin_path)
if abs_flash_bin and os.path.exists(abs_flash_bin):
os.execv(abs_flash_bin, [abs_flash_bin, "--yaml", abs_yaml, "--binary", abs_binary] + sys.argv[1:])
else:
print(f"Failed to locate flashing tool in runfiles: {abs_flash_bin}", file=sys.stderr)
sys.exit(1)
if __name__ == "__main__":
main()