21
21
22
22
cmake_minimum_required (VERSION 3.3 FATAL_ERROR)
23
23
24
- project (dummy LANGUAGES NONE)
25
-
26
- set (OMR_MODULES_DIR @OMR_MODULES_DIR@)
24
+ set (OMR_MODULES_DIR "@OMR_MODULES_DIR@" )
27
25
set (DDR_SUPPORT_DIR "@OMR_MODULES_DIR@/ddr" )
28
- set (DDR_INPUTS
29
- $<JOIN:$<TARGET_PROPERTY:@DDR_TARGET_NAME@,INPUT_TARGETS>,
30
- >
31
- )
26
+ set (DDR_INFO_DIR "@DDR_INFO_DIR@" )
32
27
set (DDR_BLACKLIST "$<TARGET_PROPERTY:@DDR_TARGET_NAME@,BLACKLIST>" )
33
28
set (DDR_OVERRIDES_FILE "$<TARGET_PROPERTY:@DDR_TARGET_NAME@,OVERRIDES_FILE>" )
34
29
set (DDR_BLOB "$<TARGET_PROPERTY:@DDR_TARGET_NAME@,BLOB>" )
35
30
set (DDR_SUPERSET "$<TARGET_PROPERTY:@DDR_TARGET_NAME@,SUPERSET>" )
31
+ set (DDR_MACRO_LIST
"${DDR_INFO_DIR} /sets/@[email protected] " )
32
+ set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${OMR_MODULES_DIR} )
33
+
34
+ set (DDR_TARGETS
35
+ $<JOIN:$<TARGET_PROPERTY:@DDR_TARGET_NAME@,DDR_TARGETS>,
36
+ >
37
+ )
38
+ set (DDR_SUBSETS
39
+ $<JOIN:$<TARGET_PROPERTY:@DDR_TARGET_NAME@,DDR_SUBSETS>,
40
+ >
41
+ )
42
+
43
+ project (@DDR_TARGET_NAME@ LANGUAGES NONE)
36
44
37
45
include ("@DDR_TOOLS_EXPORT@" )
46
+ include (OmrUtility)
38
47
39
- # If not provided, set default values for superset and blob outputs
40
- if (NOT DDR_BLOB)
41
- set (DDR_BLOB "${CMAKE_CURRENT_BINARY_DIR} /blob.dat" )
42
- endif ()
48
+ # given a var, make the path specified absolute,
49
+ # assuming paths are relative to the ddr set source directory
50
+ macro (make_absolute var_name)
51
+ if (${var_name} )
52
+ get_filename_component (${var_name} "${${var_name} }" ABSOLUTE BASE_DIR "$<TARGET_PROPERTY:@DDR_TARGET_NAME@,SOURCE_DIR>" )
53
+ endif ()
54
+ endmacro ()
43
55
44
- if (NOT DDR_SUPERSET)
45
- set (DDR_SUPERSET "${CMAKE_CURRENT_BINARY_DIR} /superset.out" )
46
- endif ()
56
+ make_absolute(DDR_BLACKLIST)
57
+ make_absolute(DDR_OVERRIDES_FILE)
58
+ make_absolute(DDR_BLOB)
59
+ make_absolute(DDR_SUPERSET)
47
60
48
61
function (get_relative_path output filename base)
49
62
get_filename_component (temp "${filename} " ABSOLUTE BASE_DIR "${base} " )
@@ -127,7 +140,6 @@ function(process_source_files src_files)
127
140
endif ()
128
141
129
142
if (OPT_OUTPUT_ANNOTATED)
130
- message (STATUS "setting annotated file for ${target} ${annotated_files} " )
131
143
set ("${OPT_OUTPUT_ANNOTATED} " "${annotated_files} " PARENT_SCOPE)
132
144
endif ()
133
145
endfunction (process_source_files)
@@ -137,15 +149,17 @@ set(target_files )
137
149
138
150
function (process_target target )
139
151
file (MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} /${target} " )
140
- file (STRINGS "${CMAKE_SOURCE_DIR} /${target} .txt" target_config)
152
+ set (target_info_file "${DDR_INFO_DIR} /targets/${target} .txt" )
153
+ # Make cmake configuration depend on input file
154
+ set_property (DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR} " APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${target_info_file} " )
155
+ file (STRINGS "${target_info_file} " target_config)
141
156
142
157
cmake_parse_arguments ("OPT" "" "SOURCE_DIR;OUTPUT_FILE" "INCLUDE_PATH;DEFINES;SOURCES;HEADERS;PREINCLUDES" ${target_config} )
143
158
144
159
if (OPT_OUTPUT_FILE)
145
160
set (target_files ${target_files} "${OPT_OUTPUT_FILE} " PARENT_SCOPE)
146
161
endif ()
147
162
148
-
149
163
process_source_files(
150
164
${OPT_SOURCES}
151
165
TARGET "${target} "
@@ -175,38 +189,66 @@ function(process_target target)
175
189
176
190
endfunction (process_target)
177
191
178
- foreach (target IN LISTS DDR_INPUTS )
192
+ foreach (target IN LISTS DDR_TARGETS )
179
193
process_target("${target} " )
180
194
endforeach ()
181
195
196
+ set (subset_macro_lists "" )
197
+ foreach (subset IN LISTS DDR_SUBSETS)
198
+ list (APPEND subset_macro_lists "${DDR_INFO_DIR} /sets/${subset} .macros" )
199
+ endforeach ()
182
200
add_custom_command (
183
- OUTPUT macroList
184
- DEPENDS ${annotated_files}
185
- COMMAND cat ${annotated_files} > macroList
201
+ OUTPUT ${DDR_MACRO_LIST}
202
+ DEPENDS ${annotated_files} ${subset_macro_lists}
203
+ COMMAND cat ${annotated_files} ${subset_macro_lists} > ${DDR_MACRO_LIST}
186
204
)
187
205
188
206
set (EXTRA_DDRGEN_OPTIONS "" )
189
207
if (DDR_BLACKLIST)
190
208
list (APPEND EXTRA_DDRGEN_OPTIONS "--blacklist" "${DDR_BLACKLIST} " )
191
209
endif ()
210
+
211
+ if (DDR_BLOB)
212
+ list (APPEND EXTRA_DDRGEN_OPTIONS "--blob" "${DDR_BLOB} " )
213
+ endif ()
214
+
215
+ if (DDR_SUPERSET)
216
+ list (APPEND EXTRA_DDRGEN_OPTIONS "--superset" "${DDR_SUPERSET} " )
217
+ endif ()
218
+
192
219
if (DDR_OVERRIDES_FILE)
193
220
# Because ddr overrides files specify relative paths, we need to run ddrgen
194
221
# in the same directory as the overrides files.
195
- get_filename_component (override_dir "${DDR_OVERRIDES_FILE} " DIRECTORY )
222
+ get_filename_component (override_file_dir "${DDR_OVERRIDES_FILE} " DIRECTORY )
196
223
197
- list (APPEND EXTRA_DDRGEN_OPTIONS "--overrides" "${DDR_OVERRIDES_FILE} " WORKING_DIRECTORY "${override_dir } " )
224
+ list (APPEND EXTRA_DDRGEN_OPTIONS "--overrides" "${DDR_OVERRIDES_FILE} " WORKING_DIRECTORY "${override_file_dir } " )
198
225
endif ()
199
226
200
- add_custom_command (
201
- OUTPUT ${DDR_BLOB} ${DDR_SUPERSET}
202
- DEPENDS macroList
203
- COMMAND omr_ddrgen
204
- ${target_files}
205
- -e
206
- --macrolist macroList
207
- --blob ${DDR_BLOB}
208
- --superset ${DDR_SUPERSET}
209
- ${EXTRA_DDRGEN_OPTIONS}
210
- )
227
+ set (subset_binaries)
228
+ foreach (subset IN LISTS DDR_SUBSETS)
229
+ # Name of file which subset generates, listing all of the input binaries
230
+ set (binaries_list_file "${DDR_INFO_DIR} /sets/${subset} .binaries" )
231
+ set_property (DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR} " APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${binaries_list_file} " )
232
+ file (STRINGS "${binaries_list_file} " binaries)
233
+ list (APPEND subset_binaries ${binaries} )
234
+ endforeach ()
211
235
212
- add_custom_target (ddrgen ALL DEPENDS ${DDR_BLOB} )
236
+ # Now we generate our own list of binaries, so that they can be parsed if we are a subset
237
+ omr_join(binaries_list "\n "
238
+ ${target_files}
239
+ ${subset_binaries}
240
+ )
241
+ file (WRITE
"${DDR_INFO_DIR} /sets/@[email protected] " "${binaries_list} " )
242
+
243
+ if (DDR_BLOB OR DDR_SUPERSET)
244
+ add_custom_command (
245
+ OUTPUT ${DDR_BLOB} ${DDR_SUPERSET}
246
+ DEPENDS ${DDR_MACRO_LIST} ${target_files} ${subset_binaries}
247
+ COMMAND omr_ddrgen
248
+ ${target_files} ${subset_binaries}
249
+ --show-empty
250
+ --macrolist ${DDR_MACRO_LIST}
251
+ ${EXTRA_DDRGEN_OPTIONS}
252
+ )
253
+ endif ()
254
+ add_custom_target (@DDR_TARGET_NAME@ ALL DEPENDS ${DDR_BLOB} ${DDR_MACRO_LIST} )
0 commit comments