MONOGRID / gainmap-js

A Javascript (TypeScript) Port of Adobe Gainmap Technology for storing HDR Images using an SDR Image + a gainmap
https://monogrid.github.io/gainmap-js/
MIT License
82 stars 5 forks source link

Can't build the project #29

Closed ranbuch closed 7 months ago

ranbuch commented 7 months ago

Hi,

I'm getting this error after cloning this repo, running npm install and running npm run prepack.

This is the error:

import { MainModule } from '../../libultrahdr-wasm/build/libultrahdr'

I found this repo but I can't understand what should I copy from there to libultrahdr-wasm/build/.

daniele-pelagatti commented 7 months ago

Hi, thanks for reporting this. I'm afraid this is a documentation issue on my side, I'm going to update the README after resolving this Here's a rough draft, let me know if it works for you (I already pushed the rollup.config.decodeonly.mjs)

Building with full encoding support (libultrahdr-wasm)

Clone the repository with git submodules recursively:

$ git clone --recurse-submodules git@github.com:MONOGRID/gainmap-js.git 

Proceed to build the libultrahdr-wasm module following the documentation found here, here's a quick summary

$ cd gainmap-js/libultrahdr-wasm/

Create a meson "cross compile config" named em.txt and place the following content inside:

[binaries]
c = 'emcc'
cpp = 'em++'
ar = 'emar'
nm = 'emnm'

[host_machine]
system = 'emscripten'
cpu_family = 'wasm32'
cpu = 'wasm32'
endian = 'little'

Then execute

$ meson setup build --cross-file=em.txt
$ meson compile -C build

After compiling the WASM, head back to the main repository

$ cd ..
$ npm i
$ npm run build

Building with no encoding support (requires no wasm)

:warning: Building the library with decode only capabilities will not allow to run playwright e2e tests with npm run test this method should only be used by people who would like to customize the "decoding" part of the library but are unable to build the WASM module for some reason (emscripten can be tricky sometimes, I've been there)

Clone the repository normally:

$ git clone git@github.com:MONOGRID/gainmap-js.git 
$ cd gainmap-js
$ npm i

build with

$ npm run build --config rollup.config.decodeonly.mjs