Skip to content

Commit

Permalink
use lol_alloc
Browse files Browse the repository at this point in the history
  • Loading branch information
nbittich committed Dec 8, 2024
1 parent f5f3c56 commit db8a635
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 2 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/release-wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Release WASM

on:
push:
tags:
- "**[0-9]+.[0-9]+.[0-9]+*"

env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: x86_64-unknown-linux-gnu
- name: Build
run: |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
wasm-pack build --target nodejs --release --scope nbittich ./rdfa-wasm
wasm-pack pack ./rdfa-wasm/pkg
- name: Upload pkg
uses: actions/upload-artifact@v4
with:
name: pkg
path: rdfa-wasm/pkg
publish:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download pkg
uses: actions/download-artifact@v4
with:
name: pkg
path: pkg
- name: Setup NPM
uses: actions/setup-node@v4
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
- name: Publish on NPM
run: |
cd pkg
npm install
npm publish --access public
19 changes: 19 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ test-case = "3.3.1"
env_logger = "0.11.5"
tortank = "0.24.2"
wasm-bindgen = "0.2.99"
lol_alloc = "0.4.1"
[profile.release]
opt-level = 'z' # Optimize for size.
lto = true # Link Time Optimization (LTO)
Expand Down
3 changes: 2 additions & 1 deletion rdfa-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ edition.workspace = true
license.workspace = true

[features]
default = ["console_error_panic_hook"]
default = ["console_error_panic_hook","lol_alloc"]


[lib]
Expand All @@ -22,3 +22,4 @@ graph-rdfa-processor.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen.workspace = true
console_error_panic_hook = { workspace = true, optional = true }
lol_alloc={workspace=true,optional=true}
6 changes: 5 additions & 1 deletion rdfa-wasm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#![cfg(target_arch = "wasm32")]
mod utils;
use graph_rdfa_processor::RdfaGraph;
use lol_alloc::{AssumeSingleThreaded, FreeListAllocator};
use wasm_bindgen::prelude::*;

// SAFETY: This application is single threaded, so using AssumeSingleThreaded is allowed.
#[global_allocator]
static ALLOCATOR: AssumeSingleThreaded<FreeListAllocator> =
unsafe { AssumeSingleThreaded::new(FreeListAllocator::new()) };
#[wasm_bindgen]
pub fn html_to_rdfa(html: &str, base: &str, well_known_prefix: &str) -> String {
utils::set_panic_hook();
Expand Down

0 comments on commit db8a635

Please sign in to comment.