1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-28 07:23:43 +02:00

Drop STANDALONE mode

STANDALONE mode was used to build flashrom without having support for
file handling. This was relevant to build libflashrom on top of
libpayload. For a while now, the code which is covered by STANDALONE has
moved to cli_*.c and is not used for libflashrom. Therefore we can drop
STANDALONE mode.

Change-Id: I58fb82270a9884a323d9850176708d230fdc5165
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/63469
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Thomas Heijligen 2022-04-07 17:48:53 +02:00 committed by Nico Huber
parent 48fef95b79
commit 50cd432c74
5 changed files with 2 additions and 23 deletions

View File

@ -290,7 +290,6 @@ ifeq ($(MAKECMDGOALS),)
.DEFAULT_GOAL := libflashrom.a .DEFAULT_GOAL := libflashrom.a
$(info Setting default goal to libflashrom.a) $(info Setting default goal to libflashrom.a)
endif endif
FLASHROM_CFLAGS += -DSTANDALONE
$(call mark_unsupported,CONFIG_DUMMY) $(call mark_unsupported,CONFIG_DUMMY)
# libpayload does not provide the romsize field in struct pci_dev that the atapromise code requires. # libpayload does not provide the romsize field in struct pci_dev that the atapromise code requires.
$(call mark_unsupported,CONFIG_ATAPROMISE) $(call mark_unsupported,CONFIG_ATAPROMISE)

View File

@ -112,12 +112,10 @@ static int check_filename(char *filename, const char *type)
/* Ensure a file is open by means of fstat */ /* Ensure a file is open by means of fstat */
static bool check_file(FILE *file) static bool check_file(FILE *file)
{ {
#ifndef STANDALONE
struct stat statbuf; struct stat statbuf;
if (fstat(fileno(file), &statbuf) < 0) if (fstat(fileno(file), &statbuf) < 0)
return false; return false;
#endif /* !STANDALONE */
return true; return true;
} }
@ -279,9 +277,7 @@ int main(int argc, char *argv[])
char *referencefile = NULL; char *referencefile = NULL;
char *layoutfile = NULL; char *layoutfile = NULL;
char *fmapfile = NULL; char *fmapfile = NULL;
#ifndef STANDALONE
char *logfile = NULL; char *logfile = NULL;
#endif /* !STANDALONE */
char *tempstr = NULL; char *tempstr = NULL;
char *pparam = NULL; char *pparam = NULL;
struct layout_include_args *include_args = NULL; struct layout_include_args *include_args = NULL;
@ -481,9 +477,6 @@ int main(int argc, char *argv[])
exit(0); exit(0);
break; break;
case 'o': case 'o':
#ifdef STANDALONE
cli_classic_abort_usage("Log file not supported in standalone mode. Aborting.\n");
#else /* STANDALONE */
if (logfile) { if (logfile) {
fprintf(stderr, "Warning: -o/--output specified multiple times.\n"); fprintf(stderr, "Warning: -o/--output specified multiple times.\n");
free(logfile); free(logfile);
@ -493,7 +486,6 @@ int main(int argc, char *argv[])
if (logfile[0] == '\0') { if (logfile[0] == '\0') {
cli_classic_abort_usage("No log filename specified.\n"); cli_classic_abort_usage("No log filename specified.\n");
} }
#endif /* STANDALONE */
break; break;
default: default:
cli_classic_abort_usage(NULL); cli_classic_abort_usage(NULL);
@ -511,13 +503,10 @@ int main(int argc, char *argv[])
cli_classic_abort_usage(NULL); cli_classic_abort_usage(NULL);
if (referencefile && check_filename(referencefile, "reference")) if (referencefile && check_filename(referencefile, "reference"))
cli_classic_abort_usage(NULL); cli_classic_abort_usage(NULL);
#ifndef STANDALONE
if (logfile && check_filename(logfile, "log")) if (logfile && check_filename(logfile, "log"))
cli_classic_abort_usage(NULL); cli_classic_abort_usage(NULL);
if (logfile && open_logfile(logfile)) if (logfile && open_logfile(logfile))
cli_classic_abort_usage(NULL); cli_classic_abort_usage(NULL);
#endif /* !STANDALONE */
#if CONFIG_PRINT_WIKI == 1 #if CONFIG_PRINT_WIKI == 1
if (list_supported_wiki) { if (list_supported_wiki) {
@ -532,9 +521,7 @@ int main(int argc, char *argv[])
goto out; goto out;
} }
#ifndef STANDALONE
start_logging(); start_logging();
#endif /* !STANDALONE */
print_buildinfo(); print_buildinfo();
msg_gdbg("Command line (%i args):", argc - 1); msg_gdbg("Command line (%i args):", argc - 1);
@ -808,9 +795,7 @@ out:
/* clean up global variables */ /* clean up global variables */
free((char *)chip_to_probe); /* Silence! Freeing is not modifying contents. */ free((char *)chip_to_probe); /* Silence! Freeing is not modifying contents. */
chip_to_probe = NULL; chip_to_probe = NULL;
#ifndef STANDALONE
free(logfile); free(logfile);
ret |= close_logfile(); ret |= close_logfile();
#endif /* !STANDALONE */
return ret; return ret;
} }

