MCPcopy Create free account
hub / github.com/crownengine/crown / parse

Method parse

src/device/device_options.cpp:104–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104int DeviceOptions::parse(bool *quit)
105{
106 CommandLine cl(_argc, _argv);
107
108 if (cl.has_option("help", 'h')) {
109 help();
110 *quit = true;
111 return EXIT_SUCCESS;
112 }
113
114 if (cl.has_option("version", 'v')) {
115 printf("Crown " CROWN_VERSION "\n");
116 *quit = true;
117 return EXIT_SUCCESS;
118 }
119
120 path::reduce(_source_dir, cl.get_parameter(0, "source-dir"));
121 path::reduce(_data_dir, cl.get_parameter(0, "data-dir"));
122 path::reduce(_bundle_dir, cl.get_parameter(0, "bundle-dir"));
123
124 _map_source_dir_name = cl.get_parameter(0, "map-source-dir");
125 if (_map_source_dir_name) {
126 path::reduce(_map_source_dir_prefix, cl.get_parameter(1, "map-source-dir"));
127 if (_map_source_dir_prefix.empty()) {
128 help("Mapped source directory must be specified.");
129 return EXIT_FAILURE;
130 }
131 }
132
133 _do_compile = cl.has_option("compile");
134 _do_bundle = cl.has_option("bundle");
135 if (_do_compile || _do_bundle) {
136 _platform = cl.get_parameter(0, "platform");
137
138 // Compile for platform the executable is built for.
139 if (_platform == NULL)
140 _platform = CROWN_PLATFORM_NAME;
141
142 if (_source_dir.empty()) {
143 help("Source dir must be specified.");
144 return EXIT_FAILURE;
145 }
146
147 if (_data_dir.empty()) {
148 _data_dir += _source_dir;
149 _data_dir += '_';
150 _data_dir += _platform;
151 }
152
153 if (_do_bundle) {
154 if (_bundle_dir.empty()) {
155 _bundle_dir += _source_dir;
156 _bundle_dir += "_bundle_";
157 _bundle_dir += _platform;
158 }
159 }
160 }
161

Callers

nothing calls this directly

Calls 15

reduceFunction · 0.85
renderer_type_from_nameFunction · 0.85
is_absoluteFunction · 0.85
strcmpFunction · 0.85
is_relativeFunction · 0.85
has_optionMethod · 0.80
get_parameterMethod · 0.80
to_stringMethod · 0.80
helpFunction · 0.70
printfFunction · 0.50
StringId32Class · 0.50
StringId64Class · 0.50

Tested by

no test coverage detected