Skip to content
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

Llama #222

Draft
wants to merge 7 commits into
base: trunk
Choose a base branch
from
Draft

Llama #222

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ set(EM_LINK_FLAGS
"--post-js ${CMAKE_CURRENT_SOURCE_DIR}/src-cpp/src/post.js"
)

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
if (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
set(EM_LINK_FLAGS
${EM_LINK_FLAGS}
"-sUSE_ES6_IMPORT_META=1"
Expand Down
10 changes: 10 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "vcpkg-emscripten-RelWithDebInfo",
"inherits": [
"vcpkg-emscripten"
],
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "vcpkg-emscripten-MinSizeRel",
"inherits": [
Expand Down
421 changes: 211 additions & 210 deletions package-lock.json

Large diffs are not rendered by default.

42 changes: 27 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
"webassembly",
"wasm",
"dot",
"llama",
"zstd",
"graphviz-dot",
"zstandard",
"expat",
"base91",
"expat-xml-parser",
"webassemby"
"webassembly"
],
"type": "module",
"exports": {
Expand Down Expand Up @@ -42,6 +43,12 @@
"require": "./dist/graphviz.cjs",
"default": "./dist/graphviz.umd.js"
},
"./llama": {
"types": "./types/llama.d.ts",
"import": "./dist/llama.js",
"require": "./dist/llama.cjs",
"default": "./dist/llama.umd.js"
},
"./zstd": {
"types": "./types/zstd.d.ts",
"import": "./dist/zstd.js",
Expand Down Expand Up @@ -73,9 +80,10 @@
"install-vcpkg:win32": "wsl -e ./scripts/cpp-install-vcpkg.sh",
"install-build-deps": "run-s install-emsdk install-vcpkg",
"uninstall-build-deps": "rimraf ./emsdk ./vcpkg ./src-expat ./src-vcpkg ./wasi-sdk ./wit-bindgen",
"clean-build": "rimraf .nyc_output bin build coverage dist* lib* output-* tmp types *.tsbuildinfo vcpkg/vcpkg",
"clean-build": "rimraf .nyc_output bin build coverage dist* lib* output-* tmp types *.tsbuildinfo",
"clean-vcpkg": "rimraf vcpkg/vcpkg vcpkg/buildtrees vcpkg/packages vcpkg/vcpkg-installed_wasm",
"clean-docs": "rimraf docs/.vitepress/dist docs/classes docs/interfaces docs/modules docs/.nojekyll docs/README.md",
"clean": "run-p clean-build clean-docs",
"clean": "run-p clean-build clean-vcpkg clean-docs",
"copy-res": "cp ./docs/*.png ./docs/.vitepress/dist",
"compile": "tsc",
"compile-watch": "npm run compile -- -w",
Expand All @@ -95,12 +103,15 @@
"build-docker-image": "docker build --rm --progress plain -f \"./docker/ubuntu-dev.dockerfile\" -t hpcc-js-wasm-build:latest \".\"",
"build-docker-wasm": "npx -y mkdirp dist && docker run --rm -it --mount source=\"$(pwd)/dist\",target=/usr/src/app/dist,type=bind,consistency=cached hpcc-js-wasm-build:latest",
"build-docker": "run-s build-docker-image build-docker-wasm",
"build": "mkdirp ./lib-esm && run-s compile-cpp compile bundle",
"build-tests": "esbuild --bundle --platform=node --format=esm --outdir=dist-test src-ts/__tests__/index-node.ts",
"build-tests-watch": "npm run build-tests -- --watch",
"build": "NPM_MODE=Release mkdirp ./lib-esm && run-s compile-cpp compile bundle",
"build-debug": "NPM_MODE=Debug mkdirp ./lib-esm && run-s compile-cpp compile bundle-debug",
"standard-version": "standard-version",
"standard-version-next": "standard-version -p next",
"standard-version-dryrun": "standard-version --dry-run",
"git-push": "git push --follow-tags upstream trunk",
"watch": "run-p compile-watch bundle-watch",
"watch": "run-p compile-watch bundle-watch build-tests-watch",
"serve-docs": "vitepress serve docs",
"serve": "ws",
"lint": "eslint src-ts/**/*.ts",
Expand All @@ -112,7 +123,7 @@
"test-bundle-node": "npx -y esbuild --platform=node --bundle ./dist/base91.js --outdir=tmp",
"test-chrome": "karma start --single-run --browsers ChromiumHeadless karma.conf.cjs",
"test-firefox": "karma start --single-run --browsers Firefox karma.conf.cjs",
"test-node": "node ./bin/dot-wasm.js -v && mocha ./dist-test/index.node.cjs --reporter spec && mocha ./dist-test/index.node.js --reporter spec",
"test-node": "node ./bin/dot-wasm.js -v && mocha ./dist-test/index-node.js --reporter spec && mocha ./dist-test/index-node.js --reporter spec",
"test": "run-s test-bundle test-bundle-node test-bundle-umd test-chrome test-node",
"coverage": "nyc npm run test-node",
"coverage-report": "nyc report --reporter=lcov",
Expand All @@ -133,22 +144,23 @@
"@types/chai": "4.3.14",
"@types/emscripten": "1.39.10",
"@types/mocha": "10.0.6",
"@types/node": "20.11.30",
"@types/node": "20.12.7",
"@types/yargs": "17.0.32",
"@typescript-eslint/eslint-plugin": "6.21.0",
"@typescript-eslint/parser": "6.21.0",
"assemblyscript": "0.27.25",
"@typescript-eslint/eslint-plugin": "7.7.0",
"@typescript-eslint/parser": "7.7.0",
"assemblyscript": "0.27.27",
"chai": "5.1.0",
"coveralls": "3.1.1",
"eslint": "8.57.0",
"esbuild": "0.20.2",
"fzstd": "0.1.1",
"karma": "6.4.3",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "3.2.0",
"karma-firefox-launcher": "2.1.3",
"karma-mocha": "2.0.1",
"karma-spec-reporter": "0.0.36",
"local-web-server": "5.3.1",
"local-web-server": "5.3.3",
"mocha": "10.4.0",
"npm-run-all": "4.1.5",
"nyc": "15.1.0",
Expand All @@ -158,10 +170,10 @@
"run-script-os": "1.1.6",
"standard-version": "9.5.0",
"tslib": "2.6.2",
"typedoc": "0.25.12",
"typedoc": "0.25.13",
"typedoc-plugin-markdown": "3.17.1",
"typescript": "5.4.3",
"vitepress": "1.0.1"
"typescript": "5.4.5",
"vitepress": "1.1.3"
},
"repository": {
"type": "git",
Expand All @@ -174,4 +186,4 @@
"url": "https://github.com/hpcc-systems/hpcc-js-wasm/issues"
},
"homepage": "https://hpcc-systems.github.io/hpcc-js-wasm/"
}
}
11 changes: 6 additions & 5 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,15 @@ export default args => {
browserTplIndex("lib-esm/index", "dist/index.umd", "dist/index"),

browserTpl("lib-esm/base91", "dist/base91.umd", "dist/base91"),
browserTpl("lib-esm/graphviz", "dist/graphviz.umd", "dist/graphviz"),
browserTpl("lib-esm/expat", "dist/expat.umd", "dist/expat"),
browserTpl("lib-esm/graphviz", "dist/graphviz.umd", "dist/graphviz"),
browserTpl("lib-esm/llama", "dist/llama.umd", "dist/llama"),
browserTpl("lib-esm/zstd", "dist/zstd.umd", "dist/zstd"),

browserTpl("lib-esm/__tests__/index-browser", "dist-test/index.umd", "dist-test/index"),
nodeTpl("lib-esm/__tests__/index-node", "dist-test/index.node", "dist-test/index.node"),
browserTpl("lib-esm/__tests__/worker-browser", "dist-test/worker.umd", "dist-test/worker"),
nodeTpl("lib-esm/__tests__/worker-node", "dist-test/worker.node", "dist-test/worker.node"),
// browserTpl("lib-esm/__tests__/index-browser", "dist-test/index.umd", "dist-test/index"),
// nodeTpl("lib-esm/__tests__/index-node", "dist-test/index.node", "dist-test/index.node"),
// browserTpl("lib-esm/__tests__/worker-browser", "dist-test/worker.umd", "dist-test/worker"),
// nodeTpl("lib-esm/__tests__/worker-node", "dist-test/worker.node", "dist-test/worker.node"),

binTpl("lib-esm/__bin__/dot-wasm", "bin/dot-wasm.js"),
];
Expand Down
9 changes: 6 additions & 3 deletions scripts/cpp-build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#!/bin/bash

