From 8ca0ae99ac3d908e96daf84a3656adec1893fbae Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 26 May 2014 11:22:19 +0200 Subject: [PATCH] Major reorganisation. New libs (libethsupport, libevm, liblll). New LLLC binary. --- CMakeLists.txt | 56 ++++++++++++++++++++++++++ main.cpp | 106 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..ff5d672d0 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,56 @@ +cmake_policy(SET CMP0015 NEW) + +aux_source_directory(. SRC_LIST) + +include_directories(..) +#link_directories(../libethsupport) +#link_directories(../libethcore) +#link_directories(../liblll) + +set(EXECUTABLE lllc) + +add_executable(${EXECUTABLE} ${SRC_LIST}) + +if (JSONRPC_LS) + add_definitions(-DETH_JSONRPC) + include_directories(${JSONRPC_ID}) + target_link_libraries(${EXECUTABLE} ${JSONRPC_LS}) +endif () + +if (READLINE_LS) + add_definitions(-DETH_READLINE) + include_directories(${READLINE_ID}) + target_link_libraries(${EXECUTABLE} ${READLINE_LS}) +endif () + +if (${TARGET_PLATFORM} STREQUAL "w64") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++") + target_link_libraries(${EXECUTABLE} gcc) + target_link_libraries(${EXECUTABLE} gdi32) + target_link_libraries(${EXECUTABLE} ws2_32) + target_link_libraries(${EXECUTABLE} mswsock) + target_link_libraries(${EXECUTABLE} shlwapi) + target_link_libraries(${EXECUTABLE} iphlpapi) + target_link_libraries(${EXECUTABLE} cryptopp) + target_link_libraries(${EXECUTABLE} boost_system-mt-s) + target_link_libraries(${EXECUTABLE} boost_filesystem-mt-s) + target_link_libraries(${EXECUTABLE} boost_thread_win32-mt-s) + set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS) +elseif (UNIX) +else () + target_link_libraries(${EXECUTABLE} ${CRYPTOPP_LIBRARIES}) + target_link_libraries(${EXECUTABLE} boost_system) + target_link_libraries(${EXECUTABLE} boost_filesystem) + find_package(Threads REQUIRED) + target_link_libraries(${EXECUTABLE} ${CMAKE_THREAD_LIBS_INIT}) +endif () + +target_link_libraries(${EXECUTABLE} lll) +target_link_libraries(${EXECUTABLE} ethcore) +target_link_libraries(${EXECUTABLE} ethsupport) +target_link_libraries(${EXECUTABLE} ${MINIUPNPC_LS}) +target_link_libraries(${EXECUTABLE} ${LEVELDB_LS}) +target_link_libraries(${EXECUTABLE} gmp) + +install( TARGETS ${EXECUTABLE} DESTINATION bin ) + diff --git a/main.cpp b/main.cpp new file mode 100644 index 000000000..1afc3ef69 --- /dev/null +++ b/main.cpp @@ -0,0 +1,106 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file main.cpp + * @author Gav Wood + * @date 2014 + * Ethereum client. + */ + +#include +#include +#include +#include +#include +#include "BuildInfo.h" +using namespace std; +using namespace eth; + +void help() +{ + cout + << "Usage lllc [OPTIONS] " << endl + << "Options:" << endl + << " -h,--help Show this help message and exit." << endl + << " -V,--version Show the version and exit." << endl; + exit(0); +} + +void version() +{ + cout << "LLLC, the Lovely Little Language Compiler " << ETH_QUOTED(ETH_VERSION) << endl; + cout << " By Gav Wood, (c) 2014." << endl; + cout << "Build: " << ETH_QUOTED(ETH_BUILD_PLATFORM) << "/" << ETH_QUOTED(ETH_BUILD_TYPE) << endl; + exit(0); +} + +enum Mode { Binary, Hex, ParseTree }; + +int main(int argc, char** argv) +{ + string infile; + Mode mode = Hex; + + for (int i = 1; i < argc; ++i) + { + string arg = argv[i]; + if (arg == "-h" || arg == "--help") + help(); + else if (arg == "-b" || arg == "--binary") + mode = Binary; + else if (arg == "-h" || arg == "--hex") + mode = Hex; + else if (arg == "-t" || arg == "--parse-tree") + mode = ParseTree; + else if (arg == "-V" || arg == "--version") + version(); + else + infile = argv[i]; + } + + string src; + if (infile.empty()) + { + string s; + while (!cin.eof()) + { + getline(cin, s); + src.append(s); + } + } + else + src = asString(contents(infile)); + + if (src.empty()) + cerr << "Empty file." << endl; + else if (mode == Binary || mode == Hex) + { + vector errors; + auto bs = compileLLL(src, &errors); + if (mode == Hex) + cout << toHex(bs) << endl; + else if (mode == Binary) + cout.write((char const*)bs.data(), bs.size()); + for (auto const& i: errors) + cerr << i << endl; + } + else if (mode == ParseTree) + { + cout << parseLLL(src) << endl; + } + + return 0; +}