Skip to content

Commit

Permalink
Initial template import for rust version
Browse files Browse the repository at this point in the history
  • Loading branch information
rj45 committed Jul 20, 2024
1 parent 4227437 commit 04876c6
Show file tree
Hide file tree
Showing 127 changed files with 5,255 additions and 144,792 deletions.
6 changes: 6 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# clipboard api is still unstable, so web-sys requires the below flag to be passed for copy (ctrl + c) to work
# https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
# check status at https://developer.mozilla.org/en-US/docs/Web/API/Clipboard#browser_compatibility
# we don't use `[build]` because of rust analyzer's build cache invalidation https://github.com/emilk/eframe_template/issues/93
[target.wasm32-unknown-unknown]
rustflags = ["--cfg=web_sys_unstable_apis"]
48 changes: 48 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Github Pages

# By default, runs if you push to main. keeps your deployed app in sync with main branch.
on:
push:
branches:
- main
# to only run when you do a new github release, comment out above part and uncomment the below trigger.
# on:
# release:
# types:
# - published

permissions:
contents: write # for committing to gh-pages branch.

jobs:
build-github-pages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4 # repo checkout
- name: Setup toolchain for wasm
run: |
rustup update stable
rustup default stable
rustup set profile minimal
rustup target add wasm32-unknown-unknown
- name: Rust Cache # cache the rust build artefacts
uses: Swatinem/rust-cache@v2
- name: Download and install Trunk binary
run: wget -qO- https://github.com/thedodd/trunk/releases/latest/download/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf-
- name: Build # build
# Environment $public_url resolves to the github project page.
# If using a user/organization page, remove the `${{ github.event.repository.name }}` part.
# using --public-url something will allow trunk to modify all the href paths like from favicon.ico to repo_name/favicon.ico .
# this is necessary for github pages where the site is deployed to username.github.io/repo_name and all files must be requested
# relatively as eframe_template/favicon.ico. if we skip public-url option, the href paths will instead request username.github.io/favicon.ico which
# will obviously return error 404 not found.
run: ./trunk build --release --public-url $public_url
env:
public_url: "https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}"
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: dist
# this option will not maintain any history of your previous pages deployment
# set to false if you want all page build to be committed to your gh-pages branch history
single-commit: true
173 changes: 173 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
on: [push, pull_request, workflow_dispatch]

name: CI

env:
# --cfg=web_sys_unstable_apis is required to enable the web_sys clipboard API which egui_web uses
# https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Clipboard.html
# https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
RUSTFLAGS: -D warnings --cfg=web_sys_unstable_apis
RUSTDOCFLAGS: -D warnings

jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: check
args: --all-features

check_wasm:
name: Check wasm32
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: wasm32-unknown-unknown
override: true
- uses: actions-rs/cargo@v1
with:
command: check
args: --all-features --lib --target wasm32-unknown-unknown

test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev
- uses: actions-rs/cargo@v1
with:
command: test
args: --lib

fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings

trunk:
name: trunk
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.76.0
target: wasm32-unknown-unknown
override: true
- name: Download and install Trunk binary
run: wget -qO- https://github.com/thedodd/trunk/releases/latest/download/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf-
- name: Build
run: ./trunk build

build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
TARGET: aarch64-apple-darwin

- os: ubuntu-latest
TARGET: aarch64-unknown-linux-gnu

- os: ubuntu-latest
TARGET: armv7-unknown-linux-gnueabihf

- os: ubuntu-latest
TARGET: x86_64-unknown-linux-gnu

- os: windows-latest
TARGET: x86_64-pc-windows-msvc
EXTENSION: .exe

steps:
- name: Building ${{ matrix.TARGET }}
run: echo "${{ matrix.TARGET }}"

- uses: actions/checkout@master
- name: Install build dependencies - Rustup
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable --profile default --target ${{ matrix.TARGET }} -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
# For linux, it's necessary to use cross from the git repository to avoid glibc problems
# Ref: https://github.com/cross-rs/cross/issues/1510
- name: Install cross for linux
if: contains(matrix.TARGET, 'linux')
run: |
cargo install cross --git https://github.com/cross-rs/cross --rev 1b8cf50d20180c1a394099e608141480f934b7f7
- name: Install cross for mac and windows
if: ${{ !contains(matrix.TARGET, 'linux') }}
run: |
cargo install cross
- name: Build
run: |
cross build --verbose --release --target=${{ matrix.TARGET }}
- name: Rename
run: cp target/${{ matrix.TARGET }}/release/eframe_template${{ matrix.EXTENSION }} eframe_template-${{ matrix.TARGET }}${{ matrix.EXTENSION }}

- uses: actions/upload-artifact@master
with:
name: eframe_template-${{ matrix.TARGET }}${{ matrix.EXTENSION }}
path: eframe_template-${{ matrix.TARGET }}${{ matrix.EXTENSION }}

- uses: svenstaro/upload-release-action@v2
name: Upload binaries to release
if: ${{ github.event_name == 'push' }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: eframe_template-${{ matrix.TARGET }}${{ matrix.EXTENSION }}
asset_name: eframe_template-${{ matrix.TARGET }}${{ matrix.EXTENSION }}
tag: ${{ github.ref }}
prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }}
overwrite: true
19 changes: 19 additions & 0 deletions .github/workflows/typos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copied from https://github.com/rerun-io/rerun_template

# https://github.com/crate-ci/typos
# Add exceptions to `.typos.toml`
# install and run locally: cargo install typos-cli && typos

name: Spell Check
on: [pull_request]

jobs:
run:
name: Spell Check
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v4

- name: Check spelling of entire workspace
uses: crate-ci/typos@master
40 changes: 21 additions & 19 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
test
digilogic
gen
src/apple.m
build
zig-cache
.zig-cache
zig-out
.cache
*.dSYM
thirdparty/adaptagrams
thirdparty/routing
# Mac stuff:
.DS_Store
circuit.dot
circuit.pdf
res/assets.zip
untitled.dlc
.vs

# user vscode configs
.vscode
routing_data.dat

# trunk output folder
dist

# Rust compile target directories:
target
target_ra
target_wasm

# https://github.com/lycheeverse/lychee
.lycheecache

# clangd cache
.cache

# can regenerate this with bear, but it's unique to your system so not in git
# cargo clean
# bear --append -- cargo build
compile_commands.json
.aider*
Loading

0 comments on commit 04876c6

Please sign in to comment.