Mercurial > hg > svcore
comparison base/HelperExecPath.cpp @ 1246:75aefcc9f07d piper
Use plugin scan results to inform the list requests issued to Piper servers
author | Chris Cannam |
---|---|
date | Thu, 03 Nov 2016 14:14:09 +0000 |
parents | c7a710f806a1 |
children | a9d0b5a2c242 |
comparison
equal
deleted
inserted
replaced
1245:0492e54ccd56 | 1246:75aefcc9f07d |
---|---|
18 #include <QCoreApplication> | 18 #include <QCoreApplication> |
19 #include <QFile> | 19 #include <QFile> |
20 #include <QDir> | 20 #include <QDir> |
21 #include <QFileInfo> | 21 #include <QFileInfo> |
22 | 22 |
23 static QStringList | 23 QStringList |
24 getSuffixes() | 24 HelperExecPath::getTags() |
25 { | 25 { |
26 if (sizeof(void *) == 8) { | 26 if (sizeof(void *) == 8) { |
27 return { "-64", "", "-32" }; | 27 if (m_type == NativeArchitectureOnly) { |
28 return { "64", "" }; | |
29 } else { | |
30 return { "64", "", "32" }; | |
31 } | |
28 } else { | 32 } else { |
29 return { "", "-32" }; | 33 return { "", "32" }; |
30 } | 34 } |
31 } | 35 } |
32 | 36 |
33 static bool | 37 static bool |
34 isGood(QString path) | 38 isGood(QString path) |
35 { | 39 { |
36 return QFile(path).exists() && QFileInfo(path).isExecutable(); | 40 return QFile(path).exists() && QFileInfo(path).isExecutable(); |
37 } | 41 } |
38 | 42 |
39 QStringList | 43 QList<HelperExecPath::HelperExec> |
40 HelperExecPath::getHelperExecutables(QString basename) | 44 HelperExecPath::getHelperExecutables(QString basename) |
41 { | 45 { |
42 QStringList dummy; | 46 QStringList dummy; |
43 return search(basename, dummy); | 47 return search(basename, dummy); |
44 } | 48 } |
45 | 49 |
46 QString | 50 QString |
47 HelperExecPath::getHelperExecutable(QString basename) | 51 HelperExecPath::getHelperExecutable(QString basename) |
48 { | 52 { |
49 QStringList execs = getHelperExecutables(basename); | 53 auto execs = getHelperExecutables(basename); |
50 if (execs.empty()) return ""; | 54 if (execs.empty()) return ""; |
51 else return execs[0]; | 55 else return execs[0].executable; |
52 } | 56 } |
53 | 57 |
54 QStringList | 58 QStringList |
55 HelperExecPath::getHelperDirPaths() | 59 HelperExecPath::getHelperDirPaths() |
56 { | 60 { |
67 QStringList candidates; | 71 QStringList candidates; |
68 (void)search(basename, candidates); | 72 (void)search(basename, candidates); |
69 return candidates; | 73 return candidates; |
70 } | 74 } |
71 | 75 |
72 QStringList | 76 QList<HelperExecPath::HelperExec> |
73 HelperExecPath::search(QString basename, QStringList &candidates) | 77 HelperExecPath::search(QString basename, QStringList &candidates) |
74 { | 78 { |
75 // Helpers are expected to exist either in the same directory as | 79 // Helpers are expected to exist either in the same directory as |
76 // this executable was found, or in a subdirectory called helpers. | 80 // this executable was found, or in a subdirectory called helpers. |
77 | 81 |
78 QString extension = ""; | 82 QString extension = ""; |
79 #ifdef _WIN32 | 83 #ifdef _WIN32 |
80 extension = ".exe"; | 84 extension = ".exe"; |
81 #endif | 85 #endif |
82 | 86 |
83 QStringList executables; | 87 QList<HelperExec> executables; |
84 QStringList dirs = getHelperDirPaths(); | 88 QStringList dirs = getHelperDirPaths(); |
85 | 89 |
86 for (QString s: getSuffixes()) { | 90 for (QString t: getTags()) { |
87 for (QString d: dirs) { | 91 for (QString d: dirs) { |
88 QString path = d + QDir::separator() + basename + s + extension; | 92 QString path = d + QDir::separator() + basename; |
93 if (t != QString()) path += "-" + t; | |
94 path += extension; | |
89 candidates.push_back(path); | 95 candidates.push_back(path); |
90 if (isGood(path)) { | 96 if (isGood(path)) { |
91 executables.push_back(path); | 97 executables.push_back({ path, t }); |
92 break; | 98 break; |
93 } | 99 } |
94 } | 100 } |
95 } | 101 } |
96 | 102 |