source ./emsdk/emsdk_env.sh
if [ ! -d "./build" ]
then
cmake -S . -B ./build --preset vcpkg-emscripten-MinSizeRel
if [ ! -d "./build" ]; then
if [ "$NPM_MODE" = "Debug" ]; then
cmake -S . -B ./build --preset vcpkg-emscripten-RelWithDebInfo
else
cmake -S . -B ./build --preset vcpkg-emscripten-MinSizeRel
fi
fi

cmake --build ./build --parallel
2 changes: 1 addition & 1 deletion scripts/cpp-install-emsdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# List of current vertsion can be found in https://github.com/emscripten-core/emsdk/tags ---
# UPDATE README.md
VERSION=3.1.53
VERSION=3.1.57

if [ ! -d "./emsdk" ]
then
Expand Down
2 changes: 1 addition & 1 deletion scripts/cpp-install-vcpkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# List of current vertsion can be found in https://github.com/microsoft/vcpkg/releases ---
# UPDATE README.md
VCPKG_BUILD_TOOLS_VERSION=2024.01.12
VCPKG_BUILD_TOOLS_VERSION=2024.03.25

if [ ! -d "./vcpkg" ]
then
Expand Down
1 change: 1 addition & 0 deletions src-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
add_subdirectory(base91)
add_subdirectory(expat)
add_subdirectory(graphviz)
add_subdirectory(llama)
add_subdirectory(zstd)
2 changes: 1 addition & 1 deletion src-cpp/base91/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <string>
#include <base91.hpp>

