Browse Source

AutoBuildMarlin re-use VSCode terminal

Scott Lahteine 5 years ago
parent
commit
97493dc62a
1 changed files with 69 additions and 18 deletions
  1. 69
    18
      buildroot/share/atom/auto_build.py

+ 69
- 18
buildroot/share/atom/auto_build.py View File

654
       global warning_continue
654
       global warning_continue
655
       global line_counter
655
       global line_counter
656
 
656
 
657
-
658
-
659
-
660
       # all '0' elements must precede all '1' elements or they'll be skipped
657
       # all '0' elements must precede all '1' elements or they'll be skipped
661
       platformio_highlights = [
658
       platformio_highlights = [
662
               ['Environment', 0, 'highlight_blue'],
659
               ['Environment', 0, 'highlight_blue'],
715
       # end - write_to_screen_with_replace
712
       # end - write_to_screen_with_replace
716
 
713
 
717
 
714
 
718
-
719
     # scan the line
715
     # scan the line
720
       line_counter = line_counter + 1
716
       line_counter = line_counter + 1
721
       max_search = len(line_input)
717
       max_search = len(line_input)
810
 # end - line_print
806
 # end - line_print
811
 
807
 
812
 
808
 
809
+##########################################################################
810
+#                                                                        #
811
+# run Platformio                                                         #
812
+#                                                                        #
813
+##########################################################################
813
 
814
 
814
-def run_PIO(dummy):
815
+
816
+#  build      platformio run -e  target_env
817
+#  clean      platformio run --target clean -e  target_env
818
+#  upload     platformio run --target upload -e  target_env
819
+#  traceback  platformio run --target upload -e  target_env
820
+#  program    platformio run --target program -e  target_env
821
+#  test       platformio test upload -e  target_env
822
+#  remote     platformio remote run --target upload -e  target_env
823
+#  debug      platformio debug -e  target_env
824
+
825
+
826
+def sys_PIO():
815
 
827
 
816
     ##########################################################################
828
     ##########################################################################
817
     #                                                                        #
829
     #                                                                        #
818
-    # run Platformio                                                         #
830
+    # run Platformio inside the same shell as this Python script             #
819
     #                                                                        #
831
     #                                                                        #
820
     ##########################################################################
832
     ##########################################################################
821
 
833
 
834
+    global build_type
835
+    global target_env
836
+
837
+    import os
838
+
839
+    print('build_type: ', build_type)
840
+    print('starting platformio')
841
+
842
+    if   build_type == 'build':
843
+          # pio_result = os.system("echo -en '\033c'")
844
+          pio_result = os.system('platformio run -e ' + target_env)
845
+    elif build_type == 'clean':
846
+          pio_result = os.system('platformio run --target clean -e ' + target_env)
847
+    elif build_type == 'upload':
848
+          pio_result = os.system('platformio run --target upload -e ' + target_env)
849
+    elif build_type == 'traceback':
850
+          pio_result = os.system('platformio run --target upload -e ' + target_env)
851
+    elif build_type == 'program':
852
+          pio_result = os.system('platformio run --target program -e ' + target_env)
853
+    elif build_type == 'test':
854
+          pio_result = os.system('platformio test upload -e ' + target_env)
855
+    elif build_type == 'remote':
856
+          pio_result = os.system('platformio remote run --target program -e ' + target_env)
857
+    elif build_type == 'debug':
858
+          pio_result = os.system('platformio debug -e ' + target_env)
859
+    else:
860
+          print('ERROR - unknown build type:  ', build_type)
861
+          raise SystemExit(0)     # kill everything
862
+
863
+    # stream output from subprocess and split it into lines
864
+      #for line in iter(pio_subprocess.stdout.readline, ''):
865
+      #      line_print(line.replace('\n', ''))
822
 
866
 
823
-    #  build      platformio run -e  target_env
824
-    #  clean      platformio run --target clean -e  target_env
825
-    #  upload     platformio run --target upload -e  target_env
826
-    #  traceback  platformio run --target upload -e  target_env
827
-    #  program    platformio run --target program -e  target_env
828
-    #  test       platformio test upload -e  target_env
829
-    #  remote     platformio remote run --target upload -e  target_env
830
-    #  debug      platformio debug -e  target_env
831
 
867
 
868
+    # append info used to run PlatformIO
869
+    #  write_to_screen_queue('\nBoard name: ' + board_name  + '\n')  # put build info at the bottom of the screen
870
+    #  write_to_screen_queue('Build type: ' + build_type  + '\n')
871
+    #  write_to_screen_queue('Environment used: ' + target_env  + '\n')
872
+    #  write_to_screen_queue(str(datetime.now()) + '\n')
873
+
874
+# end - sys_PIO
875
+
876
+
877
+
878
+def run_PIO(dummy):
832
 
879
 
833
     global build_type
880
     global build_type
834
     global target_env
881
     global target_env
906
 # end - run_PIO
953
 # end - run_PIO
907
 
954
 
908
 
955
 
956
+
909
 ########################################################################
957
 ########################################################################
910
 
958
 
911
 import time
959
 import time
926
 import tkFileDialog
974
 import tkFileDialog
927
 
975
 
928
 
976
 
929
-
930
 class output_window(Text):
977
 class output_window(Text):
931
  # based on Super Text
978
  # based on Super Text
932
     global continue_updates
979
     global continue_updates
1238
         os.environ["TARGET_ENV"] = target_env
1285
         os.environ["TARGET_ENV"] = target_env
1239
         os.environ["BOARD_NAME"] = board_name
1286
         os.environ["BOARD_NAME"] = board_name
1240
 
1287
 
1241
-        auto_build = output_window()
1242
-        auto_build.start_thread()  # executes the "run_PIO" function
1288
+        # Re-use the VSCode terminal, if possible
1289
+        if os.environ.get('PLATFORMIO_CALLER', '') == 'vscode':
1290
+            sys_PIO()
1291
+        else:
1292
+           auto_build = output_window()
1293
+           auto_build.start_thread()  # executes the "run_PIO" function
1243
 
1294
 
1244
-        auto_build.root.mainloop()
1295
+           auto_build.root.mainloop()
1245
 
1296
 
1246
 
1297
 
1247
 
1298
 

Loading…
Cancel
Save