diff options
Diffstat (limited to 'solc')
-rw-r--r-- | solc/CMakeLists.txt | 2 | ||||
-rw-r--r-- | solc/CommandLineInterface.cpp | 15 | ||||
-rw-r--r-- | solc/CommandLineInterface.h | 2 | ||||
-rw-r--r-- | solc/jsonCompiler.cpp | 13 | ||||
-rw-r--r-- | solc/main.cpp | 2 |
5 files changed, 20 insertions, 14 deletions
diff --git a/solc/CMakeLists.txt b/solc/CMakeLists.txt index a5515d81..18e83e75 100644 --- a/solc/CMakeLists.txt +++ b/solc/CMakeLists.txt @@ -18,7 +18,7 @@ else() endif() if (EMSCRIPTEN) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s EXPORTED_FUNCTIONS='[\"_compileJSON\",\"_version\",\"_compileJSONMulti\",\"_compileJSONCallback\",\"_compileStandard\"]' -s RESERVED_FUNCTION_POINTERS=20") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s EXPORTED_FUNCTIONS='[\"_compileJSON\",\"_license\",\"_version\",\"_compileJSONMulti\",\"_compileJSONCallback\",\"_compileStandard\"]' -s RESERVED_FUNCTION_POINTERS=20") add_executable(soljson jsonCompiler.cpp ${HEADERS}) eth_use(soljson REQUIRED Solidity::solidity) else() diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index d0134113..740061a1 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -190,6 +190,7 @@ static void version() static void license() { + cout << otherLicenses << endl; // This is a static variable generated by cmake from LICENSE.txt cout << licenseText << endl; exit(0); @@ -291,12 +292,12 @@ void CommandLineInterface::handleSignatureHashes(string const& _contract) cout << "Function signatures: " << endl << out; } -void CommandLineInterface::handleOnChainMetadata(string const& _contract) +void CommandLineInterface::handleMetadata(string const& _contract) { if (!m_args.count(g_argMetadata)) return; - string data = m_compiler->onChainMetadata(_contract); + string data = m_compiler->metadata(_contract); if (m_args.count(g_argOutputDir)) createFile(m_compiler->filesystemFriendlyName(_contract) + "_meta.json", data); else @@ -773,10 +774,14 @@ bool CommandLineInterface::processInput() m_compiler->setRemappings(m_args[g_argInputFile].as<vector<string>>()); for (auto const& sourceCode: m_sourceCodes) m_compiler->addSource(sourceCode.first, sourceCode.second); + if (m_args.count(g_argLibraries)) + m_compiler->setLibraries(m_libraries); // TODO: Perhaps we should not compile unless requested bool optimize = m_args.count(g_argOptimize) > 0; unsigned runs = m_args[g_argOptimizeRuns].as<unsigned>(); - bool successful = m_compiler->compile(optimize, runs, m_libraries); + m_compiler->setOptimiserSettings(optimize, runs); + + bool successful = m_compiler->compile(); for (auto const& error: m_compiler->errors()) SourceReferenceFormatter::printExceptionInformation( @@ -849,7 +854,7 @@ void CommandLineInterface::handleCombinedJSON() if (requests.count(g_strAbi)) contractData[g_strAbi] = dev::jsonCompactPrint(m_compiler->contractABI(contractName)); if (requests.count("metadata")) - contractData["metadata"] = m_compiler->onChainMetadata(contractName); + contractData["metadata"] = m_compiler->metadata(contractName); if (requests.count(g_strBinary)) contractData[g_strBinary] = m_compiler->object(contractName).toHex(); if (requests.count(g_strBinaryRuntime)) @@ -1163,7 +1168,7 @@ void CommandLineInterface::outputCompilationResults() handleBytecode(contract); handleSignatureHashes(contract); - handleOnChainMetadata(contract); + handleMetadata(contract); handleABI(contract); handleNatspec(DocumentationType::NatspecDev, contract); handleNatspec(DocumentationType::NatspecUser, contract); diff --git a/solc/CommandLineInterface.h b/solc/CommandLineInterface.h index b482c20b..8a476ef5 100644 --- a/solc/CommandLineInterface.h +++ b/solc/CommandLineInterface.h @@ -64,7 +64,7 @@ private: void handleOpcode(std::string const& _contract); void handleBytecode(std::string const& _contract); void handleSignatureHashes(std::string const& _contract); - void handleOnChainMetadata(std::string const& _contract); + void handleMetadata(std::string const& _contract); void handleABI(std::string const& _contract); void handleNatspec(DocumentationType _type, std::string const& _contract); void handleGasEstimation(std::string const& _contract); diff --git a/solc/jsonCompiler.cpp b/solc/jsonCompiler.cpp index 1d31ea30..ab928ac0 100644 --- a/solc/jsonCompiler.cpp +++ b/solc/jsonCompiler.cpp @@ -38,6 +38,9 @@ extern "C" { typedef void (*CStyleReadFileCallback)(char const* _path, char** o_contents, char** o_error); } +namespace +{ + ReadFile::Callback wrapReadCallback(CStyleReadFileCallback _readCallback = nullptr) { ReadFile::Callback readCallback; @@ -164,10 +167,6 @@ string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback // "srcmapRuntime" = "0:1:2", // "assembly" = {} // } - // }, - // "formal": { - // "errors": [ "Error 1" ], - // "why3": "why3 source" // } // } Json::Value output = Json::objectValue; @@ -264,14 +263,16 @@ string compileStandardInternal(string const& _input, CStyleReadFileCallback _rea return compiler.compile(_input); } +} + static string s_outputBuffer; extern "C" { extern char const* license() { - /// TOOD: include the copyright information on the top. - return licenseText; + static string fullLicenseText = otherLicenses + licenseText; + return fullLicenseText.c_str(); } extern char const* version() { diff --git a/solc/main.cpp b/solc/main.cpp index c61da6e9..6d559542 100644 --- a/solc/main.cpp +++ b/solc/main.cpp @@ -40,7 +40,7 @@ specified default locale if it is valid, and if not then it will modify the environment the process is running in to use a sensible default. This also means that users do not need to install language packs for their OS. */ -void setDefaultOrCLocale() +static void setDefaultOrCLocale() { #if __unix__ if (!std::setlocale(LC_ALL, "")) |