diff options
| author | Kirill Smelkov <kirr@mns.spb.ru> | 2010-06-21 20:50:32 +0400 |
|---|---|---|
| committer | Kirill Smelkov <kirr@mns.spb.ru> | 2010-06-21 20:50:41 +0400 |
| commit | 9775aea1ab634a74cd4254df85e93d4cbf098cce (patch) | |
| tree | dbdf8823c5c64ef3d4d40749401c9cb129f3521d /tcc.c | |
| parent | 3ba37e1e3f1d942c3115406cdccf01ce84d53bee (diff) | |
| parent | 2fe5210a33556ed18bc878046d39e25964a52840 (diff) | |
| download | tinycc-9775aea1ab634a74cd4254df85e93d4cbf098cce.tar.gz tinycc-9775aea1ab634a74cd4254df85e93d4cbf098cce.tar.bz2 | |
Merge branch 'kirr/tcc-MD' into mob
Hello up there.
I'm trying to change gcc to tcc for faster develpment on slow machines,
and the first obstacle that turned out was lack of dependency generation
on tcc side.
Attached patches try to fix that.
Thanks,
Kirill
* tcc-MD:
.gitignore += tags
tcc: Explicitly require -l<lib> for libraries
Document what tcc_fileextension does
tcc -E: Let output_default be <file>.o instead of a.out
tcc: Draft suppoprt for -MD/-MF options
tcc: Refactor "compute default outfile name" into libtcc function
Add input files/libs and reloc_output switch to TCCState
tcc: Fix typo in error (it's '%s', not '%s)
chmod a-x i386-gen.c
.gitignore += *.o *.a
.cvsignore -> .gitignore
Diffstat (limited to 'tcc.c')
| -rw-r--r-- | tcc.c | 63 |
1 files changed, 32 insertions, 31 deletions
@@ -32,6 +32,8 @@ static int output_type; static int reloc_output; static const char *outfile; static int do_bench = 0; +static int gen_deps; +static const char *deps_outfile; #define TCC_OPTION_HAS_ARG 0x0001 #define TCC_OPTION_NOSEP 0x0002 /* cannot have space before option and arg */ @@ -74,6 +76,9 @@ static void help(void) #ifdef CONFIG_TCC_BACKTRACE " -bt N show N callers in stack traces\n" #endif + "Misc options:\n" + " -MD generate target dependencies for make\n" + " -MF depfile put generated dependencies here\n" ); } @@ -115,6 +120,8 @@ enum { TCC_OPTION_w, TCC_OPTION_pipe, TCC_OPTION_E, + TCC_OPTION_MD, + TCC_OPTION_MF, TCC_OPTION_x, }; @@ -154,6 +161,8 @@ static const TCCOption tcc_options[] = { { "w", TCC_OPTION_w, 0 }, { "pipe", TCC_OPTION_pipe, 0}, { "E", TCC_OPTION_E, 0}, + { "MD", TCC_OPTION_MD, 0}, + { "MF", TCC_OPTION_MF, TCC_OPTION_HAS_ARG }, { "x", TCC_OPTION_x, TCC_OPTION_HAS_ARG }, { NULL }, }; @@ -374,6 +383,12 @@ static int parse_args(TCCState *s, int argc, char **argv) case TCC_OPTION_E: output_type = TCC_OUTPUT_PREPROCESS; break; + case TCC_OPTION_MD: + gen_deps = 1; + break; + case TCC_OPTION_MF: + deps_outfile = optarg; + break; case TCC_OPTION_x: break; default: @@ -393,7 +408,6 @@ int main(int argc, char **argv) int i; TCCState *s; int nb_objfiles, ret, optind; - char objfilename[1024]; int64_t start_time = 0; s = tcc_new(); @@ -444,29 +458,7 @@ int main(int argc, char **argv) } else { s->outfile = fopen(outfile, "w"); if (!s->outfile) - error("could not open '%s", outfile); - } - } else if (output_type != TCC_OUTPUT_MEMORY) { - if (!outfile) { - /* compute default outfile name */ - char *ext; - const char *name = - strcmp(files[0], "-") == 0 ? "a" : tcc_basename(files[0]); - pstrcpy(objfilename, sizeof(objfilename), name); - ext = tcc_fileextension(objfilename); -#ifdef TCC_TARGET_PE - if (output_type == TCC_OUTPUT_DLL) - strcpy(ext, ".dll"); - else - if (output_type == TCC_OUTPUT_EXE) - strcpy(ext, ".exe"); - else -#endif - if (output_type == TCC_OUTPUT_OBJ && !reloc_output && *ext) - strcpy(ext, ".o"); - else - pstrcpy(objfilename, sizeof(objfilename), "a.out"); - outfile = objfilename; + error("could not open '%s'", outfile); } } @@ -475,13 +467,14 @@ int main(int argc, char **argv) } tcc_set_output_type(s, output_type); + s->reloc_output = reloc_output; /* compile or add each files or library */ for(i = 0; i < nb_files && ret == 0; i++) { const char *filename; filename = files[i]; - if (filename[0] == '-' && filename[1]) { + if (filename[0] == '-' && filename[1] == 'l') { if (tcc_add_library(s, filename + 2) < 0) { error_noabort("cannot find %s", filename); ret = 1; @@ -501,13 +494,21 @@ int main(int argc, char **argv) if (do_bench) tcc_print_stats(s, getclock_us() - start_time); - if (s->output_type == TCC_OUTPUT_PREPROCESS) { - if (outfile) - fclose(s->outfile); - } else if (s->output_type == TCC_OUTPUT_MEMORY) + if (s->output_type == TCC_OUTPUT_MEMORY) ret = tcc_run(s, argc - optind, argv + optind); - else - ret = tcc_output_file(s, outfile) ? 1 : 0; + else { + if (s->output_type == TCC_OUTPUT_PREPROCESS) { + if (outfile) + fclose(s->outfile); + } else { + ret = tcc_output_file(s, outfile ? outfile : tcc_default_target(s)); + ret = ret ? 1 : 0; + } + + /* dump collected dependencies */ + if (gen_deps && !ret) + tcc_gen_makedeps(s, outfile, deps_outfile); + } } tcc_delete(s); |
