Skip to content

Commit

Permalink
Add xtask to project (#13)
Browse files Browse the repository at this point in the history
* Add xtask to project
* Add CI automation
* Cleanup repository
* Enable crate builds for non-wasm targets

Signed-off-by: Tin Švagelj <[email protected]>
  • Loading branch information
Caellian authored Oct 20, 2024
1 parent 28af484 commit a1b8efa
Show file tree
Hide file tree
Showing 30 changed files with 2,680 additions and 139 deletions.
4 changes: 2 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[build]
target = "wasm32-wasip1"
[alias]
xtask = "run --package xtask --release --"
82 changes: 82 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master

env:
XTASK_WASI_SDK_VERSION: 24
XTASK_BINARYEN_VERSION: 119
XTASK_TYPST_VERSION: 0.12.0
XTASK_WORK_DIR: ./ci_work_dir

jobs:
test:
name: Build Typst Plugin
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-wasip1
- name: Restore WASI SDK
uses: actions/cache/restore@v4
with:
path: ci_work_dir/wasi_sdk
key: tools-wasi-sdk-${{ env.XTASK_WASI_SDK_VERSION }}
- name: Restore wasi-stub
uses: actions/cache/restore@v4
with:
path: |
zint-typst-plugin/vendor/wasm-minimal-protocol/target/release/wasi-stub
zint-typst-plugin/vendor/wasm-minimal-protocol/target/debug/wasi-stub
key: tools-wasi-stub-${{ hashFiles('zint-typst-plugin/vendor/wasm-minimal-protocol/crates/wasi-stub/**') }}
- name: Restore wasm-opt
uses: actions/cache/restore@v4
with:
path: ci_work_dir/tools/wasm-opt
key: tools-binaryen-${{ env.XTASK_BINARYEN_VERSION }}
- name: Restore typst
uses: actions/cache/restore@v4
with:
path: ci_work_dir/tools/typst
key: tools-typst-${{ env.XTASK_TYPST_VERSION }}
- name: Run CI xtask
run: cargo xtask ci
- name: Cache WASI SDK
uses: actions/cache/save@v4
with:
path: ci_work_dir/wasi_sdk
key: tools-wasi-sdk-${{ env.XTASK_WASI_SDK_VERSION }}
- name: Cache wasi-stub
uses: actions/cache/save@v4
with:
path: |
zint-typst-plugin/vendor/wasm-minimal-protocol/target/release/wasi-stub
zint-typst-plugin/vendor/wasm-minimal-protocol/target/debug/wasi-stub
key: tools-wasi-stub-${{ hashFiles('zint-typst-plugin/vendor/wasm-minimal-protocol/crates/wasi-stub/**') }}
- name: Cache wasm-opt
uses: actions/cache/save@v4
with:
path: ci_work_dir/tools/wasm-opt
key: tools-binaryen-${{ env.XTASK_BINARYEN_VERSION }}
- name: Cache typst
uses: actions/cache/save@v4
with:
path: ci_work_dir/tools/typst
key: tools-typst-${{ env.XTASK_TYPST_VERSION }}
- uses: actions/upload-artifact@v4
with:
name: plugin-wasm
path: ./typst-package/zint_typst_plugin.wasm
retention-days: 7
- uses: actions/upload-artifact@v4
with:
name: manual
path: ./typst-package/manual.pdf
retention-days: 7
102 changes: 74 additions & 28 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# CMake build files
build/

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

### C ###
# Prerequisites
*.d

Expand Down Expand Up @@ -53,23 +36,86 @@ build/
*.i*86
*.x86_64
*.hex
*.wasm

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
license.html
*.wasm
# Build files
build/

# Cache
.cache

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

### Rust ###
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# Backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Windows shortcuts
*.lnk

### Project ###
# Compiled documents
*.pdf

# Generated files
typst-package/3rdparty_license.html
typst-package/example.svg

# Duplicate license
typst-package/LICENSE

# Keep manual
!typst-package/manual.pdf
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[submodule "zint-wasm-sys/zint"]
path = zint-wasm-sys/zint
url = https://github.com/zint/zint
[submodule "zint-typst-plugin/vendor/wasm-minimal-protocol"]
path = zint-typst-plugin/vendor/wasm-minimal-protocol
url = https://github.com/Caellian/wasm-minimal-protocol.git
branch = zint-wasi-vendor
39 changes: 32 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,40 @@
[workspace]
package.edition = "2021"
package.license = "MIT"
resolver = "2"
members = [
"zint-wasm-sys",
"zint-wasm-rs",
"zint-typst-plugin"
"zint-typst-plugin",
"zint-typst-plugin/vendor/wasm-minimal-protocol/crates/macro",
"zint-typst-plugin/vendor/wasm-minimal-protocol/crates/wasi-stub",
"xtask"
]
package.license = "MIT"
default-members = [
"zint-wasm-sys",
"zint-wasm-rs",
"zint-typst-plugin",
]

[profile.release]
lto = true # Enable link-time optimization
strip = true # Strip symbols from binary*
opt-level = 'z' # Optimize for size
codegen-units = 1 # Reduce number of codegen units to increase optimizations
panic = 'abort' # Abort on panic
# Enable link-time optimization
lto = true
# Strip symbols from binary
strip = true

[profile.plugin-debug]
inherits = "dev"
# Abort on panic
panic = 'abort'

[profile.plugin-release]
inherits = "release"
# Optimize for size
opt-level = 'z'
# Reduce number of codegen units to increase optimizations
codegen-units = 1
# Abort on panic
panic = 'abort'

[workspace.dependencies]
walkdir = "2"
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,23 @@ _(click on the image to open)_

## Build

Install wasi-sdk. Put them at `/opt/wasi-sdk`. Then run:
Clone with:
```sh
git clone --recurse-submodules -j8 https://github.com/Enter-tainer/zint-wasi.git
```

You must have standard development tools pre-installed on your machine and in path:
- cargo (rustc; get with [rustup](https://rustup.rs/))
- tar
- wget/curl
- gcc/clang

To build the typst package, run:
```sh
cargo xtask package
```
./build.sh
```

See [`xtask` readme](./xtask/README.md) for more information.

## License

Expand Down
12 changes: 0 additions & 12 deletions build.sh

This file was deleted.

File renamed without changes.
21 changes: 0 additions & 21 deletions typst-package/LICENSE

This file was deleted.

Loading

0 comments on commit a1b8efa

Please sign in to comment.