Skip to content

Commit 6ab423e

Browse files
committed
zephyr overlay
1 parent c13814f commit 6ab423e

File tree

2 files changed

+40
-6
lines changed

2 files changed

+40
-6
lines changed

tools/mcconfig.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,10 +1039,16 @@ export default class extends Tool {
10391039
this.config = config;
10401040
}
10411041
filterZephyrConfig(config) {
1042-
this.mergeProperties(config, this.zephyrConfig);
1042+
if (this.platform == "zephyr")
1043+
this.mergeProperties(config, this.zephyrConfig);
10431044
}
10441045
filterZephyrShields(config) {
1045-
this.mergeProperties(config, this.zephyrShields);
1046+
if (this.platform == "zephyr")
1047+
this.mergeProperties(config, this.zephyrShields);
1048+
}
1049+
filterZephyrOverlay(config) {
1050+
if (this.platform == "zephyr")
1051+
this.mergeProperties(config, this.zephyrOverlay);
10461052
}
10471053
filterCreation(creation) {
10481054
creation.chunk ??= {};
@@ -1273,6 +1279,7 @@ export default class extends Tool {
12731279
this.typescript = this.manifest.typescript;
12741280
this.filterZephyrConfig(this.manifest.zephyrConfig);
12751281
this.filterZephyrShields(this.manifest.zephyrShields);
1282+
this.filterZephyrOverlay(this.manifest.zephyrOverlay);
12761283

12771284
var name = this.environment.NAME
12781285
if (this.platform == "x-mac")
@@ -1423,8 +1430,14 @@ export default class extends Tool {
14231430
}
14241431

14251432
if (this.make) {
1426-
let cmd;
1433+
let cmd, overlay = "";
14271434
if (this.platform == "zephyr") {
1435+
if (this.zephyrOverlayFiles.length) {
1436+
overlay = "-DEXTRA_DTC_OVERLAY_FILE=\"";
1437+
for (var result of this.zephyrOverlayFiles)
1438+
overlay += result + " ";
1439+
overlay += "\"";
1440+
}
14281441
let command = `cd ${this.moddablePath} && `;
14291442
path = `${this.moddablePath}/build/devices/zephyr/app`;
14301443
if (this.buildTarget == "clean")
@@ -1440,9 +1453,9 @@ export default class extends Tool {
14401453

14411454
action = "build";
14421455
if (this.buildTarget == "build")
1443-
secondary = `${path} -d ${this.tmpPath}${this.slash}build -- -DEXTRA_CONF_FILE=${this.tmpPath}${this.slash}zephyr.conf -DMODDABLE_BUILD_DIR=${this.tmpPath}`
1456+
secondary = `${path} -d ${this.tmpPath}${this.slash}build -- -DEXTRA_CONF_FILE=${this.tmpPath}${this.slash}zephyr.conf -DMODDABLE_BUILD_DIR=${this.tmpPath} ${overlay}`
14441457
else if (this.buildTarget == "all" || undefined === this.buildTarget) /* all */
1445-
secondary = `${path} -d ${this.tmpPath}${this.slash}build -- -DEXTRA_CONF_FILE=${this.tmpPath}${this.slash}zephyr.conf -DMODDABLE_BUILD_DIR=${this.tmpPath} && west -z ${this.environment.ZEPHYR_BASE} flash -d ${this.tmpPath}${this.slash}build && serial2xsbug ${this.environment.UPLOAD_PORT} ${this.environment.DEBUGGER_SPEED} 8N1`;
1458+
secondary = `${path} -d ${this.tmpPath}${this.slash}build -- -DEXTRA_CONF_FILE=${this.tmpPath}${this.slash}zephyr.conf -DMODDABLE_BUILD_DIR=${this.tmpPath} ${overlay} && west -z ${this.environment.ZEPHYR_BASE} flash -d ${this.tmpPath}${this.slash}build && serial2xsbug ${this.environment.UPLOAD_PORT} ${this.environment.DEBUGGER_SPEED} 8N1`;
14461459
else
14471460
this.error("unknown target");
14481461

tools/mcmanifest.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2512,6 +2512,18 @@ export class Tool extends TOOL {
25122512
mergeManifest(all, manifest) {
25132513
var currentDirectory = this.currentDirectory;
25142514
this.currentDirectory = manifest.directory;
2515+
2516+
if (this.platform == "zephyr") {
2517+
var len = manifest.zephyrOverlay?.length;
2518+
for (var i = 0; i < len; i++) {
2519+
var path = manifest.zephyrOverlay[i];
2520+
if (path[0] == ".") {
2521+
path = this.resolvePath(manifest.directory + this.slash + path);
2522+
manifest.zephyrOverlay[i] = path;
2523+
}
2524+
}
2525+
}
2526+
25152527
this.mergePlatform(all, manifest);
25162528

25172529
if ("platforms" in manifest) {
@@ -2626,6 +2638,7 @@ export class Tool extends TOOL {
26262638
this.mergeProperties(all.run, platform.run);
26272639
this.mergeProperties(all.zephyrConfig, platform.zephyrConfig);
26282640
this.mergeProperties(all.zephyrShields, platform.zephyrShields);
2641+
this.mergeProperties(all.zephyrOverlay, platform.zephyrOverlay);
26292642
if (platform.typescript) {
26302643
let tsconfig = platform.typescript.tsconfig;
26312644
if (tsconfig) {
@@ -2815,6 +2828,7 @@ export class Tool extends TOOL {
28152828
typescript: {compiler: "tsc", tsconfig: {compilerOptions: {}}},
28162829
zephyrConfig:{},
28172830
zephyrShields:{},
2831+
zephyrOverlay:{},
28182832
};
28192833
this.manifests.forEach(manifest => this.mergeManifest(this.manifest, manifest));
28202834

@@ -2885,6 +2899,7 @@ export class Tool extends TOOL {
28852899
this.stringFiles.already = {};
28862900
this.bleServicesFiles = [];
28872901
this.bleServicesFiles.already = {};
2902+
this.zephyrOverlayFiles = [];
28882903
this.pioFiles = [];
28892904
this.pioFiles.already = {};
28902905

@@ -2898,7 +2913,13 @@ export class Tool extends TOOL {
28982913
rule.process(this.manifest.resources);
28992914
var rule = new BLERule(this);
29002915
rule.process(this.manifest.ble);
2901-
2916+
2917+
if (this.platform == "zephyr") {
2918+
for (var result in this.manifest.zephyrOverlay) {
2919+
this.zephyrOverlayFiles.push(this.manifest.zephyrOverlay[result]);
2920+
}
2921+
}
2922+
29022923
if (this.signature == null) {
29032924
if (!this.environment.NAMESPACE)
29042925
this.environment.NAMESPACE = "moddable.tech"

0 commit comments

Comments
 (0)