Skip to content

Commit 7587369

Browse files
committed
WIP
1 parent 76a307b commit 7587369

File tree

9 files changed

+37
-12
lines changed

9 files changed

+37
-12
lines changed

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,15 @@
103103
"build-docker-image": "docker build --rm --progress plain -f \"./docker/ubuntu-dev.dockerfile\" -t hpcc-js-wasm-build:latest \".\"",
104104
"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",
105105
"build-docker": "run-s build-docker-image build-docker-wasm",
106+
"build-tests": "esbuild --bundle --platform=node --format=esm --outdir=dist-test src-ts/__tests__/index-node.ts",
107+
"build-tests-watch": "npm run build-tests -- --watch",
106108
"build": "NPM_MODE=Release mkdirp ./lib-esm && run-s compile-cpp compile bundle",
107109
"build-debug": "NPM_MODE=Debug mkdirp ./lib-esm && run-s compile-cpp compile bundle-debug",
108110
"standard-version": "standard-version",
109111
"standard-version-next": "standard-version -p next",
110112
"standard-version-dryrun": "standard-version --dry-run",
111113
"git-push": "git push --follow-tags upstream trunk",
112-
"watch": "run-p compile-watch bundle-watch",
114+
"watch": "run-p compile-watch bundle-watch build-tests-watch",
113115
"serve-docs": "vitepress serve docs",
114116
"serve": "ws",
115117
"lint": "eslint src-ts/**/*.ts",
@@ -121,7 +123,7 @@
121123
"test-bundle-node": "npx -y esbuild --platform=node --bundle ./dist/base91.js --outdir=tmp",
122124
"test-chrome": "karma start --single-run --browsers ChromiumHeadless karma.conf.cjs",
123125
"test-firefox": "karma start --single-run --browsers Firefox karma.conf.cjs",
124-
"test-node": "node ./bin/dot-wasm.js -v && mocha ./dist-test/index.node.cjs --reporter spec && mocha ./dist-test/index.node.js --reporter spec",
126+
"test-node": "node ./bin/dot-wasm.js -v && mocha ./dist-test/index-node.js --reporter spec && mocha ./dist-test/index-node.js --reporter spec",
125127
"test": "run-s test-bundle test-bundle-node test-bundle-umd test-chrome test-node",
126128
"coverage": "nyc npm run test-node",
127129
"coverage-report": "nyc report --reporter=lcov",
@@ -150,6 +152,7 @@
150152
"chai": "5.1.0",
151153
"coveralls": "3.1.1",
152154
"eslint": "8.57.0",
155+
"esbuild": "0.20.2",
153156
"fzstd": "0.1.1",
154157
"karma": "6.4.3",
155158
"karma-chai": "0.1.0",

rollup.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ export default args => {
122122
browserTpl("lib-esm/llama", "dist/llama.umd", "dist/llama"),
123123
browserTpl("lib-esm/zstd", "dist/zstd.umd", "dist/zstd"),
124124

125-
browserTpl("lib-esm/__tests__/index-browser", "dist-test/index.umd", "dist-test/index"),
126-
nodeTpl("lib-esm/__tests__/index-node", "dist-test/index.node", "dist-test/index.node"),
127-
browserTpl("lib-esm/__tests__/worker-browser", "dist-test/worker.umd", "dist-test/worker"),
128-
nodeTpl("lib-esm/__tests__/worker-node", "dist-test/worker.node", "dist-test/worker.node"),
125+
// browserTpl("lib-esm/__tests__/index-browser", "dist-test/index.umd", "dist-test/index"),
126+
// nodeTpl("lib-esm/__tests__/index-node", "dist-test/index.node", "dist-test/index.node"),
127+
// browserTpl("lib-esm/__tests__/worker-browser", "dist-test/worker.umd", "dist-test/worker"),
128+
// nodeTpl("lib-esm/__tests__/worker-node", "dist-test/worker.node", "dist-test/worker.node"),
129129

130130
binTpl("lib-esm/__bin__/dot-wasm", "bin/dot-wasm.js"),
131131
];

src-cpp/base91/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <string>
22
#include <base91.hpp>
33

4-
const char *const version = "0.6.0";
4+
const char *const version = "0.6.0.1";
55

66
class CBasE91
77
{

src-cpp/llama/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
project(llamalib)
22

3-
set(CMAKE_CXX_STANDARD 14)
3+
set(CMAKE_CXX_STANDARD 17)
44

55
find_package(Llama CONFIG REQUIRED)
66

src-cpp/llama/main.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <string>
77
#include <vector>
88

9-
int simple(int argc, char **argv)
9+
int simple(int argc, const char **argv)
1010
{
1111
gpt_params params;
1212

@@ -214,6 +214,14 @@ struct llama
214214
{
215215
::free(__ptr);
216216
}
217+
218+
static void test()
219+
{
220+
std::cout << "Hello" << std::endl;
221+
int argc = 2;
222+
const char *argv[] = {"tinyllama-1.1b-1t-openorca.Q4_K_M.gguf", "Who are you?"};
223+
simple(argc, argv);
224+
}
217225
};
218226

219227
// Include JS Glue ---

src-cpp/llama/main.idl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ interface llama
44

55
static any malloc(unsigned long size);
66
static void free(any ptr);
7+
8+
static void test();
79
};

src-ts/__tests__/llama.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect } from "chai";
2-
import { Llama } from "@hpcc-js/wasm/llama";
2+
import { Llama } from "../llama";
33

4-
describe("llama", function () {
4+
describe.only("llama", function () {
55
it("version", async function () {
66
let llama = await Llama.load();
77
let v = llama.version();
@@ -21,4 +21,8 @@ describe("llama", function () {
2121
Llama.unload();
2222
});
2323

24+
it.skip("test", async function () {
25+
let llama = await Llama.load();
26+
llama.test();
27+
});
2428
});

src-ts/llama.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @ts-ignore
2-
import { loadWasm, unloadWasm } from "./llamalib.wasm.js";
2+
import { loadWasm, unloadWasm } from "../lib-esm/llamalib.wasm.js";
33
import { WasmLibrary } from "./wasm-library.js";
44

55
// Ref: http://facebook.github.io/llama/llama_manual.html
@@ -61,4 +61,11 @@ export class Llama extends WasmLibrary {
6161
version(): string {
6262
return this._exports.version();
6363
}
64+
65+
/**
66+
* @returns The Llama c++ test
67+
*/
68+
test() {
69+
this._exports.test();
70+
}
6471
}

0 commit comments

Comments
 (0)