Skip to content

Commit 650deff

Browse files
committed
add option to disable blob generation. mark rules blob as local symbol.
1 parent c9539d3 commit 650deff

11 files changed

Lines changed: 43 additions & 18 deletions

File tree

tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/ServiceModel.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class ServiceModel {
3333
boolean enableVirtualOperations;
3434
boolean disableSmithyGeneration;
3535
boolean skipModelGeneration;
36+
boolean skipEndpointRulesBlob;
3637
Collection<Error> serviceErrors;
3738
Collection<CustomPresignedUtility> presigners;
3839
Map<String, String> queryCompatibleErrorMappings;

tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/DirectFromC2jGenerator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ public ByteArrayOutputStream generateServiceSourceFromJson(String rawJson, Strin
4545
String languageBinding, String serviceName, String namespace,
4646
String licenseText, boolean generateStandalonePackage,
4747
boolean enableVirtualOperations, boolean disableSmithyGeneration,
48-
boolean useSmithyClient, boolean skipModelGeneration) throws Exception {
48+
boolean useSmithyClient, boolean skipModelGeneration,
49+
boolean skipEndpointRulesBlob) throws Exception {
4950
GsonBuilder gsonBuilder = new GsonBuilder();
5051
gsonBuilder.registerTypeAdapter(EndpointTests.EndpointTestParams.class, new EndpointTestParamsDeserializer());
5152
gsonBuilder.registerTypeAdapter(EndpointParameterValue.class, new EndpointParameterValueDeserializer());
@@ -63,7 +64,7 @@ public ByteArrayOutputStream generateServiceSourceFromJson(String rawJson, Strin
6364
}
6465
return mainClientGenerator.generateSourceFromC2jModel(c2jServiceModel, serviceName, languageBinding, namespace,
6566
licenseText, generateStandalonePackage, enableVirtualOperations, disableSmithyGeneration, useSmithyClient,
66-
skipModelGeneration);
67+
skipModelGeneration, skipEndpointRulesBlob);
6768
}
6869

