From 3f191255743985291e44487676a6b5b7155ec053 Mon Sep 17 00:00:00 2001 From: Stefano Sanfilippo Date: Sat, 7 Mar 2015 19:56:47 +0100 Subject: [PATCH] Output object file in current directory. --- CMakeLists.txt | 2 +- main.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f432754..238c2ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,7 +65,7 @@ elseif(BISON_VERSION VERSION_LESS 3.0) endif() ## 3. External components -find_package(Boost 1.48 REQUIRED regex) +find_package(Boost 1.48 REQUIRED regex system filesystem) find_package(LLVM REQUIRED CONFIG) add_definitions( diff --git a/main.cpp b/main.cpp index 4e86ca4..1b94c3c 100644 --- a/main.cpp +++ b/main.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -53,12 +54,12 @@ int main(int argc, char **argv) { parser.parse(); boost::regex namere("^(.+)\\.mc$"); - std::string outputname; + std::string outputname = boost::filesystem::path(inputname).filename().native(); - if (boost::regex_match(inputname, namere)) { - outputname = boost::regex_replace(inputname, namere, "$1.bc"); + if (boost::regex_match(outputname, namere)) { + outputname = boost::regex_replace(outputname, namere, "$1.bc"); } else { - outputname = inputname + ".bc"; + outputname = outputname + ".bc"; } if (!program.emit(&emitter)) return 1;