Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.swp
*__pycache__*
build/
56 changes: 56 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
cmake_minimum_required(VERSION 3.11)
project(milestone1 CXX)

# Set the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# --- Fetch gsl-lite (header-only) ---
include(FetchContent)
FetchContent_Declare(
gsl-lite
GIT_REPOSITORY https://github.com/gsl-lite/gsl-lite.git
GIT_TAG v0.42.0 # Use the tag "v0.42.0" as specified
SOURCE_SUBDIR include # Only fetch the header files from the "include" folder
)
FetchContent_MakeAvailable(gsl-lite)

# --- Define an interface target for gsl-lite as GSL::GSL ---
if (NOT TARGET GSL::GSL)
add_library(GSL INTERFACE)
# Add the directory that contains gsl.hpp so that the user can simply do #include <gsl.hpp>
target_include_directories(GSL INTERFACE ${gsl-lite_SOURCE_DIR}/include)
add_library(GSL::GSL ALIAS GSL)
endif()

# --- Fetch tartanllama expected (header-only) ---
FetchContent_Declare(
tl_expected
GIT_REPOSITORY https://github.com/TartanLlama/expected.git
GIT_TAG v1.1.0 # Adjust the version/tag as needed; for example "0.8.0"
SOURCE_SUBDIR include # Only fetch the header files from the "include" folder
)
FetchContent_MakeAvailable(tl_expected)

# --- Define an interface target for tartanllama expected as TL::expected ---
if (NOT TARGET TL::expected)
add_library(TL_EXPECTED INTERFACE)
# Add the directory that directly contains the "tl" folder so that
# you can include <tl/expected.hpp> without an extra "include/" prefix.
target_include_directories(TL_EXPECTED INTERFACE ${tl_expected_SOURCE_DIR}/include)
add_library(TL::expected ALIAS TL_EXPECTED)
endif()

# --- Define source file and executable ---
set(SOURCE_FILE "${CMAKE_SOURCE_DIR}/python/test_types/milestone1_main.cc")
add_executable(milestone1 ${SOURCE_FILE})

# --- Use these include directories for milestone1 ---
target_include_directories(milestone1 PRIVATE
"${CMAKE_SOURCE_DIR}/python/test_types"
"${CMAKE_SOURCE_DIR}/python/milestone1/test_types/milestone1"
"${CMAKE_SOURCE_DIR}/c/src/runtime"
)

# --- Link dependencies ---
target_link_libraries(milestone1 PRIVATE GSL::GSL TL::expected)
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,13 @@ cd python;
nix-shell;
python -m tako.main generate bakery_test/ test_types.bakery.Bakery cpp
```
To build milestone1

cd build
cmake --build .

Purely as a point of interest, it seems that PrimitiveView::parse is only used when it's necessary as the slave key of some bigger type ( struct, etc. ) otherwise it always just renders.

The parse function on some bigger type doesn't check primitive fields parse, just the complex ones. Although maybe these are functionally equivalent as long as the total size is there

rendering still tries to parse those, but it just calls .value()
Loading