MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / parseManifest

Method parseManifest

tools/mcmanifest.js:3064–3133  ·  view source on GitHub ↗
(path, manifest)

Source from the content-addressed store, hash-verified

3062 }
3063 }
3064 parseManifest(path, manifest) {
3065 let platformInclude;
3066 if (!manifest) {
3067 var buffer = this.readFileString(path);
3068 try {
3069 var manifest = JSON.parse(buffer);
3070 }
3071 catch (e) {
3072 var message = e.toString();
3073 var result = /SyntaxError: ([^:]+: )?([0-9]+): (.+)/.exec(message);
3074 if (result.length == 4) {
3075 this.reportError(path, parseInt(result[2]), result[3]);
3076 }
3077 throw new Error("'" + path + "': invalid manifest!");;
3078 }
3079 }
3080 if (path)
3081 this.manifests.already[path] = manifest;
3082 this.parseBuild(manifest);
3083 if ("platforms" in manifest) {
3084 let platforms = manifest.platforms;
3085 let platform = this.matchPlatform(platforms, this.fullplatform, false);
3086 if (platform) {
3087 this.parseBuild(platform);
3088 platformInclude = platform.include;
3089 if (platformInclude) {
3090 if (!("include" in manifest))
3091 manifest.include = platformInclude;
3092 else {
3093 if ("string" === typeof manifest.include)
3094 manifest.include = [manifest.include];
3095 manifest.include = manifest.include.concat(platformInclude);
3096 }
3097 }
3098 if ("esp32" == this.platform) {
3099 if (platform.dependency) {
3100 manifest.dependencies = [];
3101 for (let i=0; i<platform.dependency.length; i++) {
3102 var dep = platform.dependency[i];
3103// if (undefined === dep.namespace)
3104// dep.namespace = "espressif";
3105 manifest.dependencies.push(dep);
3106 }
3107 }
3108 if (platform.components) {
3109 var comp;
3110 manifest.components = [];
3111 for (let i=0; i<platform.components.length; i++) {
3112 var comp = platform.components[i];
3113 if (undefined === comp.name) {
3114 trace(`# bad component name "${comp.name}"\n`);
3115 continue;
3116 }
3117 if (!manifest.components.includes(comp.name))
3118 manifest.components.push(comp);
3119trace(`# esp32 component "${comp.name}\n`);
3120 }
3121 }

Callers 4

includeManifestMethod · 0.95
includeManifestPathMethod · 0.95
mergeNodeRedMethod · 0.95
runMethod · 0.95

Calls 7

parseBuildMethod · 0.95
matchPlatformMethod · 0.95
includeManifestMethod · 0.95
parseMethod · 0.65
concatMethod · 0.65
toStringMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected