Skip to content

Commit

Permalink
chore: Refactor source locations
Browse files Browse the repository at this point in the history
Add simple WebAssembly source

Signed-off-by: Gordon Smith <[email protected]>
  • Loading branch information
GordonSmith committed Dec 30, 2022
1 parent f81ed20 commit c6bd2ea
Show file tree
Hide file tree
Showing 90 changed files with 390 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ docker/
emsdk/
lib-*/
node_modules/
src-graphviz/
third-party/graphviz/
types/
vcpkg/
*.tsbuildinfo
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
/lib-*
/node_modules
/rust
/src-*
/src/*.wasm.ts
/third-party
/src-ts/*.wasm.ts
/tmp
/types
/vcpkg
Expand Down
2 changes: 1 addition & 1 deletion .nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"extends": "@istanbuljs/nyc-config-typescript",
"exclude": [
"build",
"src/__tests__"
"src-ts/__tests__"
]
}
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@
},
{
"name": "CLI",
"program": "${workspaceFolder}/bin/dot-wasm.mjs",
"program": "${workspaceFolder}/bin/dot-wasm.js",
"request": "launch",
"args": [
"-K neato",
"-n 2",
"./src/__tests__/simple.dot"
"./src-ts/__tests__/simple.dot"
],
"skipFiles": [
"<node_internals>/**"
Expand All @@ -109,7 +109,7 @@
},
{
"name": "CLI Version",
"program": "${workspaceFolder}/bin/dot-wasm.mjs",
"program": "${workspaceFolder}/bin/dot-wasm.js",
"request": "launch",
"args": [
"-v"
Expand Down
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE ${REPO_DIR}/emsdk/upstream/emscripten/cmake/M
set(VCPKG_ROOT ${REPO_DIR}/vcpkg)
set(VCPKG_OVERLAY_PORTS ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg-overlays)
set(VCPKG_TARGET_TRIPLET "wasm32-emscripten")
file(REMOVE ${REPO_DIR}/vcpkg/vcpkg)
# file(REMOVE ${REPO_DIR}/vcpkg/vcpkg)

project(cpp)

Expand All @@ -34,8 +34,8 @@ set(EM_LINK_FLAGS
"-sSTANDALONE_WASM=0"
"-sBINARYEN_ASYNC_COMPILATION=1"
# "-sDYNAMIC_EXECUTION=0"
"--pre-js ${CMAKE_CURRENT_SOURCE_DIR}/cpp/src/pre.js"
"--post-js ${CMAKE_CURRENT_SOURCE_DIR}/cpp/src/post.js"
"--pre-js ${CMAKE_CURRENT_SOURCE_DIR}/src-cpp/src/pre.js"
"--post-js ${CMAKE_CURRENT_SOURCE_DIR}/src-cpp/src/post.js"
)


Expand Down Expand Up @@ -68,7 +68,7 @@ endif ()

set(EMSDK_DIR "${CMAKE_SOURCE_DIR}/emsdk")
set(EXPAT_DIR "${CMAKE_SOURCE_DIR}/src-expat/expat")
set(GRAPHVIZ_DIR "${CMAKE_SOURCE_DIR}/src-graphviz")
set(GRAPHVIZ_DIR "${CMAKE_SOURCE_DIR}/third-party/graphviz")

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand All @@ -89,4 +89,4 @@ function(packWasm targetID)
add_dependencies(sfx-${targetID} ${targetID} base91lib zstdlib)
endfunction ()

add_subdirectory(cpp)
add_subdirectory(src-cpp)
22 changes: 22 additions & 0 deletions asconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"targets": {
"debug": {
"outFile": "build/debug.wasm",
"textFile": "build/debug.wat",
"sourceMap": true,
"debug": true
},
"release": {
"outFile": "build/release.wasm",
"textFile": "build/release.wat",
"sourceMap": true,
"optimizeLevel": 3,
"shrinkLevel": 0,
"converge": false,
"noAssert": false
}
},
"options": {
"bindings": "esm"
}
}
2 changes: 0 additions & 2 deletions cpp/graphviz/config.h

This file was deleted.

2 changes: 1 addition & 1 deletion docker/ubuntu-dev.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RUN apt-get install -y gcc-multilib g++-multilib pkg-config autoconf bison libto
RUN apt-get install -y python3 python3-pip

# Set the working directory
WORKDIR /usr/src/app
WORKDIR /usr/src-ts/app

COPY ./cpp ./cpp
COPY ./src ./src
Expand Down
43 changes: 41 additions & 2 deletions package-lock.json

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

17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"bin/*.*",
"dist/*.*",
"types/*",
"src/*.css"
"src-ts/*.css"
],
"scripts": {
"install-emsdk": "run-script-os",
Expand All @@ -70,13 +70,14 @@
"install-vcpkg:linux": "./scripts/cpp-install-vcpkg.sh",
"install-vcpkg:win32": "wsl -e ./scripts/cpp-install-vcpkg.sh",
"install-build-deps": "run-p install-emsdk install-graphviz install-vcpkg",
"uninstall-build-deps": "rimraf ./emsdk ./src-graphviz ./vcpkg ./src-expat ./src-vcpkg",
"uninstall-build-deps": "rimraf ./emsdk ./third-party/graphviz ./vcpkg ./src-expat ./src-vcpkg",
"clean-build": "rimraf .nyc_output bin build coverage dist* lib* output-* tmp types *.tsbuildinfo",
"clean-docs": "rimraf docs/.vitepress/dist docs/classes docs/interfaces docs/modules docs/.nojekyll docs/README.md",
"clean": "run-p clean-build clean-docs",
"copy-res": "cp ./docs/*.png ./docs/.vitepress/dist",
"compile": "tsc",
"compile-watch": "npm run compile -- -w",
"compile-asm": "asc ./src-asm/index.ts --target release",
"compile-cpp": "run-script-os",
"compile-cpp:linux": "./scripts/cpp-build.sh",
"compile-cpp:win32": "wsl -e ./scripts/cpp-build.sh",
Expand All @@ -99,16 +100,17 @@
"watch": "run-p compile-watch bundle-watch",
"serve-docs": "vitepress serve docs",
"serve": "ws",
"lint": "eslint src/**/*.ts",
"lint": "eslint src-ts/**/*.ts",
"lint-fix": "npm run lint -- --fix",
"test-cli": "node ./bin/dot-wasm.js -v",
"test-cli-help": "node ./bin/dot-wasm.js",
"test-bundle": "npx -y esbuild --bundle ./dist/base91.umd.js --bundle ./dist/base91.js --outdir=tmp",
"test-bundle-node": "npx -y esbuild --bundle --platform=node --bundle ./dist/base91.umd.js ./dist/base91.js --outdir=tmp",
"test-bundle": "npx -y esbuild --format=esm --bundle ./dist/base91.js --outdir=tmp",
"test-bundle-umd": "npx -y esbuild --platform=node --bundle ./dist/base91.umd.js --outdir=tmp",
"test-bundle-node": "npx -y esbuild --platform=node --bundle ./dist/base91.js --outdir=tmp",
"test-chrome": "karma start --single-run --browsers ChromeHeadless 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": "run-s test-bundle test-bundle-node test-chrome test-node",
"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",
"tag": "run-s standard-version git-push",
Expand All @@ -131,6 +133,7 @@
"@types/yargs": "17.0.17",
"@typescript-eslint/eslint-plugin": "5.47.0",
"@typescript-eslint/parser": "5.47.0",
"assemblyscript": "0.25.2",
"chai": "4.3.7",
"coveralls": "3.1.1",
"eslint": "8.30.0",
Expand Down Expand Up @@ -167,4 +170,4 @@
"url": "https://github.com/hpcc-systems/hpcc-js-wasm/issues"
},
"homepage": "https://hpcc-systems.github.io/hpcc-js-wasm/"
}
}
8 changes: 4 additions & 4 deletions scripts/cpp-install-graphviz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
# UPDATE README.md
VERSION=7.0.5

if [ ! -d "src-graphviz" ]
if [ ! -d "third-party/graphviz" ]
then
wget -c https://gitlab.com/graphviz/graphviz/-/archive/$VERSION/graphviz-$VERSION.tar.gz
mkdir ./src-graphviz
tar -xzf ./graphviz-$VERSION.tar.gz -C ./src-graphviz --strip-components=1
mkdir -p ./third-party/graphviz
tar -xzf ./graphviz-$VERSION.tar.gz -C ./third-party/graphviz --strip-components=1
rm ./graphviz-$VERSION.tar.gz

# Generate grammar files (and others) ---
cd ./src-graphviz
cd ./third-party/graphviz
mkdir ./build
cd ./build
cmake .. -Dwith_gvedit=OFF
Expand Down
5 changes: 5 additions & 0 deletions src-asm/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// The entry file of your WebAssembly module.

export function add(a: i32, b: i32): i32 {
return a + b;
}
6 changes: 6 additions & 0 deletions src-asm/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "assemblyscript/std/assembly.json",
"include": [
"./**/*.ts"
]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions src-cpp/graphviz/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "../../third-party/graphviz/build/config.h"
#define SFDP 1
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit c6bd2ea

Please sign in to comment.