virtual-machine 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.toml +2 -1
- package/README.md +76 -0
- package/build/{riscv_vm-FIEDMHCY.mjs → chunk-GZ343GYI.mjs} +20 -22
- package/build/chunk-Q7TFYQ5G.mjs +670 -0
- package/build/cli.js +707 -688
- package/build/index.d.ts +4 -4
- package/build/index.js +23 -24
- package/build/index.mjs +10 -3
- package/build/riscv_vm-3CIEJ5K7.mjs +12 -0
- package/build/riscv_vm-VNML57ES.mjs +12 -0
- package/build.sh +9 -2
- package/index.ts +1 -1
- package/package.json +1 -1
- package/src/main.rs +15 -5
- package/tsup/index.ts +0 -1
package/build.sh
CHANGED
|
@@ -5,14 +5,21 @@ is_mac() {
|
|
|
5
5
|
[[ "$OSTYPE" == "darwin"* ]]
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
PACKAGEJSON=./pkg/package.json
|
|
10
9
|
IMPORTFILE=./pkg/riscv_vm.js
|
|
11
10
|
|
|
12
11
|
echo "Building the rust library"
|
|
13
12
|
RUSTFLAGS=--cfg=web_sys_unstable_apis npx wasm-pack build --target web
|
|
14
13
|
|
|
14
|
+
if is_mac; then
|
|
15
|
+
sed -i '' 's/"module": "ridb_core.js",/"main": "ridb_core.js",/' $PACKAGEJSON
|
|
16
|
+
sed -i '' "/if (typeof module_or_path === 'undefined') {/,/}/d" $IMPORTFILE
|
|
17
|
+
else
|
|
18
|
+
sed -i 's/"module": "ridb_core.js",/"main": "ridb_core.js",/' $PACKAGEJSON
|
|
19
|
+
sed -i "/if (typeof module_or_path === 'undefined') {/,/}/d" $IMPORTFILE
|
|
20
|
+
fi
|
|
21
|
+
|
|
15
22
|
npx tsup --config tsup/tsup.cli.ts
|
|
16
23
|
npx tsup --config tsup/tsup.core.cjs.ts
|
|
17
24
|
npx tsup --config tsup/tsup.core.esm.ts
|
|
18
|
-
npx tsup --config tsup/tsup.core.cjs.ts --dts-only
|
|
25
|
+
npx tsup --config tsup/tsup.core.cjs.ts --dts-only
|
package/index.ts
CHANGED
package/package.json
CHANGED
package/src/main.rs
CHANGED
|
@@ -13,9 +13,9 @@ use riscv_vm::console::Console;
|
|
|
13
13
|
#[derive(Parser, Debug)]
|
|
14
14
|
#[command(author, version, about, long_about = None)]
|
|
15
15
|
struct Args {
|
|
16
|
-
/// Path to binary to load
|
|
16
|
+
/// Path or URL to binary to load
|
|
17
17
|
#[arg(short, long)]
|
|
18
|
-
kernel:
|
|
18
|
+
kernel: String,
|
|
19
19
|
|
|
20
20
|
/// Address to load kernel at (default 0x8000_0000)
|
|
21
21
|
#[arg(long, default_value_t = 0x8000_0000)]
|
|
@@ -74,9 +74,19 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
|
74
74
|
env_logger::init();
|
|
75
75
|
let args = Args::parse();
|
|
76
76
|
|
|
77
|
-
let
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
let buffer = if args.kernel.starts_with("http://") || args.kernel.starts_with("https://") {
|
|
78
|
+
println!("Downloading kernel from {}...", args.kernel);
|
|
79
|
+
let response = reqwest::blocking::get(&args.kernel)?;
|
|
80
|
+
if !response.status().is_success() {
|
|
81
|
+
return Err(format!("Failed to download kernel: {}", response.status()).into());
|
|
82
|
+
}
|
|
83
|
+
response.bytes()?.to_vec()
|
|
84
|
+
} else {
|
|
85
|
+
let mut file = File::open(&args.kernel)?;
|
|
86
|
+
let mut buffer = Vec::new();
|
|
87
|
+
file.read_to_end(&mut buffer)?;
|
|
88
|
+
buffer
|
|
89
|
+
};
|
|
80
90
|
|
|
81
91
|
let dram_size_bytes = args
|
|
82
92
|
.mem_mib
|