summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/minicargo/debug.h21
-rw-r--r--tools/minicargo/main.cpp29
2 files changed, 45 insertions, 5 deletions
diff --git a/tools/minicargo/debug.h b/tools/minicargo/debug.h
index bff9ddf3..00cd1412 100644
--- a/tools/minicargo/debug.h
+++ b/tools/minicargo/debug.h
@@ -4,10 +4,14 @@
#include <vector>
#include <sstream>
-extern void Debug_Print(::std::function<void(::std::ostream& os)> cb);
+typedef ::std::function<void(::std::ostream& os)> dbg_cb_t;
+extern void Debug_EnterScope(const char* name, dbg_cb_t );
+extern void Debug_LeaveScope(const char* name, dbg_cb_t );
+extern void Debug_Print(dbg_cb_t cb);
#define DEBUG(fmt) do { Debug_Print([&](auto& os){ os << "DEBUG: " << fmt; }); } while(0)
-#define TODO(fmt) do { Debug_Print([&](auto& os){ os << "DEBUG: " << fmt; }); abort(); } while(0)
+#define TODO(fmt) do { Debug_Print([&](auto& os){ os << "TODO: " << fmt; }); abort(); } while(0)
+#define TRACE_FUNCTION_F(fmt) DebugFunctionScope trace_function_hdr { __FUNCTION__, [&](auto& os){ os << fmt; } }
namespace {
static inline void format_to_stream(::std::ostream& os) {
@@ -19,6 +23,19 @@ namespace {
}
}
+struct DebugFunctionScope {
+ const char* m_name;
+ DebugFunctionScope(const char* name, dbg_cb_t cb):
+ m_name(name)
+ {
+ Debug_EnterScope(m_name, cb);
+ }
+ ~DebugFunctionScope()
+ {
+ Debug_LeaveScope(m_name, [](auto& ){});
+ }
+};
+
template<typename ...T>
::std::string format(const T&... v)
{
diff --git a/tools/minicargo/main.cpp b/tools/minicargo/main.cpp
index decedd6a..30d7c95c 100644
--- a/tools/minicargo/main.cpp
+++ b/tools/minicargo/main.cpp
@@ -22,10 +22,11 @@ struct ProgramOptions
// Directory containing build script outputs
const char* override_directory = nullptr;
- const char* output_directory = nullptr;
-
+ // Directory containing "vendored" (packaged) copies of packages
const char* vendor_dir = nullptr;
+ const char* output_directory = nullptr;
+
int parse(int argc, const char* argv[]);
void usage() const;
};
@@ -59,13 +60,17 @@ int main(int argc, const char* argv[])
catch(const ::std::exception& e)
{
::std::cerr << "EXCEPTION: " << e.what() << ::std::endl;
+#if _WIN32
::std::cout << "Press enter to exit..." << ::std::endl;
::std::cin.get();
+#endif
return 1;
}
+#if _WIN32
::std::cout << "Press enter to exit..." << ::std::endl;
::std::cin.get();
+#endif
return 0;
}
@@ -131,10 +136,28 @@ void ProgramOptions::usage() const
;
}
-
+static int giIndentLevel = 0;
void Debug_Print(::std::function<void(::std::ostream& os)> cb)
{
+ for(auto i = giIndentLevel; i --; )
+ ::std::cout << " ";
cb(::std::cout);
::std::cout << ::std::endl;
}
+void Debug_EnterScope(const char* name, dbg_cb_t cb)
+{
+ for(auto i = giIndentLevel; i --; )
+ ::std::cout << " ";
+ ::std::cout << ">>> " << name << "(";
+ cb(::std::cout);
+ ::std::cout << ")" << ::std::endl;
+ giIndentLevel ++;
+}
+void Debug_LeaveScope(const char* name, dbg_cb_t cb)
+{
+ giIndentLevel --;
+ for(auto i = giIndentLevel; i --; )
+ ::std::cout << " ";
+ ::std::cout << "<<< " << name << ::std::endl;
+}