From 8f8e07d287171d5deba8ae2d28256b00a3238ed5 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Thu, 30 Apr 2015 13:20:14 +0200 Subject: [PATCH] make jsconsole optional global dependency --- CMakeLists.txt | 15 +++++++++++++-- cmake/EthDependencies.cmake | 9 ++++++--- eth/CMakeLists.txt | 10 ++++++++-- eth/main.cpp | 8 ++++++++ 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97d108e6c..dc3c1ec32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,7 @@ option(GUI "Build GUI components (AlethZero, Mix)" ON) option(TESTS "Build the tests." ON) option(EVMJIT "Build just-in-time compiler for EVM code (requires LLVM)" OFF) option(ETHASHCL "Build in support for GPU mining via OpenCL" OFF) +option(JSCONSOLE "Build in javascript console" OFF) # propagates CMake configuration options to the compiler function(configureProject) @@ -193,9 +194,14 @@ eth_format_option(GUI) eth_format_option(TESTS) eth_format_option(TOOLS) eth_format_option(ETHASHCL) +eth_format_option(JSCONSOLE) eth_format_option_on_decent_platform(SERPENT) eth_format_option_on_decent_platform(NCURSES) +if (JSCONSOLE) + set(JSONRPC ON) +endif() + if (GUI) set(JSONRPC ON) endif() @@ -284,6 +290,7 @@ message("-- GUI Build GUI components ${GUI}") message("-- NCURSES Build NCurses components ${NCURSES}") message("-- TESTS Build tests ${TESTS}") message("-- ETHASHCL Build OpenCL components (experimental!) ${ETHASHCL}") +message("-- JSCONSOLE Build with javascript console ${JSCONSOLE}") message("-- EVMJIT Build LLVM-based JIT EVM (experimental!) ${EVMJIT}") message("------------------------------------------------------------------------") message("") @@ -327,8 +334,11 @@ if (JSONRPC) add_subdirectory(libweb3jsonrpc) endif() -add_subdirectory(libjsengine) -add_subdirectory(libjsconsole) +if (JSCONSOLE) + add_subdirectory(libjsengine) + add_subdirectory(libjsconsole) +endif() + add_subdirectory(secp256k1) add_subdirectory(libp2p) add_subdirectory(libdevcrypto) @@ -385,6 +395,7 @@ if (GUI) endif() + #unset(TARGET_PLATFORM CACHE) if (WIN32) diff --git a/cmake/EthDependencies.cmake b/cmake/EthDependencies.cmake index 1edc33b65..01564632f 100644 --- a/cmake/EthDependencies.cmake +++ b/cmake/EthDependencies.cmake @@ -47,9 +47,12 @@ find_package (LevelDB REQUIRED) message(" - LevelDB header: ${LEVELDB_INCLUDE_DIRS}") message(" - LevelDB lib: ${LEVELDB_LIBRARIES}") -find_package (v8 REQUIRED) -message(" - v8 header: ${V8_INCLUDE_DIRS}") -message(" - v8 lib : ${V8_LIBRARIES}") +if (JSCONSOLE) + find_package (v8 REQUIRED) + message(" - v8 header: ${V8_INCLUDE_DIRS}") + message(" - v8 lib : ${V8_LIBRARIES}") + add_definitions(-DETH_JSCONSOLE) +endif() # TODO the Jsoncpp package does not yet check for correct version number find_package (Jsoncpp 0.60 REQUIRED) diff --git a/eth/CMakeLists.txt b/eth/CMakeLists.txt index 2629befdd..a2396b432 100644 --- a/eth/CMakeLists.txt +++ b/eth/CMakeLists.txt @@ -6,7 +6,10 @@ aux_source_directory(. SRC_LIST) include_directories(BEFORE ..) include_directories(${Boost_INCLUDE_DIRS}) include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) -include_directories(${V8_INCLUDE_DIRS}) + +if (JSCONSOLE) + include_directories(${V8_INCLUDE_DIRS}) +endif() set(EXECUTABLE eth) @@ -33,7 +36,10 @@ endif() target_link_libraries(${EXECUTABLE} webthree) target_link_libraries(${EXECUTABLE} ethash) -target_link_libraries(${EXECUTABLE} jsconsole) + +if (JSCONSOLE) + target_link_libraries(${EXECUTABLE} jsconsole) +endif() if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW) eth_copy_dlls("${EXECUTABLE}" MHD_DLLS) diff --git a/eth/main.cpp b/eth/main.cpp index 5892ecd70..f4ad03b0b 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -38,7 +38,9 @@ #include #include #include +#if ETH_JSCONSOLE || !ETH_TRUE #include +#endif #if ETH_READLINE || !ETH_TRUE #include #include @@ -179,7 +181,9 @@ void help() << " -v,--verbosity <0 - 9> Set the log verbosity from 0 to 9 (default: 8)." << endl << " -V,--version Show the version and exit." << endl << " -h,--help Show this help message and exit." << endl +#if ETH_JSCONSOLE || !ETH_TRUE << " --console Use interactive javascript console" << endl +#endif ; exit(0); } @@ -881,8 +885,10 @@ int main(int argc, char** argv) else if (arg == "--json-rpc-port" && i + 1 < argc) jsonrpc = atoi(argv[++i]); #endif +#if ETH_JSCONSOLE else if (arg == "--console") useConsole = true; +#endif else if ((arg == "-v" || arg == "--verbosity") && i + 1 < argc) g_logVerbosity = atoi(argv[++i]); else if ((arg == "-x" || arg == "--peers") && i + 1 < argc) @@ -1619,6 +1625,7 @@ int main(int argc, char** argv) c->startMining(); if (useConsole) { +#if ETH_JSCONSOLE JSConsole console; while (!g_exit) { @@ -1627,6 +1634,7 @@ int main(int argc, char** argv) c->stopMining(); this_thread::sleep_for(chrono::milliseconds(100)); } +#endif } else while (!g_exit)