aboutsummaryrefslogtreecommitdiff
path: root/tcc.c
diff options
context:
space:
mode:
authorgrischka <grischka>2016-10-01 20:19:37 +0200
committergrischka <grischka>2016-10-01 20:19:37 +0200
commiteacdc426d76a88aa9b6efc698106d3f36a774905 (patch)
treef20ac27ca31fb9a98e366e430f11bd80e2ce3c8c /tcc.c
parent09a487eb2b2bcabeaeec8d2c7ca422993df0efb5 (diff)
downloadtinycc-eacdc426d76a88aa9b6efc698106d3f36a774905.tar.gz
tinycc-eacdc426d76a88aa9b6efc698106d3f36a774905.tar.bz2
libtcc: cleanup @listfile
Also: - allow more than one item per line - respect "quoted items" and escaped quotes \" (also for LIBTCCAPI tcc_setoptions) - cleanup some copy & paste
Diffstat (limited to 'tcc.c')
-rw-r--r--tcc.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/tcc.c b/tcc.c
index 0132a2e..730e1e4 100644
--- a/tcc.c
+++ b/tcc.c
@@ -92,7 +92,7 @@ static void help(void)
" -bench show compilation statistics\n"
" -xc -xa specify type of the next infile\n"
" - use stdin pipe as infile\n"
- " @listfile read line separated arguments from 'listfile'\n"
+ " @listfile read arguments from listfile\n"
"Preprocessor options:\n"
" -Idir add include path 'dir'\n"
" -Dsym[=val] define 'sym' with value 'val'\n"
@@ -256,9 +256,6 @@ int main(int argc, char **argv)
optind = tcc_parse_args(s, argc - 1, argv + 1);
- if (s->do_bench)
- start_time = getclock_us();
-
tcc_set_environment(s);
if (optind == 0) {
@@ -272,17 +269,18 @@ int main(int argc, char **argv)
if (s->verbose)
display_info(s, 0);
- if (s->print_search_dirs || (s->verbose == 2 && optind == 1)) {
- tcc_set_output_type(s, TCC_OUTPUT_MEMORY);
- display_info(s, 1);
- return 0;
- }
-
- if (s->verbose && optind == 1)
- return 0;
-
- if (s->nb_files == 0)
+ if (s->nb_files == 0) {
+ if (optind == 1) {
+ if (s->print_search_dirs || s->verbose == 2) {
+ tcc_set_output_type(s, TCC_OUTPUT_MEMORY);
+ display_info(s, 1);
+ return 1;
+ }
+ if (s->verbose)
+ return 1;
+ }
tcc_error("no input files\n");
+ }
/* check -c consistency : only single file handled. XXX: checks file type */
if (s->output_type == TCC_OUTPUT_OBJ && !s->option_r) {
@@ -293,6 +291,8 @@ int main(int argc, char **argv)
tcc_error("cannot specify multiple files with -c");
}
+ if (s->output_type == 0)
+ s->output_type = TCC_OUTPUT_EXE;
tcc_set_output_type(s, s->output_type);
if (s->output_type == TCC_OUTPUT_PREPROCESS) {
@@ -305,6 +305,9 @@ int main(int argc, char **argv)
}
}
+ if (s->do_bench)
+ start_time = getclock_us();
+
/* compile or add each files or library */
for(i = ret = 0; i < s->nb_files && ret == 0; i++) {
struct filespec *f = s->files[i];
@@ -322,6 +325,8 @@ int main(int argc, char **argv)
}
if (0 == ret) {
+ if (s->do_bench)
+ tcc_print_stats(s, getclock_us() - start_time);
if (s->output_type == TCC_OUTPUT_MEMORY) {
#ifdef TCC_IS_NATIVE
ret = tcc_run(s, argc - 1 - optind, argv + 1 + optind);
@@ -335,9 +340,6 @@ int main(int argc, char **argv)
}
}
- if (s->do_bench)
- tcc_print_stats(s, getclock_us() - start_time);
-
tcc_delete(s);
return ret;
}