@@ -18,62 +18,81 @@ function(get_object_files_for_test result skipped_entrypoints_list)
18
18
set (checked_list "" )
19
19
set (unchecked_list "${ARGN} " )
20
20
list (REMOVE_DUPLICATES unchecked_list )
21
- list (LENGTH unchecked_list length )
22
21
23
- while (length )
24
- set (indirect_list "" )
22
+ foreach (dep IN LISTS unchecked_list )
23
+ if (NOT TARGET ${dep} )
24
+ # Skip tests with undefined dependencies.
25
+ list (APPEND skipped_list ${dep} )
26
+ continue ()
27
+ endif ()
28
+ get_target_property (aliased_target ${dep} "ALIASED_TARGET" )
29
+ if (aliased_target )
30
+ # If the target is just an alias, switch to the real target.
31
+ set (dep ${aliased_target} )
32
+ endif ()
25
33
26
- foreach (dep IN LISTS unchecked_list )
27
- if (NOT TARGET ${dep} )
28
- # Skip tests with undefined dependencies.
29
- list (APPEND skipped_list ${dep} )
30
- continue ()
31
- endif ()
32
- get_target_property (dep_type ${dep} "TARGET_TYPE" )
33
- if (NOT dep_type )
34
- # Skip tests with no object dependencies.
35
- continue ()
36
- endif ()
34
+ get_target_property (dep_type ${dep} "TARGET_TYPE" )
35
+ if (NOT dep_type )
36
+ # Skip tests with no object dependencies.
37
+ continue ()
38
+ endif ()
39
+
40
+ get_target_property (dep_checked ${dep} "CHECK_OBJ_FOR_TESTS" )
41
+
42
+ if (dep_checked )
43
+ # Target full dependency has already been checked. Just use the results.
44
+ get_target_property (dep_obj ${dep} "OBJECT_FILES_FOR_TESTS" )
45
+ get_target_property (dep_skip ${dep} "SKIPPED_LIST_FOR_TESTS" )
46
+ else ()
47
+ # Target full dependency hasn't been checked. Recursively check its DEPS.
48
+ set (dep_obj "${dep} " )
49
+ set (dep_skip "" )
50
+
51
+ get_target_property (indirect_deps ${dep} "DEPS" )
52
+ get_object_files_for_test (dep_obj dep_skip ${indirect_deps} )
37
53
38
54
if (${dep_type} STREQUAL ${OBJECT_LIBRARY_TARGET_TYPE} )
39
55
get_target_property (dep_object_files ${dep} "OBJECT_FILES" )
40
56
if (dep_object_files )
41
- list (APPEND object_files ${dep_object_files} )
57
+ list (APPEND dep_obj ${dep_object_files} )
42
58
endif ()
43
59
elseif (${dep_type} STREQUAL ${ENTRYPOINT_OBJ_TARGET_TYPE} )
44
60
get_target_property (is_skipped ${dep} "SKIPPED" )
45
61
if (is_skipped )
46
- list (APPEND skipped_list ${dep} )
47
- continue ( )
62
+ list (APPEND dep_skip ${dep} )
63
+ list ( REMOVE_ITEM dep_obj ${dep} )
48
64
endif ()
49
65
get_target_property (object_file_raw ${dep} "OBJECT_FILE_RAW" )
50
66
if (object_file_raw )
51
- list (APPEND object_files ${object_file_raw} )
67
+ list (APPEND dep_obj ${object_file_raw} )
52
68
endif ()
53
69
elseif (${dep_type} STREQUAL ${ENTRYPOINT_OBJ_VENDOR_TARGET_TYPE} )
54
70
# Skip tests for externally implemented entrypoints.
55
- list (APPEND skipped_list ${dep} )
56
- continue ( )
71
+ list (APPEND dep_skip ${dep} )
72
+ list ( REMOVE_ITEM dep_obj ${dep} )
57
73
endif ()
58
74
59
- get_target_property (indirect_deps ${dep} "DEPS" )
60
- list (APPEND indirect_list "${indirect_deps} " )
61
- endforeach (dep )
75
+ set_target_properties (${dep} PROPERTIES
76
+ OBJECT_FILES_FOR_TESTS "${dep_obj} "
77
+ SKIPPED_LIST_FOR_TESTS "${dep_skip} "
78
+ CHECK_OBJ_FOR_TESTS "YES"
79
+ )
80
+
81
+ endif ()
82
+
83
+ list (APPEND object_files ${dep_obj} )
84
+ list (APPEND skipped_list ${dep_skip} )
62
85
63
- # Only add new indirect dependencies to check.
64
- list (APPEND checked_list "${unchecked_list} " )
65
- list (REMOVE_DUPLICATES indirect_list )
66
- list (REMOVE_ITEM indirect_list checked_list )
67
- set (unchecked_list "${indirect_list} " )
68
- list (LENGTH unchecked_list length )
69
- endwhile ()
86
+ endforeach (dep )
70
87
71
88
list (REMOVE_DUPLICATES object_files )
72
89
set (${result} ${object_files} PARENT_SCOPE )
73
90
list (REMOVE_DUPLICATES skipped_list )
74
91
set (${skipped_entrypoints_list} ${skipped_list} PARENT_SCOPE )
92
+
75
93
endfunction (get_object_files_for_test )
76
94
95
+
77
96
# Rule to add a libc unittest.
78
97
# Usage
79
98
# add_libc_unittest(
0 commit comments