Fix Web Build after CMake transition. (#2407)

This commit is contained in:
Tianqi Chen 2019-01-09 12:19:53 -08:00 коммит произвёл GitHub
Родитель 64e5681ddd
Коммит 794bf7fe6e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 19 добавлений и 18 удалений

Просмотреть файл

@ -32,7 +32,7 @@ cpptest:
EMCC_FLAGS= -std=c++11 -DDMLC_LOG_STACK_TRACE=0\
-Oz -s RESERVED_FUNCTION_POINTERS=2 -s MAIN_MODULE=1 -s NO_EXIT_RUNTIME=1\
-s TOTAL_MEMORY=1073741824\
-s EXTRA_EXPORTED_RUNTIME_METHODS="['cwrap','getValue','setValue','addFunction']"\
-s EXTRA_EXPORTED_RUNTIME_METHODS="['addFunction','cwrap','getValue','setValue']"\
-s USE_GLFW=3 -s USE_WEBGL2=1 -lglfw\
$(INCLUDE_FLAGS)

Просмотреть файл

@ -17,8 +17,8 @@ def find_example_resource():
index_page = os.path.join(base_path, "web/example_rpc.html")
js_files = [
os.path.join(base_path, "web/tvm_runtime.js"),
os.path.join(base_path, "lib/libtvm_web_runtime.js"),
os.path.join(base_path, "lib/libtvm_web_runtime.js.mem")
os.path.join(base_path, "build/libtvm_web_runtime.js"),
os.path.join(base_path, "build/libtvm_web_runtime.js.mem")
]
for fname in [index_page] + js_files:
if not os.path.exists(fname):

Просмотреть файл

@ -18,4 +18,4 @@ def prepare_test_libs(base_path):
if __name__ == "__main__":
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
prepare_test_libs(os.path.join(curr_path, "../../lib"))
prepare_test_libs(os.path.join(curr_path, "../../build"))

Просмотреть файл

@ -1,7 +1,7 @@
// Load Emscripten Module, need to change path to root/lib
// Load Emscripten Module, need to change path to root/build
const path = require("path");
process.chdir(path.join(__dirname, "../../lib"));
var Module = require("../../lib/libtvm_web_runtime.js");
process.chdir(path.join(__dirname, "../../build"));
var Module = require("../../build/libtvm_web_runtime.js");
// Bootstrap TVMruntime with emscripten module.
const tvm_runtime = require("../../web/tvm_runtime.js");
const tvm = tvm_runtime.create(Module);

Просмотреть файл

@ -1,7 +1,7 @@
// Load Emscripten Module, need to change path to root/lib
const path = require("path");
process.chdir(path.join(__dirname, "../../lib"));
var Module = require("../../lib/test_module.js");
process.chdir(path.join(__dirname, "../../build"));
var Module = require("../../build/test_module.js");
// Bootstrap TVMruntime with emscripten module.
const tvm_runtime = require("../../web/tvm_runtime.js");
const tvm = tvm_runtime.create(Module);

Просмотреть файл

@ -1,7 +1,7 @@
// Load Emscripten Module, need to change path to root/lib
// Load Emscripten Module, need to change path to root/build
const path = require("path");
process.chdir(path.join(__dirname, "../../lib"));
var Module = require("../../lib/libtvm_web_runtime.js");
process.chdir(path.join(__dirname, "../../build"));
var Module = require("../../build/libtvm_web_runtime.js");
// Bootstrap TVMruntime with emscripten module.
const tvm_runtime = require("../../web/tvm_runtime.js");
const tvm = tvm_runtime.create(Module);

Просмотреть файл

@ -59,7 +59,7 @@ to do so, make sure we set the environment correctly as in previous section and
make web
```
This will create ```lib/libtvm_web_runtime.bc``` and ```lib/libtvm_web_runtime.js```.
This will create ```build/libtvm_web_runtime.bc``` and ```build/libtvm_web_runtime.js```.
## Use TVM to Generate Javascript Library
@ -87,11 +87,11 @@ def prepare_test_libs(base_path):
if __name__ == "__main__":
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
prepare_test_libs(os.path.join(curr_path, "../../lib"))
prepare_test_libs(os.path.join(curr_path, "../../build"))
```
In this workflow, we use TVM to generate a ```.bc``` file and statically link
that with the ```lib/libtvm_web_runtime.bc```(emscripten.create_js will help you do that).
that with the ```build/libtvm_web_runtime.bc```(emscripten.create_js will help you do that).
The result js library is a library that contains both TVM runtime and the compiled function.
@ -101,10 +101,10 @@ The following code snippet from [tests/web/test_module_load.js](https://github.c
how to run the compiled library.
```js
// Load Emscripten Module, need to change path to root/lib
// Load Emscripten Module, need to change path to root/build
const path = require("path");
process.chdir(path.join(__dirname, "../../lib"));
var Module = require("../../lib/test_module.js");
process.chdir(path.join(__dirname, "../../buld"));
var Module = require("../../build/test_module.js");
// Bootstrap TVMruntime with emscripten module.
const tvm_runtime = require("../../web/tvm_runtime.js");
const tvm = tvm_runtime.create(Module);

Просмотреть файл

@ -11,6 +11,7 @@
#include "../src/runtime/module_util.cc"
#include "../src/runtime/system_lib_module.cc"
#include "../src/runtime/module.cc"
#include "../src/runtime/ndarray.cc"
#include "../src/runtime/registry.cc"
#include "../src/runtime/file_util.cc"
#include "../src/runtime/dso_module.cc"