Skip to content

Commit

Permalink
chore: update rust toolchain and several misc changes (#1732)
Browse files Browse the repository at this point in the history
Misc changes while working on other stuff

- Update rust to 1.67.1 and made change to .cargo/config.toml to get it to work
- Changed hangar so that it stops spitting out `undefined` when the cli errors
- Updated wasi-sdk to the latest version, and changed the install scripts that it installs a tool within the repo itself (gitignored)
  - This avoids using sudo in the install
  - It is also now a versioned dir, this should make it easier to make sure everyone stays in sync whenever it changes
- Added WingPoint, and made better use of `Into`, `From`, and `Default` so that and WingSpan for some hopefully more idiomatic rust experiences
- Added "lint" as a cached nx operation. This should be okay since it relies on changes to src files
- Made sure clippy runs with release and a couple of other flags when needed, to avoid unnecessary compilations in CI
- Run rustfmt in "lint"
- Add "--fix" arg to clippy

Fixes #813

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Monada Contribution License](https://docs.winglang.io/terms-and-policies/contribution-license.html)*.
  • Loading branch information
MarkMcCulloh authored Mar 6, 2023
1 parent 5b1c4ab commit 4fbf84d
Show file tree
Hide file tree
Showing 28 changed files with 317 additions and 258 deletions.
5 changes: 3 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[env]
CC_wasm32_wasi = "/opt/wasi-sdk/bin/clang"
AR_wasm32_wasi = "/opt/wasi-sdk/bin/ar"
WASI_SDK = { value = ".cargo/wasi-sdk-19.0", relative = true }
CC_wasm32_wasi = { value = ".cargo/wasi-sdk-19.0/bin/clang", relative = true }
AR_wasm32_wasi = { value = ".cargo/wasi-sdk-19.0/bin/ar", relative = true }
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ env:
# Testing runs out of memory without this
NODE_OPTIONS: "--max-old-space-size=4096"
PROJEN_BUMP_VERSION: "0.0.0-dev.${{ github.run_id }}.${{ github.run_attempt }}"
RUST_VERSION: "1.66.0"
RUST_VERSION: "1.67.1"

jobs:
prepare:
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
components: rustfmt
components: rustfmt,clippy
override: true

- name: Setup Cargo Cache
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
node_modules/
.env

# WASI SDK (insalled by "npm install")
.cargo/wasi-sdk-*/

# Generated wing output
*.w.out/

Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions apps/wing-playground/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions apps/wing/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/06-contributors/020-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ separately).

:::note

The first time you run `npm install` you may be asked to enter your system password, this is because
it's taking care of installing the [wasi-sdk](https://github.com/WebAssembly/wasi-sdk) for you.
The first time you run `npm install` it may take extra time to install the
[wasi-sdk](https://github.com/WebAssembly/wasi-sdk) for you. This is needed to compile Wing for WASM.

If you wish to install it manually, you may do so by running `scripts/setup_wasi.sh`

Expand Down
49 changes: 18 additions & 31 deletions libs/tree-sitter-wing/bindings/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,26 @@ fn main() {
.expect("Generating parser");

let mut c_config = cc::Build::new();
c_config.include(src_dir);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-Wno-unused-but-set-variable")
.flag_if_supported("-Wno-trigraphs");
let parser_path = src_dir.join("parser.c");
c_config.file(&parser_path);

// If your language uses an external scanner written in C,
// then include this block of code:

/*
let scanner_path = src_dir.join("scanner.c");
c_config.file(&scanner_path);
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
*/
.include(src_dir)
.flag("-Wno-unused-parameter")
.flag("-Wno-unused-but-set-variable")
.flag("-Wno-trigraphs")
.file(&src_dir.join("parser.c"));

if cfg!(target_arch = "wasm32") {
// This parser is used in a WASI context, so it needs to be compiled with
// the sysroot and other tools needed for WASI-compatible C
c_config.flag(
format!(
"--sysroot={}/share/wasi-sysroot",
env!("WASI_SDK", "WASI_SDK env not set")
)
.as_str(),
);
}

c_config.compile("parser");
println!("cargo:rerun-if-changed=grammar.js");

// If your language uses an external scanner written in C++,
// then include this block of code:

/*
let mut cpp_config = cc::Build::new();
cpp_config.cpp(true);
cpp_config.include(&src_dir);
cpp_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-Wno-unused-but-set-variable");
let scanner_path = src_dir.join("scanner.cc");
cpp_config.file(&scanner_path);
cpp_config.compile("scanner");
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
*/
println!("cargo:rerun-if-changed=grammar.js");
}
7 changes: 3 additions & 4 deletions libs/wingc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
tree-sitter = "0.20.9"
tree-sitter-traversal = "0.1.2"
sha2 = "0.10.6"
base16ct = { version = "0.1.1", features = ["alloc"] }
base16ct = { version = "0.2.0", features = ["alloc"] }
derivative = "2.2.0"
tree-sitter-wing = { path = "../tree-sitter-wing" }
wingii = { path = "../wingii" }
Expand All @@ -20,9 +20,8 @@ inflections = "1.1.1"
phf = { version = "0.11", features = ["macros"] }
indexmap = "1.9.1"
aho-corasick = "0.7.20"
lsp-types = "0.93.2"
lsp-types = "0.94.0"
indoc = "2.0.0"

[lib]
path = "src/lib.rs"
crate-type = ["cdylib", "rlib"]
crate-type = ["rlib", "cdylib"]
10 changes: 8 additions & 2 deletions libs/wingc/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@
"lint": {
"executor": "nx:run-commands",
"options": {
"command": "cargo clippy",
"cwd": "libs/wingc"
"commands": ["cargo fmt", "cargo clippy --no-deps --fix --allow-dirty"],
"cwd": "libs/wingc",
"parallel": false
},
"configurations": {
"release": {
"commands": ["cargo fmt --check", "cargo clippy --no-deps --release"]
}
}
},
"build": {
Expand Down
6 changes: 3 additions & 3 deletions libs/wingc/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ pub struct Symbol {
}

impl Symbol {
pub fn global(name: &str) -> Self {
pub fn global<S: Into<String>>(name: S) -> Self {
Self {
name: name.to_string(),
span: WingSpan::global(),
name: name.into(),
span: Default::default(),
}
}
}
Expand Down
Loading

0 comments on commit 4fbf84d

Please sign in to comment.