View File

@ -24,7 +24,6 @@
enum flashrom_log_level verbose_screen = FLASHROM_MSG_INFO; enum flashrom_log_level verbose_screen = FLASHROM_MSG_INFO;
enum flashrom_log_level verbose_logfile = FLASHROM_MSG_DEBUG2; enum flashrom_log_level verbose_logfile = FLASHROM_MSG_DEBUG2;
#ifndef STANDALONE
static FILE *logfile = NULL; static FILE *logfile = NULL;
int close_logfile(void) int close_logfile(void)
@ -64,7 +63,6 @@ void start_logging(void)
print_version(); print_version();
verbose_screen = oldverbose_screen; verbose_screen = oldverbose_screen;
} }
#endif /* !STANDALONE */
/* Please note that level is the verbosity, not the importance of the message. */ /* Please note that level is the verbosity, not the importance of the message. */
int flashrom_print_cb(enum flashrom_log_level level, const char *fmt, va_list ap) int flashrom_print_cb(enum flashrom_log_level level, const char *fmt, va_list ap)
@ -85,13 +83,13 @@ int flashrom_print_cb(enum flashrom_log_level level, const char *fmt, va_list ap
if (level != FLASHROM_MSG_SPEW) if (level != FLASHROM_MSG_SPEW)
fflush(output_type); fflush(output_type);
} }
#ifndef STANDALONE
if ((level <= verbose_logfile) && logfile) { if ((level <= verbose_logfile) && logfile) {
ret = vfprintf(logfile, fmt, logfile_args); ret = vfprintf(logfile, fmt, logfile_args);
if (level != FLASHROM_MSG_SPEW) if (level != FLASHROM_MSG_SPEW)
fflush(logfile); fflush(logfile);
} }
#endif /* !STANDALONE */
va_end(logfile_args); va_end(logfile_args);
return ret; return ret;
} }

View File

@ -442,11 +442,9 @@ void print_chip_support_status(const struct flashchip *chip);
/* cli_output.c */ /* cli_output.c */
extern enum flashrom_log_level verbose_screen; extern enum flashrom_log_level verbose_screen;
extern enum flashrom_log_level verbose_logfile; extern enum flashrom_log_level verbose_logfile;
#ifndef STANDALONE
int open_logfile(const char * const filename); int open_logfile(const char * const filename);
int close_logfile(void); int close_logfile(void);
void start_logging(void); void start_logging(void);
#endif
int flashrom_print_cb(enum flashrom_log_level level, const char *fmt, va_list ap); int flashrom_print_cb(enum flashrom_log_level level, const char *fmt, va_list ap);
/* Let gcc and clang check for correct printf-style format strings. */ /* Let gcc and clang check for correct printf-style format strings. */
int print(enum flashrom_log_level level, const char *fmt, ...) int print(enum flashrom_log_level level, const char *fmt, ...)

View File

@ -102,7 +102,6 @@ flashrom_tests = executable('flashrom_unit_tests',
cargs, cargs,
'-ffunction-sections', '-ffunction-sections',
'-fdata-sections', '-fdata-sections',
# '-DSTANDALONE',
], ],
export_dynamic : true, export_dynamic : true,
link_args : mocks, link_args : mocks,