Skip to content

Commit c6b6787

Browse files
committed
refactor(build): Update build scripts for improved functionality and clarity
1 parent 38be415 commit c6b6787

File tree

7 files changed

+37
-24
lines changed

7 files changed

+37
-24
lines changed

infra/base-images/base-builder/precompile_honggfuzz_ubuntu_24_04

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ make clean
3434
# improve portability and `-D_HF_LINUX_NO_BFD` to remove assembly instructions
3535
# from the filenames.
3636
sed -i 's/-Werror//g' Makefile
37-
CC=clang CFLAGS="-O3 -funroll-loops -D_HF_LINUX_NO_BFD -Wno-unterminated-string-initialization -Wno-error" make
37+
CC=clang CFLAGS="-O3 -funroll-loops -D_HF_LINUX_NO_BFD -Wno-unterminated-string-initialization -Wno-error" make LDFLAGS="-lBlocksRuntime -lunwind-ptrace -lunwind-generic"
3838

3939
# libhfuzz.a will be added by CC/CXX linker directly during linking,
4040
# but it's defined here to satisfy the build infrastructure

infra/base-images/base-clang/checkout_build_install_llvm_ubuntu_20_04.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function clone_with_retries {
8080

8181
# Disable exit on error since we might encounter some failures while retrying.
8282
set +e
83-
for i in $(seq 1 $CHECKOUT_RETRIES);
83+
for i in $(seq 1 $CHECKOUT_RETRIES); do
8484
rm -rf $LOCAL_PATH
8585
git clone $REPOSITORY $LOCAL_PATH
8686
CHECKOUT_RETURN_CODE=$?

infra/base-images/base-clang/checkout_build_install_llvm_ubuntu_24_04.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ function clone_with_retries {
7979

8080
# Disable exit on error since we might encounter some failures while retrying.
8181
set +e
82-
for i in $(seq 1 $CHECKOUT_RETRIES);
83-
do
82+
for i in $(seq 1 $CHECKOUT_RETRIES); do
8483
rm -rf $LOCAL_PATH
8584
git clone $REPOSITORY $LOCAL_PATH
8685
CHECKOUT_RETURN_CODE=$?
@@ -98,6 +97,16 @@ clone_with_retries https://github.com/llvm/llvm-project.git $LLVM_SRC
9897
git -C $LLVM_SRC checkout $OUR_LLVM_REVISION
9998
echo "Using LLVM revision: $OUR_LLVM_REVISION"
10099

100+
# Prepare fuzz introspector.
101+
echo "Installing fuzz introspector"
102+
FUZZ_INTROSPECTOR_CHECKOUT=341ebbd72bc9116733bcfcfab5adfd7f9b633e07
103+
104+
git clone https://github.com/ossf/fuzz-introspector.git /fuzz-introspector
105+
cd /fuzz-introspector
106+
git checkout $FUZZ_INTROSPECTOR_CHECKOUT
107+
git submodule init
108+
git submodule update
109+
101110
# For fuzz introspector.
102111
echo "Applying introspector changes"
103112
OLD_WORKING_DIR=$PWD

infra/build/functions/build_and_push_test_images.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def build_and_push_image(image, test_image_tag, version='legacy'):
5656
version)
5757
build_image(image, [main_image_name, test_image_name], main_image_name,
5858
version)
59-
# push_image(test_image_name)
59+
push_image(test_image_name)
6060

6161

6262
def build_image(image, tags, cache_from_tag, version='latest'):
@@ -279,24 +279,23 @@ def gcb_build_and_push_images(test_image_tag: str, version_tag: str = None):
279279
return wait_for_build_and_report_summary(build_id)
280280

281281

282-
def build_and_push_images(test_image_tag):
282+
def build_and_push_images(test_image_tag, version_tag=None):
283283
"""Builds and pushes base-images."""
284284
images = [
285285
['base-image'],
286286
['base-clang'],
287287
['base-builder'],
288-
['base-runner'],
289-
# Exclude 'base-builder-swift' as it takes extremely long to build because
290-
# it clones LLVM.
291288
[
292-
'base-runner-debug',
289+
'base-builder-swift',
290+
'base-builder-ruby',
291+
'base-builder-rust',
293292
'base-builder-go',
294293
'base-builder-javascript',
295294
'base-builder-jvm',
296295
'base-builder-python',
297-
'base-builder-ruby',
298-
'base-builder-rust',
299296
],
297+
['base-runner'],
298+
['base-runner-debug'],
300299
]
301300
os.environ['DOCKER_BUILDKIT'] = '1'
302301
max_parallelization = max([len(image_list) for image_list in images])
@@ -306,7 +305,8 @@ def build_and_push_images(test_image_tag):
306305
for image_list in images:
307306
args_list = []
308307
for image in image_list:
309-
for version in BASE_IMAGE_VERSIONS:
308+
versions = [version_tag] if version_tag else BASE_IMAGE_VERSIONS
309+
for version in versions:
310310
# Check if the specific versioned Dockerfile exists before adding.
311311
if version == 'legacy':
312312
dockerfile_path = os.path.join(IMAGES_DIR, image, 'Dockerfile')

infra/build/functions/build_lib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def get_signed_url(path, method='PUT', content_type=''):
287287
timestamp = datetime.datetime.utcnow() + datetime.timedelta(hours=1)
288288
timestamp = timestamp.strftime('%Y-%m-%dT%H:%M:%SZ')
289289

290-
path = urlparse(path)
290+
path = urlparse.urlparse(path)
291291
blob_path = path.path.lstrip('/')
292292
blob = f"""{method}
293293

infra/build/functions/report_generator.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def get_visible_width(text):
4141

4242
def _print_box(title, lines):
4343
"""Prints a formatted box with a title and lines."""
44-
box_width = 80
44+
box_width = 92
4545
title_line = f'║ {title.center(box_width - 4)} ║'
4646
summary_lines = [
4747
'╔' + '═' * (box_width - 2) + '╗',
@@ -66,9 +66,9 @@ def generate_final_summary(all_results):
6666
skipped = str(data['skipped'])
6767
total = str(data['total'])
6868
line = (
69-
f" {version.ljust(15)}{'Passed:'.ljust(8)} {passed.ljust(2)} | "
70-
f"{'Failed:'.ljust(8)} {failed.ljust(2)} | {'Skipped:'.ljust(8)} {skipped.ljust(2)} | "
71-
f"{'Total:'.ljust(8)} {total.ljust(2)}")
69+
f" {version.ljust(15)}{'Passed:'.ljust(8)} {passed.ljust(6)} | "
70+
f"{'Failed:'.ljust(8)} {failed.ljust(6)} | {'Skipped:'.ljust(8)} {skipped.ljust(6)} | "
71+
f"{'Total:'.ljust(7)} {total.ljust(6)}")
7272
summary_lines.append(line)
7373

7474
_print_box('FINAL BUILD REPORT', summary_lines)
@@ -85,9 +85,9 @@ def generate_comparison_table(all_results):
8585
print('\n✅ No projects were run.')
8686
return
8787

88-
project_col_width = 18
89-
header = ' Project | Legacy | Ubuntu 20.04 | Ubuntu 24.04'
90-
separator = '-------------------+------------------+------------------+------------------'
88+
project_col_width = 30
89+
header = ' Project | Legacy | Ubuntu 20.04 | Ubuntu 24.04'
90+
separator = '-------------------------------+------------------+------------------+------------------'
9191

9292
table_lines = [header, separator]
9393

infra/build/functions/trial_build.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ def trial_build_main(args=None, local_base_build=True):
212212
if not args.skip_build_images:
213213
logging.info('Starting "Build and Push Images" phase...')
214214
if local_base_build:
215-
build_and_push_test_images.build_and_push_images(test_image_tag)
215+
build_and_push_test_images.build_and_push_images(test_image_tag,
216+
args.version_tag)
216217
else:
217218
if not build_and_push_test_images.gcb_build_and_push_images(
218219
test_image_tag, version_tag=args.version_tag):
@@ -373,12 +374,15 @@ def _do_build_type_builds(args, config, credentials, build_type, projects):
373374
continue
374375

375376
try:
377+
tags = ['trial-build']
378+
if args.branch:
379+
tags.append(f'branch-{args.branch.replace("/", "-")}')
376380
build_ids[project_name] = (build_project.run_build(
377381
project_name,
378382
steps,
379383
credentials,
380384
build_type.type_name,
381-
extra_tags=['trial-build', f'branch-{args.branch.replace("/", "-")}'],
385+
extra_tags=tags,
382386
timeout=PROJECT_BUILD_TIMEOUT))
383387
time.sleep(1) # Avoid going over 75 requests per second limit.
384388
except Exception as error: # pylint: disable=broad-except
@@ -529,4 +533,4 @@ def wait_on_builds(build_ids, credentials, cloud_project, end_time,
529533

530534

531535
if __name__ == '__main__':
532-
sys.exit(main())
536+
sys.exit(trial_build_main())

0 commit comments

Comments
 (0)