Skip to content

Prep for building node addon against precompiled skipruntime #909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
submodules: true
- run:
name: Typecheck and lint typescript sources
command: SKIPRUNTIME=$(pwd)/build/skipruntime npm install && npm run build && npm run lint
command: make check-ts

compiler:
docker:
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# this builds the artifacts of this repository, orchestrating the
# various build systems

.PHONY: all
all: npm build/skdb build/init.sql
.PHONY: default
default: check check-ts

PLAYWRIGHT_REPORTER?="line"
SKARGO_PROFILE?=release
SKDB_WASM=sql/target/wasm32-unknown-unknown/$(SKARGO_PROFILE)/skdb.wasm
SKDB_BIN=sql/target/host/$(SKARGO_PROFILE)/skdb
SDKMAN_DIR?=$(HOME)/.sdkman
SKIPRUNTIME?=$(CURDIR)/build/skipruntime

export SKIPRUNTIME
.PHONY: skdb
skdb: npm build/skdb build/init.sql

################################################################################
# skdb wasm + js client
Expand Down Expand Up @@ -73,9 +73,9 @@ check:
find * -name Skargo.toml -exec sh -c 'bin/cd_sh $$(dirname {}) "skargo check"' \;

.PHONY: check-ts
check-ts:
npm install
bin/check-ts.sh
check-ts:
# delegate to pick up build-time config for libskipruntime
${MAKE} -C skipruntime-ts check-ts

.PHONY: check-sh
check-sh:
Expand Down
22 changes: 16 additions & 6 deletions skipruntime-ts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,31 @@ SHELL := /bin/bash

SKARGO_PROFILE?=release
NPM_WORKSPACES=$(shell jq --raw-output "[.workspaces[] | select((startswith(\"sql\") or contains(\"examples\")) | not)] | map(\"-w \" + .) | .[]" ../package.json)
SKIPRUNTIME?=$(realpath $(CURDIR)/..)/build/skipruntime

export SKIPRUNTIME
.PHONY: default
default: install

export LDFLAGS=-L$(realpath $(CURDIR)/..)/build/skipruntime/
export LD_LIBRARY_PATH=$(realpath $(CURDIR)/..)/build/skipruntime/

.PHONY: libskipruntime
libskipruntime:
skargo build --release --lib --manifest-path=skiplang/ffi/Skargo.toml --out-dir=../build/skipruntime/

.PHONY: install
install:
install: libskipruntime
../bin/cd_sh .. "npm install $(NPM_WORKSPACES)"

.PHONY: install-all
install-all:
install-all: libskipruntime
../bin/cd_sh .. "npm install"

.PHONY: check-ts
check-ts: install-all
../bin/check-ts.sh

.PHONY: build
build:
build: libskipruntime
../bin/cd_sh .. "npm run build $(NPM_WORKSPACES) --if-present"

bunrun-%: build
Expand All @@ -42,7 +53,6 @@ nodeserver-%:
clean:
make -C .. clean

.PHONY: run-test
run-test:
../bin/cd_sh tests "npm run test"

Expand Down
2 changes: 1 addition & 1 deletion skipruntime-ts/addon/binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"cflags!": ["-fno-exceptions"],
"cflags_cc!": ["-fno-exceptions"],
"libraries": ["-L<!(realpath $SKIPRUNTIME) -lskip-runtime-ts -Wl,--require-defined=SKIP_new_Obstack"],
"libraries": ["-lskipruntime -Wl,--require-defined=SKIP_new_Obstack"],
}
]
}
3 changes: 1 addition & 2 deletions skipruntime-ts/addon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
".": "./dist/index.js"
},
"scripts": {
"prepare": "skargo build -r --lib --manifest-path=../skiplang/ffi/Skargo.toml --out-dir=../../build/skipruntime",
"build": "skargo build -r --lib --manifest-path=../skiplang/ffi/Skargo.toml --out-dir=../../build/skipruntime && tsc && SKIPRUNTIME=$(realpath ../../build/skipruntime) node-gyp configure && node-gyp build",
"build": "tsc && node-gyp configure && node-gyp build",
"clean": "rm -rf dist && node-gyp clean",
"lint": "eslint"
},
Expand Down
2 changes: 1 addition & 1 deletion skipruntime-ts/skiplang/ffi/Skargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "skip-runtime-ts"
name = "skipruntime"
version = "0.1.0"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion skipruntime-ts/tests/examples/database.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fi

if [ "$3" = "native" ]; then
echo "Running 'database' example on @skipruntime/native"
LD_LIBRARY_PATH=$(realpath ../../build/skipruntime) SKIP_PLATFORM="native" node dist/database.js >/dev/null &
SKIP_PLATFORM="native" node dist/database.js >/dev/null &
else
echo "Running 'database' example on @skipruntime/wasm"
node dist/database.js >/dev/null &
Expand Down
2 changes: 1 addition & 1 deletion skipruntime-ts/tests/examples/departures.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fi

