feat: add __lang/rusty_jsc/, build_readme.rs

This commit is contained in:
2022-08-28 11:40:00 +08:00
parent 5d1372905f
commit 0b0d4f2f9c
8 changed files with 325 additions and 2 deletions

View File

@@ -89,6 +89,7 @@ Project or files:
│   ├── peg
│   ├── pest
│   ├── quickjs
│   ├── rusty_jsc
│   └── sana
├── __linux
│   ├── ipipe
@@ -212,6 +213,11 @@ Project or files:
│   ├── sincere
│   ├── tide
│   └── warp
├── build_readme.rs -> build_readme_rs/src/main.rs
│   ├── Cargo.lock
│   ├── Cargo.toml
│   ├── src
│   └── target
├── scripts
│   └── commit-msg.crs
└── single_file_tests
@@ -238,7 +244,6 @@ Project or files:
├── vec.rs
└── while.rs
207 directories, 36 files
211 directories, 39 files
```

34
__lang/rusty_jsc/Cargo.lock generated Normal file
View File

@@ -0,0 +1,34 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "pkg-config"
version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
[[package]]
name = "rusty_jsc"
version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97f314ea60a5ccbadc997f67a5bca81dc48e7058850e44f05911ce7f22c307de"
dependencies = [
"rusty_jsc_sys",
]
[[package]]
name = "rusty_jsc"
version = "0.1.0"
dependencies = [
"rusty_jsc 0.0.1",
]
[[package]]
name = "rusty_jsc_sys"
version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e139e91ef225f39929b7e8228584500dafd1fa407f2aedd45faa30398f0568c2"
dependencies = [
"pkg-config",
]

View File

@@ -0,0 +1,10 @@
[package]
name = "rusty_jsc"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rusty_jsc = "0.0.1"

View File

@@ -0,0 +1,17 @@
use rusty_jsc::JSContext;
fn main() {
let mut context = JSContext::default();
match context.evaluate_script("'hello, world'", 1) {
Some(value) => {
println!("{}", value.to_string(&context));
}
None => {
println!(
"Uncaught: {}",
context.get_exception().unwrap().to_string(&context)
)
}
}
}

1
build_readme.rs Symbolic link
View File

@@ -0,0 +1 @@
build_readme_rs/src/main.rs

208
build_readme_rs/Cargo.lock generated Normal file
View File

@@ -0,0 +1,208 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "build_readme_rs"
version = "0.1.0"
dependencies = [
"rust_util",
]
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "dirs-next"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1"
dependencies = [
"cfg-if",
"dirs-sys-next",
]
[[package]]
name = "dirs-sys-next"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
dependencies = [
"libc",
"redox_users",
"winapi",
]
[[package]]
name = "getrandom"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6"
dependencies = [
"cfg-if",
"libc",
"wasi",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.132"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5"
[[package]]
name = "proc-macro2"
version = "1.0.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
dependencies = [
"proc-macro2",
]
[[package]]
name = "redox_syscall"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
dependencies = [
"bitflags",
]
[[package]]
name = "redox_users"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b"
dependencies = [
"getrandom",
"redox_syscall",
"thiserror",
]
[[package]]
name = "rust_util"
version = "0.6.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df24005feacce81f4ae340464b39c380f7e01e7225bfdef62d40cb44cb1c11d7"
dependencies = [
"lazy_static",
"libc",
"term",
"term_size",
]
[[package]]
name = "rustversion"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8"
[[package]]
name = "syn"
version = "1.0.99"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "term"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f"
dependencies = [
"dirs-next",
"rustversion",
"winapi",
]
[[package]]
name = "term_size"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "thiserror"
version = "1.0.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "unicode-ident"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf"
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

View File

@@ -0,0 +1,10 @@
[package]
name = "build_readme_rs"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rust_util = { version = "0.6" }

38
build_readme_rs/src/main.rs Executable file
View File

@@ -0,0 +1,38 @@
#!/usr/bin/env runrs
//! ```cargo
//! [dependencies]
//! rust_util = { version = "0.6" }
//! ```
use std::fs;
use rust_util::{failure_and_exit, opt_result, util_cmd, XResult};
fn main() -> XResult<()> {
let readme_template_file = "README_template.md";
let readme_template = opt_result!(fs::read_to_string(readme_template_file),
"Read {} failed: {}", readme_template_file);
let output = util_cmd::run_command_or_exit("tree", &["-L", "2"]);
if !output.status.success() {
failure_and_exit!("Run tree -L 2 failed: {}", output.status);
}
let tree_output = String::from_utf8_lossy(&output.stdout).to_string();
let tree_output_lines = tree_output.lines();
let mut tree_lines = vec![];
let ignored_file_list = vec![
"LICENSE", "README.md", "README_template.md",
"build_readme.js", "build_readme_rs",
];
for ln in tree_output_lines {
let ignored = ignored_file_list.iter().any(|f| ln.ends_with(f));
if !ignored {
tree_lines.push(ln);
}
}
let joined_tree_lines = tree_lines.join("\n");
let readme = readme_template.replace("$$TREE_L2$$", &joined_tree_lines);
opt_result!(fs::write("README.md", readme), "Write README.md failed: {}");
Ok(())
}