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