-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[autorelease] Add JavaScript package.
- Loading branch information
1 parent
c09bae5
commit 12f5322
Showing
38 changed files
with
663 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/package-lock.json | ||
/package.json | ||
/node_modules | ||
/dist | ||
|
||
/*.wasm | ||
/gen | ||
/share | ||
/index.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"name": "@yowasp/nextpnr-__ARCH__", | ||
"version": "__VERSION__", | ||
"description": "nextpnr-__ARCH__ FPGA place and route tool", | ||
"author": "Catherine <[email protected]>", | ||
"license": "ISC", | ||
"homepage": "https://yowasp.org/", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/YoWASP/nextpnr.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/YoWASP/nextpnr/issues" | ||
}, | ||
"type": "module", | ||
"files": [ | ||
"lib/api.d.ts", | ||
"gen/bundle-*.js", | ||
"gen/resources-*.js", | ||
"gen/*.wasm", | ||
"gen/share/" | ||
], | ||
"exports": { | ||
"node": "./gen/bundle-node.js", | ||
"browser": "./gen/bundle-browser.js", | ||
"types": "./lib/api.d.ts" | ||
}, | ||
"types": "./lib/api.d.ts", | ||
"devDependencies": { | ||
"@bytecodealliance/jco": "^0.14.1", | ||
"@yowasp/runtime": "5.0.28", | ||
"esbuild": "^0.19.8" | ||
}, | ||
"scripts": { | ||
"pack": "yowasp-pack-resources gen/resources-nextpnr-__ARCH__.js gen share", | ||
"transpile": "jco new __FILENAME__ --wasi-command --output __BASENAME__ && jco transpile __BASENAME__ --instantiation async --no-typescript --no-namespaced-exports --map 'wasi:io/*=runtime#io' --map 'wasi:cli/*=runtime#cli' --map 'wasi:clocks/*=runtime#*' --map 'wasi:filesystem/*=runtime#fs' --map 'wasi:random/*=runtime#random' --out-dir gen/", | ||
"build:node": "esbuild --bundle lib/api.js --outfile=gen/bundle-node.js --format=esm --platform=node", | ||
"build:browser": "esbuild --bundle lib/api.js --outfile=gen/bundle-browser.js --format=esm --platform=browser", | ||
"all": "npm run transpile && npm run pack && npm run build:node && npm run build:browser" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import os | ||
import re | ||
import sys | ||
import json | ||
import subprocess | ||
|
||
|
||
arch = sys.argv[1] | ||
|
||
|
||
nextpnr_version_raw = subprocess.check_output([ | ||
"git", "-C", "../nextpnr-src", "describe", "--tags", "HEAD" | ||
], encoding="utf-8").strip() | ||
|
||
git_rev_list_raw = subprocess.check_output([ | ||
"git", "rev-list", "HEAD" | ||
], encoding="utf-8").split() | ||
|
||
nextpnr_version = re.match(r"^nextpnr-(\d+).(\d+)(?:-(\d+)-)?", nextpnr_version_raw) | ||
nextpnr_major = int(nextpnr_version[1]) | ||
nextpnr_minor = int(nextpnr_version[2]) | ||
nextpnr_node = int(nextpnr_version[3] or "0") | ||
|
||
distance = len(git_rev_list_raw) - 1 | ||
|
||
if os.environ.get("RELEASE_BRANCH", "false") in ("true", "1", "yes"): | ||
version = f"{nextpnr_major}.{nextpnr_minor}.{distance}" | ||
else: | ||
version = f"{nextpnr_major}.{nextpnr_minor + 1}.{nextpnr_node}-dev.{distance}" | ||
print(f"version {version}") | ||
|
||
|
||
with open("package-local.json", "rt") as f: | ||
package_local = json.load(f) | ||
with open("package-in.json", "rt") as f: | ||
package_json = json.load(f) | ||
package_json["version"] = version | ||
package_json["name"] = package_json["name"].replace("__ARCH__", arch) | ||
package_json["description"] = package_json["description"].replace("__ARCH__", arch) | ||
package_json["scripts"]["pack"] = package_json["scripts"]["pack"].replace("__ARCH__", arch) | ||
transpile_commands = [] | ||
for transpile_file in package_local["scripts"]["transpile"]: | ||
transpile_commands.append(package_json["scripts"]["transpile"] | ||
.replace("__FILENAME__", transpile_file) | ||
.replace("__BASENAME__", os.path.basename(transpile_file))) | ||
package_json["scripts"]["transpile"] = " && ".join(transpile_commands) | ||
with open("package.json", "wt") as f: | ||
json.dump(package_json, f, indent=2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/package-lock.json | ||
/package.json | ||
/node_modules | ||
/dist | ||
|
||
/*.wasm | ||
/gen | ||
/share | ||
/index.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
export type Tree = { | ||
[name: string]: Tree | string | Uint8Array | ||
}; | ||
|
||
export class Exit extends Error { | ||
code: number; | ||
files: Tree; | ||
} | ||
|
||
export type Command = (args?: string[], files?: Tree, options?: { | ||
printLine?: (line: string) => void, | ||
decodeASCII?: boolean | ||
}) => Promise<Tree>; | ||
|
||
|
||
export const runEcppll: Command; | ||
export const runEcpbram: Command; | ||
export const runEcpmulti: Command; | ||
export const runEcppack: Command; | ||
export const runEcpunpack: Command; | ||
export const runNextpnrEcp5: Command; | ||
|
||
export const commands: { | ||
'ecppll': Command, | ||
'ecpbram': Command, | ||
'ecpmulti': Command, | ||
'ecppack': Command, | ||
'ecpunpack': Command, | ||
'nextpnr-ecp5': Command, | ||
}; |
Oops, something went wrong.