Skip to content

Commit

Permalink
build: add ci.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
nieyuyao committed Apr 7, 2024
1 parent 16c867e commit 340c410
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 4 deletions.
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ root = true
[*]
indent_style = space
end_of_line = lf
indent_style = tab
indent_size = 2
charset = utf-8
max_line_length = 100
Expand Down
Empty file removed .github/build.yml
Empty file.
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node

Check failure on line 1 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / build (18.x)

.github/workflows/ci.yml#L1

This run was manually canceled.
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI

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

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x, 18.x]
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: setup node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: install dependencies
run: npm install

- name: setup emscripten
run: cd emsdk && ./emsdk install latest && ./emsdk activate latest && cd ..

- name: build esm
run: npm run build:esm --if-present

- name: build cjs
run: npm run build:cjs --if-present

- name: test
run: npm run test
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ EMSDK_INCLUDE_DIR = emsdk/upstream/emscripten/cache/sysroot/include
.PHONY: clean

webp-wasm.js: webp.o decode.o encode.o version.o ${CODEC_DIR}/libwebp.a ${CODEC_DIR}/libsharpyuv.a ${CODEC_DIR}/libsharpyuv.a ${CODEC_DIR}/libwebpmux.a
emcc \
emsdk/upstream/emscripten/emcc \
-lembind \
-s EXPORT_ES6=$(EXPORT_ES6) \
-s MODULARIZE \
Expand All @@ -15,7 +15,7 @@ webp-wasm.js: webp.o decode.o encode.o version.o ${CODEC_DIR}/libwebp.a ${CODEC_
-v

%.o: ${SRC}/%.cpp
em++ -c \
emsdk/upstream/emscripten/em++ -c \
-std=c++17 \
-I ${CODEC_DIR} \
-I ${EMSDK_INCLUDE_DIR} \
Expand All @@ -27,7 +27,7 @@ webp-wasm.js: webp.o decode.o encode.o version.o ${CODEC_DIR}/libwebp.a ${CODEC_
$(MAKE) -C $(@D)

$(CODEC_DIR)/Makefile: ${CODEC_DIR}/CMakeLists.txt
emcmake cmake \
emsdk/upstream/emscripten/emcmake cmake \
-DCMAKE_DISABLE_FIND_PACKAGE_Threads=1 \
-DWEBP_BUILD_CWEBP=0 \
-DWEBP_BUILD_DWEBP=0 \
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# `webp.wasm`

A webp wasm library based on libwebp.

#### Example

```shell
Expand Down
7 changes: 7 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
DIST_DIR="./dist"
WASM_OUT_DIR="./dist/cjs"
EXPORT_ES6=0
CLEAN_WASM_DIR=${WASM_OUT_DIR}

if [ -d $DIST_DIR ]; then
rm -rf $DIST_DIR
fi

mkdir $DIST_DIR

if [ $1 == "-dev" ]; then
WASM_OUT_DIR="./src"
CLEAN_WASM_DIR="${WASM_OUT_DIR}/webp-wasm.*"
Expand Down
1 change: 1 addition & 0 deletions webp/webp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "encode.h"
#include "decode.h"


EMSCRIPTEN_BINDINGS(module)
{
emscripten::value_object<SimpleWebPConfig>("SimpleWebPConfig")
Expand Down

0 comments on commit 340c410

Please sign in to comment.