diff --git a/BUGS b/BUGS index 549ce9e..a059c5f 100644 --- a/BUGS +++ b/BUGS @@ -7,6 +7,7 @@ Current - If a job is paused for longer than the timeout period, sometimes it has the timed out status when un-paused. - Tmp files are being left behind after shutdown. +- gcc is not working inside the sandbox. Current (tool related) diff --git a/README.md b/README.md index 55393fe..4c9d38e 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,9 @@ Extensions | Tools .pl .pm .t | [perl_syntax](https://en.wikipedia.org/wiki/Perl) • [perldoc](http://perldoc.perl.org/) • [perltidy](http://perltidy.sourceforge.net/) .pod .pod6 | [perldoc](http://perldoc.perl.org/) .java | [uncrustify](http://uncrustify.sourceforge.net/) -.c .h | [splint](http://www.splint.org/) • [uncrustify](http://uncrustify.sourceforge.net/) +.c .h | [c_syntax](https://gcc.gnu.org/) • [splint](http://www.splint.org/) • [uncrustify](http://uncrustify.sourceforge.net/) .o | [objdump_headers](https://en.wikipedia.org/wiki/Objdump) • [objdump_disassemble](https://en.wikipedia.org/wiki/Objdump) • [readelf](https://en.wikipedia.org/wiki/Objdump) -.cpp | bcpp • [uncrustify](http://uncrustify.sourceforge.net/) +.cpp | [cpp_syntax](https://gcc.gnu.org/) • bcpp • [uncrustify](http://uncrustify.sourceforge.net/) .pdf | [pdf2txt](http://www.unixuser.org/~euske/python/pdfminer/) .html | [html_syntax](http://www.html-tidy.org/) • [tidy](http://www.html-tidy.org/) • [html2text](http://www.mbayer.de/html2text/) .php | [php5_syntax](https://en.wikipedia.org/wiki/PHP) diff --git a/tools.py b/tools.py index 46c5bb3..1b0e848 100644 --- a/tools.py +++ b/tools.py @@ -509,6 +509,12 @@ perltidy.url = "http://perltidy.sourceforge.net/" # perl6_syntax.dependencies = {"rakudo"} +def c_syntax(path): + return _run_command(["gcc", "-fsyntax-only", path]) +c_syntax.dependencies = {"gcc"} +c_syntax.url = "https://gcc.gnu.org/" + + def splint(path): stdout, stderr, returncode = _do_command(["splint", "-preproc", path]) status = Status.ok if returncode == 0 else Status.problem @@ -595,6 +601,12 @@ html2text.dependencies = {"html2text"} html2text.url = "html2text" +def cpp_syntax(path): + return _run_command(["gcc", "-fsyntax-only", path]) +cpp_syntax.dependencies = {"gcc"} +cpp_syntax.url = "https://gcc.gnu.org/" + + def bcpp(path): stdout, stderr, returncode = _do_command(["bcpp", "-fi", path]) status = Status.normal if returncode == 0 else Status.problem @@ -754,9 +766,9 @@ TOOLS_FOR_EXTENSIONS = \ # (["p6", "pm6"], [perl6_syntax, perldoc]), (["pod", "pod6"], [perldoc]), (["java"], [uncrustify]), - (["c", "h"], [splint, uncrustify]), + (["c", "h"], [c_syntax, splint, uncrustify]), (["o"], [objdump_headers, objdump_disassemble, readelf]), - (["cpp"], [bcpp, uncrustify]), + (["cpp"], [cpp_syntax, bcpp, uncrustify]), (["pdf"], [pdf2txt]), (["html"], [html_syntax, tidy, html2text]), (["php"], [php5_syntax]), diff --git a/tools_test.py b/tools_test.py index 98790b8..03d08e5 100755 --- a/tools_test.py +++ b/tools_test.py @@ -153,6 +153,9 @@ class ToolsTestCase(unittest.TestCase): ("hello.h", tools.Status.normal), ("hello.cpp", tools.Status.normal)]) + def test_c_syntax(self): + self._test_tool(tools.c_syntax, [("hello.c", tools.Status.ok)]) + def test_splint(self): self._test_tool(tools.splint, [("hello.c", tools.Status.ok), ("hello.h", tools.Status.ok)]) @@ -194,6 +197,9 @@ class ToolsTestCase(unittest.TestCase): def test_html2text(self): self._test_tool(tools.html2text, [("hi.html", tools.Status.normal)]) + def test_cpp_syntax(self): + self._test_tool(tools.cpp_syntax, [("hello.cpp", tools.Status.ok)]) + def test_bcpp(self): self._test_tool(tools.bcpp, [("hello.cpp", tools.Status.normal)])