Skip to content

Commit 4aa105a

Browse files
author
Rafał Hibner
committed
Add option to skip types or schema generation
1 parent fb3f17d commit 4aa105a

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;
@@ -3823,6 +3828,8 @@ int main(int argc, char** argv)
38233828
bool stubs = false;
38243829
bool noIntrospection = false;
38253830
bool prefixedHeaders = false;
3831+
bool noTypes = false;
3832+
bool noSchema = false;
38263833
std::string schemaFileName;
38273834
std::string filenamePrefix;
38283835
std::string schemaNamespace;
@@ -3849,7 +3856,11 @@ int main(int argc, char** argv)
38493856
"Unimplemented fields throw runtime exceptions instead of compiler errors")("no-"
38503857
"introspection",
38513858
po::bool_switch(&noIntrospection),
3852-
"Do not generate support for Introspection")("prefix-headers",
3859+
"Do not generate support for Introspection")("no-types",
3860+
po::bool_switch(&noTypes),
3861+
"Do not generate SharedTypes")("no-schema",
3862+
po::bool_switch(&noSchema),
3863+
"Do not generate Schema")("prefix-headers",
38533864
po::bool_switch(&prefixedHeaders),
38543865
"Prefix generated object header filenames");
38553866
positional.add("schema", 1).add("prefix", 1).add("namespace", 1);
@@ -3916,6 +3927,8 @@ int main(int argc, char** argv)
39163927
verbose, // verbose
39173928
stubs, // stubs
39183929
noIntrospection, // noIntrospection
3930+
noTypes, // noTypes
3931+
noSchema, // noSchema
39193932
prefixedHeaders, // prefixedHeaders
39203933
})
39213934
.Build();

0 commit comments

Comments
 (0)