Skip to content

gitBOM support via environment variable GITBOM_BUILD_MODE #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions gcc-11.3.0/gcc/c-family/c-opts.c
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,17 @@ c_common_finish (void)
with cpp_destroy (). */
cpp_finish (parse_in, deps_stream);

const char *gitbom_mode = getenv("GITBOM_BUILD_MODE");
// may not need to call getenv, simply checking parse_in->gitbom_deps is not NULL.
// but anyway, parse_in->gitbom_deps is checked in the deps_write_gitbom_file() function.
if (gitbom_mode && strcmp(this_input_filename, "/dev/null") && strcmp(out_fname, "/dev/null")) {
char gitbom_file[PATH_MAX];
// need to include ppid, to avoid conflicts when the same .c file is compiled to multiple .o files
sprintf(gitbom_file, "%s.pid%d.gitbom_deps", this_input_filename, getppid()); // assume the input_file dir is writable
//printf("after cpp_finish, writing to %s, the gitbom_deps of out_fname: %s input_file: %s\n", gitbom_file, out_fname, this_input_filename);
deps_write_gitbom_file(parse_in, gitbom_file);
}

if (deps_stream && deps_stream != out_stream && deps_stream != stdout
&& (ferror (deps_stream) || fclose (deps_stream)))
fatal_error (input_location, "closing dependency file %s: %m", deps_file);
Expand Down
Loading