History

more consistent command line handling

bellard committed 24 years ago

Commit a50e58e1 parent 61a15991 file · +46 −17Browse files

Unified · Split

tcc.c+46−17
@@ -61,6 +61,10 @@ · 60 unmodified lines
6161 #define CONFIG_TCC_PREFIX "/usr/local"
6262 #endif
6363
64+/* path to find crt1.o, crti.o and crtn.o. Only needed when generating
65+ executables or dlls */
66+#define CONFIG_TCC_CRT_PREFIX "/usr/lib"
67+
6468 /* amount of virtual memory associated to a section (currently, we do
6569 not realloc them) */
6670 #define SECTION_VSIZE (1024 * 1024)
@@ -7617,26 +7621,37 @@ void tcc_add_file(TCCState *s, const char *filename) · 7550 unmodified lines
76177621 void help(void)
76187622 {
76197623 printf("tcc version 0.9.8 - Tiny C Compiler - Copyright (C) 2001, 2002 Fabrice Bellard\n"
7620− "usage: tcc [-Idir] [-Dsym[=val]] [-Usym] [-llib] [-g] [-b]\n"
7621− " [-i infile] [-bench] infile [infile_args...]\n"
7624+ "usage: tcc [-c] [-o outfile] [-bench] [-Idir] [-Dsym[=val]] [-Usym]\n"
7625+ " [-g] [-b] [-llib] [-shared] [-static]\n"
7626+ " [--] infile1 [infile2... --] [infile_args...]\n"
76227627 "\n"
7623− "-Idir : add include path 'dir'\n"
7624− "-Dsym[=val] : define 'sym' with value 'val'\n"
7625− "-Usym : undefine 'sym'\n"
7626− "-llib : link with dynamic library 'lib'\n"
7627− "-g : generate runtime debug info\n"
7628+ "General options:\n"
7629+ " -c compile only - generate an object file\n"
7630+ " -i infile compile infile\n"
7631+ " -o outfile set output filename (NOT WORKING YET)\n"
7632+ " -bench output compilation statistics\n"
7633+ " -- allows multiples input files if no -o option given. Also\n"
7634+ " separate input files from runtime arguments\n"
7635+ "Preprocessor options:\n"
7636+ " -Idir add include path 'dir'\n"
7637+ " -Dsym[=val] define 'sym' with value 'val'\n"
7638+ " -Usym undefine 'sym'\n"
7639+ "C compiler options:\n"
7640+ " -g generate runtime debug info\n"
76287641 #ifdef CONFIG_TCC_BCHECK
7629− "-b : compile with built-in memory and bounds checker (implies -g)\n"
7642+ " -b compile with built-in memory and bounds checker (implies -g)\n"
76307643 #endif
7631− "-i infile : compile infile\n"
7632− "-bench : output compilation statistics\n"
7644+ "Linker options:\n"
7645+ " -llib link with dynamic library 'lib'\n"
7646+ " -shared generate a shared library (NOT WORKING YET)\n"
7647+ " -static static linking (NOT WORKING YET)\n"
76337648 );
76347649 }
76357650
76367651 int main(int argc, char **argv)
76377652 {
76387653 char *r, *outfile;
7639− int optind, file_type;
7654+ int optind, file_type, multiple_files;
76407655 TCCState *s;
76417656
76427657 s = tcc_new();
@@ -7644,6 +7659,7 @@ int main(int argc, char **argv) · 1 unmodified line
76447659
76457660 optind = 1;
76467661 outfile = NULL;
7662+ multiple_files = 0;
76477663 while (1) {
76487664 if (optind >= argc) {
76497665 show_help:
@@ -7654,7 +7670,10 @@ int main(int argc, char **argv) · 4 unmodified lines
76547670 if (r[0] != '-')
76557671 break;
76567672 optind++;
7657− if (r[1] == 'I') {
7673+ if (r[1] == '-') {
7674+ /* '--' enables multiple files input */
7675+ multiple_files = 1;
7676+ } else if (r[1] == 'I') {
76587677 if (tcc_add_include_path(s, r + 2) < 0)
76597678 error("too many include paths");
76607679 } else if (r[1] == 'D') {
@@ -7672,10 +7691,6 @@ int main(int argc, char **argv) · 11 unmodified lines
76727691 char buf[1024];
76737692 snprintf(buf, sizeof(buf), "lib%s.so", r + 2);
76747693 tcc_add_dll(s, buf);
7675− } else if (r[1] == 'i') {
7676− if (optind >= argc)
7677− goto show_help;
7678− tcc_add_file(s, argv[optind++]);
76797694 } else if (!strcmp(r + 1, "bench")) {
76807695 do_bench = 1;
76817696 #ifdef CONFIG_TCC_BCHECK
@@ -7713,6 +7728,7 @@ int main(int argc, char **argv) · 31 unmodified lines
77137728 /* the following options are only for testing, so not
77147729 documented */
77157730 if (r[1] == 'c') {
7731+ multiple_files = 1;
77167732 file_type = TCC_FILE_OBJ;
77177733 } else if (!strcmp(r + 1, "static")) {
77187734 static_link = 1;
@@ -7721,13 +7737,26 @@ int main(int argc, char **argv) · 2 unmodified lines
77217737 } else if (r[1] == 'o') {
77227738 if (optind >= argc)
77237739 goto show_help;
7740+ multiple_files = 1;
77247741 outfile = argv[optind++];
77257742 } else {
77267743 error("invalid option -- '%s'", r);
77277744 }
77287745 }
7729−
7746+
77307747 tcc_add_file(s, argv[optind]);
7748+ if (multiple_files) {
7749+ while ((optind + 1) < argc) {
7750+ optind++;
7751+ r = argv[optind];
7752+ if (r[0] == '-') {
7753+ if (r[1] != '-')
7754+ error("'--' expected");
7755+ break;
7756+ }
7757+ tcc_add_file(s, r);
7758+ }
7759+ }
77317760
77327761 if (do_bench) {
77337762 printf("total: %d idents, %d lines, %d bytes\n",

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t