From a6a5db7440a7f702e84ca423aef728c3d9459292 Mon Sep 17 00:00:00 2001
From: Campbell Barton <ideasman42@gmail.com>
Date: Thu, 6 Mar 2014 22:35:21 +1100
Subject: [PATCH] Initial commit for qtcreator external tools

---
 .../qtcreator/externaltools/qtc_doxy_file.py  | 44 +++++++++++++++++++
 .../qtcreator/externaltools/qtc_doxy_file.xml | 11 +++++
 utils_ide/qtcreator/readme.rst                | 44 +++++++++++++++++++
 3 files changed, 99 insertions(+)
 create mode 100755 utils_ide/qtcreator/externaltools/qtc_doxy_file.py
 create mode 100644 utils_ide/qtcreator/externaltools/qtc_doxy_file.xml
 create mode 100644 utils_ide/qtcreator/readme.rst

diff --git a/utils_ide/qtcreator/externaltools/qtc_doxy_file.py b/utils_ide/qtcreator/externaltools/qtc_doxy_file.py
new file mode 100755
index 0000000..5034cf9
--- /dev/null
+++ b/utils_ide/qtcreator/externaltools/qtc_doxy_file.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python3
+"""
+This script takes 2-3 args: [--browse] <Doxyfile> <sourcefile>
+
+--browse will open the resulting docs in a web browser.
+"""
+import sys
+import os
+import subprocess
+import tempfile
+
+def find_gitroot(filepath_reference):
+    path = filepath_reference
+    path_prev = ""
+    while not os.path.exists(os.path.join(path, ".git")) and path != path_prev:
+        path_prev = path
+        path = os.path.dirname(path)
+    return path
+
+def find_doxy(filepath_reference):
+    root = find_gitroot(filepath_reference)
+
+    # project specific!
+    return os.path.join(root, "doc", "doxygen", "Doxyfile")
+
+sourcefile = sys.argv[-1]
+
+doxyfile = find_doxy(sourcefile)
+os.chdir(os.path.dirname(doxyfile))
+
+tempfile = tempfile.NamedTemporaryFile(mode='w+b')
+doxyfile_tmp = tempfile.name
+tempfile.write(open(doxyfile, "r+b").read())
+tempfile.write(b'\n\n')
+tempfile.write(b'INPUT=' + os.fsencode(sourcefile) + b'\n')
+tempfile.flush()
+
+subprocess.call(("doxygen", doxyfile_tmp))
+del tempfile
+
+# Maybe handy, but also annoying?
+if "--browse" in sys.argv:
+    import webbrowser
+    webbrowser.open("html/files.html")
diff --git a/utils_ide/qtcreator/externaltools/qtc_doxy_file.xml b/utils_ide/qtcreator/externaltools/qtc_doxy_file.xml
new file mode 100644
index 0000000..2a2ac13
--- /dev/null
+++ b/utils_ide/qtcreator/externaltools/qtc_doxy_file.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<externaltool id="qtc_doxygen_file">
+    <description>Doxygen a single file</description>
+    <displayname>Doxygen File</displayname>
+    <category>Documentation</category>
+    <executable output="showinpane" error="showinpane" modifiesdocument="no">
+        <path>qtc_doxy_file.py</path>
+        <arguments>--browse %{CurrentDocument:FilePath}</arguments>
+        <workingdirectory>%{CurrentProject:BuildPath}</workingdirectory>
+    </executable>
+</externaltool>
diff --git a/utils_ide/qtcreator/readme.rst b/utils_ide/qtcreator/readme.rst
new file mode 100644
index 0000000..1e0239a
--- /dev/null
+++ b/utils_ide/qtcreator/readme.rst
@@ -0,0 +1,44 @@
+This repository contains utilities to perform various editing operations as well as some utilities to integrate
+Uncrustify and Meld.
+
+
+This is for my own personal use, but I have tried to make the tools generic (where possible) and useful to others.
+
+
+Installing
+==========
+
+All the scripts install to QtCreators ``externaltools`` path:
+
+eg:
+``~/.config/QtProject/qtcreator/externaltools/``
+
+Currently QtCreator has no way to reference commands relative to this directory so the ``externaltools`` dir **must**
+be added to the systems ``PATH``.
+
+
+Tools
+=====
+
+Here are a list of the tools with some details on how they work.
+
+
+Assembler Preview
+-----------------
+
+``External Tools -> Compiler -> Assembler Preview``
+
+This tool generates the assembly for the current open document,
+saving it to a file in the same path with an ".asm" extension.
+
+This can be handy for checking if the compiler is really optimizing out code as expected.
+
+Or if some change really does't change any functionality.
+
+The way it works is to get a list of the build commands that would run, and get those commands for the current file.
+
+Then this command runs, swapping out object creation args for arguments that create the assembly.
+
+.. note:: It would be nice to open this file, but currently this isnt supported. its just created along side the source.
+
+.. note:: Currently only GCC is supported.
-- 
GitLab