@@ -30,20 +30,25 @@ if(NOT EXECUTORCH_ROOT)
30
30
set (EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR} /.. )
31
31
endif ()
32
32
33
+ if (NOT FLATC_EXECUTABLE )
34
+ set (FLATC_EXECUTABLE flatc )
35
+ endif ()
36
+
33
37
# Paths to headers generated from the .fbs files. set(_etdump_schemas
34
38
# etdump_schema_flatcc.fbs scalar_type.fbs)
35
39
36
- set (_etdump_schema__srcs
37
- ${CMAKE_CURRENT_SOURCE_DIR} /etdump/etdump_schema_flatcc.fbs
38
- ${CMAKE_CURRENT_SOURCE_DIR} /etdump/scalar_type.fbs )
39
-
40
+ set (_etdump_schema_names "etdump_schema_flatcc.fbs" "scalar_type.fbs" )
41
+ set (_bundled_input_schema_names "bundled_program_schema.fbs" "scalar_type.fbs" )
40
42
41
- set (_bundled_program_schema_dir
42
- ${CMAKE_CURRENT_SOURCE_DIR} /bundled_program/schema )
43
+ foreach (schema_file ${_etdump_schema_names} )
44
+ list (APPEND _etdump_schema__srcs
45
+ "${CMAKE_CURRENT_SOURCE_DIR} /etdump/${schema_file} " )
46
+ endforeach ()
43
47
44
- set (_bundled_program_schema__srcs
45
- ${_bundled_program_schema_dir} /bundled_program_schema.fbs
46
- ${_bundled_program_schema_dir} /scalar_type.fbs )
48
+ foreach (schema_file ${_bundled_input_schema_names} )
49
+ list (APPEND _bundled_program_schema__srcs
50
+ "${CMAKE_CURRENT_SOURCE_DIR} /bundled_program/schema/${schema_file} " )
51
+ endforeach ()
47
52
48
53
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /../third-party/flatcc
49
54
${CMAKE_BINARY_DIR} /third-party/flatcc )
@@ -53,6 +58,7 @@ include(ExternalProject)
53
58
54
59
# The include directory that will contain the generated schema headers.
55
60
set (_program_schema__include_dir "${CMAKE_BINARY_DIR} /sdk/include" )
61
+ set (_bundled_schema__include_dir "${CMAKE_BINARY_DIR} /sdk/bundled_program" )
56
62
57
63
# Add the host project
58
64
# lint_cmake: -readability/wonkycase
@@ -65,30 +71,33 @@ ExternalProject_Add(
65
71
)
66
72
67
73
set (_etdump_schema__outputs )
68
- foreach (fbs_file ${_etdump_schema__srcs} )
69
- string (REGEX REPLACE "[.]fbs$" "_generated.h" generated "${fbs_file} " )
74
+ foreach (fbs_file ${_etdump_schema_names} )
75
+ string (REGEX REPLACE "[.]fbs$" "_reader.h" generated "${fbs_file} " )
76
+ list (APPEND _etdump_schema__outputs
77
+ "${_program_schema__include_dir} /executorch/sdk/etdump/${generated} " )
78
+ string (REGEX REPLACE "[.]fbs$" "_builder.h" generated "${fbs_file} " )
70
79
list (APPEND _etdump_schema__outputs
71
- "${_program_schema__include_dir} /${generated} " )
80
+ "${_program_schema__include_dir} /executorch/sdk/etdump/ ${generated} " )
72
81
endforeach ()
73
82
83
+ # lint_cmake: -linelength
74
84
set (_bundled_program_schema__outputs )
75
- foreach (fbs_file ${_bundled_program_schema__srcs } )
85
+ foreach (fbs_file ${_bundled_input_schema_names } )
76
86
string (REGEX REPLACE "[.]fbs$" "_generated.h" generated "${fbs_file} " )
77
- list (APPEND _bundled_program_schema__outputs
78
- "${_program_schema__include_dir} /${generated} " )
87
+ list (
88
+ APPEND
89
+ _bundled_program_schema__outputs
90
+ "${_bundled_schema__include_dir} /executorch/sdk/bundled_program/schema/${generated} "
91
+ )
79
92
endforeach ()
80
93
81
94
add_library (etdump_schema INTERFACE ${_etdump_schema__outputs} )
82
- add_library (bundled_program_schema
83
- INTERFACE ${_bundled_program_schema__outputs} )
95
+ add_library (bundled_program_schema INTERFACE
96
+ ${_bundled_program_schema__outputs} )
84
97
85
98
# Ensure the host tool is built before the main project
86
99
add_dependencies (etdump_schema flatcc_cli )
87
100
88
- message ("Debug _etdump_schema__outputs: ${_etdump_schema__outputs} " )
89
- message ("Debug _bundled_program_schema__outputs:\
90
- ${_bundled_program_schema__outputs} " )
91
-
92
101
file (MAKE_DIRECTORY ${_program_schema__include_dir} /executorch/sdk/etdump )
93
102
file (MAKE_DIRECTORY
94
103
${_program_schema__include_dir} /executorch/sdk/bundled_program )
@@ -104,23 +113,35 @@ add_custom_command(
104
113
COMMENT "Generating etdump headers"
105
114
VERBATIM )
106
115
116
+ add_library (etdump ${CMAKE_CURRENT_SOURCE_DIR} /etdump/etdump_flatcc.cpp
117
+ ${CMAKE_CURRENT_SOURCE_DIR} /etdump/emitter.cpp )
118
+
119
+ target_link_libraries (
120
+ etdump
121
+ PUBLIC etdump_schema
122
+ PRIVATE executorch )
123
+
107
124
add_custom_command (
108
125
OUTPUT ${_bundled_program_schema__outputs}
109
126
COMMAND
110
- ${CMAKE_SOURCE_DIR} /third-party/flatcc/bin/flatcc -cwr -o
111
- ${_program_schema__include_dir }/executorch/sdk/bundled_program
127
+ ${FLATC_EXECUTABLE} --cpp --cpp-std c++11 --gen-mutable --scoped-enums -o
128
+ " ${_bundled_schema__include_dir } /executorch/sdk/bundled_program/schema"
112
129
${_bundled_program_schema__srcs}
113
130
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} /sdk
114
- DEPENDS flatcc_project
131
+ DEPENDS ${FLATC_EXECUTABLE} ${_bundled_program_schema__srcs}
115
132
COMMENT "Generating bundled_program headers"
116
133
VERBATIM )
117
134
118
- target_include_directories (
119
- etdump PUBLIC ${_program_schema__include_dir}
120
- ${CMAKE_SOURCE_DIR} /third-party/flatcc/include )
135
+ # add_library(bundled_program INTERFACE ${_bundled_program_schema__outputs})
136
+ add_library (bundled_program
137
+ ${CMAKE_CURRENT_SOURCE_DIR} /bundled_program/bundled_program.cpp )
138
+ target_link_libraries (bundled_program executorch bundled_program_schema )
121
139
122
140
set_target_properties (bundled_program PROPERTIES LINKER_LANGUAGE CXX )
123
141
target_include_directories (
124
- bundled_program
125
- INTERFACE ${_program_schema__include_dir}
126
- ${EXECUTORCH_ROOT} /third-party/flatbuffers/include )
142
+ bundled_program PUBLIC ${_bundled_schema__include_dir}
143
+ ${EXECUTORCH_ROOT} /third-party/flatbuffers/include )
144
+
145
+ target_include_directories (
146
+ etdump PUBLIC ${_program_schema__include_dir}
147
+ ${CMAKE_SOURCE_DIR} /third-party/flatcc/include )
0 commit comments