From 22e0691a7024c606dbab8460225a6accf50be80b Mon Sep 17 00:00:00 2001
From: Bob Kuhn <bob.kuhn@att.net>
Date: Tue, 22 May 2018 02:04:51 -0500
Subject: [PATCH] [2.0.x] Add Sublime support for Auto build, minor Auto-build
 update (#10809)

---
 buildroot/share/atom/auto_build.py            |  7 ++
 .../auto_build_sublime_menu/000_read_me.txt   | 40 +++++++++++
 .../auto_build_sublime_menu/Main.sublime-menu | 66 +++++++++++++++++++
 3 files changed, 113 insertions(+)
 create mode 100644 buildroot/share/sublime/auto_build_sublime_menu/000_read_me.txt
 create mode 100644 buildroot/share/sublime/auto_build_sublime_menu/Main.sublime-menu

diff --git a/buildroot/share/atom/auto_build.py b/buildroot/share/atom/auto_build.py
index 498140b471..4dce045305 100644
--- a/buildroot/share/atom/auto_build.py
+++ b/buildroot/share/atom/auto_build.py
@@ -69,6 +69,13 @@
 import sys
 import os
 
+pwd = os.getcwd()    # make sure we're executing from the correct directory level
+pwd = pwd.replace('\\', '/')
+if 0 <= pwd.find('buildroot/share/atom'):
+  pwd = pwd[ : pwd.find('buildroot/share/atom')]
+  os.chdir(pwd)
+print 'pwd: ', pwd
+
 num_args = len(sys.argv)
 if num_args > 1:
   build_type = str(sys.argv[1])
diff --git a/buildroot/share/sublime/auto_build_sublime_menu/000_read_me.txt b/buildroot/share/sublime/auto_build_sublime_menu/000_read_me.txt
new file mode 100644
index 0000000000..5853977911
--- /dev/null
+++ b/buildroot/share/sublime/auto_build_sublime_menu/000_read_me.txt
@@ -0,0 +1,40 @@
+Overview:
+1) Install Sublime
+2) Install Deviot  (?optional?)
+3) Install WebDevShell (this will execute the auto-build script)
+4) Copy the menu configuration to the proper Sublime directory
+5) Add platformio to your path (usually not needed)
+
+
+Sublime with autobuild
+  Tools
+    Install Package Control
+  Tools
+    Command Palette
+      Package Control: Install Package
+          type in deviot and click on it
+  Tools
+    Command Palette
+      Package Control: Install Package
+          type in WebDevShell and click on it
+
+  in Sublime, open Marlin directory with "platformio.ini" in it
+
+  starting in the top level directory, go to the folder "Buildroot/shared/Sublime"
+    copy the folder "auto_build_sublime_menu" and contents to:
+      Windows
+       \Users\your_user_name\AppData\Roaming\Sublime Text 3\Packages
+      Linux
+        /home/your_user_name/.config/sublime-text-3/Packages/User
+      macOS (Click on the Finder's 'Go' menu and hold down Option to open...)
+        ~/Library/Application Support/Sublime Text 3/Packages/User
+
+The menu should now be visible
+
+If you get an error message that says "file not found" and  "subprocess.Popen(['platformio' ... "
+then you'll need to add platformio to your path.
+  macOS
+      sudo nano /etc/paths
+        add these to the bottom
+            /Users/bob/.platformio
+            /Users/bob/.platformio/penv/bin
diff --git a/buildroot/share/sublime/auto_build_sublime_menu/Main.sublime-menu b/buildroot/share/sublime/auto_build_sublime_menu/Main.sublime-menu
new file mode 100644
index 0000000000..b1c34930b4
--- /dev/null
+++ b/buildroot/share/sublime/auto_build_sublime_menu/Main.sublime-menu
@@ -0,0 +1,66 @@
+[
+
+    {
+        "caption": "Auto Build",
+        "children": [
+            {
+                "caption": "PIO Build",
+                "command": "webdevshell",
+                "args": {
+                    "command": "python buildroot/share/atom/auto_build.py build"
+                }
+            },
+            {
+                "caption": "PIO Clean",
+                "command": "webdevshell",
+                "args": {
+                    "command": "python buildroot/share/atom/auto_build.py clean"
+                }
+            },
+            {
+                "caption": "PIO Upload",
+                "command": "webdevshell",
+                "args": {
+                    "command": "python buildroot/share/atom/auto_build.py  upload"
+                }
+            },
+            {
+                "caption": "PIO Upload (traceback)",
+                "command": "webdevshell",
+                "args": {
+                    "command": "python buildroot/share/atom/auto_build.py  traceback"
+                }
+            },
+            {
+                "caption": "PIO Upload using Programmer",
+                "command": "webdevshell",
+                "args": {
+                    "command": "python buildroot/share/atom/auto_build.py  program"
+                }
+            },
+            {
+                "caption": "PIO Test",
+                "command": "webdevshell",
+                "args": {
+                    "command": "python buildroot/share/atom/auto_build.py  test"
+                }
+            },
+            {
+                "caption": "PIO Debug",
+                "command": "webdevshell",
+                "args": {
+                    "command": "python buildroot/share/atom/auto_build.py  debug"
+                }
+            },
+            {
+                "caption": "PIO Remote",
+                "command": "webdevshell",
+                "args": {
+                    "command": "python buildroot/share/atom/auto_build.py  remote"
+                }
+            }
+        ],
+        "id": "AutoBuild",
+        "mnemonic": "A"
+    }
+]
\ No newline at end of file
-- 
GitLab