MCPcopy Create free account
hub / github.com/acidicoala/SmokeAPI / generate_lookup_json

Function generate_lookup_json

tools/src/steamworks_parser.cpp:176–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174 }
175
176 void generate_lookup_json(const fs::path& steamworks_dir, const std::set<std::string>& sdk_filter) {
177 // Ideally the top level lookup should be unordered json (i.e. keys sorted alphabetically).
178 // But the library doesn't support inserting ordered_json instances as values in json objects.
179 nlohmann::ordered_json lookup;
180
181 // The thread pool noticeably speeds up the overall parsing.
182 // Thread count of 4 seems to yield most optimal performance benefits.
183 constexpr auto thread_count = 4;
184 LOG_INFO("Creating task pool with {} threads", thread_count);
185 BS::thread_pool pool(thread_count);
186
187 // Go over each steamworks sdk version
188 for(const auto& entry : fs::directory_iterator(steamworks_dir)) {
189 if(not entry.is_directory()) {
190 continue;
191 }
192
193 if(
194 not sdk_filter.empty() and
195 not sdk_filter.contains(kb::path::to_str(entry.path().filename()))
196 ) {
197 continue;
198 }
199
200 parse_sdk(entry.path(), lookup, pool);
201 }
202
203 // Wait for all tasks to finish
204 pool.wait();
205
206 const auto interface_lookup_path = fs::path("interface_lookup.json");
207
208 std::ofstream lookup_output(interface_lookup_path);
209 lookup_output << std::setw(4) << lookup;
210
211 LOG_INFO(
212 "Interface lookup generated at: {}",
213 kb::path::to_str(fs::absolute(interface_lookup_path))
214 );
215 }
216}
217
218/**

Callers 1

MAINFunction · 0.85

Calls 1

parse_sdkFunction · 0.85

Tested by

no test coverage detected