mirror of https://github.com/google/oss-fuzz.git
* Clean artifacts in /out as part of build_fuzzers. * Add prompt before build directory clean, also --no-clean option.
This commit is contained in:
parent
41318de4c5
commit
04395afc00
|
@ -71,6 +71,8 @@ def main():
|
||||||
build_fuzzers_parser.add_argument('project_name')
|
build_fuzzers_parser.add_argument('project_name')
|
||||||
build_fuzzers_parser.add_argument('source_path', help='path of local source',
|
build_fuzzers_parser.add_argument('source_path', help='path of local source',
|
||||||
nargs='?')
|
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_parser = subparsers.add_parser(
|
||||||
'check_build', help='Checks that fuzzers execute without errors.')
|
'check_build', help='Checks that fuzzers execute without errors.')
|
||||||
|
@ -298,11 +300,30 @@ def build_image(args):
|
||||||
|
|
||||||
def build_fuzzers(args):
|
def build_fuzzers(args):
|
||||||
"""Build fuzzers."""
|
"""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):
|
if not _build_image(args.project_name):
|
||||||
return 1
|
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 = [
|
env = [
|
||||||
'FUZZING_ENGINE=' + args.engine,
|
'FUZZING_ENGINE=' + args.engine,
|
||||||
'SANITIZER=' + args.sanitizer
|
'SANITIZER=' + args.sanitizer
|
||||||
|
@ -321,7 +342,7 @@ def build_fuzzers(args):
|
||||||
'%s:/src/%s' % (_get_absolute_path(args.source_path), args.project_name)
|
'%s:/src/%s' % (_get_absolute_path(args.source_path), args.project_name)
|
||||||
]
|
]
|
||||||
command += [
|
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),
|
'-v', '%s:/work' % os.path.join(BUILD_DIR, 'work', project_name),
|
||||||
'-t', 'gcr.io/oss-fuzz/%s' % project_name
|
'-t', 'gcr.io/oss-fuzz/%s' % project_name
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue