Clean artifacts in /out as part of build_fuzzers (#1384) (#1389)

* Clean artifacts in /out as part of build_fuzzers.

* Add prompt before build directory clean, also --no-clean option.
This commit is contained in:
Abhishek Arya 2018-04-30 21:01:48 -07:00 committed by GitHub
parent 41318de4c5
commit 04395afc00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 2 deletions

View File

@ -71,6 +71,8 @@ def main():
build_fuzzers_parser.add_argument('project_name')
build_fuzzers_parser.add_argument('source_path', help='path of local source',
nargs='?')
build_fuzzers_parser.add_argument('--no-clean', action='store_true',
help='do not clean existing artifacts.')
check_build_parser = subparsers.add_parser(
'check_build', help='Checks that fuzzers execute without errors.')
@ -298,11 +300,30 @@ def build_image(args):
def build_fuzzers(args):
"""Build fuzzers."""
project_name = args.project_name
no_clean = args.no_clean
if not no_clean:
y_or_n = raw_input(
'WARNING: Remove existing build artifacts in /out '
'(recommended if build config changed) ? (y/N): ')
no_clean = y_or_n.lower() != 'y'
project_name = args.project_name
if not _build_image(args.project_name):
return 1
project_out_dir = os.path.join(BUILD_DIR, 'out', project_name)
if no_clean:
print('Keeping existing build artifacts as-is (if any).')
else:
print('Cleaning existing build artifacts.')
# Clean old and possibly conflicting artifacts in project's out directory.
docker_run([
'-v', '%s:/out' % project_out_dir,
'-t', 'gcr.io/oss-fuzz/%s' % project_name,
'/bin/bash', '-c', 'rm -rf /out/*'
])
env = [
'FUZZING_ENGINE=' + args.engine,
'SANITIZER=' + args.sanitizer
@ -321,7 +342,7 @@ def build_fuzzers(args):
'%s:/src/%s' % (_get_absolute_path(args.source_path), args.project_name)
]
command += [
'-v', '%s:/out' % os.path.join(BUILD_DIR, 'out', project_name),
'-v', '%s:/out' % project_out_dir,
'-v', '%s:/work' % os.path.join(BUILD_DIR, 'work', project_name),
'-t', 'gcr.io/oss-fuzz/%s' % project_name
]