blob: 9c5d07078cda7a61e9f502e1102d911034b55f66 [file] [edit]
# 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
def check_filesystem_overrides(app_path, board_id):
"""
Checks if application's boards/ directory has config or overlay overrides for board.
Matches <board_name>.conf, <board_name>_<qualifiers>.conf, etc.
"""
boards_dir = os.path.join(app_path, "boards")
if not os.path.isdir(boards_dir):
return False
board_name = board_id
board_qualifiers = ""
if "/" in board_id:
board_name, board_qualifiers = board_id.split("/", 1)
candidates = []
if board_qualifiers:
candidates.append(f"{board_name}_{board_qualifiers}.conf")
candidates.append(f"{board_name}_{board_qualifiers}.overlay")
candidates.append(f"{board_name}.conf")
candidates.append(f"{board_name}.overlay")
for c in candidates:
if os.path.exists(os.path.join(boards_dir, c)):
return True
return False