From 2a6ca13148d02d4221fe5a9b8845856fb45604ea Mon Sep 17 00:00:00 2001
From: me-no-dev <hristo@espressif.com>
Date: Tue, 27 Aug 2019 23:06:49 +0300
Subject: [PATCH 1/8] Rework the sketch builder to match the IDE

---
 tools/build.py            | 78 ++++++++++++++++++++++-----------------
 tools/test-arduino-ide.sh | 11 ++++--
 2 files changed, 52 insertions(+), 37 deletions(-)

diff --git a/tools/build.py b/tools/build.py
index 28bb453ae62..694e33cd4b7 100755
--- a/tools/build.py
+++ b/tools/build.py
@@ -29,28 +29,30 @@
 import tempfile
 import shutil
 
-def compile(tmp_dir, sketch, tools_dir, hardware_dir, ide_path, f, args):
+def compile(tmp_dir, cache_dir, sketch, ide_path, f, args):
     cmd = ide_path + '/arduino-builder '
     cmd += '-compile -logger=human '
-    cmd += '-build-path "' + tmp_dir + '" '
+    cmd += '-hardware "' + ide_path + '/hardware" '
+    if args.usr_path:
+        cmd += '-hardware "' + args.usr_path + '/hardware" '
+    if args.hardware_path:
+        for hw_dir in args.hardware_path:
+            cmd += '-hardware "' + hw_dir + '" '
     cmd += '-tools "' +  ide_path + '/tools-builder" '
+    if args.tools_path:
+        for tools_dir in args.tools_path:
+            cmd += '-tools "' + tools_dir + '" '
+    cmd += '-built-in-libraries "' +  ide_path + '/libraries" '
+    if args.usr_path:
+        cmd += '-libraries "' + args.usr_path + '/libraries" '
     if args.library_path:
         for lib_dir in args.library_path:
             cmd += '-libraries "' + lib_dir + '" '
-    cmd += '-hardware "' + ide_path + '/hardware" '
-    if args.hardware_dir:
-        for hw_dir in args.hardware_dir:
-            cmd += '-hardware "' + hw_dir + '" '
-    else:
-        cmd += '-hardware "' + hardware_dir + '" '
-    # Debug=Serial,DebugLevel=Core____
-    cmd += '-fqbn=espressif:esp32:{board_name}:' \
-            'FlashFreq={flash_freq},' \
-            'PartitionScheme=huge_app,' \
-            'UploadSpeed=921600'.format(**vars(args))
-    cmd += ' '
-    cmd += '-ide-version=10607 '
+    cmd += '-fqbn={fqbn} '.format(**vars(args))
+    cmd += '-ide-version=10810 '
+    cmd += '-build-path "' + tmp_dir + '" '
     cmd += '-warnings={warnings} '.format(**vars(args))
+    cmd += '-build-cache "' + cache_dir + '" '
     if args.verbose:
         cmd += '-verbose '
     cmd += sketch
@@ -65,22 +67,18 @@ def compile(tmp_dir, sketch, tools_dir, hardware_dir, ide_path, f, args):
 
 def parse_args():
     parser = argparse.ArgumentParser(description='Sketch build helper')
-    parser.add_argument('-v', '--verbose', help='Enable verbose output',
-                        action='store_true')
+    parser.add_argument('-v', '--verbose', help='Enable verbose output', action='store_true')
     parser.add_argument('-i', '--ide_path', help='Arduino IDE path')
-    parser.add_argument('-p', '--build_path', help='Build directory')
-    parser.add_argument('-l', '--library_path', help='Additional library path',
-                        action='append')
-    parser.add_argument('-d', '--hardware_dir', help='Additional hardware path',
-                        action='append')
-    parser.add_argument('-b', '--board_name', help='Board name', default='esp32')
-    parser.add_argument('-w', '--warnings', help='Compilation warnings level',
-                        default='none', choices=['none', 'all', 'more'])
+    parser.add_argument('-b', '--build_path', help='Build directory')
+    parser.add_argument('-c', '--build_cache', help='Core Cache directory')
+    parser.add_argument('-u', '--usr_path', help='Arduino Home directory (holds your sketches, libraries and hardware)')
+    parser.add_argument('-f', '--fqbn', help='Arduino Board FQBN')
+    parser.add_argument('-l', '--library_path', help='Additional library path', action='append')
+    parser.add_argument('-h', '--hardware_path', help='Additional hardware path', action='append')
+    parser.add_argument('-t', '--tools_path', help='Additional tools path', action='append')
+    parser.add_argument('-w', '--warnings', help='Compilation warnings level', default='none', choices=['none', 'all', 'more', 'default'])
     parser.add_argument('-o', '--output_binary', help='File name for output binary')
