Skip to content

Commit 2db690c

Browse files
author
Rafał Hibner
committed
Add option to skip types or schema generation
1 parent 3d693ab commit 2db690c

File tree

2 files changed

+43
-28
lines changed

2 files changed

+43
-28
lines changed

include/SchemaGenerator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ struct [[nodiscard("unnecessary construction")]] GeneratorOptions
2424
const bool verbose = false;
2525
const bool stubs = false;
2626
const bool noIntrospection = false;
27+
const bool noTypes = false;
28+
const bool noSchema = false;
2729
const bool prefixedHeaders = false;
2830
};
2931

src/SchemaGenerator.cpp

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -125,41 +125,46 @@ std::vector<std::string> Generator::Build() const noexcept
125125
{
126126
std::vector<std::string> builtFiles;
127127

128-
if (outputSharedTypesHeader() && _options.verbose)
129-
{
130-
builtFiles.push_back(_sharedTypesHeaderPath);
131-
}
128+
if (!_options.noTypes){
129+
if (outputSharedTypesHeader() && _options.verbose)
130+
{
131+
builtFiles.push_back(_sharedTypesHeaderPath);
132+
}
132133

133-
if (outputSharedTypesModule() && _options.verbose)
134-
{
135-
builtFiles.push_back(_sharedTypesModulePath);
136-
}
134+
if (outputSharedTypesModule() && _options.verbose)
135+
{
136+
builtFiles.push_back(_sharedTypesModulePath);
137+
}
137138

138-
if (outputSchemaHeader() && _options.verbose)
139-
{
140-
builtFiles.push_back(_schemaHeaderPath);
139+
if (outputSharedTypesSource())
140+
{
141+
builtFiles.push_back(_sharedTypesSourcePath);
142+
}
141143
}
142144

143-
if (outputSchemaModule() && _options.verbose)
144-
{
145-
builtFiles.push_back(_schemaModulePath);
146-
}
147145

148-
if (outputSharedTypesSource())
149-
{
150-
builtFiles.push_back(_sharedTypesSourcePath);
151-
}
146+
if (!_options.noSchema){
147+
if (outputSchemaHeader() && _options.verbose)
148+
{
149+
builtFiles.push_back(_schemaHeaderPath);
150+
}
152151

153-
if (outputSchemaSource())
154-
{
155-
builtFiles.push_back(_schemaSourcePath);
156-
}
152+
if (outputSchemaModule() && _options.verbose)
153+
{
154+
builtFiles.push_back(_schemaModulePath);
155+
}
157156

158-
auto separateFiles = outputSeparateFiles();
157+
if (outputSchemaSource())
158+
{
159+
builtFiles.push_back(_schemaSourcePath);
160+
}
159161

160-
for (auto& file : separateFiles)
161-
{
162-
builtFiles.push_back(std::move(file));
162+
auto separateFiles = outputSeparateFiles();
163+
164+
for (auto& file : separateFiles)
165+
{
166+
builtFiles.push_back(std::move(file));
167+
}
163168
}
164169

165170
return builtFiles;
@@ -3821,6 +3826,8 @@ int main(int argc, char** argv)
38213826
bool stubs = false;
38223827
bool noIntrospection = false;
38233828
bool prefixedHeaders = false;
3829+
bool noTypes = false;
3830+
bool noSchema = false;
38243831
std::string schemaFileName;
38253832
std::string filenamePrefix;
38263833
std::string schemaNamespace;
@@ -3847,7 +3854,11 @@ int main(int argc, char** argv)
38473854
"Unimplemented fields throw runtime exceptions instead of compiler errors")("no-"
38483855
"introspection",
38493856
po::bool_switch(&noIntrospection),
3850-
"Do not generate support for Introspection")("prefix-headers",
3857+
"Do not generate support for Introspection")("no-types",
3858+
po::bool_switch(&noTypes),
3859+
"Do not generate SharedTypes")("no-schema",
3860+
po::bool_switch(&noSchema),
3861+
"Do not generate Schema")("prefix-headers",
38513862
po::bool_switch(&prefixedHeaders),
38523863
"Prefix generated object header filenames");
38533864
positional.add("schema", 1).add("prefix", 1).add("namespace", 1);
@@ -3914,6 +3925,8 @@ int main(int argc, char** argv)
39143925
verbose, // verbose
39153926
stubs, // stubs
39163927
noIntrospection, // noIntrospection
3928+
noTypes, // noTypes
3929+
noSchema, // noSchema
39173930
prefixedHeaders, // prefixedHeaders
39183931
})
39193932
.Build();

0 commit comments

Comments
 (0)