From f8d2af74c85eae3fae2348107a54b790842c6133 Mon Sep 17 00:00:00 2001
From: Zuzana Baranova <xbaranov@fi.muni.cz>
Date: Sun, 23 Jun 2019 09:00:01 +0000
Subject: [PATCH] tools: Add dioscc (divcc with DiOS).

---
 tools/dioscc.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 tools/dioscc.cpp

diff --git a/tools/dioscc.cpp b/tools/dioscc.cpp
new file mode 100644
index 000000000..403469350
--- /dev/null
+++ b/tools/dioscc.cpp
@@ -0,0 +1,52 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+
+/*
+ * (c) 2017 Jan Horáček <me@apophis.cz>
+ * (c) 2017-2019 Zuzana Baranová <xbaranov@fi.muni.cz>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <divine/cc/cc1.hpp> //CompileError
+#include <divine/cc/native.hpp>
+#include <divine/rt/dios-cc.hpp>
+#include <divine/rt/runtime.hpp>
+#include <divine/ui/version.hpp>
+
+
+using namespace divine;
+
+/* usage: same as gcc */
+int main( int argc, char **argv )
+{
+    try {
+        rt::NativeDiosCC nativeCC( { argv + 1, argv + argc } );
+        nativeCC.set_cxx( brick::string::endsWith( argv[0], "divc++" ) );
+        auto& po = nativeCC._po;
+
+        if ( po.hasHelp || po.hasVersion )
+        {
+            nativeCC.print_info( ui::version() );
+            return 0;
+        }
+
+        return nativeCC.run();
+
+    } catch ( cc::CompileError &err ) {
+        std::cerr << err.what() << std::endl;
+        return 1;
+    } catch ( std::runtime_error &err ) {
+        std::cerr << "compilation failed: " << err.what() << std::endl;
+        return 2;
+    }
+}
-- 
GitLab