mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-22 23:08:01 +00:00
0dafc779ce
This pull request adds changes described in **this comment**: - `.github/scripts/json_generator.py` - a small script that generates several json files for different platforms. - [generate_versions.yml](https://github.com/paritytech/revive/compare/as-release-json?expand=1#diff-2aee05b96020ac60943e6dfcb30597e53898f31542aeb570468b970d9a13a5a6) - the workflow that runs when release is published, creates info.json files and pushes them into resolc-bin repo - `js/build.js` is adjusted in order to set `RESOLC_WASM_URI` from env variable - ⚠️ Release workflow is changed: - In PRs and main branch it'll only build artifacts - Release will happen automatically only on the `v*` tag push. This is needed for revive_web.js to have the necessary `RESOLC_WASM_URI` - workflow will check that version in Cargo.toml is the same as the tag when the new tag is pushed cc https://github.com/paritytech/revive/issues/162 cc https://github.com/paritytech/devops/issues/3890
55 lines
1.5 KiB
JavaScript
55 lines
1.5 KiB
JavaScript
const fs = require("fs");
|
|
const path = require("path");
|
|
const { minify } = require("terser");
|
|
|
|
const SOLJSON_URI =
|
|
"https://binaries.soliditylang.org/wasm/soljson-v0.8.29+commit.ab55807c.js";
|
|
const RESOLC_WASM_URI =
|
|
process.env.RELEASE_RESOLC_WASM_URI || "http://127.0.0.1:8080/resolc.wasm";
|
|
const RESOLC_WASM_TARGET_DIR = path.join(
|
|
__dirname,
|
|
"../target/wasm32-unknown-emscripten/release",
|
|
);
|
|
const RESOLC_JS = path.join(RESOLC_WASM_TARGET_DIR, "resolc.js");
|
|
const RESOLC_WEB_JS = path.join(RESOLC_WASM_TARGET_DIR, "resolc_web.js");
|
|
|
|
const resolcJs = fs.readFileSync(RESOLC_JS, "utf-8");
|
|
|
|
const packedJsContent = `
|
|
if (typeof importScripts === "function") {
|
|
importScripts("${SOLJSON_URI}");
|
|
|
|
var moduleArgs = {
|
|
wasmBinary: (function () {
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open("GET", "${RESOLC_WASM_URI}", false);
|
|
xhr.responseType = "arraybuffer";
|
|
xhr.send(null);
|
|
return new Uint8Array(xhr.response);
|
|
})(),
|
|
soljson: Module
|
|
};
|
|
} else {
|
|
console.log("Not a WebWorker, skipping Soljson and WASM loading.");
|
|
}
|
|
|
|
${resolcJs}
|
|
|
|
createRevive = createRevive.bind(null, moduleArgs);
|
|
`;
|
|
|
|
minify(packedJsContent)
|
|
.then((minifiedJs) => {
|
|
if (minifiedJs.error) {
|
|
console.error("Error during minification:", minifiedJs.error);
|
|
process.exit(1);
|
|
}
|
|
|
|
fs.writeFileSync(RESOLC_WEB_JS, minifiedJs.code, "utf-8");
|
|
console.log(`Combined script written to ${RESOLC_WEB_JS}`);
|
|
})
|
|
.catch((err) => {
|
|
console.error("Minification failed:", err);
|
|
process.exit(1);
|
|
});
|