Skip to content
Closed
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
21 changes: 21 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,27 @@ jobs:
- name: Run tests
run: cargo test --verbose

build-fedora:
runs-on: fedora-latest

steps:
- uses: actions/checkout@v4
- name: Install LLVM 14
run: |
sudo dnf update
sudo dnf install -y llvm14 llvm14-devel clang clang-libs
sudo ln -s /usr/lib64/llvm14/lib/libLLVM-14.so /usr/lib64/libllvm14.so
- name: Set LLVM environment variables
run: |
export LLVM_SYS_140_PREFIX=/usr/lib64/llvm14
- name: Build
run: |
source ~/.bashrc
cargo clean
cargo build --verbose
- name: Run tests
run: cargo test --verbose

build-macos:
runs-on: macos-latest

Expand Down
4 changes: 4 additions & 0 deletions llvm_temporary/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ fn linux_original() {
println!("cargo:rustc-link-lib=llvm-14");
println!("cargo:rustc-link-search=native=/usr/lib/llvm-14/lib");

println!("cargo:rustc-env=WAVE_LLVM_MAJOR=14");

println!("cargo:rustc-link-lib=stdc++");
println!("cargo:rustc-link-lib=ffi");
println!("cargo:rustc-link-lib=z");
Expand All @@ -53,6 +55,7 @@ fn try_macos_paths() {
}

fn link_macos(prefix: PathBuf) {
println!("cargo:rustc-env=WAVE_LLVM_MAJOR=14");
let lib = prefix.join("lib");

println!("cargo:rustc-link-search=native={}", lib.display());
Expand Down Expand Up @@ -83,6 +86,7 @@ fn try_windows_paths() {
}

fn link_windows(prefix: PathBuf) {
println!("cargo:rustc-env=WAVE_LLVM_MAJOR=14");
let lib = prefix.join("lib");

println!("cargo:rustc-link-search=native={}", lib.display());
Expand Down
5 changes: 5 additions & 0 deletions llvm_temporary/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
pub mod llvm_temporary;

pub fn backend() -> Option<String> {
option_env!("WAVE_LLVM_MAJOR")
.map(|v| format!("LLVM {}", v))
}
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use colorex::Colorize;
use crate::version::get_os_pretty_name;

use commands::DebugFlags;
use llvm_temporary::backend;

pub unsafe fn compile_and_run(path: &Path, opt_flag: &str, debug: &DebugFlags) {
runner::run_wave_file(path, opt_flag, debug);
Expand All @@ -26,4 +27,10 @@ pub fn version_wave() {
version::version().color("2,161,47"),
os
);

if let Some(backend) = backend() {
println!(" backend: {}", backend.color("117,117,117"));
} else {
println!("{}", " backend: unknown backend".color("117,117,117"));
}
}
81 changes: 68 additions & 13 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,29 +85,84 @@ fn print_usage() {
}

fn print_help() {
println!("{}", "Wave Compiler — Commands & Options".color("145,161,2"));
println!("{}", "Wave Compiler".color("145,161,2"));
println!("{}", "Commands & Options");
print_usage();

println!("\nCommands:");
println!(" {} {}", "run <file>".color("38,139,235"), "Execute Wave file");
println!(" {} {}", "build <file>".color("38,139,235"), "Compile Wave file");
println!(" {} {}", "--help".color("38,139,235"), "Show help");
println!(" {} {}", "--version".color("38,139,235"), "Show version");
println!(
" {:<18} {}",
"run <file>".color("38,139,235"),
"Execute Wave file"
);
println!(
" {:<18} {}",
"build <file>".color("38,139,235"),
"Compile Wave file"
);
println!(
" {:<18} {}",
"--help".color("38,139,235"),
"Show this help message"
);
println!(
" {:<18} {}",
"--version".color("38,139,235"),
"Show compiler version"
);

println!("\nOptimization:");
println!(" -O0, -O1, -O2, -O3, -Oz, -Ofast");
println!(
" {:<18} {}",
"-O0 .. -O3".color("38,139,235"),
"Set optimization level"
);
println!(
" {:<18} {}",
"-Oz".color("38,139,235"),
"Optimize for binary size"
);
println!(
" {:<18} {}",
"-Ofast".color("38,139,235"),
"Enable aggressive optimizations"
);

println!("\nDebug options:");
println!(" --debug-wave=tokens");
println!(" --debug-wave=ast");
println!(" --debug-wave=ir");
println!(" --debug-wave=mc");
println!(" --debug-wave=hex");
println!(" --debug-wave=all");
println!(
" {:<22} {}",
"--debug-wave=tokens".color("38,139,235"),
"Print lexer tokens"
);
println!(
" {:<22} {}",
"--debug-wave=ast".color("38,139,235"),
"Print AST"
);
println!(
" {:<22} {}",
"--debug-wave=ir".color("38,139,235"),
"Print LLVM IR"
);
println!(
" {:<22} {}",
"--debug-wave=mc".color("38,139,235"),
"Print machine code"
);
println!(
" {:<22} {}",
"--debug-wave=hex".color("38,139,235"),
"Print raw hex output"
);
println!(
" {:<22} {}",
"--debug-wave=all".color("38,139,235"),
"Enable all debug outputs"
);

println!("\nExamples:");
println!(" wavec run test.wave");
println!(" wavec run -O3 test.wave");
println!(" wavec run --debug-wave=ir test.wave");
println!(" wavec run -Ofast --debug-wave=all test.wave");
}
}
Loading