Skip to content

Commit a2b3625

Browse files
committed
Move autodetect after user options.
1 parent c5368b8 commit a2b3625

File tree

3 files changed

+49
-37
lines changed

3 files changed

+49
-37
lines changed

include/configGenerator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ class ConfigGenerator
252252
*/
253253
bool buildDefaultValues();
254254

255+
bool buildAutoDetectValues();
256+
255257
/**
256258
* Sets up all config values that have a forced value.
257259
* @return True if it succeeds, false if it fails.

source/configGenerator.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ bool ConfigGenerator::passConfig(const int argc, char** argv)
6666
if (!buildForcedValues()) {
6767
return false;
6868
}
69+
if (!buildAutoDetectValues()) {
70+
return false;
71+
}
6972
// Perform validation of values
7073
if (!passCurrentValues()) {
7174
return false;
@@ -546,14 +549,7 @@ bool ConfigGenerator::changeConfig(const string& option)
546549
toggleConfigValue(i, enable);
547550
}
548551
} else if (option2 == "autodetect") {
549-
// Change AUTODETECT_LIBS
550-
vector<string> list;
551-
if (!getConfigList("AUTODETECT_LIBS", list)) {
552-
return false;
553-
}
554-
for (const auto& i : list) {
555-
toggleConfigValue(i, enable);
556-
}
552+
toggleConfigValue(option2, enable);
557553
} else {
558554
// Check if the option is a component
559555
vector<string> list;

source/configGenerator_build.cpp

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,45 @@ bool ConfigGenerator::buildDefaultValues()
263263
const auto autoDet = getConfigOption("autodetect");
264264
if ((autoDet == m_configValues.end()) || (autoDet->m_value != "0")) {
265265
// Enable all the auto detected libs
266-
list.resize(0);
266+
vector<string> list;
267+
if (getConfigList("AUTODETECT_LIBS", list)) {
268+
fastToggleConfigValue("autodetect", true);
269+
} else {
270+
// If no auto list then just use hard enables
271+
fastToggleConfigValue("bzlib", true);
272+
fastToggleConfigValue("iconv", true);
273+
fastToggleConfigValue("lzma", true);
274+
fastToggleConfigValue("schannel", true);
275+
fastToggleConfigValue("sdl", true);
276+
fastToggleConfigValue("sdl2", true);
277+
fastToggleConfigValue("zlib", true);
278+
279+
// Enable hwaccels by default.
280+
fastToggleConfigValue("d3d11va", true);
281+
fastToggleConfigValue("dxva2", true);
282+
283+
string sFileName;
284+
if (findFile(m_rootDirectory + "compat/cuda/dynlink_cuda.h", sFileName)) {
285+
fastToggleConfigValue("cuda", true);
286+
fastToggleConfigValue("cuvid", true);
287+
}
288+
if (findFile(m_rootDirectory + "compat/nvenc/nvEncodeAPI.h", sFileName)) {
289+
fastToggleConfigValue("nvenc", true);
290+
}
291+
}
292+
}
293+
294+
return buildForcedValues();
295+
}
296+
297+
bool ConfigGenerator::buildAutoDetectValues()
298+
{
299+
// Check if auto detection is enabled
300+
const auto autoDet = getConfigOption("autodetect");
301+
if ((autoDet != m_configValues.end())) {
302+
// Enable/Disable all the auto detected libs
303+
const bool enableAuto = (autoDet->m_value != "0");
304+
vector<string> list;
267305
if (getConfigList("AUTODETECT_LIBS", list)) {
268306
string sFileName;
269307
for (const auto& i : list) {
@@ -386,35 +424,11 @@ bool ConfigGenerator::buildDefaultValues()
386424
// Just disable
387425
enable = false;
388426
}
389-
fastToggleConfigValue(i, enable);
390-
}
391-
fastToggleConfigValue("autodetect", true);
392-
} else {
393-
// If no auto list then just use hard enables
394-
fastToggleConfigValue("bzlib", true);
395-
fastToggleConfigValue("iconv", true);
396-
fastToggleConfigValue("lzma", true);
397-
fastToggleConfigValue("schannel", true);
398-
fastToggleConfigValue("sdl", true);
399-
fastToggleConfigValue("sdl2", true);
400-
fastToggleConfigValue("zlib", true);
401-
402-
// Enable hwaccels by default.
403-
fastToggleConfigValue("d3d11va", true);
404-
fastToggleConfigValue("dxva2", true);
405-
406-
string sFileName;
407-
if (findFile(m_rootDirectory + "compat/cuda/dynlink_cuda.h", sFileName)) {
408-
fastToggleConfigValue("cuda", true);
409-
fastToggleConfigValue("cuvid", true);
410-
}
411-
if (findFile(m_rootDirectory + "compat/nvenc/nvEncodeAPI.h", sFileName)) {
412-
fastToggleConfigValue("nvenc", true);
427+
toggleConfigValue(i, enable && enableAuto, true);
413428
}
414429
}
415430
}
416-
417-
return buildForcedValues();
431+
return true;
418432
}
419433

420434
bool ConfigGenerator::buildForcedValues()
@@ -876,8 +890,8 @@ void ConfigGenerator::buildReplaceValues(
876890
}
877891
}
878892
for (auto& newReplaceValue : newReplaceValues) {
879-
// Add them to the returned list (done here so that any checks above that test if it is reserved only operate on
880-
// the unmodified original list)
893+
// Add them to the returned list (done here so that any checks above that test if it is reserved only
894+
// operate on the unmodified original list)
881895
replaceValues[newReplaceValue.first] = newReplaceValue.second;
882896
}
883897

0 commit comments

Comments
 (0)