Skip to content

Commit 054dd12

Browse files
Adding platform installation directory as a possible base for board.json variants_dir attribute.
1 parent 8c460f2 commit 054dd12

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

builder/frameworks/arduino/arduino_common.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,21 @@
4444

4545

4646
def get_variants_dir():
47+
# variants_dir is not specified in board.json file
48+
# Use <framework>/variants as a default path
4749
if "build.variants_dir" not in board:
4850
return os.path.join(FRAMEWORK_DIR, "variants")
4951

52+
# Check if specified variants_dir exist as a package subdirectory to support custom packages installations
53+
package_variants = os.path.join(platform.get_dir(), board.get("build.variants_dir"))
54+
if os.path.isabs(package_variants):
55+
return package_variants
56+
57+
# Check if the specified variants_dir exist as an absolute path on it's own
5058
if os.path.isabs(env.subst(board.get("build.variants_dir"))):
5159
return board.get("build.variants_dir", "")
5260

61+
# Last resort, use specified variants_dir as subdirectory in current project path
5362
return os.path.join("$PROJECT_DIR", board.get("build.variants_dir"))
5463

5564

0 commit comments

Comments
 (0)