1
1
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
# SPDX-License-Identifier: Apache-2.0.
3
- #
4
3
5
- # helper function that that gives primitive map functionality by treating a colon as the key-value separator, while the list semi-colon separates pairs
6
- # to use, pass the list-map in as a third parameter (see helper functions below)
7
- function (get_map_element KEY VALUE_VAR)
8
- foreach (ELEMENT_PAIR ${ARGN} )
9
- STRING (REGEX REPLACE "([^:]+):.*" "\\ 1" KEY_RESULT ${ELEMENT_PAIR} )
10
- if (${KEY_RESULT} STREQUAL ${KEY} )
11
- STRING (REGEX REPLACE "[^:]+:(.*)" "\\ 1" VALUE_RESULT ${ELEMENT_PAIR} )
12
- set (${VALUE_VAR} "${VALUE_RESULT} " PARENT_SCOPE)
13
- return ()
14
- endif ()
15
- endforeach ()
16
- set (${VALUE_VAR} "" PARENT_SCOPE)
17
- endfunction (get_map_element)
18
-
19
- function (get_multimap_element KEY VALUE_VAR)
4
+ # Return all values for a key from a flatmap
5
+ # I.e. given a flatmap list of items such as "key1:val1,val2,val3;key2:val2;key1:valDoNotLoseMe" and "key1" as arguments
6
+ # when called such as "get_flatmap_value(${TEST_NAME} TEMP_VAR ${TEST_DEPENDENCY_LIST})"
7
+ # will return "val1,val2,val3,valDoNotLoseMe"
8
+ function (get_flatmap_value KEY VALUE_VAR)
20
9
set (${VALUE_VAR} "" PARENT_SCOPE)
21
10
set (RETURN_LIST "" )
22
11
foreach (ELEMENT_PAIR ${ARGN} )
@@ -27,39 +16,27 @@ function(get_multimap_element KEY VALUE_VAR)
27
16
endif ()
28
17
endforeach ()
29
18
set (${VALUE_VAR} "${RETURN_LIST} " PARENT_SCOPE)
30
- endfunction (get_multimap_element)
31
-
32
- # a bunch of key-value retrieval functions for the list-maps we defined above
33
- function (get_c2j_date_for_service SERVICE_NAME C2J_DATE_VAR)
34
- get_map_element(${SERVICE_NAME} TEMP_VAR ${C2J_LIST} )
35
- set (${C2J_DATE_VAR} "${TEMP_VAR} " PARENT_SCOPE)
36
- endfunction ()
37
-
38
- function (get_c2j_name_for_service SERVICE_NAME C2J_NAME_VAR)
39
- get_map_element(${SERVICE_NAME} TEMP_VAR ${C2J_SPECIAL_NAME_LIST} )
40
- if (TEMP_VAR)
41
- set (${C2J_NAME_VAR} "${TEMP_VAR} " PARENT_SCOPE)
42
- else ()
43
- set (${C2J_NAME_VAR} "${SERVICE_NAME} " PARENT_SCOPE)
44
- endif ()
45
- endfunction ()
19
+ endfunction (get_flatmap_value)
46
20
47
21
function (get_test_projects_for_service SERVICE_NAME TEST_PROJECT_NAME_VAR)
48
- get_multimap_element (${SERVICE_NAME} TEMP_VAR ${SDK_TEST_PROJECT_LIST} )
22
+ get_flatmap_value (${SERVICE_NAME} TEMP_VAR ${SDK_TEST_PROJECT_LIST} )
49
23
set (${TEST_PROJECT_NAME_VAR} "${TEMP_VAR} " PARENT_SCOPE)
50
24
endfunction ()
51
25
52
26
function (get_dependencies_for_sdk PROJECT_NAME DEPENDENCY_LIST_VAR)
53
- get_map_element(${PROJECT_NAME} TEMP_VAR ${SDK_DEPENDENCY_LIST} )
54
- # "core" is the default dependency for every sdk.
55
- # Since we removed the hand-written C2J_LIST and instead auto generating it based on models,
56
- # and location of models may not exist or incorrect when SDK is installed and then source has been deleted by customers.
57
- # we end up getting an incomplete C2J_LIST when customers call find_package(AWSSDK). But C2J_LIST is only used in customers code for dependencies completing.
58
- set (${DEPENDENCY_LIST_VAR} "${TEMP_VAR} ,core" PARENT_SCOPE)
27
+ get_flatmap_value(${PROJECT_NAME} TEMP_VAR ${SDK_DEPENDENCY_LIST} )
28
+ list (FIND TEMP_VAR "core" _index)
29
+ if (${_index} GREATER -1) # old cmake search in a list syntax
30
+ # core is already there
31
+ set (${DEPENDENCY_LIST_VAR} "${TEMP_VAR} " PARENT_SCOPE)
32
+ else ()
33
+ # "core" is the default dependency for every sdk.
34
+ set (${DEPENDENCY_LIST_VAR} "${TEMP_VAR} ,core" PARENT_SCOPE)
35
+ endif ()
59
36
endfunction ()
60
37
61
38
function (get_dependencies_for_test TEST_NAME DEPENDENCY_LIST_VAR)
62
- get_map_element (${TEST_NAME} TEMP_VAR ${TEST_DEPENDENCY_LIST} )
39
+ get_flatmap_value (${TEST_NAME} TEMP_VAR ${TEST_DEPENDENCY_LIST} )
63
40
set (${DEPENDENCY_LIST_VAR} "${TEMP_VAR} " PARENT_SCOPE)
64
41
endfunction ()
65
42
@@ -80,69 +57,20 @@ function(get_sdks_depending_on SDK_NAME DEPENDING_SDKS_VAR)
80
57
set (${DEPENDING_SDKS_VAR} "${TEMP_SDK_LIST} " PARENT_SCOPE)
81
58
endfunction ()
82
59
83
- # function that automatically picks up models from <sdkrootdir>/code-generation/api-descriptions/ directory and build
84
- # C2J_LIST needed for generation, services have multiple models will use the latest model (decided by model files' date)
85
- # services have the name format abc.def.ghi will be renamed to ghi-def-abc (dot will not be accepted as Windows directory name )
86
- # and put into C2J_SPECIAL_NAME_LIST, but rumtime.lex will be renamed to lex based on historical reason.
60
+ # Function that reads <repo>/src/generated and builds a list of all available generated service clients for a build,
61
+ # The resulting $SERVICE_CLIENT_LIST is as simple as "cognito-identity,s3,dynamodb,etc,..."
87
62
function (build_sdk_list)
88
- file (GLOB ALL_MODEL_FILES "${CMAKE_CURRENT_SOURCE_DIR} /tools/code-generation/api-descriptions/*-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9].normal.json" )
89
- foreach (model IN LISTS ALL_MODEL_FILES)
90
- get_filename_component (modelName "${model} " NAME )
91
- STRING (REGEX MATCH "([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9])" date "${modelName} " )
92
- STRING (REGEX REPLACE "-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9].normal.json" "" svc "${modelName} " )
93
- #special svc name conversion, e.g: runtime.lex->lex; abc.def.ghi->ghi-def-abc
94
- if ("${svc} " STREQUAL "runtime.lex" )
95
- LIST (APPEND C2J_SPECIAL_NAME_LIST "lex:runtime.lex" )
96
- set (svc "lex" )
97
- elseif ("${svc} " STREQUAL "runtime.lex.v2" )
98
- LIST (APPEND C2J_SPECIAL_NAME_LIST "lexv2-runtime:runtime.lex.v2" )
99
- set (svc "lexv2-runtime" )
100
- elseif ("${svc} " STREQUAL "models.lex.v2" )
101
- LIST (APPEND C2J_SPECIAL_NAME_LIST "lexv2-models:models.lex.v2" )
102
- set (svc "lexv2-models" )
103
- elseif ("${svc} " STREQUAL "transfer" )
104
- LIST (APPEND C2J_SPECIAL_NAME_LIST "awstransfer:transfer" )
105
- set (svc "awstransfer" )
106
- elseif ("${svc} " STREQUAL "transcribe-streaming" )
107
- LIST (APPEND C2J_SPECIAL_NAME_LIST "transcribestreaming:transcribe-streaming" )
108
- set (svc "transcribestreaming" )
109
- elseif ("${svc} " STREQUAL "streams.dynamodb" )
110
- LIST (APPEND C2J_SPECIAL_NAME_LIST "dynamodbstreams:streams.dynamodb" )
111
- set (svc "dynamodbstreams" )
112
- elseif ("${svc} " MATCHES "\\ ." )
113
- string (REPLACE "." ";" nameParts ${svc} )
114
- LIST (REVERSE nameParts)
115
- string (REPLACE ";" "-" tmpSvc "${nameParts} " )
116
- LIST (APPEND C2J_SPECIAL_NAME_LIST "${tmpSvc} :${svc} " )
117
- set (svc "${tmpSvc} " )
118
- elseif ("${svc} " STREQUAL "ec2" )
119
- if (PLATFORM_ANDROID AND CMAKE_HOST_WIN32 ) # ec2 isn't building for android on windows atm due to an internal compiler error, TODO: investigate further
120
- continue ()
121
- endif ()
122
- elseif ("${svc} " STREQUAL "s3" )
123
- LIST (APPEND C2J_SPECIAL_NAME_LIST "s3-crt:s3" )
124
- message (STATUS "Add s3-crt:s3 to C2J_SPECIAL_NAME_LIST" )
125
- endif ()
126
- get_map_element(${svc} existingDate ${C2J_LIST} )
127
- if ("${existingDate} " STREQUAL "" )
128
- LIST (APPEND C2J_LIST "${svc} :${date} " )
129
- if ("${svc} " STREQUAL "s3" )
130
- LIST (APPEND C2J_LIST "s3-crt:${date} " )
131
- endif ()
132
- elseif (${existingDate} STRLESS ${date} )
133
- LIST (REMOVE_ITEM C2J_LIST "${svc} :${existingDate} " )
134
- LIST (APPEND C2J_LIST "${svc} :${date} " )
135
- if ("${svc} " STREQUAL "s3" )
136
- LIST (REMOVE_ITEM C2J_LIST "s3-crt:${existingDate} " )
137
- LIST (APPEND C2J_LIST "s3-crt:${date} " )
138
- endif ()
139
- endif ()
63
+ set (LIST_DIRECTORIES true )
64
+ file (GLOB ALL_GENERATED_CLIENTS $LIST_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR} /src/generated/aws-cpp-sdk-*" )
65
+ foreach (clientDir IN LISTS ALL_MODEL_FILES)
66
+ get_filename_component (clientDir "${model} " NAME )
67
+ STRING (REGEX REPLACE "^aws-cpp-sdk-" "" serviceName "${clientDir} " )
68
+ LIST (APPEND SERVICE_CLIENT_LIST "${serviceName} " )
140
69
endforeach ()
141
- set (C2J_LIST "${C2J_LIST} " PARENT_SCOPE)
142
- set (C2J_SPECIAL_NAME_LIST "${C2J_SPECIAL_NAME_LIST} " PARENT_SCOPE)
70
+ set (SERVICE_CLIENT_LIST "${SERVICE_CLIENT_LIST} " PARENT_SCOPE)
143
71
endfunction ()
144
72
145
-
73
+ # A list of so-called "hand-written SDK high-level libraries/components"
146
74
set (HIGH_LEVEL_SDK_LIST "" )
147
75
list (APPEND HIGH_LEVEL_SDK_LIST "access-management" )
148
76
list (APPEND HIGH_LEVEL_SDK_LIST "identity-management" )
@@ -151,6 +79,7 @@ list(APPEND HIGH_LEVEL_SDK_LIST "transfer")
151
79
list (APPEND HIGH_LEVEL_SDK_LIST "s3-encryption" )
152
80
list (APPEND HIGH_LEVEL_SDK_LIST "text-to-speech" )
153
81
82
+ # A flatmap list of sdk_component:sdk_component_tests,sdk_component_another_tests
154
83
set (SDK_TEST_PROJECT_LIST "" )
155
84
list (APPEND SDK_TEST_PROJECT_LIST "cloudfront:tests/aws-cpp-sdk-cloudfront-integration-tests" )
156
85
list (APPEND SDK_TEST_PROJECT_LIST "cognito-identity:tests/aws-cpp-sdk-cognitoidentity-integration-tests" )
@@ -184,11 +113,9 @@ build_sdk_list()
184
113
185
114
if (EXISTS "${CMAKE_SOURCE_DIR} /generated" )
186
115
if (EXISTS "${CMAKE_SOURCE_DIR} /generated/tests" )
187
- foreach (GENERATED_C2J_TEST IN LISTS C2J_LIST)
188
- STRING (REGEX REPLACE "([^:]+):.*" "\\ 1" GENERATED_C2J_TEST_RESULT ${GENERATED_C2J_TEST} )
189
-
190
- if (EXISTS "${CMAKE_SOURCE_DIR} /generated/tests/${GENERATED_C2J_TEST_RESULT} -gen-tests" )
191
- list (APPEND SDK_TEST_PROJECT_LIST "${GENERATED_C2J_TEST_RESULT} :generated/tests/${GENERATED_C2J_TEST_RESULT} -gen-tests" )
116
+ foreach (SERVICE_NAME IN LISTS SERVICE_CLIENT_LIST)
117
+ if (EXISTS "${CMAKE_SOURCE_DIR} /generated/tests/${SERVICE_NAME} -gen-tests" )
118
+ list (APPEND SDK_TEST_PROJECT_LIST "${SERVICE_NAME} :generated/tests/${SERVICE_NAME} -gen-tests" )
192
119
endif ()
193
120
endforeach ()
194
121
endif ()
@@ -213,10 +140,7 @@ list(APPEND TEST_DEPENDENCY_LIST "text-to-speech:polly,core")
213
140
list (APPEND TEST_DEPENDENCY_LIST "transfer:s3,core" )
214
141
list (APPEND TEST_DEPENDENCY_LIST "logs:access-management,cognito-identity,iam,core" )
215
142
216
- # make a list of the generated clients
217
- set (GENERATED_SERVICE_LIST "" )
218
- foreach (GENERATED_C2J_SERVICE IN LISTS C2J_LIST)
219
- STRING (REGEX REPLACE "([^:]+):.*" "\\ 1" SERVICE_RESULT ${GENERATED_C2J_SERVICE} )
220
- list (APPEND GENERATED_SERVICE_LIST ${SERVICE_RESULT} )
221
- list (APPEND SDK_DEPENDENCY_LIST "${SERVICE_RESULT} :core" )
143
+ set (GENERATED_SERVICE_LIST ${SERVICE_CLIENT_LIST} )
144
+ foreach (SERVICE_NAME IN LISTS SERVICE_CLIENT_LIST)
145
+ list (APPEND SDK_DEPENDENCY_LIST "${SERVICE_NAME} :core" )
222
146
endforeach ()
0 commit comments