mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add cmake-based header generation
This commit is contained in:
parent
37f4a1c64e
commit
a710ec1b4e
@ -140,6 +140,7 @@ add_subdirectory(libevmasm)
|
||||
add_subdirectory(libyul)
|
||||
add_subdirectory(libsolidity)
|
||||
add_subdirectory(libsolc)
|
||||
add_subdirectory(stdlib)
|
||||
add_subdirectory(tools)
|
||||
|
||||
if (NOT EMSCRIPTEN)
|
||||
|
21
stdlib/CMakeLists.txt
Normal file
21
stdlib/CMakeLists.txt
Normal file
@ -0,0 +1,21 @@
|
||||
# This will re-generate the headers if any file within src was modified.
|
||||
set_directory_properties(PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/stdlib/src/)
|
||||
|
||||
set(STDLIB precompiles)
|
||||
set(GENERATED_STDLIB_HEADERS)
|
||||
foreach(src IN LISTS STDLIB)
|
||||
set(STDLIB_FILE ${CMAKE_SOURCE_DIR}/stdlib/src/${src}.sol)
|
||||
file(READ ${STDLIB_FILE} STDLIB_FILE_CONTENT HEX)
|
||||
string(REGEX MATCHALL ".." STDLIB_FILE_CONTENT "${STDLIB_FILE_CONTENT}")
|
||||
string(REGEX REPLACE ";" ",\n\t0x" STDLIB_FILE_CONTENT "${STDLIB_FILE_CONTENT}")
|
||||
set(STDLIB_FILE_CONTENT "0x${STDLIB_FILE_CONTENT}")
|
||||
set(STDLIB_FILE_NAME ${src})
|
||||
configure_file("${CMAKE_SOURCE_DIR}/stdlib/stdlib.src.h.in" ${CMAKE_BINARY_DIR}/include/stdlib/${src}.h @ONLY)
|
||||
list(APPEND GENERATED_STDLIB_HEADERS ${CMAKE_BINARY_DIR}/include/stdlib/${src}.h)
|
||||
endforeach()
|
||||
|
||||
configure_file("${CMAKE_SOURCE_DIR}/stdlib/stdlib.h.in" ${CMAKE_BINARY_DIR}/include/stdlib.h @ONLY)
|
||||
|
||||
#add_library(stdlib
|
||||
# ${GENERATED_STDLIB_HEADERS}
|
||||
#)
|
15
stdlib/stdlib.h.in
Normal file
15
stdlib/stdlib.h.in
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "stdlib/precompiles.h"
|
||||
|
||||
namespace solidity::stdlib
|
||||
{
|
||||
|
||||
static std::map<std::string, std::string> sources = {
|
||||
{ "std/precompiles.sol", precompiles },
|
||||
};
|
||||
|
||||
} // namespace solidity::stdlib
|
13
stdlib/stdlib.src.h.in
Normal file
13
stdlib/stdlib.src.h.in
Normal file
@ -0,0 +1,13 @@
|
||||
// The generation of this file is defined in stdlib/CMakeLists.txt.
|
||||
// This file was generated by using the content of stdlib/src/@STDLIB_FILE_NAME@.sol.
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace solidity::stdlib
|
||||
{
|
||||
|
||||
static char const @STDLIB_FILE_NAME@[] = {
|
||||
@STDLIB_FILE_CONTENT@, 0
|
||||
};
|
||||
|
||||
} // namespace solidity::stdlib
|
Loading…
Reference in New Issue
Block a user