Skip to content

Commit

Permalink
Issue #2223: Handle .obj files as well to make life easier
Browse files Browse the repository at this point in the history
  • Loading branch information
suborb committed Apr 12, 2023
1 parent 4a72000 commit 5f3c2b7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
12 changes: 10 additions & 2 deletions src/zcc/zcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,9 @@ int process(char *suffix, char *nextsuffix, char *processor, char *extraargs, en
case filter:
snprintf(buffer, sizeof(buffer), "%s %s < \"%s\" > \"%s\"", processor, extraargs, filelist[number], outname);
break;
case filter_out:
snprintf(buffer, sizeof(buffer), "%s %s \"%s\" > \"%s\"", processor, extraargs, filelist[number], outname);
break;
case filter_outspecified_flag:
snprintf(buffer, sizeof(buffer), "%s %s < \"%s\" -o \"%s\"", processor, extraargs, filelist[number], outname);
break;
Expand Down Expand Up @@ -804,7 +807,7 @@ int linkthem(char *linker)

for (i = 0; i < nfiles; ++i)
{
if (hassuffix(filelist[i], c_extension))
if (hassuffix(filelist[i], c_extension) || hassuffix(filelist[i],"obj"))
{
fprintf(out, "%s\n", filelist[i]);
if (prj) fprintf(prj, "%s\n", original_filenames[i]);
Expand Down Expand Up @@ -835,7 +838,7 @@ int linkthem(char *linker)

for (i = 0; i < nfiles; ++i)
{
if (hassuffix(filelist[i], c_extension))
if (hassuffix(filelist[i], c_extension) )
{
offs += snprintf(cmdline + offs, len - offs, " \"%s\"", filelist[i]);
if (prj) fprintf(prj, "%s\n", original_filenames[i]);
Expand Down Expand Up @@ -1544,6 +1547,9 @@ int main(int argc, char **argv)
exit(1);
free(ptr);
break;
case OBJFILE2:
if (process(".obj", c_extension, c_copycmd, "", filter_out, i, YES, YES))
exit(1);
case OBJFILE:
break;
default:
Expand Down Expand Up @@ -2044,6 +2050,8 @@ int get_filetype_by_suffix(char *name)
return ASMFILE;
if (strcmp(ext, ".o") == 0)
return OBJFILE;
if (strcmp(ext, ".obj") == 0)
return OBJFILE2;
if (strcmp(ext, ".m4") == 0)
return M4FILE;
if (strcmp(ext, ".h") == 0)
Expand Down
11 changes: 6 additions & 5 deletions src/zcc/zcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ int snprintf(char * buffer, size_t bufsize, const char * format, ...);
#define SFILE 4
#define ASMFILE 5
#define OBJFILE 6
#define M4FILE 7
#define HDRFILE 8
#define INCFILE 9
#define LLFILE 10
#define OBJFILE2 7
#define M4FILE 8
#define HDRFILE 9
#define INCFILE 10
#define LLFILE 11

#define NO 0
#define YES 1
Expand All @@ -60,5 +61,5 @@ int snprintf(char * buffer, size_t bufsize, const char * format, ...);
#define MAX_COPT_RULE_FILES 100


enum iostyle { outimplied=1, outspecified, filter, outspecified_flag, filter_outspecified_flag };
enum iostyle { outimplied=1, outspecified, filter, outspecified_flag, filter_outspecified_flag, filter_out };

0 comments on commit 5f3c2b7

Please sign in to comment.