From 77597d6baa31ccbe38c38a2719f1e1b0370b7ba6 Mon Sep 17 00:00:00 2001 From: st8ingenious Date: Mon, 1 Aug 2016 14:49:49 +0300 Subject: [PATCH 1/3] Added .hpp in allowed file extensions Enable compiler to extract .hpp files included in arduino projects. --- .../src/Codebender/CompilerBundle/Handler/UtilityHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Symfony/src/Codebender/CompilerBundle/Handler/UtilityHandler.php b/Symfony/src/Codebender/CompilerBundle/Handler/UtilityHandler.php index f674b6e..095467f 100644 --- a/Symfony/src/Codebender/CompilerBundle/Handler/UtilityHandler.php +++ b/Symfony/src/Codebender/CompilerBundle/Handler/UtilityHandler.php @@ -36,7 +36,7 @@ function extractFiles($directory, $request_files, $lib_extraction) // separated by "|" to be used in regular expressions. They are also // used as keys in an array that will contain the paths of all the // extracted files. - $allowedExtensions = array("c", "cpp", "h", "inc", "ino", "o", "S"); + $allowedExtensions = array("c", "cpp", "h", "inc", "ino", "o", "S", "hpp"); $files = array(); foreach ($allowedExtensions as $ext) $files[$ext] = array(); From a5d4a0e8fb47c20d0437a09924ff75bb3cda675a Mon Sep 17 00:00:00 2001 From: st8ingenious Date: Mon, 1 Aug 2016 14:58:52 +0300 Subject: [PATCH 2/3] new test added added an ino which includes an .hpp file. The .hpp defines a var that is used by the ino, in order to insure that the hpp file is correctly fetched by the compiler. --- .../DefaultControllerFunctionalTest.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Symfony/src/Codebender/CompilerBundle/Tests/Controller/DefaultControllerFunctionalTest.php b/Symfony/src/Codebender/CompilerBundle/Tests/Controller/DefaultControllerFunctionalTest.php index d4e11b6..26f35b0 100644 --- a/Symfony/src/Codebender/CompilerBundle/Tests/Controller/DefaultControllerFunctionalTest.php +++ b/Symfony/src/Codebender/CompilerBundle/Tests/Controller/DefaultControllerFunctionalTest.php @@ -50,6 +50,30 @@ public function testInvalidInput() } + public function testSkchHppUnoSyntaxCheck() + { + $files = array(array("filename" => "SkchHpp.ino", "content" => "#include\nvoid setup()\n{\nSerial.begin(9600);\n\tint x = vardeb+5;\nSerial.println(x);\n}\n\nvoid loop()\n{\n\n}\n")); + $format = "syntax"; + $version = "105"; + $libraries = array('jsonlib' => array('files' => array('filename' => 'jsonhp.hpp', 'content' => "#define vardeb 3;\n"))); + $build = array("mcu" => "atmega328p", "f_cpu" => "16000000", "core" => "arduino", "variant" => "standard"); + + $data = json_encode(array("files" => $files, "format" => $format, "version" => $version, "libraries" => $libraries, "build" => $build)); + + $client = static::createClient(); + + $authorizationKey = $client->getContainer()->getParameter("authorizationKey"); + + $client->request('POST', '/' . $authorizationKey . '/v1', array(), array(), array(), $data); + + $response = json_decode($client->getResponse()->getContent(), true); + + $this->assertEquals($response["success"], true); + $this->assertTrue(is_numeric($response["time"])); + + } + + public function testBlinkUnoSyntaxCheck() { $files = array(array("filename" => "Blink.ino", "content" => "int led = 13;\nvoid setup() {pinMode(led, OUTPUT);}\nvoid loop() {\ndigitalWrite(led, HIGH);\ndelay(1000);\ndigitalWrite(led, LOW);\ndelay(1000);\n}\n")); From 82d55b4535245cd617a751e036be5ca4b85d03c5 Mon Sep 17 00:00:00 2001 From: st8ingenious Date: Mon, 1 Aug 2016 15:02:15 +0300 Subject: [PATCH 3/3] .hpp support in autocompletion (untested) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit added hpp extension into “doAutocomplete” function for future compatibility --- .../src/Codebender/CompilerBundle/Handler/CompilerHandler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Symfony/src/Codebender/CompilerBundle/Handler/CompilerHandler.php b/Symfony/src/Codebender/CompilerBundle/Handler/CompilerHandler.php index c997232..8b8ba66 100644 --- a/Symfony/src/Codebender/CompilerBundle/Handler/CompilerHandler.php +++ b/Symfony/src/Codebender/CompilerBundle/Handler/CompilerHandler.php @@ -1134,7 +1134,7 @@ private function doAutocomplete($ARDUINO_CORES_DIR, $compiler_config, $compile_d $ext = pathinfo($file, PATHINFO_EXTENSION); if (!in_array($ext, array("ino", "c", "cpp", "h", "hpp"))) - return array("success" => false, "message" => "Sorry, autocompletion is only supported for .ino, .c, .cpp or .h files."); + return array("success" => false, "message" => "Sorry, autocompletion is only supported for .ino, .c, .cpp, .h or .hpp files."); if ($ext == "ino") { $ext = "cpp"; @@ -1149,7 +1149,7 @@ private function doAutocomplete($ARDUINO_CORES_DIR, $compiler_config, $compile_d $json_array = array("file" => $compiler_config["autocmpfile"], "row" => $compiler_config["autocmprow"], "column" => $compiler_config["autocmpcol"], "prefix" => $compiler_config["autocmpprefix"], "command" => $commandline); } - elseif ($ext == "cpp" || $ext == "h") + elseif ($ext == "cpp" || $ext == "h" || $ext == "hpp" ) { $commandline = "$CPP $CPPFLAGS $core_includes $target_arch -MMD $include_directories -c -o $filename.o $filename.$ext 2>&1"; $json_array = array("file" => $compiler_config["autocmpfile"], "row" => $compiler_config["autocmprow"], "column" => $compiler_config["autocmpcol"], "prefix" => $compiler_config["autocmpprefix"], "command" => $commandline);