Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add experimental support for WebAssembly #20

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

njor
Copy link

@njor njor commented May 5, 2017

Just a few simple modifications to be able to compile to WebAssembly.

README.md Outdated

1. Get the source code (just like above)

2. Install the "incoming" branch of emscripten. You can obtain emscripten by using [Emscripten SDK](https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, something like that ?
2. Install the "incoming" branch of emscripten. You can obtain emscripten by using [Emscripten SDK](https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html). At the time of writing, the current version of Emscripten does not support WebAssembly yet, so you will need to install the "incoming" branch (see as well WebAssembly’s [Developer’s Guide](http://webassembly.org/getting-started/developers-guide/) for a short introduction about WebAssembly).

--- ./emscripten/master/src/embind/embind.js 2016-12-20 13:05:20.498980029 -0800
+++ ./emscripten/master/src/embind/embind.js 2016-12-20 13:12:11.599146929 -0800
--- ./src/embind/embind.js 2016-12-20 13:05:20.498980029 -0800
+++ ./src/embind/embind.js 2016-12-20 13:12:11.599146929 -0800
Copy link
Collaborator

@huningxin huningxin May 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file change needed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes the patch more generic, and usable with both emscripten/master and emscripten/incoming by changing just the patch command line (cf readme).

basename = "cv"

destFiles = [ os.path.join('..', '..', 'build', basename + ext ) for ext in [ ".js", ".data", ".wasm" ] ]
opencv = destFiles[0]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about following directory structure?

build
  |----js
  |      |---- cv.js
  |      |---- cv.data
  |----wasm
            |----cv.wasm
            |----cv.data

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, putting all the files in the same folder with different names seemed simpler to me for the time being, as the .js file generated by emscripten expects to find its related .data (and .wasm, in case of WebAssembly) in the same folder as the .html file.
Having all the files in the same folder with different names depending on the technology used (WebAssembly or asm.js) simplifies the use: the user can just copy everything in build/ to the folder of his/her .html file, and then either load cv.js or cv-wasm.js depending on what technology s/he wants to use.

@drhouse82
Copy link

I think the compiled files are not up to date with the last source changes, are they?
I suggest newest compiled files.

@drhouse82
Copy link

to be added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants