parent
f40b590721
commit
3fcdada6b4
|
@ -71,11 +71,16 @@ namespace {
|
||||||
|
|
||||||
namespace llvmc {
|
namespace llvmc {
|
||||||
|
|
||||||
|
// Sometimes plugins want to condition on the value in argv[0].
|
||||||
|
const char* ProgramName;
|
||||||
|
|
||||||
int Main(int argc, char** argv) {
|
int Main(int argc, char** argv) {
|
||||||
try {
|
try {
|
||||||
LanguageMap langMap;
|
LanguageMap langMap;
|
||||||
CompilationGraph graph;
|
CompilationGraph graph;
|
||||||
|
|
||||||
|
ProgramName = argv[0];
|
||||||
|
|
||||||
cl::ParseCommandLineOptions
|
cl::ParseCommandLineOptions
|
||||||
(argc, argv, "LLVM Compiler Driver (Work In Progress)", true);
|
(argc, argv, "LLVM Compiler Driver (Work In Progress)", true);
|
||||||
|
|
||||||
|
|
|
@ -678,6 +678,28 @@ errors as its status code.
|
||||||
.. _Graphviz: http://www.graphviz.org/
|
.. _Graphviz: http://www.graphviz.org/
|
||||||
.. _Ghostview: http://pages.cs.wisc.edu/~ghost/
|
.. _Ghostview: http://pages.cs.wisc.edu/~ghost/
|
||||||
|
|
||||||
|
Conditioning on the executable name
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
For now, the executable name (the value passed to the driver in ``argv[0]``) is
|
||||||
|
accessible only in the C++ code (i.e. hooks). Use the following code::
|
||||||
|
|
||||||
|
namespace llvmc {
|
||||||
|
extern const char* ProgramName;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string MyHook() {
|
||||||
|
//...
|
||||||
|
if (strcmp(ProgramName, "mydriver") == 0) {
|
||||||
|
//...
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
In general, you're encouraged not to make the behaviour dependent on the
|
||||||
|
executable file name, and use command-line switches instead. See for example how
|
||||||
|
the ``Base`` plugin behaves when it needs to choose the correct linker options
|
||||||
|
(think ``g++`` vs. ``gcc``).
|
||||||
|
|
||||||
.. raw:: html
|
.. raw:: html
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
Loading…
Reference in New Issue