Просмотр исходного кода

update ci to also build host example

hathach 5 лет назад
Родитель
Сommit
5fb3d439b3

+ 16 - 3
.github/workflows/build.yml

@@ -26,9 +26,22 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        example: ['board_test', 'cdc_dual_ports', 'cdc_msc', 'cdc_msc_freertos', 'dfu_rt', 
-                  'hid_composite', 'hid_composite_freertos', 'hid_generic_inout', 'midi_test', 'msc_dual_lun', 'net_lwip_webserver',
-                  'usbtmc', 'webusb_serial']
+        example:
+        - 'device/board_test'
+        - 'device/cdc_dual_ports'
+        - 'device/cdc_msc'
+        - 'device/cdc_msc_freertos'
+        - 'device/dfu_rt'
+        - 'device/hid_composite'
+        - 'device/hid_composite_freertos'
+        - 'device/hid_generic_inout'
+        - 'device/midi_test'
+        - 'device/msc_dual_lun'
+        - 'device/net_lwip_webserver'
+        - 'device/usbtmc'
+        - 'device/webusb_serial'
+        - 'host/cdc_msc_hid'
+        
     steps:
     - name: Setup Python
       uses: actions/setup-python@v1

+ 0 - 0
examples/host/cdc_msc_hid/.only.MCU_LPC175X_6X


+ 0 - 0
examples/host/cdc_msc_hid/.only.MCU_LPC177X_8X


+ 0 - 0
examples/host/cdc_msc_hid/.only.MCU_LPC18XX


+ 0 - 0
examples/host/cdc_msc_hid/.only.MCU_LPC40XX


+ 0 - 0
examples/host/cdc_msc_hid/.only.MCU_LPC43XX


+ 4 - 1
examples/host/cdc_msc_hid/src/main.c

@@ -185,7 +185,8 @@ void tuh_hid_keyboard_unmounted_cb(uint8_t dev_addr)
 // invoked ISR context
 void tuh_hid_keyboard_isr(uint8_t dev_addr, xfer_result_t event)
 {
-
+  (void) dev_addr;
+  (void) event;
 }
 
 #endif
@@ -206,6 +207,8 @@ void tuh_hid_mouse_unmounted_cb(uint8_t dev_addr)
 // invoked ISR context
 void tuh_hid_mouse_isr(uint8_t dev_addr, xfer_result_t event)
 {
+  (void) dev_addr;
+  (void) event;
 }
 #endif
 

+ 29 - 12
tools/build_all.py

@@ -4,6 +4,10 @@ import sys
 import subprocess
 import time
 
+SUCCEEDED = "\033[32msucceeded\033[0m"
+FAILED = "\033[31mfailed\033[0m"
+SKIPPED = "\033[33mskipped\033[0m"
+
 success_count = 0
 fail_count = 0
 skip_count = 0
@@ -11,15 +15,19 @@ exit_status = 0
 
 total_time = time.monotonic()
 
-build_format = '| {:23} | {:30} | {:9} | {:7} | {:6} | {:6} |'
-build_separator = '-' * 100
+build_format = '| {:29} | {:30} | {:18} | {:7} | {:6} | {:6} |'
+build_separator = '-' * 106
 
 # If examples are not specified in arguments, build all
 all_examples = []
 
 for entry in os.scandir("examples/device"):
     if entry.is_dir():
-        all_examples.append(entry.name)
+        all_examples.append("device/" + entry.name)
+
+for entry in os.scandir("examples/host"):
+    if entry.is_dir():
+        all_examples.append("host/" + entry.name)
 
 if len(sys.argv) > 1:
     input_examples = list(set(all_examples).intersection(sys.argv))
@@ -43,14 +51,14 @@ if len(sys.argv) > 1:
 all_boards.sort()
 
 def build_example(example, board):
-    subprocess.run("make -C examples/device/{} BOARD={} clean".format(example, board), shell=True,
+    subprocess.run("make -C examples/{} BOARD={} clean".format(example, board), shell=True,
                    stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-    return subprocess.run("make -j -C examples/device/{} BOARD={} all".format(example, board), shell=True,
+    return subprocess.run("make -j -C examples/{} BOARD={} all".format(example, board), shell=True,
                           stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
 
 def build_size(example, board):
     #elf_file = 'examples/device/{}/_build/build-{}/{}-firmware.elf'.format(example, board, board)
-    elf_file = 'examples/device/{}/_build/build-{}/*.elf'.format(example, board)
+    elf_file = 'examples/{}/_build/build-{}/*.elf'.format(example, board)
     size_output = subprocess.run('size {}'.format(elf_file), shell=True, stdout=subprocess.PIPE).stdout.decode("utf-8")
     size_list = size_output.split('\n')[1].split('\t')
     flash_size = int(size_list[0])
@@ -58,7 +66,7 @@ def build_size(example, board):
     return (flash_size, sram_size)
 
 def skip_example(example, board):
-    ex_dir = 'examples/device/' + example
+    ex_dir = 'examples/' + example
     board_mk = 'hw/bsp/{}/board.mk'.format(board)
 
     with open(board_mk) as mk:
@@ -74,10 +82,19 @@ def skip_example(example, board):
             if mcu_cflag in mk_contents:
                 return 1
 
+        # Build only list, if exists only these MCU are built
+        only_list = list(glob.iglob(ex_dir + '/.only.MCU_*'))
+        if len(only_list) > 0:
+            for only_file in only_list:
+                mcu_cflag = '-DCFG_TUSB_MCU=OPT_' + os.path.basename(only_file).split('.')[2]
+                if mcu_cflag in mk_contents:
+                    return 0
+            return 1
+
     return 0
 
 print(build_separator)
-print(build_format.format('Example', 'Board', 'Result', 'Time', 'Flash', 'SRAM'))
+print(build_format.format('Example', 'Board', '\033[39mResult\033[0m', 'Time', 'Flash', 'SRAM'))
 
 for example in all_examples:
     print(build_separator)
@@ -89,19 +106,19 @@ for example in all_examples:
 
         # Check if board is skipped
         if skip_example(example, board):
-            success = "\033[33mskipped\033[0m  "
+            success = SKIPPED
             skip_count += 1
             print(build_format.format(example, board, success, '-', flash_size, sram_size))
         else:
             build_result = build_example(example, board)
 
             if build_result.returncode == 0:
-                success = "\033[32msucceeded\033[0m"
+                success = SUCCEEDED
                 success_count += 1
                 (flash_size, sram_size) = build_size(example, board)
             else:
                 exit_status = build_result.returncode
-                success = "\033[31mfailed\033[0m   "
+                success = FAILED
                 fail_count += 1
 
             build_duration = time.monotonic() - start_time
@@ -114,7 +131,7 @@ for example in all_examples:
 
 total_time = time.monotonic() - total_time
 print(build_separator)
-print("Build Sumamary: {} \033[32msucceeded\033[0m, {} \033[31mfailed\033[0m, {} \033[33mskipped\033[0m and took {:.2f}s".format(success_count, fail_count, skip_count, total_time))
+print("Build Summary: {} {}, {} {}, {} {} and took {:.2f}s".format(success_count, SUCCEEDED, fail_count, FAILED, skip_count, SKIPPED, total_time))
 print(build_separator)
 
 sys.exit(exit_status)