6970
/**

tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/MainGenerator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public ByteArrayOutputStream generateSourceFromC2jModel(C2jServiceModel c2jModel
3636
String serviceName, String languageBinding,
3737
String namespace, String licenseText, boolean generateStandalonePackage,
3838
boolean enableVirtualOperations, boolean disableSmithyGeneration,
39-
boolean useSmithyClient, boolean skipModelGeneration) throws Exception {
39+
boolean useSmithyClient, boolean skipModelGeneration,
40+
boolean skipEndpointRulesBlob) throws Exception {
4041

4142
SdkSpec spec = new SdkSpec(languageBinding, serviceName, null);
4243
// Transform to ServiceModel
@@ -51,6 +52,7 @@ public ByteArrayOutputStream generateSourceFromC2jModel(C2jServiceModel c2jModel
5152
serviceModel.setDisableSmithyGeneration(disableSmithyGeneration);
5253
serviceModel.setUseSmithyClient(useSmithyClient);
5354
serviceModel.setSkipModelGeneration(skipModelGeneration);
55+
serviceModel.setSkipEndpointRulesBlob(skipEndpointRulesBlob);
5456

5557
spec.setVersion(serviceModel.getMetadata().getApiVersion());
5658

tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/cpp/CppClientGenerator.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ public SdkFileEntry[] generateSourceFiles(ServiceModel serviceModel) throws Exce
121121
}
122122
fileList.add(generateClientConfigurationFile(serviceModel));
123123
if (serviceModel.getEndpointRules() != null) {
124-
fileList.add(generateEndpointRulesHeaderFile(serviceModel));
125-
fileList.add(generateEndpointRulesSourceFile(serviceModel));
124+
if (!serviceModel.isSkipEndpointRulesBlob()) {
125+
fileList.add(generateEndpointRulesHeaderFile(serviceModel));
126+
fileList.add(generateEndpointRulesSourceFile(serviceModel));
127+
}
126128
fileList.add(generateEndpointProviderHeaderFile(serviceModel));
127129
fileList.add(generateEndpointProviderSourceFile(serviceModel));
128130

@@ -585,7 +587,8 @@ protected SdkFileEntry generateRegionSourceFile(ServiceModel serviceModel) throw
585587

586588
protected SdkFileEntry generateEndpointRulesHeaderFile(ServiceModel serviceModel) throws Exception {
587589
String templateName = "/com/amazonaws/util/awsclientgenerator/velocity/cpp/endpoint/EndpointRulesHeader.vm";
588-
String fileName = String.format("include/aws/%s/%sEndpointRules.h", serviceModel.getMetadata().getProjectName(),
590+
String fileName = String.format("include/aws/%s/internal/%sEndpointRules.h",
591+
serviceModel.getMetadata().getProjectName(),
589592
serviceModel.getMetadata().getClassNamePrefix());
590593
return generateSingleSourceFile(serviceModel, templateName, fileName);
591594
}

tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/main.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public class main {
4646
static final String ENABLE_VIRTUAL_OPERATIONS = "enable-virtual-operations";
4747
static final String DISABLE_SMITHY_GENERATION = "disable-smithy-generation";
4848
static final String SKIP_MODEL_GENERATION = "skip-model-generation";
49+
static final String SKIP_ENDPOINT_RULES_BLOB = "skip-endpoint-rules-blob";
4950
static final String USE_SMITHY_CLIENT = "use-smithy-client";
5051

5152
public static void main(String[] args) throws IOException {
@@ -90,6 +91,7 @@ public static void main(String[] args) throws IOException {
9091
boolean enableVirtualOperations = argPairs.containsKey(ENABLE_VIRTUAL_OPERATIONS);
9192
boolean disableSmithyGeneration = argPairs.containsKey(DISABLE_SMITHY_GENERATION);
9293
boolean skipModelGeneration = argPairs.containsKey(SKIP_MODEL_GENERATION);
94+
boolean skipEndpointRulesBlob = argPairs.containsKey(SKIP_ENDPOINT_RULES_BLOB);
9395

9496
String arbitraryJson = readFile(argPairs.getOrDefault(INPUT_FILE_NAME, ""));
9597
String endpointRules = null;
@@ -129,7 +131,7 @@ public static void main(String[] args) throws IOException {
129131
if (!generateTests) {
130132
generated = generateService(arbitraryJson, endpointRules, endpointRuleTests, languageBinding, serviceName, namespace,
131133
licenseText, generateStandalonePackage, enableVirtualOperations, disableSmithyGeneration, useSmithyClient,
132-
skipModelGeneration);
134+
skipModelGeneration, skipEndpointRulesBlob);
133135

134136
componentOutputName = String.format("aws-cpp-sdk-%s", serviceName);
135137
} else if (argPairs.containsKey(ENDPOINT_TESTS)) {
@@ -212,7 +214,8 @@ private static ByteArrayOutputStream generateService(String arbitraryJson,
212214
boolean enableVirtualOperations,
213215
boolean disableSmithyGeneration,
214216
boolean useSmithyClient,
215-
boolean skipModelGeneration) throws Exception {
217+
boolean skipModelGeneration,
218+
boolean skipEndpointRulesBlob) throws Exception {
216219
MainGenerator generator = new MainGenerator();
217220
DirectFromC2jGenerator directFromC2jGenerator = new DirectFromC2jGenerator(generator);
218221

@@ -228,7 +231,8 @@ private static ByteArrayOutputStream generateService(String arbitraryJson,
228231
enableVirtualOperations,
229232
disableSmithyGeneration,
230233
useSmithyClient,
231-
skipModelGeneration);
234+
skipModelGeneration,
235+
skipEndpointRulesBlob);
232236
return outputStream;
233237
}
234238

@@ -343,6 +347,7 @@ private static void printHelp() {
343347
System.out.println("\t\t--outputfile Writes the generated zip archive to the file.");
344348
System.out.println("\t\t--disable-smithy-generation Disable smithy-based generation (default: enabled)");
345349
System.out.println("\t\t--skip-model-generation Skip model file generation (headers+sources), only generate client files. Use when model files come from Smithy codegen.");
350+
System.out.println("\t\t--skip-endpoint-rules-blob Skip generation of the JSON endpoint-rules blob and GetRulesBlob accessor. Use when the BDD bytecode blob carries the ruleset instead.");
346351

347352
}
348353

tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/CMakeFile.vm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ file(GLOB AWS_${projectNameCaps}_MODEL_HEADERS
3434
"include/aws/${metadata.projectName}/model/*.h"
3535
)
3636

37+
file(GLOB AWS_${projectNameCaps}_INTERNAL_HEADERS
38+
"include/aws/${metadata.projectName}/internal/*.h"
39+
)
40+
3741
file(GLOB AWS_${projectNameCaps}_SOURCE
3842
"source/*.cpp"
3943
)
@@ -45,6 +49,7 @@ file(GLOB AWS_${projectNameCaps}_MODEL_SOURCE
4549
#set($cmakeVarStart = "${")
4650
file(GLOB ${projectNameCaps}_UNIFIED_HEADERS
4751
${cmakeVarStart}AWS_${projectNameCaps}_HEADERS}
52+
${cmakeVarStart}AWS_${projectNameCaps}_INTERNAL_HEADERS}
4853
${cmakeVarStart}AWS_${projectNameCaps}_MODEL_HEADERS}
4954
)
5055

@@ -67,6 +72,7 @@ if(WIN32)
6772
\#if we are compiling for visual studio, create a sane directory tree.
6873
if(MSVC)
6974
source_group("Header Files${dirDelim}aws${dirDelim}${metadata.projectName}" FILES ${cmakeVarStart}AWS_${projectNameCaps}_HEADERS})
75+
source_group("Header Files${dirDelim}aws${dirDelim}${metadata.projectName}${dirDelim}internal" FILES ${cmakeVarStart}AWS_${projectNameCaps}_INTERNAL_HEADERS})
7076
source_group("Header Files${dirDelim}aws${dirDelim}${metadata.projectName}${dirDelim}model" FILES ${cmakeVarStart}AWS_${projectNameCaps}_MODEL_HEADERS})
7177
source_group("Source Files" FILES ${cmakeVarStart}AWS_${projectNameCaps}_SOURCE})
7278
source_group("Source Files${dirDelim}model" FILES ${cmakeVarStart}AWS_${projectNameCaps}_MODEL_SOURCE})

tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/ServiceExportHeader.vm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@
2626
$define ${api}
2727
$define AWS_${metadata.classNamePrefix.toUpperCase()}_EXTERN extern
2828
#endif // USE_IMPORT_EXPORT
29+
$define AWS_${metadata.classNamePrefix.toUpperCase()}_LOCAL
2930
\#else // defined (USE_WINDOWS_DLL_SEMANTICS) || defined (WIN32)
3031
$define ${api}
3132
$define AWS_${metadata.classNamePrefix.toUpperCase()}_EXTERN extern
33+
\#if __GNUC__ >= 4
34+
$define AWS_${metadata.classNamePrefix.toUpperCase()}_LOCAL __attribute__((visibility("hidden")))
35+
\#else
36+
$define AWS_${metadata.classNamePrefix.toUpperCase()}_LOCAL
37+
#endif
3238
#endif // defined (USE_WINDOWS_DLL_SEMANTICS) || defined (WIN32)

tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/endpoint/EndpointProviderHeader.vm

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
\#include <aws/core/utils/memory/stl/AWSString.h>
2121
\#include <aws/core/utils/memory/stl/AWSVector.h>
2222

23-
#if($serviceModel.endpointRules)
24-
\#include <aws/${metadata.projectName}/${metadata.classNamePrefix}EndpointRules.h>
25-
#end
2623

2724

2825
namespace ${rootNamespace}
@@ -126,9 +123,7 @@ class ${exportMacro} ${epProviderClassName} : public ${metadata.classNamePrefix}
126123
public:
127124
using ${metadata.classNamePrefix}ResolveEndpointOutcome = Aws::Endpoint::ResolveEndpointOutcome;
128125

129-
${epProviderClassName}()
130-
: ${metadata.classNamePrefix}DefaultEpProviderBase(${rootNamespace}::${serviceNamespace}::${metadata.classNamePrefix}EndpointRules::GetRulesBlob(), ${rootNamespace}::${serviceNamespace}::${metadata.classNamePrefix}EndpointRules::RulesBlobSize)
131-
{}
126+
${epProviderClassName}();
132127

133128
~${metadata.classNamePrefix}EndpointProvider()
134129
{

tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/endpoint/EndpointProviderSource.vm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
#set($epContextClassName = "${metadata.classNamePrefix}ClientContextParameters")
88
#set($epBuiltInClassName = "${metadata.classNamePrefix}BuiltInParameters")
99
\#include <aws/${metadata.projectName}/${metadata.classNamePrefix}EndpointProvider.h>
10+
#if ($serviceModel.endpointRules)
11+
\#include <aws/${metadata.projectName}/internal/${metadata.classNamePrefix}EndpointRules.h>
12+
#end
1013

1114
namespace ${rootNamespace}
1215
{
@@ -33,6 +36,10 @@ namespace ${serviceNamespace}
3336
namespace Endpoint
3437
{
3538
#if ($serviceModel.endpointRules)
39+
${metadata.classNamePrefix}EndpointProvider::${metadata.classNamePrefix}EndpointProvider()
40+
: ${metadata.classNamePrefix}DefaultEpProviderBase(${rootNamespace}::${serviceNamespace}::${metadata.classNamePrefix}EndpointRules::GetRulesBlob(), ${rootNamespace}::${serviceNamespace}::${metadata.classNamePrefix}EndpointRules::RulesBlobSize)
41+
{}
42+
3643
#if ($serviceModel.clientContextParams)
3744
#foreach($memberEntry in $serviceModel.clientContextParams.entrySet())
3845
#if(${memberEntry.value.type} == "boolean")

tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/endpoint/EndpointRulesHeader.vm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@ namespace ${rootNamespace}
1212
namespace ${serviceNamespace}
1313
{
1414
#if ($serviceModel.endpointRules)
15-
class ${metadata.classNamePrefix}EndpointRules
15+
class AWS_${metadata.classNamePrefix.toUpperCase()}_LOCAL ${metadata.classNamePrefix}EndpointRules
1616
{
1717
public:
1818
#set($PartitionsBlobStrLen = $serviceModel.endpointRules.length() - 1)
1919
static const size_t RulesBlobStrLen;
2020
static const size_t RulesBlobSize;
2121

22-
##C++ compilers are required to support maximum length 65536 of string literal, therefore, using raw C array
2322
static const char* GetRulesBlob();
2423
};
2524
#end

0 commit comments

Comments
 (0)