2020-01-13 23:25:12 +00:00
|
|
|
# Copyright 2020 Google LLC
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
2021-01-20 21:23:55 +00:00
|
|
|
"""Builds a specific OSS-Fuzz project's fuzzers for CI tools."""
|
2020-01-29 19:03:43 +00:00
|
|
|
import logging
|
2020-01-13 23:25:12 +00:00
|
|
|
import sys
|
|
|
|
|
2021-02-04 14:52:22 +00:00
|
|
|
import build_fuzzers
|
2021-10-26 02:18:17 +00:00
|
|
|
import logs
|
2021-01-28 20:10:57 +00:00
|
|
|
import config_utils
|
2020-01-29 19:03:43 +00:00
|
|
|
|
2021-01-20 21:29:47 +00:00
|
|
|
# pylint: disable=c-extension-no-member
|
|
|
|
# pylint gets confused because of the relative import of cifuzz.
|
|
|
|
|
2021-10-26 02:18:17 +00:00
|
|
|
logs.init()
|
2020-01-29 19:03:43 +00:00
|
|
|
|
2020-01-13 23:25:12 +00:00
|
|
|
|
2021-07-01 00:19:03 +00:00
|
|
|
def build_fuzzers_entrypoint():
|
|
|
|
"""Builds OSS-Fuzz project's fuzzers for CI tools."""
|
2021-01-28 22:49:03 +00:00
|
|
|
config = config_utils.BuildFuzzersConfig()
|
2020-02-03 23:35:04 +00:00
|
|
|
|
2021-01-28 20:10:57 +00:00
|
|
|
if config.dry_run:
|
2020-02-03 23:35:04 +00:00
|
|
|
# Sets the default return code on error to success.
|
2020-02-28 17:41:44 +00:00
|
|
|
returncode = 0
|
2020-12-07 18:50:11 +00:00
|
|
|
else:
|
|
|
|
# The default return code when an error occurs.
|
|
|
|
returncode = 1
|
2020-02-03 23:35:04 +00:00
|
|
|
|
2021-02-04 14:52:22 +00:00
|
|
|
if not build_fuzzers.build_fuzzers(config):
|
2021-07-21 05:32:32 +00:00
|
|
|
logging.error('Error building fuzzers for (commit: %s, pr_ref: %s).',
|
2021-11-01 00:36:07 +00:00
|
|
|
config.git_sha, config.pr_ref)
|
2020-12-07 18:50:11 +00:00
|
|
|
return returncode
|
2020-06-12 01:27:01 +00:00
|
|
|
|
2021-10-04 15:21:28 +00:00
|
|
|
return 0
|
2020-01-13 23:25:12 +00:00
|
|
|
|
|
|
|
|
2021-07-01 00:19:03 +00:00
|
|
|
def main():
|
|
|
|
"""Builds OSS-Fuzz project's fuzzers for CI tools.
|
|
|
|
|
|
|
|
Note: The resulting fuzz target binaries of this build are placed in
|
|
|
|
the directory: ${GITHUB_WORKSPACE}/out
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
0 on success or nonzero on failure.
|
|
|
|
"""
|
|
|
|
return build_fuzzers_entrypoint()
|
|
|
|
|
|
|
|
|
2020-01-13 23:25:12 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(main())
|