kopia lustrzana https://github.com/espressif/esp-idf
ldgen: create python script to find linker script includes
rodzic
23a03cf6ad
commit
022a1da4e9
|
@ -66,6 +66,7 @@ tools/ci/multirun_with_pyenv.sh
|
|||
components/espcoredump/test/test_espcoredump.py
|
||||
components/espcoredump/test/test_espcoredump.sh
|
||||
tools/ldgen/ldgen.py
|
||||
tools/ldgen/lddeps.py
|
||||
tools/ldgen/test/test_fragments.py
|
||||
tools/ldgen/test/test_generation.py
|
||||
examples/build_system/cmake/idf_as_lib/build.sh
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
|
||||
# !/usr/bin/env python
|
||||
#
|
||||
# Copyright 2019 Espressif Systems (Shanghai) PTE LTD
|
||||
#
|
||||
# This script is used by the linker script generation in order to list a template's
|
||||
# INCLUDE'd linker scripts recursively. This is so that updates to these INCLUDE'd
|
||||
# scripts also trigger a relink of the app.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# http://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 re
|
||||
import argparse
|
||||
|
||||
|
||||
INCLUDE_PATTERN = re.compile(r"INCLUDE[\t ]+([^\n]+)")
|
||||
|
||||
|
||||
def find_includes(file_path, includes_list):
|
||||
# Find include files recursively
|
||||
file_dir = os.path.dirname(file_path)
|
||||
|
||||
with open(file_path, "r") as f:
|
||||
includes_list.append(file_path)
|
||||
includes = re.findall(INCLUDE_PATTERN, f.read())
|
||||
|
||||
for include in includes:
|
||||
include_file_path = os.path.abspath(os.path.join(file_dir, include))
|
||||
find_includes(include_file_path, includes_list)
|
||||
|
||||
|
||||
def main():
|
||||
argparser = argparse.ArgumentParser(description="List INCLUDE'd linker scripts recursively")
|
||||
argparser.add_argument("input", help="input linker script")
|
||||
args = argparser.parse_args()
|
||||
|
||||
includes_list = list()
|
||||
find_includes(args.input, includes_list)
|
||||
includes_list.remove(args.input)
|
||||
|
||||
print(" ".join(includes_list))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Ładowanie…
Reference in New Issue