if [ "$3" = "native" ]; then
echo "Running 'departures' example on @skipruntime/native"
LD_LIBRARY_PATH=$(realpath ../../build/skipruntime) SKIP_PLATFORM="native" node dist/departures.js >/dev/null &
SKIP_PLATFORM="native" node dist/departures.js >/dev/null &
else
echo "Running 'departures' example on @skipruntime/wasm"
node dist/departures.js >/dev/null &
Expand Down
2 changes: 1 addition & 1 deletion skipruntime-ts/tests/examples/groups.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fi

if [ "$3" = "native" ]; then
echo "Running 'groups' example on @skipruntime/native"
LD_LIBRARY_PATH=$(realpath ../../build/skipruntime) SKIP_PLATFORM="native" node dist/groups.js >/dev/null &
SKIP_PLATFORM="native" node dist/groups.js >/dev/null &
else
echo "Running 'groups' example on @skipruntime/wasm"
node dist/groups.js >/dev/null &
Expand Down
4 changes: 2 additions & 2 deletions skipruntime-ts/tests/examples/remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ fi

if [ "$3" = "native" ]; then
echo "Running 'remote' example on @skipruntime/native"
LD_LIBRARY_PATH=$(realpath ../../build/skipruntime) SKIP_PLATFORM="native" node dist/sum.js >/dev/null &
LD_LIBRARY_PATH=$(realpath ../../build/skipruntime) SKIP_PLATFORM="native" node dist/remote.js >/dev/null &
SKIP_PLATFORM="native" node dist/sum.js >/dev/null &
SKIP_PLATFORM="native" node dist/remote.js >/dev/null &
else
echo "Running 'remote' example on @skipruntime/wasm"
node dist/sum.js >/dev/null &
Expand Down
2 changes: 1 addition & 1 deletion skipruntime-ts/tests/examples/sheet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fi

if [ "$3" = "native" ]; then
echo "Running 'sheet' example on @skipruntime/native"
LD_LIBRARY_PATH=$(realpath ../../build/skipruntime) SKIP_PLATFORM="native" node dist/sheet.js >/dev/null &
SKIP_PLATFORM="native" node dist/sheet.js >/dev/null &
else
echo "Running 'sheet' example on @skipruntime/wasm"
node dist/sheet.js >/dev/null &
Expand Down
2 changes: 1 addition & 1 deletion skipruntime-ts/tests/examples/sum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fi

if [ "$3" = "native" ]; then
echo "Running 'sum' example on @skipruntime/native"
LD_LIBRARY_PATH=$(realpath ../../build/skipruntime) SKIP_PLATFORM="native" node dist/sum.js >/dev/null &
SKIP_PLATFORM="native" node dist/sum.js >/dev/null &
else
echo "Running 'sum' example on @skipruntime/wasm"
node dist/sum.js >/dev/null &
Expand Down
2 changes: 1 addition & 1 deletion skipruntime-ts/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"build": "tsc",
"clean": "rm -rf dist",
"lint": "eslint src/",
"test": "LD_LIBRARY_PATH=$(realpath ../../build/skipruntime) mocha"
"test": "mocha"
},
"devDependencies": {
"@types/mocha": "^10.0.10",
Expand Down
6 changes: 3 additions & 3 deletions skipruntime-ts/wasm/src/skipruntime_init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ async function wasmUrl(): Promise<URL | string> {
//@ts-expect-error ImportMeta is incomplete
if (import.meta.env || import.meta.webpack) {
const imported = (await import(
//@ts-expect-error Cannot find module './skstore.wasm?url' or its corresponding type declarations.
"./libskip-runtime-ts.wasm?url"
//@ts-expect-error Cannot find module './libskipruntime.wasm?url' or its corresponding type declarations.
"./libskipruntime.wasm?url"
)) as Imported;
return imported.default;
}

return new URL("./libskip-runtime-ts.wasm", import.meta.url);
return new URL("./libskipruntime.wasm", import.meta.url);
}

export async function initServiceFor(
Expand Down
6 changes: 2 additions & 4 deletions sql/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ SHELL := /bin/bash
SKARGO_PROFILE?=release

SCRIPT_DIR=$(shell dirname $(shell realpath $(firstword $(MAKEFILE_LIST))))
SKIPRUNTIME?=$(realpath $(SCRIPT_DIR)/..)/build/skipruntime

export SKIPRUNTIME

.PHONY: check-src
check-src: build
Expand All @@ -20,7 +17,8 @@ check-all: check-src check-tests

.PHONY: build
build:
../bin/cd_sh .. "npm install && npm run build -w skdb -w skdb-tests"
${MAKE} -C ../skipruntime-ts install-all
../bin/cd_sh .. "npm run build -w skdb -w skdb-tests"

.PHONY: clean
clean:
Expand Down