Comparing version 0.0.0 to 0.0.1
@@ -38,2 +38,4 @@ "use strict"; | ||
.option("-d, --download <URL>", "download project from share URL") | ||
.option("-m, --pxt-modules", "write pxt_modules/*") | ||
.option("-i, --init-mkc", "initialize mkc.json") | ||
.parse(process.argv); | ||
@@ -43,8 +45,9 @@ const opts = commander_1.program; | ||
return downloadProjectAsync(opts.download); | ||
let prj = new mkc.Project(files.findProjectDir()); | ||
const prj = new mkc.Project(files.findProjectDir()); | ||
yield prj.loadEditorAsync(); | ||
prj.service.runSync("(() => { pxt.savedAppTheme().experimentalHw = true; pxt.reloadAppTargetVariant() })()"); | ||
const hwVariants = prj.service.runSync("pxt.getHwVariants()"); | ||
if (opts.hw) { | ||
yield prj.loadEditorAsync(); | ||
const cfgs = prj.service.runSync("pxt.getHwVariants()"); | ||
const hw = opts.hw.toLowerCase(); | ||
const selected = cfgs.filter(cfg => { | ||
const selected = hwVariants.filter(cfg => { | ||
return cfg.name.toLowerCase() == hw || | ||
@@ -56,3 +59,3 @@ hwid(cfg).toLowerCase() == hw || | ||
console.error(`No such HW id: ${opts.hw}. Available hw:`); | ||
for (let cfg of cfgs) { | ||
for (let cfg of hwVariants) { | ||
console.error(`${hwid(cfg)}, ${cfg.card.name} - ${cfg.card.description}`); | ||
@@ -62,8 +65,9 @@ } | ||
} | ||
prj = new mkc.Project(files.findProjectDir()); | ||
prj.hwVariant = hwid(selected[0]); | ||
function hwid(cfg) { | ||
return cfg.name.replace(/hw---/, ""); | ||
} | ||
} | ||
if (opts.initMkc) { | ||
console.log("saving mkc.json"); | ||
fs.writeFileSync("mkc.json", JSON.stringify(prj.mainPkg.mkcConfig, null, 4)); | ||
} | ||
prj.writePxtModules = !!opts.pxtModules; | ||
if (!opts.javaScript || opts.hw) | ||
@@ -73,2 +77,9 @@ opts.native = true; | ||
opts.native = false; | ||
if (opts.native && hwVariants.length) { | ||
if (!prj.mainPkg.mkcConfig.hwVariant) { | ||
console.log("selecting first hw-variant: " + hwid(hwVariants[0])); | ||
prj.hwVariant = hwid(hwVariants[0]); | ||
} | ||
console.log(`using hwVariant: ${prj.mainPkg.mkcConfig.hwVariant}`); | ||
} | ||
const simpleOpts = { | ||
@@ -79,2 +90,5 @@ native: opts.native | ||
console.log("all done"); | ||
function hwid(cfg) { | ||
return cfg.name.replace(/hw---/, ""); | ||
} | ||
}); | ||
@@ -81,0 +95,0 @@ } |
@@ -55,2 +55,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const mkcJson = ws.packages["this"].mkcConfig; | ||
const pcfg = ws.packages[myid].config; | ||
@@ -60,4 +61,4 @@ const pending = []; | ||
const ver = pcfg.dependencies[pkgid]; | ||
if (pkgid == "hw" && ed.hwVariant) | ||
pkgid = "hw---" + ed.hwVariant; | ||
if (pkgid == "hw" && mkcJson.hwVariant) | ||
pkgid = "hw---" + mkcJson.hwVariant; | ||
if (ws.packages[pkgid] !== undefined) | ||
@@ -64,0 +65,0 @@ continue; // already loaded |
@@ -10,2 +10,3 @@ /// <reference path="../external/pxtpackage.d.ts" /> | ||
targetWebsite: string; | ||
hwVariant?: string; | ||
} | ||
@@ -26,3 +27,2 @@ export interface Cache { | ||
targetJson: any; | ||
hwVariant?: string; | ||
} | ||
@@ -46,4 +46,7 @@ export interface Package { | ||
lastPxtJson: string; | ||
hwVariant: string; | ||
private _hwVariant; | ||
writePxtModules: boolean; | ||
constructor(directory: string, cache?: Cache); | ||
get hwVariant(): string; | ||
set hwVariant(value: string); | ||
protected readFileAsync(filename: string): Promise<string>; | ||
@@ -50,0 +53,0 @@ protected saveBuiltFilesAsync(res: service.CompileResult): Promise<void>; |
@@ -24,5 +24,14 @@ "use strict"; | ||
this.cache = cache; | ||
this.writePxtModules = true; | ||
if (!this.cache) | ||
this.cache = exports.files.mkHomeCache(); | ||
} | ||
get hwVariant() { | ||
return this._hwVariant; | ||
} | ||
set hwVariant(value) { | ||
this._hwVariant = value; | ||
if (this.mainPkg) | ||
this.mainPkg.mkcConfig.hwVariant = value; | ||
} | ||
readFileAsync(filename) { | ||
@@ -61,2 +70,4 @@ return exports.files.readPrjFileAsync(this.directory, filename); | ||
exports.loader.guessMkcJson(prj); | ||
if (this.hwVariant) | ||
prj.mkcConfig.hwVariant = this.hwVariant; | ||
// TODO handle require("lzma") in worker | ||
@@ -82,3 +93,2 @@ prj.config.binaryonly = true; | ||
const newEditor = yield exports.downloader.downloadAsync(this.cache, this.mainPkg.mkcConfig.targetWebsite, !forceUpdate); | ||
newEditor.hwVariant = this.hwVariant; | ||
if (!this.editor || newEditor.versionNumber != this.editor.versionNumber) { | ||
@@ -99,4 +109,6 @@ this.editor = newEditor; | ||
const ws = yield exports.loader.loadDeps(this.editor, this.mainPkg); | ||
if (this.service.lastUser !== this) | ||
if (this.writePxtModules && this.service.lastUser !== this) { | ||
console.log("writing pxt_modules/*"); | ||
yield this.savePxtModulesAsync(ws); | ||
} | ||
}); | ||
@@ -103,0 +115,0 @@ } |
@@ -57,4 +57,2 @@ "use strict"; | ||
this.runFunctionSync("pxt.setupSimpleCompile", []); | ||
if (ed.hwVariant) | ||
this.runFunctionSync("pxt.setHwVariant", [ed.hwVariant]); | ||
} | ||
@@ -107,3 +105,5 @@ runScript(content, filename) { | ||
if (resp == null) { | ||
console.log(`compling C++; this can take a while`); | ||
const cdata = opts.extinfo.compileData; | ||
// writeFileSync("compilereq.json", JSON.stringify(JSON.parse(new Buffer(cdata, "base64").toString()), null, 4)) | ||
const cresp = yield downloader.requestAsync({ | ||
@@ -114,3 +114,2 @@ url: "https://www.makecode.com/api/compile/extension", | ||
}); | ||
console.log(cresp); | ||
const hexurl = cresp.json.hex; | ||
@@ -151,2 +150,3 @@ const jsonUrl = hexurl.replace(/\.hex/, ".json"); | ||
this.sandbox._scriptText = prj.files; | ||
this.runFunctionSync("pxt.setHwVariant", [prj.mkcConfig.hwVariant || null]); | ||
return this.runAsync("pxt.simpleGetCompileOptionsAsync(_scriptText, _opts)"); | ||
@@ -153,0 +153,0 @@ } |
{ | ||
"name": "makecode", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "MakeCode (PXT) - web-cached build tool", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -9,4 +9,14 @@ # MakeCode build tool | ||
## Usage | ||
In a folder with `pxt.json` file, run: | ||
``` | ||
> makecode | ||
``` | ||
You can also pass `--hw f4`, `--hw d5` etc. Try `--hw help` to get a list. | ||
## License | ||
MIT |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
82001
1302
22
32