Skip to content

Commit 00df9ec

Browse files
committed
use correct name for generating local macro on endpoints blob
1 parent c83a534 commit 00df9ec

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

tools/code-generation/smithy/cpp-codegen/smithy-cpp-codegen/src/main/java/com/amazonaws/util/awsclientsmithygenerator/generators/ServiceNameUtil.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import software.amazon.smithy.aws.traits.ServiceTrait;
99

1010
import java.util.Map;
11+
import java.util.Optional;
1112

1213
public final class ServiceNameUtil {
1314

@@ -170,12 +171,18 @@ public static String getExportMacro(ServiceShape service, Map<String, String> se
170171
* Follows C2J convention: AWS_{UPPERCASED_SERVICE_NAME}_LOCAL
171172
*
172173
* @param service The service shape to generate the macro for
173-
* @param serviceMap Service ID mappings for namespace overrides (reserved for future consistency with getSmithyServiceName)
174+
* @param serviceMap Service ID mappings, used to resolve the key into namespaceMap
175+
* @param namespaceMap Namespace overrides, keyed by smithy service name; the macro must follow the
176+
* override because the C2J-generated {@code <Prefix>_EXPORTS.h} defines it off
177+
* {@code metadata.classNamePrefix}
174178
* @return The local macro in format AWS_{SERVICE_NAME}_LOCAL
175179
*/
176-
public static String getLocalMacro(ServiceShape service, Map<String, String> serviceMap) {
177-
String serviceName = getServiceName(service);
178-
return "AWS_" + serviceName.toUpperCase() + "_LOCAL";
180+
public static String getLocalMacro(ServiceShape service, Map<String, String> serviceMap,
181+
Map<String, String> namespaceMap) {
182+
return Optional.ofNullable(namespaceMap.get(getSmithyServiceName(service, serviceMap)))
183+
.orElseGet(() -> getServiceName(service))
184+
.toUpperCase()
185+
.transform(name -> "AWS_" + name + "_LOCAL");
179186
}
180187

181188
public static boolean isS3CrtProjection(ServiceShape service) {

tools/code-generation/smithy/cpp-codegen/smithy-cpp-codegen/src/main/java/com/amazonaws/util/awsclientsmithygenerator/generators/endpointrules/EndpointRulesCodegenPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private void generateEndpointRules(ServiceShape service, Map<String, String> ser
7676
Map<String, String> namespaceMap, String pythonExecutable,
7777
String bddBytecoderPath, CppWriterDelegator writerDelegator) {
7878
String smithyServiceName = ServiceNameUtil.getSmithyServiceName(service, serviceMap);
79-
String localMacro = ServiceNameUtil.getLocalMacro(service, serviceMap);
79+
String localMacro = ServiceNameUtil.getLocalMacro(service, serviceMap, namespaceMap);
8080
String namespace = namespaceMap.getOrDefault(smithyServiceName, ServiceNameUtil.getServiceName(service));
8181
String classPrefix = Optional.ofNullable(namespaceMap.get(smithyServiceName))
8282
.map(ServiceNameUtil::capitalize)

0 commit comments

Comments
 (0)