Skip to content

Commit 60d5272

Browse files
Add C++ transpiler backend with build-time generated tests
Co-Authored-By: zemanadam893@gmail.com <zemanadam893@gmail.com>
1 parent 8d1a165 commit 60d5272

23 files changed

Lines changed: 2872 additions & 0 deletions

‎src/engine/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ target_sources(scratchcpp
4545
)
4646

4747
add_subdirectory(internal/llvm)
48+
add_subdirectory(internal/cpp)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
target_sources(scratchcpp
2+
PRIVATE
3+
cppprelude.h
4+
cppruntime.cpp
5+
cppruntime.h
6+
cppcodebuilder.cpp
7+
cppcodebuilder.h
8+
cppcodebuilderfactory.cpp
9+
cppcodebuilderfactory.h
10+
cppregister.h
11+
cppcompilercontext.cpp
12+
cppcompilercontext.h
13+
cppexecutablecode.cpp
14+
cppexecutablecode.h
15+
cppexecutioncontext.cpp
16+
cppexecutioncontext.h
17+
)
18+
19+
# Embed the runtime prelude into the library, it's a part of the generated code
20+
set(CPP_PRELUDE_HEADER ${CMAKE_CURRENT_BINARY_DIR}/cppprelude_source.h)
21+
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/cppprelude.h CPP_PRELUDE_CONTENT)
22+
file(WRITE ${CPP_PRELUDE_HEADER} "// Generated from cppprelude.h\n#pragma once\n\nstatic const char *CPP_PRELUDE_SOURCE = R\"scpp_raw(${CPP_PRELUDE_CONTENT})scpp_raw\";\n")
23+
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cppprelude.h)
24+
25+
target_include_directories(scratchcpp PRIVATE ${CMAKE_CURRENT_BINARY_DIR})

0 commit comments

Comments
 (0)