Skip to content

Commit 0714250

Browse files
OSS-Fuzz Teamcopybara-github
authored andcommitted
index_build: Add --binaries-only
This is useful so that we can disable re-indexing (for now) for faster incremental rebuilds, but still build binaries with the same compilation flags. PiperOrigin-RevId: 780037474
1 parent 6f69f08 commit 0714250

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

infra/base-images/base-builder/indexer/clang_wrapper.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,9 @@ def main(argv: list[str]) -> None:
523523
filter_log_file = Path(cdb_path) / f"{build_id}_filter_log.txt"
524524
_write_filter_log(filter_log_file, filtered_compile_commands)
525525

526-
run_indexer(build_id, linker_commands)
526+
if not os.getenv("INDEXER_BINARIES_ONLY"):
527+
run_indexer(build_id, linker_commands)
528+
527529
linker_commands = json.dumps(linker_commands)
528530
commands_path = Path(cdb_path) / f"{build_id}_linker_commands.json"
529531
commands_path.write_text(linker_commands)

infra/base-images/base-builder/indexer/index_build.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,16 @@ def copy_fuzzing_engine() -> Path:
274274
def build_project(
275275
targets_to_index: Sequence[str] | None = None,
276276
compile_args: Sequence[str] | None = None,
277+
binaries_only: bool = False,
277278
):
278279
"""Build the actual project."""
279280
set_env_vars()
280281
if targets_to_index:
281282
os.environ['INDEXER_TARGETS'] = ','.join(targets_to_index)
282283

284+
if binaries_only:
285+
os.environ['INDEXER_BINARIES_ONLY'] = '1'
286+
283287
fuzzing_engine_path = copy_fuzzing_engine()
284288

285289
build_fuzzing_engine_command = [
@@ -606,6 +610,11 @@ def main():
606610
action='store_true',
607611
help='Use gzipped tar (.tgz) for the output snapshot',
608612
)
613+
parser.add_argument(
614+
'--binaries-only',
615+
action='store_true',
616+
help='Build target binaries only, and not index archives.',
617+
)
609618
args = parser.parse_args()
610619

611620
# Clean up the existing OUT by default, otherwise we may run into various
@@ -631,7 +640,7 @@ def main():
631640
SNAPSHOT_DIR.mkdir(exist_ok=True)
632641
# We don't have an existing /out dir on oss-fuzz's build infra.
633642
OUT.mkdir(parents=True, exist_ok=True)
634-
build_project(targets_to_index, args.compile_arg)
643+
build_project(targets_to_index, args.compile_arg, args.binaries_only)
635644

636645
if args.target_arg:
637646
target_args = args.target_arg
@@ -647,11 +656,12 @@ def main():
647656
logging.info('No target env specified.')
648657
target_env = {}
649658

650-
file_extension = '.tgz' if args.compressed else '.tar'
651-
test_and_archive(target_args, target_env, targets_to_index, file_extension)
659+
if not args.binaries_only:
660+
file_extension = '.tgz' if args.compressed else '.tar'
661+
test_and_archive(target_args, target_env, targets_to_index, file_extension)
652662

653-
for snapshot in SNAPSHOT_DIR.iterdir():
654-
shutil.move(str(snapshot), OUT)
663+
for snapshot in SNAPSHOT_DIR.iterdir():
664+
shutil.move(str(snapshot), OUT)
655665

656666
# By default, this directory has o-rwx and its contents can't be deleted
657667
# by a non-root user from outside the container. The rest of the files are

0 commit comments

Comments
 (0)