-    parser.add_argument('-k', '--keep', action='store_true',
-                        help='Don\'t delete temporary build directory')
-    parser.add_argument('--flash_freq', help='Flash frequency', default=40,
-                        type=int, choices=[40, 80])
+    parser.add_argument('-k', '--keep', action='store_true', help='Don\'t delete temporary build directory')
     parser.add_argument('sketch_path', help='Sketch file path')
     return parser.parse_args()
 
@@ -95,21 +93,30 @@ def main():
                   "or ARDUINO_IDE_PATH environment variable.", file=sys.stderr)
             return 2
 
+    if not args.fqbn:
+        print("Please specify Arduino Board FQBN using the --fqbn option", file=sys.stderr)
+        return 3
+
     sketch_path = args.sketch_path
+    
     tmp_dir = args.build_path
     created_tmp_dir = False
     if not tmp_dir:
         tmp_dir = tempfile.mkdtemp()
         created_tmp_dir = True
 
-    tools_dir = os.path.dirname(os.path.realpath(__file__)) + '/../tools'
-    # this is not the correct hardware folder to add.
-    hardware_dir = os.path.dirname(os.path.realpath(__file__)) + '/../cores'
-
+    cache_dir = args.build_cache
+    created_cache_dir = False
+    if not cache_dir:
+        cache_dir = tempfile.mkdtemp()
+        created_cache_dir = True
+    
     output_name = tmp_dir + '/' + os.path.basename(sketch_path) + '.bin'
+    
     if args.verbose:
         print("Sketch: ", sketch_path)
         print("Build dir: ", tmp_dir)
+        print("Cache dir: ", cache_dir)
         print("Output: ", output_name)
 
     if args.verbose:
@@ -117,7 +124,7 @@ def main():
     else:
         f = open(tmp_dir + '/build.log', 'w')
 
-    res = compile(tmp_dir, sketch_path, tools_dir, hardware_dir, ide_path, f, args)
+    res = compile(tmp_dir, cache_dir, sketch_path, ide_path, f, args)
     if res != 0:
         return res
 
@@ -127,5 +134,8 @@ def main():
     if created_tmp_dir and not args.keep:
         shutil.rmtree(tmp_dir, ignore_errors=True)
 
+    if created_cache_dir and not args.keep:
+        shutil.rmtree(cache_dir, ignore_errors=True)
+
 if __name__ == '__main__':
     sys.exit(main())
diff --git a/tools/test-arduino-ide.sh b/tools/test-arduino-ide.sh
index 0b9e66abbfc..af249d59562 100755
--- a/tools/test-arduino-ide.sh
+++ b/tools/test-arduino-ide.sh
@@ -16,11 +16,15 @@ if [ "$CHUNK_INDEX" -ge "$CHUNKS_CNT" ]; then
 	exit 1
 fi
 
+export ARDUINO_BOARD_FQBN="espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none"
+
 export ARDUINO_IDE_PATH=$HOME/arduino_ide
-export ARDUINO_LIB_PATH=$HOME/Arduino/libraries
+export ARDUINO_USR_PATH=$HOME/Arduino
+
 export EXAMPLES_PATH=$TRAVIS_BUILD_DIR/libraries
-export EXAMPLES_BUILD_DIR=$TRAVIS_BUILD_DIR/build.tmp
-export EXAMPLES_BUILD_CMD="python tools/build.py -b esp32 -v -k -p $EXAMPLES_BUILD_DIR -l $ARDUINO_LIB_PATH "
+export EXAMPLES_BUILD_DIR=$HOME/build.tmp
+export EXAMPLES_CACHE_DIR=$HOME/cache.tmp
+export EXAMPLES_BUILD_CMD="python $TRAVIS_BUILD_DIR/tools/build.py -v -k -b $EXAMPLES_BUILD_DIR -c $EXAMPLES_CACHE_DIR -u $ARDUINO_USR_PATH -f $ARDUINO_BOARD_FQBN "
 export EXAMPLES_SIZE_BIN=$TRAVIS_BUILD_DIR/tools/xtensa-esp32-elf/bin/xtensa-esp32-elf-size
 
 function print_size_info()
