Skip to content

Commit 5f9047a

Browse files
committed
Gives a speed boost to collecting the submodules
Since all of the submodules are only there to provide files and not for the purposes of being able to update them using git there is no reason to clone the full depth of the submodules repositories. The updates that are done now are shallow updates and only include 1 level of commit data. This has greatly improved the in which it takes to collect the submodules.
1 parent ac9e1c6 commit 5f9047a

File tree

2 files changed

+57
-11
lines changed

2 files changed

+57
-11
lines changed

builder/__init__.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ def get_lvgl():
196196
'submodule',
197197
'update',
198198
'--init',
199+
'--depth=1',
199200
'--',
200201
f'lib/lvgl'
201202
]
@@ -214,7 +215,7 @@ def get_micropython():
214215
'submodule',
215216
'update',
216217
'--init',
217-
'--remote',
218+
'--depth=1',
218219
'--',
219220
f'lib/micropython'
220221
]
@@ -224,13 +225,27 @@ def get_micropython():
224225
if result != 0:
225226
sys.exit(result)
226227

228+
mkrules_path = 'lib/micropython/py/mkrules.mk'
229+
with open(mkrules_path, 'rb') as f:
230+
data = f.read().decode('utf-8')
231+
232+
pattern = '$(Q)git submodule update --init $(addprefix $(TOP)/,$(GIT_SUBMODULES))'
233+
if pattern in data:
234+
data = data.replace(
235+
pattern,
236+
'$(Q)git submodule update --init --depth=1 $(addprefix $(TOP)/,$(GIT_SUBMODULES))'
237+
)
238+
with open(mkrules_path, 'wb') as f:
239+
f.write(data.encode('utf-8'))
240+
227241

228242
def get_pycparser():
229243
cmd_ = [
230244
'git',
231245
'submodule',
232246
'update',
233247
'--init',
248+
'--depth=1',
234249
'--',
235250
f'lib/pycparser'
236251
]
@@ -303,6 +318,11 @@ def process_output(myproc, out_to_screen, spinner, cmpl, out_queue):
303318
line_updated = False
304319
err_updated = False
305320

321+
event = threading.Event()
322+
323+
os.set_blocking(myproc.stdout.fileno(), False)
324+
os.set_blocking(myproc.stderr.fileno(), False)
325+
306326
event = threading.Event()
307327
spinner_lock = threading.Lock()
308328
if spinner:
@@ -408,6 +428,7 @@ def process_output(myproc, out_to_screen, spinner, cmpl, out_queue):
408428
if not err_updated and not line_updated:
409429
if myproc.poll() is not None:
410430
break
431+
event.wait(0.1)
411432

412433
err_updated = False
413434
line_updated = False

builder/esp32.py

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,12 @@ def get_espidf():
115115
cmd = [
116116
[
117117
'git', 'submodule', 'update', '--init',
118-
f'--jobs {os.cpu_count()}', '--', 'lib/esp-idf'
118+
f'--jobs {os.cpu_count()}', '--depth=1',
119+
'--', 'lib/esp-idf'
119120
],
120-
['cd', 'lib/esp-idf'],
121+
['cd lib/esp-idf'],
121122
[
122-
'git', 'submodule', 'update', '--init',
123+
'git', 'submodule', 'update', '--init', '--depth=1',
123124
f'--jobs {os.cpu_count()}', '--',
124125
'components/bt/host/nimble/nimble',
125126
'components/esp_wifi',
@@ -473,7 +474,10 @@ def has_correct_idf():
473474
cached_idf_version = version
474475

475476
return (
476-
cached_idf_version is not None and cached_idf_version == IDF_VER
477+
cached_idf_version is not None and (
478+
cached_idf_version == IDF_VER or
479+
cached_idf_version == IDF_VER.rsplit('.', 1)[0]
480+
)
477481
)
478482

479483

@@ -580,10 +584,34 @@ def setup_idf_environ():
580584
# There were some modifications made with how the environment gets set up
581585
# @cheops put quite a bit of time in to research the best solution
582586
# and also with the testing of the code.
583-
if IDF_ENVIRON_SET or (not IDF_ENVIRON_SET and has_correct_idf()):
587+
588+
if IDF_ENVIRON_SET:
584589
env = os.environ
585590
IDF_ENVIRON_SET = True
586-
elif not IDF_ENVIRON_SET:
591+
elif has_correct_idf():
592+
idf_path = get_idf_path()
593+
594+
cmd = [
595+
['cd', idf_path],
596+
[
597+
'git', 'submodule', 'update', '--init', '--depth=1',
598+
f'--jobs {os.cpu_count()}', '--',
599+
'components/bt/host/nimble/nimble',
600+
'components/esp_wifi',
601+
'components/esptool_py/esptool',
602+
'components/lwip/lwip',
603+
'components/mbedtls/mbedtls',
604+
'components/bt/controller/lib_esp32',
605+
'components/bt/controller/lib_esp32c3_family'
606+
]
607+
]
608+
env = os.environ
609+
result, _ = spawn(cmd, spinner=True, env=env)
610+
if result != 0:
611+
sys.exit(result)
612+
613+
IDF_ENVIRON_SET = True
614+
else:
587615
print('Getting ESP-IDF build Environment')
588616
idf_path = 'lib/esp-idf'
589617

@@ -641,9 +669,6 @@ def setup_idf_environ():
641669

642670
env = os.environ
643671
IDF_ENVIRON_SET = True
644-
else:
645-
# this is a sanity check and should never actually run
646-
env = os.environ
647672

648673
if 'GITHUB_RUN_ID' in os.environ:
649674
idf_path = os.path.abspath(env["IDF_PATH"])
@@ -678,7 +703,7 @@ def submodules():
678703
env = {k: v for k, v in os.environ.items()}
679704
env['IDF_PATH'] = os.path.abspath(idf_path)
680705

681-
result, _ = spawn(cmds, env=env)
706+
result, _ = spawn(cmds, spinner=True, env=env)
682707
if result != 0:
683708
sys.exit(result)
684709

0 commit comments

Comments
 (0)