• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2021 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15import("//build_overrides/pigweed.gni")
16
17import("$dir_pw_build/exec.gni")
18import("$dir_pw_malloc/backend.gni")
19
20# Executable wrapper that includes some baremetal startup code.
21template("mimxrt595_executable") {
22  group(target_name) {
23    deps = [
24      ":${target_name}__binary",
25      ":${target_name}__elf",
26    ]
27  }
28
29  # .elf binary created by the standard toolchain.
30  _base_target_name = target_name
31  executable("${target_name}__elf") {
32    output_name = "${_base_target_name}"
33    forward_variables_from(invoker, "*")
34    if (!defined(deps)) {
35      deps = []
36    }
37    deps += [ "//targets/mimxrt595_evk:boot" ]
38    if (pw_malloc_BACKEND != "") {
39      if (!defined(configs)) {
40        configs = []
41      }
42      configs += [ "$dir_pw_malloc:pw_malloc_wrapper_config" ]
43    }
44  }
45
46  # .bin binary created by extracting from the toolchain output.
47  pw_exec("${target_name}__binary") {
48    if (defined(invoker.output_dir)) {
49      _output_dir = invoker.output_dir
50    } else {
51      _output_dir = target_out_dir
52    }
53
54    outputs = [ "${_output_dir}/${_base_target_name}.bin" ]
55    deps = [ ":${_base_target_name}__elf" ]
56
57    program = "arm-none-eabi-objcopy"
58    args = [
59      "-Obinary",
60      "<TARGET_FILE(:${_base_target_name}__elf)>",
61      rebase_path(outputs[0], root_build_dir),
62    ]
63  }
64}
65