forked from eclipse-omr/omr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced a number of changes - Headers can now be directly associated with a ddr set - A DDR set no longer needs to be specified when enabling DDR for a target. - Added a new command `ddr_set_add_targets` which adds a target to a DDR set. Combined with the above, this allows for a delayed definition of a DDR set. In addition targets can be in multiple DDR sets. - DDR sets can now be composed via `ddr_set_add_targets`. This means we can get rid of the awkward `OMR_DDR_SET` mechanics. Instead we just define our own DDR set, and consumers simply add our DDR set to theirs - omr_ prefix removed from ddr related target names. - Added GLOB_HEADERS and GLOB_HEADERS_RECURSIVE options to target_enable_ddr, which glob the target source directory for headers Signed-off-by: Devin Nakamura <[email protected]>
- Loading branch information
Showing
18 changed files
with
177 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,29 +21,42 @@ | |
|
||
cmake_minimum_required(VERSION 3.3 FATAL_ERROR) | ||
|
||
project(dummy LANGUAGES NONE) | ||
|
||
set(OMR_MODULES_DIR @OMR_MODULES_DIR@) | ||
set(OMR_MODULES_DIR "@OMR_MODULES_DIR@") | ||
set(DDR_SUPPORT_DIR "@OMR_MODULES_DIR@/ddr") | ||
set(DDR_INPUTS | ||
$<JOIN:$<TARGET_PROPERTY:@DDR_TARGET_NAME@,INPUT_TARGETS>, | ||
> | ||
) | ||
set(DDR_INFO_DIR "@DDR_INFO_DIR@") | ||
set(DDR_BLACKLIST "$<TARGET_PROPERTY:@DDR_TARGET_NAME@,BLACKLIST>") | ||
set(DDR_OVERRIDES_FILE "$<TARGET_PROPERTY:@DDR_TARGET_NAME@,OVERRIDES_FILE>") | ||
set(DDR_BLOB "$<TARGET_PROPERTY:@DDR_TARGET_NAME@,BLOB>") | ||
set(DDR_SUPERSET "$<TARGET_PROPERTY:@DDR_TARGET_NAME@,SUPERSET>") | ||
set(DDR_MACRO_LIST "${DDR_INFO_DIR}/sets/@[email protected]") | ||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${OMR_MODULES_DIR}) | ||
|
||
set(DDR_TARGETS | ||
$<JOIN:$<TARGET_PROPERTY:@DDR_TARGET_NAME@,DDR_TARGETS>, | ||
> | ||
) | ||
set(DDR_SUBSETS | ||
$<JOIN:$<TARGET_PROPERTY:@DDR_TARGET_NAME@,DDR_SUBSETS>, | ||
> | ||
) | ||
|
||
project(@DDR_TARGET_NAME@ LANGUAGES NONE) | ||
|
||
include("@DDR_TOOLS_EXPORT@") | ||
include(OmrUtility) | ||
|
||
# If not provided, set default values for superset and blob outputs | ||
if(NOT DDR_BLOB) | ||
set(DDR_BLOB "${CMAKE_CURRENT_BINARY_DIR}/blob.dat") | ||
endif() | ||
# given a var, make the path specified absolute, | ||
# assuming paths are relative to the ddr set source directory | ||
macro(make_absolute var_name) | ||
if(${var_name}) | ||
get_filename_component(${var_name} "${${var_name}}" ABSOLUTE BASE_DIR "$<TARGET_PROPERTY:@DDR_TARGET_NAME@,SOURCE_DIR>") | ||
endif() | ||
endmacro() | ||
|
||
if(NOT DDR_SUPERSET) | ||
set(DDR_SUPERSET "${CMAKE_CURRENT_BINARY_DIR}/superset.out") | ||
endif() | ||
make_absolute(DDR_BLACKLIST) | ||
make_absolute(DDR_OVERRIDES_FILE) | ||
make_absolute(DDR_BLOB) | ||
make_absolute(DDR_SUPERSET) | ||
|
||
function(get_relative_path output filename base) | ||
get_filename_component(temp "${filename}" ABSOLUTE BASE_DIR "${base}") | ||
|
@@ -127,7 +140,6 @@ function(process_source_files src_files) | |
endif() | ||
|
||
if(OPT_OUTPUT_ANNOTATED) | ||
message(STATUS "setting annotated file for ${target} ${annotated_files}") | ||
set("${OPT_OUTPUT_ANNOTATED}" "${annotated_files}" PARENT_SCOPE) | ||
endif() | ||
endfunction(process_source_files) | ||
|
@@ -137,15 +149,17 @@ set(target_files ) | |
|
||
function(process_target target) | ||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${target}") | ||
file(STRINGS "${CMAKE_SOURCE_DIR}/${target}.txt" target_config) | ||
set(target_info_file "${DDR_INFO_DIR}/targets/${target}.txt") | ||
# Make cmake configuration depend on input file | ||
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${target_info_file}") | ||
file(STRINGS "${target_info_file}" target_config) | ||
|
||
cmake_parse_arguments("OPT" "" "SOURCE_DIR;OUTPUT_FILE" "INCLUDE_PATH;DEFINES;SOURCES;HEADERS;PREINCLUDES" ${target_config}) | ||
|
||
if(OPT_OUTPUT_FILE) | ||
set(target_files ${target_files} "${OPT_OUTPUT_FILE}" PARENT_SCOPE) | ||
endif() | ||
|
||
|
||
process_source_files( | ||
${OPT_SOURCES} | ||
TARGET "${target}" | ||
|
@@ -175,38 +189,66 @@ function(process_target target) | |
|
||
endfunction(process_target) | ||
|
||
foreach(target IN LISTS DDR_INPUTS) | ||
foreach(target IN LISTS DDR_TARGETS) | ||
process_target("${target}") | ||
endforeach() | ||
|
||
set(subset_macro_lists "") | ||
foreach(subset IN LISTS DDR_SUBSETS) | ||
list(APPEND subset_macro_lists "${DDR_INFO_DIR}/sets/${subset}.macros") | ||
endforeach() | ||
add_custom_command( | ||
OUTPUT macroList | ||
DEPENDS ${annotated_files} | ||
COMMAND cat ${annotated_files} > macroList | ||
OUTPUT ${DDR_MACRO_LIST} | ||
DEPENDS ${annotated_files} ${subset_macro_lists} | ||
COMMAND cat ${annotated_files} ${subset_macro_lists} > ${DDR_MACRO_LIST} | ||
) | ||
|
||
set(EXTRA_DDRGEN_OPTIONS "") | ||
if(DDR_BLACKLIST) | ||
list(APPEND EXTRA_DDRGEN_OPTIONS "--blacklist" "${DDR_BLACKLIST}") | ||
endif() | ||
|
||
if(DDR_BLOB) | ||
list(APPEND EXTRA_DDRGEN_OPTIONS "--blob" "${DDR_BLOB}") | ||
endif() | ||
|
||
if(DDR_SUPERSET) | ||
list(APPEND EXTRA_DDRGEN_OPTIONS "--superset" "${DDR_SUPERSET}") | ||
endif() | ||
|
||
if(DDR_OVERRIDES_FILE) | ||
# Because ddr overrides files specify relative paths, we need to run ddrgen | ||
# in the same directory as the overrides files. | ||
get_filename_component(override_dir "${DDR_OVERRIDES_FILE}" DIRECTORY) | ||
get_filename_component(override_file_dir "${DDR_OVERRIDES_FILE}" DIRECTORY) | ||
|
||
list(APPEND EXTRA_DDRGEN_OPTIONS "--overrides" "${DDR_OVERRIDES_FILE}" WORKING_DIRECTORY "${override_dir}") | ||
list(APPEND EXTRA_DDRGEN_OPTIONS "--overrides" "${DDR_OVERRIDES_FILE}" WORKING_DIRECTORY "${override_file_dir}") | ||
endif() | ||
|
||
add_custom_command( | ||
OUTPUT ${DDR_BLOB} ${DDR_SUPERSET} | ||
DEPENDS macroList | ||
COMMAND omr_ddrgen | ||
${target_files} | ||
-e | ||
--macrolist macroList | ||
--blob ${DDR_BLOB} | ||
--superset ${DDR_SUPERSET} | ||
${EXTRA_DDRGEN_OPTIONS} | ||
) | ||
set(subset_binaries) | ||
foreach(subset IN LISTS DDR_SUBSETS) | ||
# Name of file which subset generates, listing all of the input binaries | ||
set(binaries_list_file "${DDR_INFO_DIR}/sets/${subset}.binaries") | ||
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${binaries_list_file}") | ||
file(STRINGS "${binaries_list_file}" binaries) | ||
list(APPEND subset_binaries ${binaries}) | ||
endforeach() | ||
|
||
add_custom_target(ddrgen ALL DEPENDS ${DDR_BLOB}) | ||
# Now we generate our own list of binaries, so that they can be parsed if we are a subset | ||
omr_join(binaries_list "\n" | ||
${target_files} | ||
${subset_binaries} | ||
) | ||
file(WRITE "${DDR_INFO_DIR}/sets/@[email protected]" "${binaries_list}") | ||
|
||
if(DDR_BLOB OR DDR_SUPERSET) | ||
add_custom_command( | ||
OUTPUT ${DDR_BLOB} ${DDR_SUPERSET} | ||
DEPENDS ${DDR_MACRO_LIST} ${target_files} ${subset_binaries} | ||
COMMAND omr_ddrgen | ||
${target_files} ${subset_binaries} | ||
--show-empty | ||
--macrolist ${DDR_MACRO_LIST} | ||
${EXTRA_DDRGEN_OPTIONS} | ||
) | ||
endif() | ||
add_custom_target(@DDR_TARGET_NAME@ ALL DEPENDS ${DDR_BLOB} ${DDR_MACRO_LIST}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.