Skip to content

Commit

Permalink
Generate fbs headers files through cmake during build flow
Browse files Browse the repository at this point in the history
  • Loading branch information
vtangTT committed Oct 29, 2024
1 parent bfa337a commit 1ddcb2a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 219 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ compile_commands.json
.vscode/
*.log
*.csv

# Generated flatbuffer header for simulation device
device/simulation/tt_simulation_device_generated.h
25 changes: 24 additions & 1 deletion cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,34 @@ CPMAddPackage(
GITHUB_REPOSITORY google/flatbuffers
GIT_TAG v24.3.25
OPTIONS
"FLATBUFFERS_BUILD_FLATC OFF"
"FLATBUFFERS_BUILD_FLATC ON"
"FLATBUFFERS_BUILD_TESTS OFF"
"FLATBUFFERS_SKIP_MONSTER_EXTRA ON"
"FLATBUFFERS_STRICT_MODE ON"
)
function(GENERATE_FBS_HEADER FBS_FILE)
get_filename_component(FBS_FILE_NAME ${FBS_FILE} NAME)
get_filename_component(FBS_FILE_DIR ${FBS_FILE} DIRECTORY)
set(FBS_GENERATED_HEADER "${FBS_FILE_DIR}/${FBS_FILE_NAME}_generated.h")
add_custom_command(
OUTPUT
${FBS_GENERATED_HEADER}
COMMAND
flatc
ARGS
--cpp -o "${FBS_FILE_DIR}/" ${FBS_FILE}
DEPENDS
flatc
${FBS_FILE}
COMMENT "Building C++ header for ${FBS_FILE}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_custom_target(
flatbuffer_generated_header
DEPENDS
${FBS_GENERATED_HEADER}
)
endfunction()

############################################################################################################################
# libuv (for process management)
Expand Down
6 changes: 6 additions & 0 deletions device/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
set(POSITION_INDEPENDENT_CODE ON)

GENERATE_FBS_HEADER(
${PROJECT_SOURCE_DIR}/device/simulation/tt_simulation_device.fbs
)

set(UMD_DEVICE_SRCS
architecture_implementation.cpp
cpuset_lib.cpp
Expand All @@ -24,6 +28,8 @@ add_library(device SHARED ${UMD_DEVICE_SRCS})
add_library(${PROJECT_NAME}::device ALIAS device)
add_library(${PROJECT_NAME}_device ALIAS device) # For legacy I guess

add_dependencies(device flatbuffer_generated_header)

target_include_directories(
device
PUBLIC
Expand Down
218 changes: 0 additions & 218 deletions device/simulation/tt_simulation_device_generated.h

This file was deleted.

0 comments on commit 1ddcb2a

Please sign in to comment.