From 6d7cf7bace73fa378ad709dba56abc20804d1a7e Mon Sep 17 00:00:00 2001 From: Gabriel Ebner Date: Sun, 16 Oct 2016 11:26:52 -0400 Subject: [PATCH] fix(tests/shell): fix build --- src/shell/CMakeLists.txt | 4 +++- src/shell/lean_js.cpp | 20 -------------------- src/shell/lean_js_main.cpp | 28 ++++++++++++++++++++++++++++ src/tests/shell/CMakeLists.txt | 4 ++-- 4 files changed, 33 insertions(+), 23 deletions(-) create mode 100644 src/shell/lean_js_main.cpp diff --git a/src/shell/CMakeLists.txt b/src/shell/CMakeLists.txt index b2377d6683..abbee01816 100644 --- a/src/shell/CMakeLists.txt +++ b/src/shell/CMakeLists.txt @@ -2,9 +2,11 @@ add_executable(lean lean.cpp json.cpp server.cpp) target_link_libraries(lean leanstatic) install(TARGETS lean DESTINATION bin) -add_executable(lean_js lean_js.cpp) +add_executable(lean_js lean_js.cpp lean_js_main.cpp) target_link_libraries(lean_js leanstatic) +add_library(shell_js OBJECT lean_js.cpp) + if(${EMSCRIPTEN}) target_link_libraries(lean "--memory-init-file 0") diff --git a/src/shell/lean_js.cpp b/src/shell/lean_js.cpp index c8b5c54bec..f38487e3b3 100644 --- a/src/shell/lean_js.cpp +++ b/src/shell/lean_js.cpp @@ -81,23 +81,3 @@ int emscripten_import_module(std::string mname) { int emscripten_process_file(std::string input_filename) { return g_shell->process_file(input_filename); } - -#if defined(LEAN_EMSCRIPTEN) - -#include -EMSCRIPTEN_BINDINGS(LEAN_JS) { - emscripten::function("lean_init", &initialize_emscripten); - emscripten::function("lean_import_module", &emscripten_import_module); - emscripten::function("lean_process_file", &emscripten_process_file); -} - -int main() { return 0; } - -#else - -int main(int, char **) { - initialize_emscripten(); - emscripten_import_module("standard"); -} - -#endif diff --git a/src/shell/lean_js_main.cpp b/src/shell/lean_js_main.cpp new file mode 100644 index 0000000000..c5812fdb3c --- /dev/null +++ b/src/shell/lean_js_main.cpp @@ -0,0 +1,28 @@ +/* +Copyright (c) 2015 Microsoft Corporation. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. + +Author: Leonardo de Moura +*/ +#include +#include "shell/lean_js.h" + +#if defined(LEAN_EMSCRIPTEN) + +#include +EMSCRIPTEN_BINDINGS(LEAN_JS) { + emscripten::function("lean_init", &initialize_emscripten); + emscripten::function("lean_import_module", &emscripten_import_module); + emscripten::function("lean_process_file", &emscripten_process_file); +} + +int main() { return 0; } + +#else + +int main(int, char **) { + initialize_emscripten(); + emscripten_import_module("standard"); +} + +#endif diff --git a/src/tests/shell/CMakeLists.txt b/src/tests/shell/CMakeLists.txt index f41ef2bb3c..ca0c077d11 100644 --- a/src/tests/shell/CMakeLists.txt +++ b/src/tests/shell/CMakeLists.txt @@ -1,5 +1,5 @@ -add_executable(shell_test shell.cpp ${LEAN_OBJS}) -target_link_libraries(shell_test ${EXTRA_LIBS}) +add_executable(shell_test shell.cpp $) +target_link_libraries(shell_test leanstatic) # TODO(Leo): add after stdlib is activated again # add_test(NAME "emscripten_test"