Skip to content
Walter Perdan edited this page Jan 10, 2024 · 15 revisions

Welcome to the jsartoolkitNFT wiki!

Build instructions

You need to build if you make changes to the source code in artoolkit.api.js, ARToolkitJS.cpp or any other file in the emscripten folder. Before building the project you need to clone the repository. Follow the instructions.

Clone the repository

  1. Clone this repository
  2. Clone WebARKitLib project to get the latest source files. From within JSARToolKitNFT directory do git submodule update --init. If you already cloned WebARKitLib to a different directory you can:
  • create a link in the jsartoolkitNFT/emscripten/ directory that points to WebARKitLib (jsartoolkitNFT/emscripten/WebARKitLib) (Linux and macOS only)
  • or, set the WEBARKITLIB_ROOT environment variable to point to your WebARKitLib clone
  • or, change the tools/makem.js file to point to your WebARKitLib clone (line 20)

NOTE:

When writing JavaScript and making changes be aware that the emscripten uglifier does not support the ES6 syntax.

Build the project

Recommended: Build using Docker

  1. Install Docker (if you havn't already): get Docker
  2. Clone WebARKitLib repository on your machine: git submodule update --init
  3. npm install
  4. From inside jsartoolkitNFT directory run docker run -dit --name emscripten -v $(pwd):/src emscripten/emsdk:3.1.40 bash to download and start the container, in preparation for the build. To change esmcripten version change the tag.
  5. docker exec emscripten npm run build to build JS version of WebARKitLib
  6. docker exec emscripten npm run build-no-libar to build JS version of WebARKitLib without rebuilding libar.bc
  7. docker stop emscripten to stop the container after the build, if needed
  8. docker rm emscripten to remove the container
  9. docker rmi emscripten/emsdk:3.1.40 to remove the Docker image, if you don't need it anymore
  10. The build artifacts will appear in /build. There's a build with debug symbols in artoolkitNFT.debug.js file and the optimized build with bundled JS API in artoolkitNFT.min.js; also, a WebAssembly build artoolkitNFT_wasm.js and artoolkitNFT_wasm.wasm
  11. (optional) if you are using the ES6 version you need also to build the distribution library in dist folder run : npm run build-ts

⚠️ Not recommended ⚠️ : Build local with manual emscripten setup

To prevent issues with Emscripten setup and to not have to maintain several build environments (macOS, Windows, Linux) we only maintain the Build using Docker. Following are the instructions of the last know build on Linux which we verified are working. Use at own risk. Not working on macOS!

  1. Install build tools

  2. Install node.js (https://nodejs.org/en/)

  3. Install python2 (https://www.python.org/downloads/)

  4. Install emscripten (https://emscripten.org/docs/getting_started/downloads.html#download-and-install) We used emscripten/emsdk version 3.1.40

JSARToolKitNFT aim is to create a Javascript version of WebARKitLib. First, you need the WebARKitLib repository on your machine:

  1. Clone WebARKitLib project to get the latest source files. From within jsartoolkitNFT directory do git submodule update --init. If you already cloned WebARKitLib to a different directory you can:
  • create a link in the jsartoolkitNFT/emscripten/ directory that points to WebARKitLib (jsartoolkitNFT/emscripten/WebARKitLib)
  • or, set the WEBARKITLIB_ROOT environment variable to point to your WebARKitLib clone
  • or, change the tools/makem.js file to point to your WebARKitLib clone (line 20)
  1. Building

  2. Make sure EMSCRIPTEN env variable is set (e.g. EMSCRIPTEN=/usr/lib/emsdk_portable/emscripten/master/ node tools/makem.js

  3. Run npm install

  4. Run npm run build

During development, you can run npm run watch, it will rebuild the library everytime you change ./js/ directory. You can also run the script with the option npm run build-no-libar if you have already build libar.bc and you don't want to rebuild.

  1. The built ASM.js files are in /build. There's a build with debug symbols in artoolkitNFT.debug.js and the optimized build with bundled JS API in artoolkitNFT.min.js.
  2. (optional) if you are using the ES6 version you need also to build the distribution library in dist folder run : npm run build-ts