const char *const version = "0.6.0";
const char *const version = "0.6.0.1";

class CBasE91
{
Expand Down
46 changes: 46 additions & 0 deletions src-cpp/llama/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
project(llamalib)

set(CMAKE_CXX_STANDARD 17)

find_package(Llama CONFIG REQUIRED)

# See: https://github.com/emscripten-core/emscripten/blob/main/src/settings.js
string(REPLACE ";" " " CPP_FLAGS "${EM_CPP_FLAGS}")

set(EM_LINK_FLAGS
${EM_LINK_FLAGS}
"-sEXPORT_NAME='${CMAKE_PROJECT_NAME}'"
"-sEXPORTED_FUNCTIONS=\"[]\""
"-sEXPORTED_RUNTIME_METHODS=\"[UTF8ToString]\""
"--post-js ${CMAKE_CURRENT_BINARY_DIR}/main_glue.js"
)
string(REPLACE ";" " " LINK_FLAGS "${EM_LINK_FLAGS}")

# Generate Glue from IDL file ---
add_custom_command(
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/main.idl
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/main_glue.js ${CMAKE_CURRENT_BINARY_DIR}/main_glue.cpp
COMMAND python3 ${CMAKE_BINARY_DIR}/../emsdk/upstream/emscripten/tools/webidl_binder.py ${CMAKE_CURRENT_SOURCE_DIR}/main.idl ${CMAKE_CURRENT_BINARY_DIR}/main_glue
)
set_property(SOURCE main.cpp APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/main_glue.cpp)
# --- --- ---

include_directories(
${VCPKG_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${Llama_DIR}/common
)

add_executable(llamalib
main.cpp
${Llama_DIR}/common/common.cpp
)

set_target_properties(llamalib PROPERTIES COMPILE_FLAGS "${CPP_FLAGS}")
set_target_properties(llamalib PROPERTIES LINK_FLAGS "${LINK_FLAGS}")

target_link_libraries(llamalib
PRIVATE llama
)

packWasm(llamalib)