~garritfra/antimony

5ab35ac3afe1632613b117c3e82e7cb1318b0e5f — Garrit Franke 9 months ago dac2038 + e820bd9 backend-flag
Merge branch 'master' into backend-flag
4 files changed, 14 insertions(+), 6 deletions(-)

M .builds/ci.yml
M contrib/PKGBUILD
M src/builder/mod.rs
M src/generator/c.rs
M .builds/ci.yml => .builds/ci.yml +2 -1
@@ 1,11 1,12 @@
image: archlinux
packages:
  - rust
  - node
  - nodejs
sources:
  - https://git.sr.ht/~garritfra/antimony
tasks:
  - build: |
      cd antimony
      cargo build
      cargo test
      cargo clippy --all-targets -- -D warnings

M contrib/PKGBUILD => contrib/PKGBUILD +2 -2
@@ 1,7 1,7 @@
# Maintainer: Garrit Franke <garrit@slashdev.space>
# Contributor: Alexey Yerin <yyp@disroot.org>
pkgname="antimony-git"
pkgver=v0.4.0.r7.fe7b035
pkgver=v0.5.1.r1.fd08c6a
pkgrel=1
pkgdesc="The bullshit-free programming language"
url="https://github.com/antimony-lang/antimony"


@@ 39,5 39,5 @@ check() {
package() {
	cd "${srcdir}/antimony"

	install -Dm755 target/release/antimony "${pkgdir}/usr/bin/antimony"
	install -Dm755 target/release/sb "${pkgdir}/usr/bin/sb"
}

M src/builder/mod.rs => src/builder/mod.rs +7 -0
@@ 50,6 50,10 @@ impl Builder {
        let in_file = self.in_file.clone();
        // Resolve path deltas between working directory and entrypoint
        let base_directory = self.get_base_path()?;

        // During building, we change the environment directory.
        // After we're done, we have to set it back to the initial directory.
        let initial_directory = env::current_dir().expect("Current directory does not exist");
        if let Ok(resolved_delta) = in_file.strip_prefix(&base_directory) {
            // TODO: This error could probably be handled better
            let _ = env::set_current_dir(base_directory);


@@ 59,6 63,9 @@ impl Builder {

        // Append standard library
        self.build_stdlib();

        // Change back to the initial directory
        env::set_current_dir(initial_directory).expect("Could not set current directory");
        Ok(())
    }


M src/generator/c.rs => src/generator/c.rs +3 -3
@@ 53,13 53,13 @@ pub(super) fn generate_type(t: Either<Variable, Option<Type>>) -> String {
            Type::Any => "void *".into(),
            Type::Bool => "bool".into(),
            Type::Struct(_) => todo!(),
            Type::Array(_) => match name {
            Type::Array(t) => match name {
                Some(n) => format!(
                    "{T} {N}[]",
                    T = generate_type(Either::Right(Some(t))),
                    T = generate_type(Either::Right(Some(*t))),
                    N = n
                ),
                None => format!("{}[]", generate_type(Either::Right(Some(t)))),
                None => format!("{}[]", generate_type(Either::Right(Some(*t)))),
            },
        },
        None => "void".into(),