@@ -857,7 +857,7 @@ def submodules():
857857
858858 cmds = [
859859 [f'export "IDF_PATH={ os .path .abspath (idf_path )} "' ],
860- ['cd' , idf_path ],
860+ ['cd' , os . path . abspath ( idf_path ) ],
861861 ['./install.sh' , 'all' ]
862862 ]
863863
@@ -870,36 +870,42 @@ def submodules():
870870 if result != 0 :
871871 sys .exit (result )
872872
873- env , cmds = setup_idf_environ ()
873+ if 'GITHUB_RUN_ID' in os .environ :
874+ cmds = [
875+ [f'export "IDF_PATH={ os .path .abspath (idf_path )} "' ],
876+ ['cd' , os .path .abspath (idf_path )],
877+ ['. ./export.sh' ],
878+ [f'cd { SCRIPT_DIR } ' ]
879+ ]
880+ else :
881+ cmds = [
882+ [f'cd { os .path .abspath (idf_path )} ' ],
883+ [f'. ./export.sh' ],
884+ [f'cd { SCRIPT_DIR } ' ]
885+ ]
874886
875- wifi_lib = os .path .abspath (
876- os .path .join (idf_path , 'components/esp_wifi/lib' )
877- )
878- berkeley_db = os .path .abspath ('lib/micropython/lib/berkeley-db-1.xx/README' )
879-
880- if not os .path .exists (berkeley_db ) or not os .path .exists (wifi_lib ):
881- cmds .append (['cd lib/micropython' ])
882- for dep in (
883- 'tinyusb' ,
884- 'micropython-lib' ,
885- 'protobuf-c' ,
886- 'wiznet5k' ,
887- 'lwip' ,
888- 'mbedtls' ,
889- 'axtls' ,
890- 'berkeley-db-1.xx' ,
891- 'btstack'
892- ):
893- path = f"lib/{ dep } "
887+ for name , file in (
888+ ('berkeley-db-1.xx' , 'README' ),
889+ ('mbedtls' , 'README.md' ),
890+ ('micropython-lib' , 'README.md' )
891+ ):
892+ file = os .path .join ('lib/micropython/lib' , name , file )
893+ if not os .path .exists (file ):
894+ cmds .extend ([
895+ [f'git submodule sync lib/{ name } ' ],
896+ [f'git submodule update --init --depth=1 lib/{ name } ' ]
897+ ])
898+ if cmds :
899+ cmds .insert (0 , ['cd lib/micropython' ])
900+ cmds .append (['cd ../..' ])
901+
902+ cmds .extend (submodules_cmd [:])
903+
904+ return_code , _ = spawn (cmds , env = env )
905+ if return_code != 0 :
906+ sys .exit (return_code )
894907
895- cmds .append ([f'git submodule sync { path } ' ])
896- cmds .append ([f'git submodule update --init --depth=1 { path } ' ])
897908
898- return_code , _ = spawn (cmds , env = env )
899- if return_code != 0 :
900- sys .exit (return_code )
901-
902-
903909def find_esp32_ports (chip ):
904910 from esptool .targets import CHIP_DEFS # NOQA
905911 from esptool .util import FatalError # NOQA
0 commit comments