Mikhail Glushenkov | 086976d | 2010-10-23 07:33:02 +0000 | [diff] [blame] | 1 | //===--- Main.cpp - The LLVM Compiler Driver -------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open |
| 6 | // Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // Usually this file just includes CompilerDriver/Main.inc, but here we apply |
| 11 | // some trickery to make the built-in '-save-temps' option hidden and enable |
| 12 | // '--temp-dir' by default. |
| 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
| 16 | #include "llvm/CompilerDriver/BuiltinOptions.h" |
| 17 | #include "llvm/CompilerDriver/Main.h" |
| 18 | |
Michael J. Spencer | 3cc52ea | 2010-11-29 18:47:54 +0000 | [diff] [blame^] | 19 | #include "llvm/Support/Path.h" |
Mikhail Glushenkov | 086976d | 2010-10-23 07:33:02 +0000 | [diff] [blame] | 20 | #include "llvm/Config/config.h" |
| 21 | |
| 22 | #include <iostream> |
| 23 | |
| 24 | #include "PIC16.inc" |
| 25 | |
| 26 | namespace { |
| 27 | |
| 28 | // Modify the PACKAGE_VERSION to use build number in top level configure file. |
| 29 | void PIC16VersionPrinter(void) { |
| 30 | std::cout << "MPLAB C16 1.0 " << PACKAGE_VERSION << "\n"; |
| 31 | } |
| 32 | |
| 33 | } |
| 34 | |
| 35 | int main(int argc, char** argv) { |
| 36 | |
| 37 | // HACK |
| 38 | SaveTemps.setHiddenFlag(llvm::cl::Hidden); |
| 39 | TempDirname.setHiddenFlag(llvm::cl::Hidden); |
| 40 | Languages.setHiddenFlag(llvm::cl::Hidden); |
| 41 | DryRun.setHiddenFlag(llvm::cl::Hidden); |
| 42 | |
| 43 | llvm::cl::SetVersionPrinter(PIC16VersionPrinter); |
| 44 | |
| 45 | // Ask for a standard temp dir, but just cache its basename., and delete it. |
| 46 | llvm::sys::Path tempDir; |
| 47 | tempDir = llvm::sys::Path::GetTemporaryDirectory(); |
| 48 | TempDirname = tempDir.getBasename(); |
| 49 | tempDir.eraseFromDisk(true); |
| 50 | |
| 51 | // We are creating a temp dir in current dir, with the cached name. |
| 52 | // But before that remove if one already exists with that name.. |
| 53 | tempDir = TempDirname; |
| 54 | tempDir.eraseFromDisk(true); |
| 55 | |
| 56 | return llvmc::Main(argc, argv); |
| 57 | } |