-
-
Notifications
You must be signed in to change notification settings - Fork 24
Home
You need to build the library if you make changes to the C++ core (emscripten folder) or the TypeScript API (src folder). Before building, you need to clone the repository and fetch the submodules.
- Clone this repository:
git clone https://github.com/webarkit/jsartoolkitNFT.git cd jsartoolkitNFT - Initialize and update the WebARKitLib submodule:
If you already cloned WebARKitLib to a different directory, you can either:
git submodule update --init
- Create a symlink in the
emscripten/directory pointing to WebARKitLib (emscripten/WebARKitLib) (Linux and macOS only). - Set the
WEBARKITLIB_ROOTenvironment variable to point to your WebARKitLib clone. - Modify the
WEBARKITLIB_ROOTpath intools/makem.jsto point to your clone.
- Create a symlink in the
There are three ways to build the project:
If you use Visual Studio Code, you can build and develop inside a pre-configured Docker container automatically.
- Ensure Docker Desktop is installed and running.
- Install the VS Code Dev Containers extension.
- Open the repository in Visual Studio Code.
- When prompted, click Reopen in Container (or open the Command Palette
Ctrl+Shift+P/Cmd+Shift+Pand chooseDev Containers: Reopen in Container). - VS Code will build the Docker container and configure all dependencies (EMSDK, CMake, Ninja, Node.js).
- Once open, run the following in the integrated terminal:
npm run build
If you prefer running Docker manually from the command line, you can use the built-in cross-platform helper scripts:
-
Start the background Docker container:
(This starts a persistent background container named
npm run setup-docker
emscripten-jsartoolkitnftand automatically resolves the host workspace path, working seamlessly on Windows, macOS, and Linux). -
Compile the build files inside the container:
(Or run
npm run build-docker
npm run build-docker-no-libarif you want to skip rebuildinglibar.o). -
Stop and clean up the container (when you are done):
docker stop emscripten-jsartoolkitnft docker rm emscripten-jsartoolkitnft
You can compile natively on your host machine if you have the proper tools configured.
- Node.js (v18+)
-
Emscripten SDK (v4.0.17+) available in your PATH (e.g.
source <path-to-emsdk>/emsdk_env.sh). -
CMake (v3.5+) and Ninja (recommended, especially on Windows:
choco install ninjaorwinget install MSBuild.Ninja).
- Run
npm installto install dependencies. - Run the build command:
(Or run
npm run build
npm run build-no-libarif you don't need to rebuildlibar.o). - To rebuild the TypeScript/ES6 distributions, run:
npm run build-ts
During development, you can run npm run watch. It will watch the ./js/ directory and rebuild the library automatically whenever you change API or worker files.
All build outputs are saved to the /build and /dist directories:
-
/build/artoolkitNFT.debug.js(debug build with symbols) -
/build/artoolkitNFT.min.js(optimized build) -
/build/artoolkitNFT_wasm.js(WebAssembly build) -
/dist/ARToolkitNFT.js(compiled UMD distribution)