@@ -93,6 +97,7 @@ function count_sketches()
 function build_sketches()
 {
     mkdir -p $EXAMPLES_BUILD_DIR
+    mkdir -p $EXAMPLES_CACHE_DIR
     local chunk_idex=$1
     local chunks_num=$2
     count_sketches

From 9b70e259ca36b946b80e9d034e1d9305e78b5667 Mon Sep 17 00:00:00 2001
From: me-no-dev <hristo@espressif.com>
Date: Tue, 27 Aug 2019 23:12:16 +0300
Subject: [PATCH 2/8] Fix argument overlap

---
 tools/build.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/build.py b/tools/build.py
index 694e33cd4b7..d524943e64f 100755
--- a/tools/build.py
+++ b/tools/build.py
@@ -74,7 +74,7 @@ def parse_args():
     parser.add_argument('-u', '--usr_path', help='Arduino Home directory (holds your sketches, libraries and hardware)')
     parser.add_argument('-f', '--fqbn', help='Arduino Board FQBN')
     parser.add_argument('-l', '--library_path', help='Additional library path', action='append')
-    parser.add_argument('-h', '--hardware_path', help='Additional hardware path', action='append')
+    parser.add_argument('-d', '--hardware_path', help='Additional hardware path', action='append')
     parser.add_argument('-t', '--tools_path', help='Additional tools path', action='append')
     parser.add_argument('-w', '--warnings', help='Compilation warnings level', default='none', choices=['none', 'all', 'more', 'default'])
     parser.add_argument('-o', '--output_binary', help='File name for output binary')

From 32852094542ebcc52af59a5759ab24c465a56bfe Mon Sep 17 00:00:00 2001
From: me-no-dev <hristo@espressif.com>
Date: Tue, 27 Aug 2019 23:21:07 +0300
Subject: [PATCH 3/8] Fix missing paths

---
 tools/test-arduino-ide.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/test-arduino-ide.sh b/tools/test-arduino-ide.sh
index af249d59562..3ad07166937 100755
--- a/tools/test-arduino-ide.sh
+++ b/tools/test-arduino-ide.sh
@@ -98,6 +98,9 @@ function build_sketches()
 {
     mkdir -p $EXAMPLES_BUILD_DIR
     mkdir -p $EXAMPLES_CACHE_DIR
+    mkdir -p $ARDUINO_USR_PATH/libraries
+    mkdir -p $ARDUINO_USR_PATH/hardware
+    
     local chunk_idex=$1
     local chunks_num=$2
     count_sketches

From 6b3071cc5b099bc7f0709a862cd55706953423b8 Mon Sep 17 00:00:00 2001
From: me-no-dev <hristo@espressif.com>
Date: Tue, 27 Aug 2019 23:47:44 +0300
Subject: [PATCH 4/8] Link the board to the home folder

---
 tools/prep-arduino-ide.sh | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tools/prep-arduino-ide.sh b/tools/prep-arduino-ide.sh
index 7dfd1911a22..90c8d397386 100755
--- a/tools/prep-arduino-ide.sh
+++ b/tools/prep-arduino-ide.sh
@@ -5,10 +5,9 @@ wget -O arduino.tar.xz https://www.arduino.cc/download.php?f=/arduino-nightly-li
 tar xf arduino.tar.xz
 mv arduino-nightly $HOME/arduino_ide
 mkdir -p $HOME/Arduino/libraries
+mkdir -p $HOME/Arduino/hardware/espressif
+cd $HOME/Arduino/hardware/espressif
 
-cd $HOME/arduino_ide/hardware
-mkdir espressif
-cd espressif
 ln -s $TRAVIS_BUILD_DIR esp32
 cd esp32/tools
 python get.py

From ed76bc3b572d5f6bf1134ca0ca28a1e740376d0a Mon Sep 17 00:00:00 2001
From: me-no-dev <hristo@espressif.com>
Date: Wed, 28 Aug 2019 01:00:02 +0300
Subject: [PATCH 5/8] Rename files for clarity

---
 .travis.yml                                   | 20 +------------------
 tools/{build.py => build-sketch.py}           |  0
 tools/build-tests.sh                          |  2 +-
 tools/build.sh                                |  9 ---------
 ...heck_cmakelists.sh => check-cmakelists.sh} |  0
 tools/{deploy.sh => deploy-release.sh}        |  0
 tools/test-arduino-ide.sh                     |  2 +-
 7 files changed, 3 insertions(+), 30 deletions(-)
 rename tools/{build.py => build-sketch.py} (100%)
 delete mode 100755 tools/build.sh
 rename tools/{check_cmakelists.sh => check-cmakelists.sh} (100%)
 rename tools/{deploy.sh => deploy-release.sh} (100%)

diff --git a/.travis.yml b/.travis.yml
index 871e2a74d29..400a6ec07a8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,7 +10,6 @@ os:
 git:
   depth: false
 
-# new script start
 before_install:
   - git submodule update --init --recursive
 
@@ -57,27 +56,10 @@ jobs:
       deploy:
       - provider: script
         skip_cleanup: true
-        script: bash $TRAVIS_BUILD_DIR/tools/deploy.sh -t$TRAVIS_TAG -a$ESP32_GITHUB_TOKEN -s$TRAVIS_REPO_SLUG -drelease
+        script: bash $TRAVIS_BUILD_DIR/tools/deploy-release.sh -t$TRAVIS_TAG -a$ESP32_GITHUB_TOKEN -s$TRAVIS_REPO_SLUG -drelease
         on:
           tags: true
 
-# old script start
-# env:
-#     global:
-#         - secure: "l/4Dt+KQ/mACtGAHDUsPr66fUte840PZoQ4xpPikqWZI0uARu4l+Ym7+sHinnT6fBqrj8AJeBYGz4nFa8NK4LutZn9mSD40w+sxl0wSV4oHV8rzKe3Cd8+sMG3+o33yWoikMNjSvqa73Q0rm+SgrlInNdZbuAyixL+a2alaWSnGPm4F2xwUGj+S33TOy5P/Xp77CYtCV5S8vzyk/eEdNhoF0GYePJVdfuzCOUjXMyT5OWxORkzzQ7Hnn/Ka/RDfV8Si4HgujLQBrK5q6iPnNBFqBSqilYBepSMn4opnOBpIm0SCgePz7XQEFC83buA7GUcnCnfg38bf+dCwHaODf1d1PmqVRYt2QmfinexXtM4afAtL0iBUDtvrfnXHzwW9w82VeZhpbJSVh9DUQvB0IlsZeCz9J9PUBAi3N+SMX+9l+BomYwRUlPuKY+Ef2JKk9q6mxtUkky5R0daAlVxEhpVdQks1rT+T+NMoDMemxQ3SKEiqAHh6EgHecruszffmZ71uLX9MpERpew0qN+UFiafws+jkTjx+3yF9yut0Hf9sMbeAYzzkGzRqJTUEBJ6B29Cql8M0yRXCNN/8wuuTHhG8esstozga4ZQoIVrq7mEAgup376PTcNfr1+imbbWVQ7lJdYIuDe6OS5V3OX6np11vgK/DbhfyzvQv9Z1zAGnM="
-#         - REMOTE_URL=https://github.com/$TRAVIS_REPO_SLUG/releases/download/$TRAVIS_TAG
-    
-# script:
-#   - bash $TRAVIS_BUILD_DIR/tools/build.sh
-
-# deploy:
-#   provider: script
-#   skip_cleanup: true
-#   script: bash $TRAVIS_BUILD_DIR/tools/deploy.sh -t$TRAVIS_TAG -a$ESP32_GITHUB_TOKEN -s$TRAVIS_REPO_SLUG -drelease
-
-#   on:
-#     tags: true
-
 notifications:
   email:
     on_success: change
diff --git a/tools/build.py b/tools/build-sketch.py
similarity index 100%
rename from tools/build.py
rename to tools/build-sketch.py
diff --git a/tools/build-tests.sh b/tools/build-tests.sh
index 53c186a9523..a1a31c6bfaf 100755
--- a/tools/build-tests.sh
+++ b/tools/build-tests.sh
@@ -29,7 +29,7 @@ fi
 # CMake Test
 if [ "$CHUNK_INDEX" -eq 0 ]; then
 	echo -e "travis_fold:start:check_cmakelists"
-	tools/check_cmakelists.sh
+	tools/check-cmakelists.sh
 	if [ $? -ne 0 ]; then exit 1; fi
 	echo -e "travis_fold:end:check_cmakelists"
 fi
diff --git a/tools/build.sh b/tools/build.sh
deleted file mode 100755
index 3b3ab40c242..00000000000
--- a/tools/build.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/bash
-
-if [ ! -z "$TRAVIS_TAG" ]; then
-    # zip the package if tagged build
-    tools/build-release.sh -a$ESP32_GITHUB_TOKEN
-#else
-    # run cmake and sketch tests
-    #tools/build-tests.sh
-fi
diff --git a/tools/check_cmakelists.sh b/tools/check-cmakelists.sh
similarity index 100%
rename from tools/check_cmakelists.sh
rename to tools/check-cmakelists.sh
diff --git a/tools/deploy.sh b/tools/deploy-release.sh
similarity index 100%
rename from tools/deploy.sh
rename to tools/deploy-release.sh
diff --git a/tools/test-arduino-ide.sh b/tools/test-arduino-ide.sh
index 3ad07166937..e8d473efb0f 100755
--- a/tools/test-arduino-ide.sh
+++ b/tools/test-arduino-ide.sh
@@ -24,7 +24,7 @@ export ARDUINO_USR_PATH=$HOME/Arduino
 export EXAMPLES_PATH=$TRAVIS_BUILD_DIR/libraries
 export EXAMPLES_BUILD_DIR=$HOME/build.tmp
 export EXAMPLES_CACHE_DIR=$HOME/cache.tmp
-export EXAMPLES_BUILD_CMD="python $TRAVIS_BUILD_DIR/tools/build.py -v -k -b $EXAMPLES_BUILD_DIR -c $EXAMPLES_CACHE_DIR -u $ARDUINO_USR_PATH -f $ARDUINO_BOARD_FQBN "
+export EXAMPLES_BUILD_CMD="python $TRAVIS_BUILD_DIR/tools/build-sketch.py -v -k -b $EXAMPLES_BUILD_DIR -c $EXAMPLES_CACHE_DIR -u $ARDUINO_USR_PATH -f $ARDUINO_BOARD_FQBN "
 export EXAMPLES_SIZE_BIN=$TRAVIS_BUILD_DIR/tools/xtensa-esp32-elf/bin/xtensa-esp32-elf-size
 
 function print_size_info()

From 2461785b3f9fb0f1e39dadee4bc5c204a9d26e6e Mon Sep 17 00:00:00 2001
From: me-no-dev <hristo@espressif.com>
Date: Wed, 28 Aug 2019 01:04:14 +0300
Subject: [PATCH 6/8] prep files for moving

---
 .travis.yml               | 14 +++++++-------
 tools/build-tests.sh      | 10 +++++-----
 tools/test-arduino-ide.sh |  2 +-
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 400a6ec07a8..d8e7997a9e7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -23,27 +23,27 @@ jobs:
     - name: "Build Arduino 0"
       if: tag IS blank AND (type = pull_request OR (type = push AND branch = master))
       stage: build
-      script: $TRAVIS_BUILD_DIR/tools/build-tests.sh 0 4
+      script: $TRAVIS_BUILD_DIR/tools/ci/build-tests.sh 0 4
 
     - name: "Build Arduino 1"
       if: tag IS blank AND (type = pull_request OR (type = push AND branch = master))
       stage: build
-      script: $TRAVIS_BUILD_DIR/tools/build-tests.sh 1 4
+      script: $TRAVIS_BUILD_DIR/tools/ci/build-tests.sh 1 4
 
     - name: "Build Arduino 2"
       if: tag IS blank AND (type = pull_request OR (type = push AND branch = master))
       stage: build
-      script: $TRAVIS_BUILD_DIR/tools/build-tests.sh 2 4
+      script: $TRAVIS_BUILD_DIR/tools/ci/build-tests.sh 2 4
 
     - name: "Build Arduino 3"
       if: tag IS blank AND (type = pull_request OR (type = push AND branch = master))
       stage: build
-      script: $TRAVIS_BUILD_DIR/tools/build-tests.sh 3 4
+      script: $TRAVIS_BUILD_DIR/tools/ci/build-tests.sh 3 4
 
     - name: "Build PlatformIO"
       if: tag IS blank AND (type = pull_request OR (type = push AND branch = master))
       stage: build
-      script: $TRAVIS_BUILD_DIR/tools/build-tests.sh 4 4
+      script: $TRAVIS_BUILD_DIR/tools/ci/build-tests.sh 4 4
 
     - name: "Package & Deploy"
       if: tag IS present
@@ -51,12 +51,12 @@ jobs:
       env:
         - secure: "l/4Dt+KQ/mACtGAHDUsPr66fUte840PZoQ4xpPikqWZI0uARu4l+Ym7+sHinnT6fBqrj8AJeBYGz4nFa8NK4LutZn9mSD40w+sxl0wSV4oHV8rzKe3Cd8+sMG3+o33yWoikMNjSvqa73Q0rm+SgrlInNdZbuAyixL+a2alaWSnGPm4F2xwUGj+S33TOy5P/Xp77CYtCV5S8vzyk/eEdNhoF0GYePJVdfuzCOUjXMyT5OWxORkzzQ7Hnn/Ka/RDfV8Si4HgujLQBrK5q6iPnNBFqBSqilYBepSMn4opnOBpIm0SCgePz7XQEFC83buA7GUcnCnfg38bf+dCwHaODf1d1PmqVRYt2QmfinexXtM4afAtL0iBUDtvrfnXHzwW9w82VeZhpbJSVh9DUQvB0IlsZeCz9J9PUBAi3N+SMX+9l+BomYwRUlPuKY+Ef2JKk9q6mxtUkky5R0daAlVxEhpVdQks1rT+T+NMoDMemxQ3SKEiqAHh6EgHecruszffmZ71uLX9MpERpew0qN+UFiafws+jkTjx+3yF9yut0Hf9sMbeAYzzkGzRqJTUEBJ6B29Cql8M0yRXCNN/8wuuTHhG8esstozga4ZQoIVrq7mEAgup376PTcNfr1+imbbWVQ7lJdYIuDe6OS5V3OX6np11vgK/DbhfyzvQv9Z1zAGnM="
         - REMOTE_URL=https://github.com/$TRAVIS_REPO_SLUG/releases/download/$TRAVIS_TAG
-      script: bash $TRAVIS_BUILD_DIR/tools/build-release.sh -a$ESP32_GITHUB_TOKEN
+      script: bash $TRAVIS_BUILD_DIR/tools/ci/build-release.sh -a$ESP32_GITHUB_TOKEN
       before_deploy: git submodule update --init
       deploy:
       - provider: script
         skip_cleanup: true
-        script: bash $TRAVIS_BUILD_DIR/tools/deploy-release.sh -t$TRAVIS_TAG -a$ESP32_GITHUB_TOKEN -s$TRAVIS_REPO_SLUG -drelease
+        script: bash $TRAVIS_BUILD_DIR/tools/ci/deploy-release.sh -t$TRAVIS_TAG -a$ESP32_GITHUB_TOKEN -s$TRAVIS_REPO_SLUG -drelease
         on:
           tags: true
 
diff --git a/tools/build-tests.sh b/tools/build-tests.sh
index a1a31c6bfaf..6ec5e2feac8 100755
--- a/tools/build-tests.sh
+++ b/tools/build-tests.sh
@@ -29,7 +29,7 @@ fi
 # CMake Test
 if [ "$CHUNK_INDEX" -eq 0 ]; then
 	echo -e "travis_fold:start:check_cmakelists"
-	tools/check-cmakelists.sh
+	tools/ci/check-cmakelists.sh
 	if [ $? -ne 0 ]; then exit 1; fi
 	echo -e "travis_fold:end:check_cmakelists"
 fi
@@ -37,12 +37,12 @@ fi
 if [ "$BUILD_PIO" -eq 0 ]; then
 	# ArduinoIDE Test
 	echo -e "travis_fold:start:prep_arduino_ide"
-	tools/prep-arduino-ide.sh
+	tools/ci/prep-arduino-ide.sh
 	if [ $? -ne 0 ]; then exit 1; fi
 	echo -e "travis_fold:end:prep_arduino_ide"
 
 	echo -e "travis_fold:start:test_arduino_ide"
-	tools/test-arduino-ide.sh $CHUNK_INDEX $CHUNKS_CNT
+	tools/ci/test-arduino-ide.sh $CHUNK_INDEX $CHUNKS_CNT
 	if [ $? -ne 0 ]; then exit 1; fi
 	echo -e "travis_fold:end:test_arduino_ide"
 
@@ -53,12 +53,12 @@ else
 	# PlatformIO Test
 	echo -e "travis_fold:start:prep_platformio"
 	cd tools && python get.py && cd ..
-	tools/prep-platformio.sh
+	tools/ci/prep-platformio.sh
 	if [ $? -ne 0 ]; then exit 1; fi
 	echo -e "travis_fold:end:prep_platformio"
 
 	echo -e "travis_fold:start:test_platformio"
-	tools/test-platformio.sh
+	tools/ci/test-platformio.sh
 	if [ $? -ne 0 ]; then exit 1; fi
 	echo -e "travis_fold:end:test_platformio"
 fi
\ No newline at end of file
diff --git a/tools/test-arduino-ide.sh b/tools/test-arduino-ide.sh
index e8d473efb0f..a689660f967 100755
--- a/tools/test-arduino-ide.sh
+++ b/tools/test-arduino-ide.sh
@@ -24,7 +24,7 @@ export ARDUINO_USR_PATH=$HOME/Arduino
 export EXAMPLES_PATH=$TRAVIS_BUILD_DIR/libraries
 export EXAMPLES_BUILD_DIR=$HOME/build.tmp
 export EXAMPLES_CACHE_DIR=$HOME/cache.tmp
-export EXAMPLES_BUILD_CMD="python $TRAVIS_BUILD_DIR/tools/build-sketch.py -v -k -b $EXAMPLES_BUILD_DIR -c $EXAMPLES_CACHE_DIR -u $ARDUINO_USR_PATH -f $ARDUINO_BOARD_FQBN "
+export EXAMPLES_BUILD_CMD="python $TRAVIS_BUILD_DIR/tools/ci/build-sketch.py -v -k -b $EXAMPLES_BUILD_DIR -c $EXAMPLES_CACHE_DIR -u $ARDUINO_USR_PATH -f $ARDUINO_BOARD_FQBN "
 export EXAMPLES_SIZE_BIN=$TRAVIS_BUILD_DIR/tools/xtensa-esp32-elf/bin/xtensa-esp32-elf-size
 
 function print_size_info()

From 0da36ca0884934cfb9a9de20d129b5c7c039aff5 Mon Sep 17 00:00:00 2001
From: me-no-dev <hristo@espressif.com>
Date: Wed, 28 Aug 2019 01:05:05 +0300
Subject: [PATCH 7/8] move ci files to own subfolder

---
 tools/{ => ci}/build-release.sh    | 0
 tools/{ => ci}/build-sketch.py     | 0
 tools/{ => ci}/build-tests.sh      | 0
 tools/{ => ci}/check-cmakelists.sh | 0
 tools/{ => ci}/deploy-release.sh   | 0
 tools/{ => ci}/prep-arduino-ide.sh | 0
 tools/{ => ci}/prep-platformio.sh  | 0
 tools/{ => ci}/test-arduino-ide.sh | 0
 tools/{ => ci}/test-platformio.sh  | 0
 9 files changed, 0 insertions(+), 0 deletions(-)
 rename tools/{ => ci}/build-release.sh (100%)
 rename tools/{ => ci}/build-sketch.py (100%)
 rename tools/{ => ci}/build-tests.sh (100%)
 rename tools/{ => ci}/check-cmakelists.sh (100%)
 rename tools/{ => ci}/deploy-release.sh (100%)
 rename tools/{ => ci}/prep-arduino-ide.sh (100%)
 rename tools/{ => ci}/prep-platformio.sh (100%)
 rename tools/{ => ci}/test-arduino-ide.sh (100%)
 rename tools/{ => ci}/test-platformio.sh (100%)

diff --git a/tools/build-release.sh b/tools/ci/build-release.sh
similarity index 100%
rename from tools/build-release.sh
rename to tools/ci/build-release.sh
diff --git a/tools/build-sketch.py b/tools/ci/build-sketch.py
similarity index 100%
rename from tools/build-sketch.py
rename to tools/ci/build-sketch.py
diff --git a/tools/build-tests.sh b/tools/ci/build-tests.sh
similarity index 100%
rename from tools/build-tests.sh
rename to tools/ci/build-tests.sh
diff --git a/tools/check-cmakelists.sh b/tools/ci/check-cmakelists.sh
similarity index 100%
rename from tools/check-cmakelists.sh
rename to tools/ci/check-cmakelists.sh
diff --git a/tools/deploy-release.sh b/tools/ci/deploy-release.sh
similarity index 100%
rename from tools/deploy-release.sh
rename to tools/ci/deploy-release.sh
diff --git a/tools/prep-arduino-ide.sh b/tools/ci/prep-arduino-ide.sh
similarity index 100%
rename from tools/prep-arduino-ide.sh
rename to tools/ci/prep-arduino-ide.sh
diff --git a/tools/prep-platformio.sh b/tools/ci/prep-platformio.sh
similarity index 100%
rename from tools/prep-platformio.sh
rename to tools/ci/prep-platformio.sh
diff --git a/tools/test-arduino-ide.sh b/tools/ci/test-arduino-ide.sh
similarity index 100%
rename from tools/test-arduino-ide.sh
rename to tools/ci/test-arduino-ide.sh
diff --git a/tools/test-platformio.sh b/tools/ci/test-platformio.sh
similarity index 100%
rename from tools/test-platformio.sh
rename to tools/ci/test-platformio.sh

From eae913af38bda16bade96e58e54d31ff7f54fe98 Mon Sep 17 00:00:00 2001
From: Me No Dev <me-no-dev@users.noreply.github.com>
Date: Wed, 28 Aug 2019 01:08:54 +0300
Subject: [PATCH 8/8] Update Github CI to use the new script locations

---
 .github/workflows/main.yml | 78 +++++++++++++++++++-------------------
 1 file changed, 39 insertions(+), 39 deletions(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 146e28042df..baa6a22041c 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -18,17 +18,17 @@ jobs:
     - name: Pull submodules
       run: git submodule update --init --recursive
     - name: Run CMake Check
-      run: ./tools/check_cmakelists.sh
+      run: ./tools/ci/check-cmakelists.sh
 
     - name: Install Arduino IDE
       env:
         #ESP32_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/prep-arduino-ide.sh
+      run: ./tools/ci/prep-arduino-ide.sh
     - name: Test Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/test-arduino-ide.sh 0 18
+      run: ./tools/ci/test-arduino-ide.sh 0 18
     - name: Sketch Sizes
       run: cat size.log
 
@@ -43,11 +43,11 @@ jobs:
     - name: Install Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/prep-arduino-ide.sh
+      run: ./tools/ci/prep-arduino-ide.sh
     - name: Test Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/test-arduino-ide.sh 1 18
+      run: ./tools/ci/test-arduino-ide.sh 1 18
     - name: Sketch Sizes
       run: cat size.log
 
@@ -62,11 +62,11 @@ jobs:
     - name: Install Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/prep-arduino-ide.sh
+      run: ./tools/ci/prep-arduino-ide.sh
     - name: Test Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/test-arduino-ide.sh 2 18
+      run: ./tools/ci/test-arduino-ide.sh 2 18
     - name: Sketch Sizes
       run: cat size.log
 
@@ -81,11 +81,11 @@ jobs:
     - name: Install Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/prep-arduino-ide.sh
+      run: ./tools/ci/prep-arduino-ide.sh
     - name: Test Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/test-arduino-ide.sh 3 18
+      run: ./tools/ci/test-arduino-ide.sh 3 18
     - name: Sketch Sizes
       run: cat size.log
 
@@ -100,11 +100,11 @@ jobs:
     - name: Install Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/prep-arduino-ide.sh
+      run: ./tools/ci/prep-arduino-ide.sh
     - name: Test Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/test-arduino-ide.sh 4 18
+      run: ./tools/ci/test-arduino-ide.sh 4 18
     - name: Sketch Sizes
       run: cat size.log
 
@@ -119,11 +119,11 @@ jobs:
     - name: Install Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/prep-arduino-ide.sh
+      run: ./tools/ci/prep-arduino-ide.sh
     - name: Test Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/test-arduino-ide.sh 5 18
+      run: ./tools/ci/test-arduino-ide.sh 5 18
     - name: Sketch Sizes
       run: cat size.log
 
@@ -138,11 +138,11 @@ jobs:
     - name: Install Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/prep-arduino-ide.sh
+      run: ./tools/ci/prep-arduino-ide.sh
     - name: Test Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/test-arduino-ide.sh 6 18
+      run: ./tools/ci/test-arduino-ide.sh 6 18
     - name: Sketch Sizes
       run: cat size.log
 
@@ -157,11 +157,11 @@ jobs:
     - name: Install Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/prep-arduino-ide.sh
+      run: ./tools/ci/prep-arduino-ide.sh
     - name: Test Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/test-arduino-ide.sh 7 18
+      run: ./tools/ci/test-arduino-ide.sh 7 18
     - name: Sketch Sizes
       run: cat size.log
 
@@ -176,11 +176,11 @@ jobs:
     - name: Install Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/prep-arduino-ide.sh
+      run: ./tools/ci/prep-arduino-ide.sh
     - name: Test Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/test-arduino-ide.sh 8 18
+      run: ./tools/ci/test-arduino-ide.sh 8 18
     - name: Sketch Sizes
       run: cat size.log
 
@@ -195,11 +195,11 @@ jobs:
     - name: Install Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/prep-arduino-ide.sh
+      run: ./tools/ci/prep-arduino-ide.sh
     - name: Test Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/test-arduino-ide.sh 9 18
+      run: ./tools/ci/test-arduino-ide.sh 9 18
     - name: Sketch Sizes
       run: cat size.log
 
@@ -214,11 +214,11 @@ jobs:
     - name: Install Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/prep-arduino-ide.sh
+      run: ./tools/ci/prep-arduino-ide.sh
     - name: Test Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/test-arduino-ide.sh 10 18
+      run: ./tools/ci/test-arduino-ide.sh 10 18
     - name: Sketch Sizes
       run: cat size.log
 
@@ -233,11 +233,11 @@ jobs:
     - name: Install Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/prep-arduino-ide.sh
+      run: ./tools/ci/prep-arduino-ide.sh
     - name: Test Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/test-arduino-ide.sh 11 18
+      run: ./tools/ci/test-arduino-ide.sh 11 18
     - name: Sketch Sizes
       run: cat size.log
 
@@ -252,11 +252,11 @@ jobs:
     - name: Install Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/prep-arduino-ide.sh
+      run: ./tools/ci/prep-arduino-ide.sh
     - name: Test Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/test-arduino-ide.sh 12 18
+      run: ./tools/ci/test-arduino-ide.sh 12 18
     - name: Sketch Sizes
       run: cat size.log
 
@@ -271,11 +271,11 @@ jobs:
     - name: Install Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/prep-arduino-ide.sh
+      run: ./tools/ci/prep-arduino-ide.sh
     - name: Test Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/test-arduino-ide.sh 13 18
+      run: ./tools/ci/test-arduino-ide.sh 13 18
     - name: Sketch Sizes
       run: cat size.log
 
@@ -290,11 +290,11 @@ jobs:
     - name: Install Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/prep-arduino-ide.sh
+      run: ./tools/ci/prep-arduino-ide.sh
     - name: Test Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/test-arduino-ide.sh 14 18
+      run: ./tools/ci/test-arduino-ide.sh 14 18
     - name: Sketch Sizes
       run: cat size.log
 
@@ -309,11 +309,11 @@ jobs:
     - name: Install Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/prep-arduino-ide.sh
+      run: ./tools/ci/prep-arduino-ide.sh
     - name: Test Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/test-arduino-ide.sh 15 18
+      run: ./tools/ci/test-arduino-ide.sh 15 18
     - name: Sketch Sizes
       run: cat size.log
 
@@ -328,11 +328,11 @@ jobs:
     - name: Install Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/prep-arduino-ide.sh
+      run: ./tools/ci/prep-arduino-ide.sh
     - name: Test Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/test-arduino-ide.sh 16 18
+      run: ./tools/ci/test-arduino-ide.sh 16 18
     - name: Sketch Sizes
       run: cat size.log
 
@@ -347,11 +347,11 @@ jobs:
     - name: Install Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/prep-arduino-ide.sh
+      run: ./tools/ci/prep-arduino-ide.sh
     - name: Test Arduino IDE
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/test-arduino-ide.sh 17 18
+      run: ./tools/ci/test-arduino-ide.sh 17 18
     - name: Sketch Sizes
       run: cat size.log
 
@@ -371,6 +371,6 @@ jobs:
     - name: Install PlatformIO
       env:
         TRAVIS_BUILD_DIR: ${{ github.workspace }}
-      run: ./tools/prep-platformio.sh
+      run: ./tools/ci/prep-platformio.sh
     - name: Test PlatformIO
-      run: ./tools/test-platformio.sh
+      run: ./tools/ci/test-platformio.sh