Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: "nightly"
toolchain: "stable"
rustflags: "-A warnings"
- run: cargo check
- run: cargo test
11 changes: 9 additions & 2 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@ git clone https://github.com/$USER/goboscript
cd goboscript
```

Install and set the default Rust toolchain to nightly:
Install and set the default Rust toolchain to stable:

```bash
rustup toolchain install stable
rustup default stable
```

Formatting still uses nightly rustfmt options (`cargo +nightly fmt`), so install
nightly too:

```bash
rustup toolchain install nightly
rustup default nightly
```

## Development
Expand Down
14 changes: 4 additions & 10 deletions docs/install.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# Install

!!! tip
goboscript requires the **nightly** Rust toolchain. Install it once with:
```bash
rustup toolchain install nightly
```

## Install from source

Clones and installs the latest version from the git repository. Requires `git` and the
Expand All @@ -14,29 +8,29 @@ Clones and installs the latest version from the git repository. Requires `git` a
```bash
git clone https://github.com/aspizu/goboscript
cd goboscript
cargo +nightly install --path .
cargo install --path .
```

To update:

```bash
cd goboscript
git pull
cargo +nightly install --path .
cargo install --path .
```

## Install from source (using cargo)

Installs the latest version from the git repository in a single command.

```bash
cargo +nightly install --git https://github.com/aspizu/goboscript --locked
cargo install --git https://github.com/aspizu/goboscript --locked
```

To update:

```bash
cargo +nightly install --git https://github.com/aspizu/goboscript --locked --force
cargo install --git https://github.com/aspizu/goboscript --locked --force
```

## Install with nix
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
pkgs = import nixpkgs {
inherit system overlays;
};
rust = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default);
rust = pkgs.rust-bin.stable.latest.default;
in rec {
packages.goboscript = pkgs.callPackage ./default.nix {
inherit (pkgs) pkg-config openssl;
Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(normalize_lexically)]

pub mod ast;
pub mod blocks;
pub mod codegen;
Expand Down
34 changes: 33 additions & 1 deletion src/misc.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,40 @@
use core::fmt;
use std::io;
use std::{
io,
path::{
Component,
Path,
PathBuf,
},
};

use arcstr::ArcStr;

// TODO: Replace with `Path::normalize_lexically` when it becomes stable.
pub fn normalize_lexically(path: &Path) -> PathBuf {
let mut normalized = PathBuf::new();
for component in path.components() {
match component {
Component::CurDir => {}
Component::ParentDir => {
if matches!(
normalized.components().next_back(),
Some(Component::Normal(_))
) {
normalized.pop();
} else if !path.has_root() {
normalized.push("..");
}
}
other => normalized.push(other.as_os_str()),
}
}
if normalized.as_os_str().is_empty() {
normalized.push(".");
}
normalized
}

pub fn write_comma_io<T>(mut file: T, comma: &mut bool) -> io::Result<()>
where T: io::Write {
if *comma {
Expand Down
6 changes: 3 additions & 3 deletions src/translation_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::{
Diagnostic,
DiagnosticKind,
},
misc::normalize_lexically,
standard_library::StandardLibrary,
vfs::VFS,
};
Expand Down Expand Up @@ -71,8 +72,7 @@ impl TranslationUnit {
path: unit.path.clone(),
owner: Owner::Local,
});
unit.included
.insert(unit.path.normalize_lexically().unwrap());
unit.included.insert(normalize_lexically(&unit.path));
Ok(unit)
}

Expand Down Expand Up @@ -311,7 +311,7 @@ fn add_include_to_translation_unit(
(Owner::Local, unit.path.parent().unwrap().join(path))
};

let mut path = path.normalize_lexically().unwrap();
let mut path = normalize_lexically(&path);
if path.extension().is_none_or(|ext| ext != "gs") {
path = path.with_added_extension("gs");
}
Expand Down
Loading