Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fornwall committed Feb 8, 2024
1 parent 6d9fb04 commit e4f1aed
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 315 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ target
/.cargo
/.idea
*.zip
tmp/
2 changes: 1 addition & 1 deletion Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "rust-gpu-compiler"
version = "0.34.0"
version = "0.1.0"
edition = "2021"
rust-version = "1.64"
rust-version = "1.75"
authors = ["Fredrik Fornwall <[email protected]>"]
description = "Command-line tool to TODO"
homepage = "https://rust-script.org"
Expand Down
18 changes: 14 additions & 4 deletions build-zip.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
set -e -u

RUST_GPU_REVISION=8678d58d61a78f01201ec854cb5e3835c014fa3b
Expand All @@ -8,15 +8,24 @@ CHANNEL=nightly-2023-09-30
# Install nightly toolchain
rustup uninstall $CHANNEL # To avoid old targets
rustup install --profile minimal $CHANNEL
RUSTUP_TOOLCHAIN_FOLDER=$HOME/.rustup/toolchains/${CHANNEL}-${TARGET}
du -sh $RUSTUP_TOOLCHAIN_FOLDER
# rustup install $CHANNEL
rustup component add rust-src rustc-dev llvm-tools --toolchain $CHANNEL
RUSTUP_TOOLCHAIN_FOLDER=${CHANNEL}-${TARGET}
RUSTUP_TOOLCHAIN_PATH=$HOME/.rustup/toolchains/$RUSTUP_TOOLCHAIN_FOLDER
du -sh $RUSTUP_TOOLCHAIN_PATH

# Bundle toolchain up before building (which bloats toolchain dir)
BUILD_DIR=target/rust-gpu-compiler-distribution
rm -Rf $BUILD_DIR
mkdir -p $BUILD_DIR
cd $BUILD_DIR
cp -Rf $RUSTUP_TOOLCHAIN_FOLDER .
cp -Rf $RUSTUP_TOOLCHAIN_PATH .
# Trim away not needed parts:
# rm -Rf $RUSTUP_TOOLCHAIN_FOLDER/lib/rustlib
rm -Rf $RUSTUP_TOOLCHAIN_FOLDER/{etc,libexec,share}
rm $RUSTUP_TOOLCHAIN_FOLDER/bin/{rust-gdb,rust-gdbgui,rust-lldb,rustdoc}
# llvm-strip --strip-unneeded $RUSTUP_TOOLCHAIN_FOLDER/lib/*.so
llvm-strip --strip-unneeded $RUSTUP_TOOLCHAIN_FOLDER/bin/*
cd ../../

# Build rust-gpu-compiler
Expand All @@ -37,5 +46,6 @@ cd ../..
cd $BUILD_DIR
cp ../$TARGET/release/rust-gpu-compiler .
cp ../$RUSTGPU_DIR/target/$TARGET/release/librustc_codegen_spirv.so .
llvm-strip --strip-unneeded librustc_codegen_spirv.so rust-gpu-compiler
zip ../../rust-gpu-compiler.zip -r .
cd ../../
4 changes: 4 additions & 0 deletions examples/shader.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//! ```cargo
//! [dependencies]
//! microjson = "0.1.2"
//! ```
#![no_std]

use spirv_std::glam::{vec4, Vec4};
Expand Down
7 changes: 0 additions & 7 deletions rust-toolchain.toml

This file was deleted.

51 changes: 2 additions & 49 deletions src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ pub struct Args {
pub clear_cache: bool,
pub debug: bool,
pub force: bool,
pub toolchain_version: Option<String>,
#[cfg(windows)]
pub install_file_association: bool,
#[cfg(windows)]
pub uninstall_file_association: bool,
}

impl Args {
Expand Down Expand Up @@ -77,7 +72,7 @@ impl Args {
.short('p')
.action(ArgAction::SetTrue)
.requires("shader")
.conflicts_with_all(["debug", "force", "test", "bench"])
.conflicts_with_all(["debug", "force", "test"])
)
.arg(Arg::new("pkg_path")
.help("Specify where to place the generated Cargo package")
Expand All @@ -90,44 +85,7 @@ impl Args {
.help("Compile and run tests")
.long("test")
.action(ArgAction::SetTrue)
.conflicts_with_all(["bench", "debug", "force"])
)
.arg(Arg::new("bench")
.help("Compile and run benchmarks. Requires a nightly toolchain")
.long("bench")
.action(ArgAction::SetTrue)
.conflicts_with_all(["test", "debug", "force"])
)
.arg(Arg::new("toolchain")
.help("Build the script using the given toolchain version")
.long("toolchain")
.short('t')
.num_args(1)
// Benchmarking currently requires nightly:
.conflicts_with("bench")
);

#[cfg(windows)]
let app = app
.arg(
Arg::new("install-file-association")
.help("Install a file association so that rust-script executes .ers files")
.long("install-file-association")
.exclusive(true)
.action(ArgAction::SetTrue),
)
.arg(
Arg::new("uninstall-file-association")
.help(
"Uninstall the file association that makes rust-script execute .ers files",
)
.long("uninstall-file-association")
.exclusive(true)
.action(ArgAction::SetTrue),
)
.group(
ArgGroup::new("file-association")
.args(["install-file-association", "uninstall-file-association"]),
.conflicts_with_all(["debug", "force"])
);

let mut m = app.get_matches();
Expand Down Expand Up @@ -160,11 +118,6 @@ impl Args {
clear_cache: m.get_flag("clear-cache"),
debug: m.get_flag("debug"),
force: m.get_flag("force"),
toolchain_version: m.get_one::<String>("toolchain").map(Into::into),
#[cfg(windows)]
install_file_association: m.get_flag("install-file-association"),
#[cfg(windows)]
uninstall_file_association: m.get_flag("uninstall-file-association"),
}
}
}
11 changes: 0 additions & 11 deletions src/consts.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
/*!
This module just contains any big string literals I don't want cluttering up the rest of the code.
*/

pub const PROGRAM_NAME: &str = "rust-gpu";

/*
What follows are the templates used to wrap script input.
*/

/// Substitution for the script body.
pub const SCRIPT_BODY_SUB: &str = "script";

/**
When generating a package's unique ID, how many hex nibbles of the digest should be used *at most*?
Expand Down
101 changes: 0 additions & 101 deletions src/file_assoc.rs

This file was deleted.

Loading

0 comments on commit e4f1aed

Please sign in to comment.