Browse Source

Implement --output-data-var switch (allows specifying the on-computer file name for the data variable).

git-svn-id: file:///var/svn/tigccpp/trunk@1155 9552661e-59e3-4036-b4f2-dbe53926924f
kevinkofler 17 years ago
parent
commit
73b434b00f
3 changed files with 28 additions and 4 deletions
  1. 15 3
      tigcc/ld-tigcc/export/export.c
  2. 3 1
      tigcc/ld-tigcc/export/export.h
  3. 10 0
      tigcc/ld-tigcc/main_opt.inc

+ 15 - 3
tigcc/ld-tigcc/export/export.c

@@ -1,7 +1,7 @@
 /* export.c: Routines for file exports
 
    Copyright (C) 2002-2004 Sebastian Reichelt
-   Copyright (C) 2003-2005 Kevin Kofler
+   Copyright (C) 2003-2007 Kevin Kofler
    Copyright (C) 2004 Billy Charvet
 
    This program is free software; you can redistribute it and/or modify
@@ -285,6 +285,10 @@ SIZE DestFileSize = 0;
 // Folder and variable name for main file.
 char ProgramFolder[MAX_NAME_LEN+1] = "main", ProgramName[MAX_NAME_LEN+1] = "program";
 #ifdef DATA_VAR_SUPPORT
+// Destination file name without extension for the data file.
+// If NULL, a default name is picked (either DestFile or DestFile+"-data").
+const char *DestDataFile = NULL;
+SIZE DestDataFileSize = 0;
 // Folder and variable name for data file.
 char DataFolder[MAX_NAME_LEN+1] = "", DataName[MAX_NAME_LEN+1] = "data";
 #endif /* DATA_VAR_SUPPORT */
@@ -399,12 +403,20 @@ BOOLEAN GetOutputFile (INT_EXP_FILE *File, SIZE FileSize, unsigned int DestCalc,
 				
 				{
 					SIZE FileNameSize = DestFileSize;
+					const char *DestFileName = DestFile;
+#ifdef DATA_VAR_SUPPORT
+					if (FileRole == FR_DATA && DestDataFile)
+					{
+						FileNameSize = DestDataFileSize;
+						DestFileName = DestDataFile;
+					}
+#endif /* DATA_VAR_SUPPORT */
 					
 					// Create a temporary file name string.
 					char CurOutputFileName[FileNameSize+5+1+MAX_FILE_EXT_LEN+1];
-					strncpy (CurOutputFileName, DestFile, FileNameSize);
+					strncpy (CurOutputFileName, DestFileName, FileNameSize);
 #if defined(DATA_VAR_SUPPORT) && defined(PUCRUNCH_SUPPORT)
-					if (Pack && FileRole == FR_DATA)
+					if (Pack && FileRole == FR_DATA && !DestDataFile)
 					{
 						strncpy (CurOutputFileName + FileNameSize, "-data", 5);
 						FileNameSize += 5;

+ 3 - 1
tigcc/ld-tigcc/export/export.h

@@ -1,6 +1,6 @@
 /* export.h: Routines for file exports
 
-   Copyright (C) 2003 Kevin Kofler
+   Copyright (C) 2003-2007 Kevin Kofler
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -35,6 +35,8 @@ extern const char *DestFile;
 extern SIZE DestFileSize;
 extern char ProgramFolder[MAX_NAME_LEN+1], ProgramName[MAX_NAME_LEN+1];
 #ifdef DATA_VAR_SUPPORT
+extern const char *DestDataFile;
+extern SIZE DestDataFileSize;
 extern char DataFolder[MAX_NAME_LEN+1], DataName[MAX_NAME_LEN+1];
 #endif /* DATA_VAR_SUPPORT */
 #ifdef PUCRUNCH_SUPPORT

+ 10 - 0
tigcc/ld-tigcc/main_opt.inc

@@ -220,6 +220,16 @@
 					else
 						Error (NULL, "`--output' option must be followed by a name.");
 				}
+				else if (ArgMatches ("output-data-var"))
+				{
+					if ((++CurArg) < ArgCount)
+					{
+						DestDataFile = Args [CurArg];
+						DestDataFileSize = strlen (DestDataFile);
+					}
+					else
+						Error (NULL, "`--output-data-var' option must be followed by a name.");
+				}
 				else if ((ArgMatches ("varname")) || (ArgMatches ("n")))
 				{
 					if ((++CurArg) < ArgCount)