erg-lang / erg

A statically typed language compatible with Python
http://erg-lang.org
Apache License 2.0
2.69k stars 55 forks source link

Added cargo command aliases, and cfg target for Windows #183

Closed GreasySlug closed 2 years ago

GreasySlug commented 2 years ago

If compiling with cargo, long commands need to be typed, but this allows execution with short commands. If you prefer some other alias name, please give me some suggestions.

Threads are used for windows, but this is not necessary for Unix/Linux. So, use cfg to target Windows only.

@mtshiba

GreasySlug commented 2 years ago
name: Rust

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

env:
  CARGO_TERM_COLOR: always

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - uses: Swatinem/rust-cache@v2
    - name: Build
      run: cargo build --verbose
    - name: Run tests
      run: cargo test --verbose
    - uses: actions-rs/cargo@v1
      with:
        command: clippy
        args: -- -D warnings

It seems that only Ubuntu is supported, so please can I request Windows support? https://docs.github.com/ja/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources

GreasySlug commented 2 years ago

cfg!(windows) doesn't ignore platform dependencies. In the future, when writing low-level processes such as read and terminal, dependencies will be required for each platform. It is a good idea to write processes that take this into account now.

The code below is not good, but it works.

#[cfg(target_os = "windows")]
fn main() {
    const STACK_SIZE: usize = 4 * 1024 * 1024;

    let child = thread::Builder::new()
        .stack_size(STACK_SIZE)
        .spawn(run)
        .unwrap();

    // Wait for thread to join
    child.join().unwrap();
}

#[cfg(not(target_os = "windows"))]
fn main() {
    run();
}
mtshiba commented 2 years ago

It seems to fail to build on Ubuntu.

mtshiba commented 2 years ago

Thanks!