├── .github ├── actions │ └── github-release │ │ ├── README.md │ │ ├── action.yml │ │ ├── main.js │ │ ├── package-lock.json │ │ └── package.json └── workflows │ └── main.yml ├── .gitignore ├── LICENSE ├── README.md ├── build-engine.sh ├── download-engine.sh ├── gecko-repository ├── gecko-revision ├── object-files.list ├── rebuild.sh └── rust-toolchain.toml /.github/actions/github-release/README.md: -------------------------------------------------------------------------------- 1 | # github-release 2 | 3 | An action used to publish GitHub releases for `wasmtime`. 4 | 5 | As of the time of this writing there's a few actions floating around which 6 | perform github releases but they all tend to have their set of drawbacks. 7 | 8 | To handle all this this action rolls-its-own implementation using the 9 | actions/toolkit repository and packages published there. These run in a Docker 10 | container and take various inputs to orchestrate the release from the build. 11 | 12 | More comments can be found in `main.js`. 13 | 14 | Testing this is really hard. If you want to try though run `npm install` and 15 | then `node main.js`. You'll have to configure a bunch of env vars though to get 16 | anything reasonably working. 17 | -------------------------------------------------------------------------------- /.github/actions/github-release/action.yml: -------------------------------------------------------------------------------- 1 | name: 'wasmtime github releases' 2 | description: 'wasmtime github releases' 3 | inputs: 4 | token: 5 | description: '' 6 | required: true 7 | name: 8 | description: '' 9 | required: true 10 | files: 11 | description: '' 12 | required: true 13 | runs: 14 | using: 'node16' 15 | main: 'main.js' 16 | -------------------------------------------------------------------------------- /.github/actions/github-release/main.js: -------------------------------------------------------------------------------- 1 | const core = require('@actions/core'); 2 | const path = require("path"); 3 | const fs = require("fs"); 4 | const github = require('@actions/github'); 5 | const glob = require('glob'); 6 | 7 | function sleep(milliseconds) { 8 | return new Promise(resolve => setTimeout(resolve, milliseconds)) 9 | } 10 | 11 | async function runOnce() { 12 | // Load all our inputs and env vars. Note that `getInput` reads from `INPUT_*` 13 | const files = core.getInput('files'); 14 | const name = core.getInput('name'); 15 | const token = core.getInput('token'); 16 | const slug = process.env.GITHUB_REPOSITORY; 17 | const owner = slug.split('/')[0]; 18 | const repo = slug.split('/')[1]; 19 | const sha = process.env.GITHUB_SHA; 20 | 21 | core.info(`files: ${files}`); 22 | core.info(`name: ${name}`); 23 | core.info(`token: ${token}`); 24 | 25 | const octokit = github.getOctokit(token); 26 | 27 | // Try to load the release for this tag, and if it doesn't exist then make a 28 | // new one. We might race with other builders on creation, though, so if the 29 | // creation fails try again to get the release by the tag. 30 | let release = null; 31 | try { 32 | core.info(`fetching release`); 33 | release = await octokit.rest.repos.getReleaseByTag({ owner, repo, tag: name }); 34 | } catch (e) { 35 | console.log("ERROR: ", JSON.stringify(e, null, 2)); 36 | core.info(`creating a release`); 37 | try { 38 | release = await octokit.rest.repos.createRelease({ 39 | owner, 40 | repo, 41 | tag_name: name, 42 | prerelease: name === 'dev', 43 | }); 44 | } catch(e) { 45 | console.log("ERROR: ", JSON.stringify(e, null, 2)); 46 | core.info(`fetching one more time`); 47 | release = await octokit.rest.repos.getReleaseByTag({ owner, repo, tag: name }); 48 | } 49 | } 50 | console.log("found release: ", JSON.stringify(release.data, null, 2)); 51 | 52 | // Upload all the relevant assets for this release as just general blobs. 53 | for (const file of glob.sync(files)) { 54 | const size = fs.statSync(file).size; 55 | const name = path.basename(file); 56 | for (const asset of release.data.assets) { 57 | if (asset.name !== name) 58 | continue; 59 | console.log(`deleting prior asset ${asset.id}`); 60 | await octokit.rest.repos.deleteReleaseAsset({ 61 | owner, 62 | repo, 63 | asset_id: asset.id, 64 | }); 65 | } 66 | core.info(`upload ${file}`); 67 | await octokit.rest.repos.uploadReleaseAsset({ 68 | data: fs.createReadStream(file), 69 | headers: { 'content-length': size, 'content-type': 'application/octet-stream' }, 70 | name, 71 | url: release.data.upload_url, 72 | }); 73 | } 74 | } 75 | 76 | async function run() { 77 | const retries = 10; 78 | for (let i = 0; i < retries; i++) { 79 | try { 80 | await runOnce(); 81 | break; 82 | } catch (e) { 83 | if (i === retries - 1) 84 | throw e; 85 | logError(e); 86 | console.log("RETRYING after 10s"); 87 | await sleep(10000) 88 | } 89 | } 90 | } 91 | 92 | function logError(e) { 93 | console.log("ERROR: ", e.message); 94 | try { 95 | console.log(JSON.stringify(e, null, 2)); 96 | } catch (e) { 97 | // ignore json errors for now 98 | } 99 | console.log(e.stack); 100 | } 101 | 102 | run().catch(err => { 103 | logError(err); 104 | core.setFailed(err.message); 105 | }); 106 | -------------------------------------------------------------------------------- /.github/actions/github-release/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wasmtime-github-release", 3 | "version": "0.0.0", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "wasmtime-github-release", 9 | "version": "0.0.0", 10 | "dependencies": { 11 | "@actions/core": "^1.9.1", 12 | "@actions/github": "^5.1.0", 13 | "glob": "^7.1.5" 14 | } 15 | }, 16 | "node_modules/@actions/core": { 17 | "version": "1.9.1", 18 | "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz", 19 | "integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==", 20 | "dependencies": { 21 | "@actions/http-client": "^2.0.1", 22 | "uuid": "^8.3.2" 23 | } 24 | }, 25 | "node_modules/@actions/github": { 26 | "version": "5.1.0", 27 | "resolved": "https://registry.npmjs.org/@actions/github/-/github-5.1.0.tgz", 28 | "integrity": "sha512-tuI80F7JQIhg77ZTTgUAPpVD7ZnP9oHSPN8xw7LOwtA4vEMbAjWJNbmLBfV7xua7r016GyjzWLuec5cs8f/a8A==", 29 | "dependencies": { 30 | "@actions/http-client": "^2.0.1", 31 | "@octokit/core": "^3.6.0", 32 | "@octokit/plugin-paginate-rest": "^2.17.0", 33 | "@octokit/plugin-rest-endpoint-methods": "^5.13.0" 34 | } 35 | }, 36 | "node_modules/@actions/http-client": { 37 | "version": "2.0.1", 38 | "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz", 39 | "integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==", 40 | "dependencies": { 41 | "tunnel": "^0.0.6" 42 | } 43 | }, 44 | "node_modules/@octokit/auth-token": { 45 | "version": "2.5.0", 46 | "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.5.0.tgz", 47 | "integrity": "sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g==", 48 | "dependencies": { 49 | "@octokit/types": "^6.0.3" 50 | } 51 | }, 52 | "node_modules/@octokit/core": { 53 | "version": "3.6.0", 54 | "resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.6.0.tgz", 55 | "integrity": "sha512-7RKRKuA4xTjMhY+eG3jthb3hlZCsOwg3rztWh75Xc+ShDWOfDDATWbeZpAHBNRpm4Tv9WgBMOy1zEJYXG6NJ7Q==", 56 | "dependencies": { 57 | "@octokit/auth-token": "^2.4.4", 58 | "@octokit/graphql": "^4.5.8", 59 | "@octokit/request": "^5.6.3", 60 | "@octokit/request-error": "^2.0.5", 61 | "@octokit/types": "^6.0.3", 62 | "before-after-hook": "^2.2.0", 63 | "universal-user-agent": "^6.0.0" 64 | } 65 | }, 66 | "node_modules/@octokit/endpoint": { 67 | "version": "6.0.12", 68 | "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.12.tgz", 69 | "integrity": "sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA==", 70 | "dependencies": { 71 | "@octokit/types": "^6.0.3", 72 | "is-plain-object": "^5.0.0", 73 | "universal-user-agent": "^6.0.0" 74 | } 75 | }, 76 | "node_modules/@octokit/graphql": { 77 | "version": "4.8.0", 78 | "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.8.0.tgz", 79 | "integrity": "sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg==", 80 | "dependencies": { 81 | "@octokit/request": "^5.6.0", 82 | "@octokit/types": "^6.0.3", 83 | "universal-user-agent": "^6.0.0" 84 | } 85 | }, 86 | "node_modules/@octokit/openapi-types": { 87 | "version": "12.11.0", 88 | "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-12.11.0.tgz", 89 | "integrity": "sha512-VsXyi8peyRq9PqIz/tpqiL2w3w80OgVMwBHltTml3LmVvXiphgeqmY9mvBw9Wu7e0QWk/fqD37ux8yP5uVekyQ==" 90 | }, 91 | "node_modules/@octokit/plugin-paginate-rest": { 92 | "version": "2.21.3", 93 | "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.21.3.tgz", 94 | "integrity": "sha512-aCZTEf0y2h3OLbrgKkrfFdjRL6eSOo8komneVQJnYecAxIej7Bafor2xhuDJOIFau4pk0i/P28/XgtbyPF0ZHw==", 95 | "dependencies": { 96 | "@octokit/types": "^6.40.0" 97 | }, 98 | "peerDependencies": { 99 | "@octokit/core": ">=2" 100 | } 101 | }, 102 | "node_modules/@octokit/plugin-rest-endpoint-methods": { 103 | "version": "5.16.2", 104 | "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.16.2.tgz", 105 | "integrity": "sha512-8QFz29Fg5jDuTPXVtey05BLm7OB+M8fnvE64RNegzX7U+5NUXcOcnpTIK0YfSHBg8gYd0oxIq3IZTe9SfPZiRw==", 106 | "dependencies": { 107 | "@octokit/types": "^6.39.0", 108 | "deprecation": "^2.3.1" 109 | }, 110 | "peerDependencies": { 111 | "@octokit/core": ">=3" 112 | } 113 | }, 114 | "node_modules/@octokit/request": { 115 | "version": "5.6.3", 116 | "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.6.3.tgz", 117 | "integrity": "sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A==", 118 | "dependencies": { 119 | "@octokit/endpoint": "^6.0.1", 120 | "@octokit/request-error": "^2.1.0", 121 | "@octokit/types": "^6.16.1", 122 | "is-plain-object": "^5.0.0", 123 | "node-fetch": "^2.6.7", 124 | "universal-user-agent": "^6.0.0" 125 | } 126 | }, 127 | "node_modules/@octokit/request-error": { 128 | "version": "2.1.0", 129 | "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.1.0.tgz", 130 | "integrity": "sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==", 131 | "dependencies": { 132 | "@octokit/types": "^6.0.3", 133 | "deprecation": "^2.0.0", 134 | "once": "^1.4.0" 135 | } 136 | }, 137 | "node_modules/@octokit/types": { 138 | "version": "6.41.0", 139 | "resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.41.0.tgz", 140 | "integrity": "sha512-eJ2jbzjdijiL3B4PrSQaSjuF2sPEQPVCPzBvTHJD9Nz+9dw2SGH4K4xeQJ77YfTq5bRQ+bD8wT11JbeDPmxmGg==", 141 | "dependencies": { 142 | "@octokit/openapi-types": "^12.11.0" 143 | } 144 | }, 145 | "node_modules/balanced-match": { 146 | "version": "1.0.2", 147 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", 148 | "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" 149 | }, 150 | "node_modules/before-after-hook": { 151 | "version": "2.2.3", 152 | "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", 153 | "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==" 154 | }, 155 | "node_modules/brace-expansion": { 156 | "version": "1.1.11", 157 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 158 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 159 | "dependencies": { 160 | "balanced-match": "^1.0.0", 161 | "concat-map": "0.0.1" 162 | } 163 | }, 164 | "node_modules/concat-map": { 165 | "version": "0.0.1", 166 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 167 | "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" 168 | }, 169 | "node_modules/deprecation": { 170 | "version": "2.3.1", 171 | "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", 172 | "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==" 173 | }, 174 | "node_modules/fs.realpath": { 175 | "version": "1.0.0", 176 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 177 | "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" 178 | }, 179 | "node_modules/glob": { 180 | "version": "7.2.3", 181 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", 182 | "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", 183 | "dependencies": { 184 | "fs.realpath": "^1.0.0", 185 | "inflight": "^1.0.4", 186 | "inherits": "2", 187 | "minimatch": "^3.1.1", 188 | "once": "^1.3.0", 189 | "path-is-absolute": "^1.0.0" 190 | }, 191 | "engines": { 192 | "node": "*" 193 | }, 194 | "funding": { 195 | "url": "https://github.com/sponsors/isaacs" 196 | } 197 | }, 198 | "node_modules/inflight": { 199 | "version": "1.0.6", 200 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 201 | "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", 202 | "dependencies": { 203 | "once": "^1.3.0", 204 | "wrappy": "1" 205 | } 206 | }, 207 | "node_modules/inherits": { 208 | "version": "2.0.4", 209 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 210 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" 211 | }, 212 | "node_modules/is-plain-object": { 213 | "version": "5.0.0", 214 | "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", 215 | "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==", 216 | "engines": { 217 | "node": ">=0.10.0" 218 | } 219 | }, 220 | "node_modules/minimatch": { 221 | "version": "3.1.2", 222 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", 223 | "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", 224 | "dependencies": { 225 | "brace-expansion": "^1.1.7" 226 | }, 227 | "engines": { 228 | "node": "*" 229 | } 230 | }, 231 | "node_modules/node-fetch": { 232 | "version": "2.6.7", 233 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", 234 | "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", 235 | "dependencies": { 236 | "whatwg-url": "^5.0.0" 237 | }, 238 | "engines": { 239 | "node": "4.x || >=6.0.0" 240 | }, 241 | "peerDependencies": { 242 | "encoding": "^0.1.0" 243 | }, 244 | "peerDependenciesMeta": { 245 | "encoding": { 246 | "optional": true 247 | } 248 | } 249 | }, 250 | "node_modules/once": { 251 | "version": "1.4.0", 252 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 253 | "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", 254 | "dependencies": { 255 | "wrappy": "1" 256 | } 257 | }, 258 | "node_modules/path-is-absolute": { 259 | "version": "1.0.1", 260 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 261 | "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", 262 | "engines": { 263 | "node": ">=0.10.0" 264 | } 265 | }, 266 | "node_modules/tr46": { 267 | "version": "0.0.3", 268 | "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", 269 | "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" 270 | }, 271 | "node_modules/tunnel": { 272 | "version": "0.0.6", 273 | "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", 274 | "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==", 275 | "engines": { 276 | "node": ">=0.6.11 <=0.7.0 || >=0.7.3" 277 | } 278 | }, 279 | "node_modules/universal-user-agent": { 280 | "version": "6.0.0", 281 | "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", 282 | "integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==" 283 | }, 284 | "node_modules/uuid": { 285 | "version": "8.3.2", 286 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", 287 | "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", 288 | "bin": { 289 | "uuid": "dist/bin/uuid" 290 | } 291 | }, 292 | "node_modules/webidl-conversions": { 293 | "version": "3.0.1", 294 | "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", 295 | "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" 296 | }, 297 | "node_modules/whatwg-url": { 298 | "version": "5.0.0", 299 | "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", 300 | "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", 301 | "dependencies": { 302 | "tr46": "~0.0.3", 303 | "webidl-conversions": "^3.0.0" 304 | } 305 | }, 306 | "node_modules/wrappy": { 307 | "version": "1.0.2", 308 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 309 | "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" 310 | } 311 | }, 312 | "dependencies": { 313 | "@actions/core": { 314 | "version": "1.9.1", 315 | "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz", 316 | "integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==", 317 | "requires": { 318 | "@actions/http-client": "^2.0.1", 319 | "uuid": "^8.3.2" 320 | } 321 | }, 322 | "@actions/github": { 323 | "version": "5.1.0", 324 | "resolved": "https://registry.npmjs.org/@actions/github/-/github-5.1.0.tgz", 325 | "integrity": "sha512-tuI80F7JQIhg77ZTTgUAPpVD7ZnP9oHSPN8xw7LOwtA4vEMbAjWJNbmLBfV7xua7r016GyjzWLuec5cs8f/a8A==", 326 | "requires": { 327 | "@actions/http-client": "^2.0.1", 328 | "@octokit/core": "^3.6.0", 329 | "@octokit/plugin-paginate-rest": "^2.17.0", 330 | "@octokit/plugin-rest-endpoint-methods": "^5.13.0" 331 | } 332 | }, 333 | "@actions/http-client": { 334 | "version": "2.0.1", 335 | "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz", 336 | "integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==", 337 | "requires": { 338 | "tunnel": "^0.0.6" 339 | } 340 | }, 341 | "@octokit/auth-token": { 342 | "version": "2.5.0", 343 | "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.5.0.tgz", 344 | "integrity": "sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g==", 345 | "requires": { 346 | "@octokit/types": "^6.0.3" 347 | } 348 | }, 349 | "@octokit/core": { 350 | "version": "3.6.0", 351 | "resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.6.0.tgz", 352 | "integrity": "sha512-7RKRKuA4xTjMhY+eG3jthb3hlZCsOwg3rztWh75Xc+ShDWOfDDATWbeZpAHBNRpm4Tv9WgBMOy1zEJYXG6NJ7Q==", 353 | "requires": { 354 | "@octokit/auth-token": "^2.4.4", 355 | "@octokit/graphql": "^4.5.8", 356 | "@octokit/request": "^5.6.3", 357 | "@octokit/request-error": "^2.0.5", 358 | "@octokit/types": "^6.0.3", 359 | "before-after-hook": "^2.2.0", 360 | "universal-user-agent": "^6.0.0" 361 | } 362 | }, 363 | "@octokit/endpoint": { 364 | "version": "6.0.12", 365 | "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.12.tgz", 366 | "integrity": "sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA==", 367 | "requires": { 368 | "@octokit/types": "^6.0.3", 369 | "is-plain-object": "^5.0.0", 370 | "universal-user-agent": "^6.0.0" 371 | } 372 | }, 373 | "@octokit/graphql": { 374 | "version": "4.8.0", 375 | "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.8.0.tgz", 376 | "integrity": "sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg==", 377 | "requires": { 378 | "@octokit/request": "^5.6.0", 379 | "@octokit/types": "^6.0.3", 380 | "universal-user-agent": "^6.0.0" 381 | } 382 | }, 383 | "@octokit/openapi-types": { 384 | "version": "12.11.0", 385 | "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-12.11.0.tgz", 386 | "integrity": "sha512-VsXyi8peyRq9PqIz/tpqiL2w3w80OgVMwBHltTml3LmVvXiphgeqmY9mvBw9Wu7e0QWk/fqD37ux8yP5uVekyQ==" 387 | }, 388 | "@octokit/plugin-paginate-rest": { 389 | "version": "2.21.3", 390 | "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.21.3.tgz", 391 | "integrity": "sha512-aCZTEf0y2h3OLbrgKkrfFdjRL6eSOo8komneVQJnYecAxIej7Bafor2xhuDJOIFau4pk0i/P28/XgtbyPF0ZHw==", 392 | "requires": { 393 | "@octokit/types": "^6.40.0" 394 | } 395 | }, 396 | "@octokit/plugin-rest-endpoint-methods": { 397 | "version": "5.16.2", 398 | "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.16.2.tgz", 399 | "integrity": "sha512-8QFz29Fg5jDuTPXVtey05BLm7OB+M8fnvE64RNegzX7U+5NUXcOcnpTIK0YfSHBg8gYd0oxIq3IZTe9SfPZiRw==", 400 | "requires": { 401 | "@octokit/types": "^6.39.0", 402 | "deprecation": "^2.3.1" 403 | } 404 | }, 405 | "@octokit/request": { 406 | "version": "5.6.3", 407 | "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.6.3.tgz", 408 | "integrity": "sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A==", 409 | "requires": { 410 | "@octokit/endpoint": "^6.0.1", 411 | "@octokit/request-error": "^2.1.0", 412 | "@octokit/types": "^6.16.1", 413 | "is-plain-object": "^5.0.0", 414 | "node-fetch": "^2.6.7", 415 | "universal-user-agent": "^6.0.0" 416 | } 417 | }, 418 | "@octokit/request-error": { 419 | "version": "2.1.0", 420 | "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.1.0.tgz", 421 | "integrity": "sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==", 422 | "requires": { 423 | "@octokit/types": "^6.0.3", 424 | "deprecation": "^2.0.0", 425 | "once": "^1.4.0" 426 | } 427 | }, 428 | "@octokit/types": { 429 | "version": "6.41.0", 430 | "resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.41.0.tgz", 431 | "integrity": "sha512-eJ2jbzjdijiL3B4PrSQaSjuF2sPEQPVCPzBvTHJD9Nz+9dw2SGH4K4xeQJ77YfTq5bRQ+bD8wT11JbeDPmxmGg==", 432 | "requires": { 433 | "@octokit/openapi-types": "^12.11.0" 434 | } 435 | }, 436 | "balanced-match": { 437 | "version": "1.0.2", 438 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", 439 | "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" 440 | }, 441 | "before-after-hook": { 442 | "version": "2.2.3", 443 | "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", 444 | "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==" 445 | }, 446 | "brace-expansion": { 447 | "version": "1.1.11", 448 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 449 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 450 | "requires": { 451 | "balanced-match": "^1.0.0", 452 | "concat-map": "0.0.1" 453 | } 454 | }, 455 | "concat-map": { 456 | "version": "0.0.1", 457 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 458 | "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" 459 | }, 460 | "deprecation": { 461 | "version": "2.3.1", 462 | "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", 463 | "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==" 464 | }, 465 | "fs.realpath": { 466 | "version": "1.0.0", 467 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 468 | "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" 469 | }, 470 | "glob": { 471 | "version": "7.2.3", 472 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", 473 | "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", 474 | "requires": { 475 | "fs.realpath": "^1.0.0", 476 | "inflight": "^1.0.4", 477 | "inherits": "2", 478 | "minimatch": "^3.1.1", 479 | "once": "^1.3.0", 480 | "path-is-absolute": "^1.0.0" 481 | } 482 | }, 483 | "inflight": { 484 | "version": "1.0.6", 485 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 486 | "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", 487 | "requires": { 488 | "once": "^1.3.0", 489 | "wrappy": "1" 490 | } 491 | }, 492 | "inherits": { 493 | "version": "2.0.4", 494 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 495 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" 496 | }, 497 | "is-plain-object": { 498 | "version": "5.0.0", 499 | "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", 500 | "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==" 501 | }, 502 | "minimatch": { 503 | "version": "3.1.2", 504 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", 505 | "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", 506 | "requires": { 507 | "brace-expansion": "^1.1.7" 508 | } 509 | }, 510 | "node-fetch": { 511 | "version": "2.6.7", 512 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", 513 | "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", 514 | "requires": { 515 | "whatwg-url": "^5.0.0" 516 | } 517 | }, 518 | "once": { 519 | "version": "1.4.0", 520 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 521 | "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", 522 | "requires": { 523 | "wrappy": "1" 524 | } 525 | }, 526 | "path-is-absolute": { 527 | "version": "1.0.1", 528 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 529 | "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==" 530 | }, 531 | "tr46": { 532 | "version": "0.0.3", 533 | "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", 534 | "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" 535 | }, 536 | "tunnel": { 537 | "version": "0.0.6", 538 | "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", 539 | "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==" 540 | }, 541 | "universal-user-agent": { 542 | "version": "6.0.0", 543 | "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", 544 | "integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==" 545 | }, 546 | "uuid": { 547 | "version": "8.3.2", 548 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", 549 | "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" 550 | }, 551 | "webidl-conversions": { 552 | "version": "3.0.1", 553 | "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", 554 | "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" 555 | }, 556 | "whatwg-url": { 557 | "version": "5.0.0", 558 | "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", 559 | "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", 560 | "requires": { 561 | "tr46": "~0.0.3", 562 | "webidl-conversions": "^3.0.0" 563 | } 564 | }, 565 | "wrappy": { 566 | "version": "1.0.2", 567 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 568 | "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" 569 | } 570 | } 571 | } 572 | -------------------------------------------------------------------------------- /.github/actions/github-release/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wasmtime-github-release", 3 | "version": "0.0.0", 4 | "main": "main.js", 5 | "dependencies": { 6 | "@actions/core": "^1.9.1", 7 | "@actions/github": "^5.1.0", 8 | "glob": "^7.1.5" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | branches: [main] 5 | tags-ignore: [dev] 6 | pull_request: 7 | branches: [main] 8 | defaults: 9 | run: 10 | shell: bash 11 | 12 | jobs: 13 | build_engine: 14 | name: Build Engine 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v2 18 | with: 19 | submodules: true 20 | 21 | - name: Cache SpiderMonkey tarball 22 | uses: actions/cache@v2 23 | id: sm-cache 24 | with: 25 | path: | 26 | dist 27 | key: cache-${{ hashFiles('build-engine.sh') }}-${{ hashFiles('gecko-revision') }}-${{ hashFiles('object-files.list') }} 28 | 29 | - name: "Build and bundle SpiderMonkey" 30 | if: steps.sm-cache.outputs.cache-hit != 'true' 31 | run: | 32 | mkdir dist 33 | sudo apt-get update -y 34 | 35 | bash ./build-engine.sh release 36 | tar -a -cf dist/spidermonkey-wasm-static-lib_release.tar.gz release 37 | rm -rf release obj-release 38 | 39 | bash ./build-engine.sh release weval 40 | tar -a -cf dist/spidermonkey-wasm-static-lib_release_weval.tar.gz release-weval 41 | rm -rf release-weval obj-release-weval 42 | 43 | bash ./build-engine.sh debug 44 | tar -a -cf dist/spidermonkey-wasm-static-lib_debug.tar.gz debug 45 | rm -rf debug obj-debug 46 | 47 | - name: Calculate tag name 48 | run: | 49 | name=rev_$GITHUB_SHA 50 | echo ::set-output name=val::$name 51 | echo TAG=$name >> $GITHUB_ENV 52 | id: tagname 53 | 54 | # Upload tarball as an artifact of the github action run, so the output 55 | # can be inspected for pull requests. 56 | - name: Upload tarball 57 | uses: actions/upload-artifact@v4 58 | if: github.event_name != 'push' || (github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/v')) 59 | with: 60 | name: spidermonkey-wasm-static-lib.zip 61 | path: dist/ 62 | 63 | # ... and if this was an actual push (tag or `main`) then we publish a 64 | # new release. This'll automatically publish a tag release or update `dev` 65 | # with this `sha` 66 | - run: cd .github/actions/github-release && npm install --production 67 | - name: Publish Release 68 | uses: ./.github/actions/github-release 69 | if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) 70 | with: 71 | files: "dist/*.tar.gz" 72 | name: ${{ steps.tagname.outputs.val }} 73 | token: ${{ secrets.GITHUB_TOKEN }} 74 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /gecko-dev 2 | /obj-release 3 | /obj-debug 4 | /release 5 | /debug 6 | /dist 7 | /mozconfig-* 8 | .DS_Store 9 | .vscode 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | 204 | 205 | --- LLVM Exceptions to the Apache 2.0 License ---- 206 | 207 | As an exception, if, as a result of your compiling your source code, portions 208 | of this Software are embedded into an Object form of such source code, you 209 | may redistribute such embedded portions in such Object form without complying 210 | with the conditions of Sections 4(a), 4(b) and 4(d) of the License. 211 | 212 | In addition, if you combine or link compiled forms of this Software with 213 | software that is licensed under the GPLv2 ("Combined Software") and if a 214 | court of competent jurisdiction determines that the patent provision (Section 215 | 3), the indemnity provision (Section 9) or other Section of the License 216 | conflicts with the conditions of the GPLv2, you may retroactively and 217 | prospectively choose to deem waived or otherwise exclude such Section(s) of 218 | the License, but only in their entirety and only with respect to the Combined 219 | Software. 220 | 221 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Scripts for building and downloading pre-built versions of SpiderMonkey, compiled to wasm32-wasi as a static library. 2 | 3 | ## Building from upstream source 4 | The `build-engine.sh` script can be used to build either release or debug builds. It's recommended that this script only be used in CI environments, as it bootstraps a build environment for SpiderMonkey on each invokation. 5 | 6 | The source is retrieved from the repository in `gecko-repository` at the revision in `gecko-revision`. 7 | 8 | ### Building for release or debug 9 | The script can compile both release and debug builds, with `release` being the default. To compile a debug build, pass `debug` as the first argument: 10 | ```sh 11 | sh build-engine.sh debug 12 | ``` 13 | 14 | ### Build output 15 | Running the build script will result in three different subdirectories in the current directory: 16 | - `include`, containing the public header files 17 | - `lib`, containing the object files and static libraries needed to statically link SpiderMonkey 18 | - `obj`, the output directory the SpiderMonkey build system creates. This can be ignored or deleted 19 | 20 | ## Downloading pre-built releases 21 | The `download-engine.sh` script can be used to download pre-built object files and headers for static linking for either release or debug builds. The object files are compiled to wasm32-wasi, and can be used on any platform. 22 | 23 | Running `download-engine.sh [debug]` will download a tarball for a SpiderMonkey build (release by default, debug if the `debug` argument is passed), and extract it. When successful, it'll result in the subdirectories `lib` and `include` in the current working directory. 24 | 25 | **Note:** `download-engine.sh` can be called from anywhere, but must itself reside in a git checkout whose `origin` is the github repository to download the release from. It expects that repository to have a release whose name is derived from the current git revision of the containing checkout. 26 | -------------------------------------------------------------------------------- /build-engine.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | set -x 5 | 6 | working_dir="$(pwd)" 7 | script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" 8 | 9 | mode="${1:-release}" 10 | weval="" 11 | if [[ $# > 1 ]] && [[ "$2" == "weval" ]]; then 12 | weval=-weval 13 | fi 14 | mozconfig="${working_dir}/mozconfig-${mode}${weval}" 15 | objdir="obj-$mode${weval}" 16 | outdir="$mode${weval}" 17 | rebuild="${REBUILD_ENGINE:-0}" 18 | 19 | cat << EOF > "$mozconfig" 20 | ac_add_options --enable-project=js 21 | ac_add_options --enable-application=js 22 | ac_add_options --target=wasm32-unknown-wasi 23 | ac_add_options --without-system-zlib 24 | ac_add_options --without-intl-api 25 | ac_add_options --disable-jit 26 | ac_add_options --disable-shared-js 27 | ac_add_options --disable-shared-memory 28 | ac_add_options --disable-tests 29 | ac_add_options --disable-clang-plugin 30 | ac_add_options --enable-jitspew 31 | ac_add_options --enable-optimize=-O3 32 | ac_add_options --enable-js-streams 33 | ac_add_options --enable-portable-baseline-interp 34 | ac_add_options --prefix=${working_dir}/${objdir}/dist 35 | mk_add_options MOZ_OBJDIR=${working_dir}/${objdir} 36 | mk_add_options AUTOCLOBBER=1 37 | EOF 38 | 39 | target="$(uname)" 40 | case "$target" in 41 | Linux) 42 | echo "ac_add_options --disable-stdcxx-compat" >> "$mozconfig" 43 | ;; 44 | 45 | Darwin) 46 | echo "ac_add_options --host=aarch64-apple-darwin" >> "$mozconfig" 47 | ;; 48 | 49 | *) 50 | echo "Unsupported build target: $target" 51 | exit 1 52 | ;; 53 | esac 54 | 55 | case "$mode" in 56 | release) 57 | echo "ac_add_options --disable-debug" >> "$mozconfig" 58 | ;; 59 | 60 | debug) 61 | echo "ac_add_options --enable-debug" >> "$mozconfig" 62 | ;; 63 | 64 | *) 65 | echo "Unknown build type: $mode" 66 | exit 1 67 | ;; 68 | esac 69 | 70 | case "$weval" in 71 | -weval) 72 | echo "ac_add_options --enable-portable-baseline-interp-force" >> "$mozconfig" 73 | echo "ac_add_options --enable-aot-ics" >> "$mozconfig" 74 | echo "ac_add_options --enable-aot-ics-force" >> "$mozconfig" 75 | echo "ac_add_options --enable-pbl-weval" >> "$mozconfig" 76 | ;; 77 | esac 78 | 79 | # For a full build (not a rebuild), we need to clone the repo and do some setup work. 80 | # `rebuild.sh` invokes this script with REBUILD_ENGINE=1 which sets rebuild=1 81 | # and skips this setup. 82 | if [[ $rebuild == 0 ]]; then 83 | # Ensure the Rust version matches that used by Gecko, and can compile to WASI 84 | rustup target add wasm32-wasi 85 | 86 | fetch_commits= 87 | if [[ ! -a gecko-dev ]]; then 88 | 89 | # Clone Gecko repository at the required revision 90 | mkdir gecko-dev 91 | 92 | git -C gecko-dev init 93 | git -C gecko-dev remote add --no-tags -t wasi-embedding \ 94 | origin "$(cat "$script_dir/gecko-repository")" 95 | 96 | fetch_commits=1 97 | fi 98 | 99 | target_rev="$(cat "$script_dir/gecko-revision")" 100 | if [[ -n "$fetch_commits" ]] || \ 101 | [[ "$(git -C gecko-dev rev-parse HEAD)" != "$target_rev" ]]; then 102 | git -C gecko-dev fetch --depth 1 origin "$target_rev" 103 | git -C gecko-dev checkout FETCH_HEAD 104 | fi 105 | 106 | # Use Gecko's build system bootstrapping to ensure all dependencies are 107 | # installed 108 | cd gecko-dev 109 | ./mach --no-interactive bootstrap --application-choice=js --no-system-changes 110 | 111 | # ... except, that doesn't install the wasi-sysroot, which we need, so we do 112 | # that manually. 113 | cd ~/.mozbuild 114 | python3 \ 115 | "${working_dir}/gecko-dev/mach" \ 116 | --no-interactive \ 117 | artifact \ 118 | toolchain \ 119 | --bootstrap \ 120 | --from-build \ 121 | sysroot-wasm32-wasi 122 | fi 123 | 124 | cd "$working_dir" 125 | 126 | # Build SpiderMonkey for WASI 127 | MOZCONFIG="${mozconfig}" \ 128 | MOZ_FETCHES_DIR=~/.mozbuild \ 129 | CC=~/.mozbuild/clang/bin/clang \ 130 | CXX=~/.mozbuild/clang/bin/clang++ \ 131 | AR=~/.mozbuild/clang/bin/llvm-ar \ 132 | python3 "${working_dir}/gecko-dev/mach" \ 133 | --no-interactive \ 134 | build 135 | 136 | # Copy header, object, and static lib files 137 | rm -rf "$outdir" 138 | mkdir -p "$outdir/lib" 139 | 140 | cd "$objdir" 141 | cp -Lr dist/include "../$outdir" 142 | 143 | while read -r file; do 144 | cp "$file" "../$outdir/lib" 145 | done < "$script_dir/object-files.list" 146 | 147 | cp js/src/build/libjs_static.a "wasm32-wasi/${mode}/libjsrust.a" "../$outdir/lib" 148 | -------------------------------------------------------------------------------- /download-engine.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eo pipefail 4 | 5 | script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" 6 | 7 | # # Get github repository url 8 | gh_url='https://github.'$(cd "$script_dir" && git remote get-url origin | cut -f2 -d. | tr ':' /) 9 | 10 | mode="release" 11 | if [[ $1 == "debug" ]] 12 | then 13 | mode="debug" 14 | fi 15 | weval="" 16 | if [[ $2 == "weval" ]] 17 | then 18 | weval="_weval" 19 | fi 20 | 21 | git_rev="$(git -C "$script_dir" rev-parse HEAD)" 22 | file="spidermonkey-wasm-static-lib_${mode}${weval}.tar.gz" 23 | bundle_url="${gh_url}/releases/download/rev_${git_rev}/${file}" 24 | 25 | curl --fail -L -O "$bundle_url" 26 | tar xf "$file" 27 | rm "$file" 28 | -------------------------------------------------------------------------------- /gecko-repository: -------------------------------------------------------------------------------- 1 | https://github.com/bytecodealliance/gecko-dev -------------------------------------------------------------------------------- /gecko-revision: -------------------------------------------------------------------------------- 1 | 7acfe5fcdb611518ecc36f5720cb784fdda1ad08 2 | -------------------------------------------------------------------------------- /object-files.list: -------------------------------------------------------------------------------- 1 | memory/build/Unified_cpp_memory_build0.o 2 | memory/mozalloc/Unified_cpp_memory_mozalloc0.o 3 | mozglue/misc/AutoProfilerLabel.o 4 | mozglue/misc/ConditionVariable_noop.o 5 | mozglue/misc/MmapFaultHandler.o 6 | mozglue/misc/Mutex_noop.o 7 | mozglue/misc/Printf.o 8 | mozglue/misc/StackWalk.o 9 | mozglue/misc/TimeStamp.o 10 | mozglue/misc/TimeStamp_posix.o 11 | mozglue/misc/Uptime.o 12 | mozglue/misc/Decimal.o 13 | mfbt/lz4.o 14 | mfbt/lz4frame.o 15 | mfbt/lz4hc.o 16 | mfbt/xxhash.o 17 | mfbt/Unified_cpp_mfbt0.o 18 | mfbt/Unified_cpp_mfbt1.o 19 | -------------------------------------------------------------------------------- /rebuild.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | export REBUILD_ENGINE=1 4 | exec $(dirname $0)/build-engine.sh "$@" 5 | -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "1.77.1" 3 | targets = [ "wasm32-wasi" ] 4 | profile = "minimal" 5 | --------------------------------------------------------------------------------