1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-09 22:29:35 +00:00

Added a new option --dep-target to the compiler. This option allows to set the

target in the generated dependency file. The cl65 utility will use this option
to override the depdendency target, if actual object files are to be generated
from C input. So the generated dependency will not have the intermediate .s
file as target, but the final .o file, which allows to use the dependency
files without further processing.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4660 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2010-05-02 09:56:40 +00:00
parent e61bf7094c
commit d54ca88743
6 changed files with 62 additions and 9 deletions

View File

@ -85,6 +85,7 @@ Long options:
--debug Debug mode
--debug-info Add debug info to object file
--debug-opt name Debug optimization steps
--dep-target target Use this dependency target
--disable-opt name Disable an optimization step
--enable-opt name Enable an optimization step
--forget-inc-paths Forget include search paths
@ -185,6 +186,16 @@ Here is a description of all the command line options:
mortals:-)
<label id="option-dep-target">
<tag><tt>--dep-target target</tt></tag>
When generating a dependency file, don't use the actual output file as the
target of the dependency, but the file specified with this option. The
option has no effect if neither <tt/<ref id="option-create-dep"
name="--create-dep">/ nor <tt/<ref id="option-create-full-dep"
name="--create-full-dep">/ is specified.
<tag><tt>-D sym[=definition]</tt></tag>
Define a macro on the command line. If no definition is given, the macro

View File

@ -64,6 +64,7 @@ IntStack CodeSizeFactor = INTSTACK(100);/* Size factor for generated code */
/* File names */
StrBuf DepName = STATIC_STRBUF_INITIALIZER; /* Name of dependencies file */
StrBuf FullDepName = STATIC_STRBUF_INITIALIZER; /* Name of full dependencies file */
StrBuf DepTarget = STATIC_STRBUF_INITIALIZER; /* Name of dependency target */

View File

@ -72,6 +72,7 @@ extern IntStack CodeSizeFactor; /* Size factor for generated code */
/* File names */
extern StrBuf DepName; /* Name of dependencies file */
extern StrBuf FullDepName; /* Name of full dependencies file */
extern StrBuf DepTarget; /* Name of dependency target */

View File

@ -590,15 +590,24 @@ static void CreateDepFile (const char* Name, InputType Types)
/* Create a dependency file with the given name and place dependencies for
* all files with the given types there.
*/
{
{
const char* Target;
/* Open the file */
FILE* F = fopen (Name, "w");
if (F == 0) {
Fatal ("Cannot open dependency file `%s': %s", Name, strerror (errno));
Fatal ("Cannot open dependency file `%s': %s", Name, strerror (errno));
}
/* Print the output file followed by a tab char */
fprintf (F, "%s:\t", OutputFilename);
/* If a dependency target was given, use it, otherwise use the output
* file name as target, followed by a tab character.
*/
if (SB_IsEmpty (&DepTarget)) {
Target = OutputFilename;
} else {
Target = SB_GetConstBuf (&DepTarget);
}
fprintf (F, "%s:\t", Target);
/* Write out the dependencies for the output file */
WriteDep (F, Types);

View File

@ -116,6 +116,7 @@ static void Usage (void)
" --debug\t\t\tDebug mode\n"
" --debug-info\t\t\tAdd debug info to object file\n"
" --debug-opt name\t\tDebug optimization steps\n"
" --dep-target target\t\tUse this dependency target\n"
" --disable-opt name\t\tDisable an optimization step\n"
" --enable-opt name\t\tEnable an optimization step\n"
" --forget-inc-paths\t\tForget include search paths\n"
@ -497,6 +498,14 @@ static void OptDebugOpt (const char* Opt attribute ((unused)), const char* Arg)
static void OptDepTarget (const char* Opt attribute ((unused)), const char* Arg)
/* Handle the --dep-target option */
{
FileNameOption (Opt, Arg, &DepTarget);
}
static void OptDisableOpt (const char* Opt attribute ((unused)), const char* Arg)
/* Disable an optimization step */
{
@ -752,6 +761,7 @@ int main (int argc, char* argv[])
{ "--debug", 0, OptDebug },
{ "--debug-info", 0, OptDebugInfo },
{ "--debug-opt", 1, OptDebugOpt },
{ "--dep-target", 1, OptDepTarget },
{ "--disable-opt", 1, OptDisableOpt },
{ "--enable-opt", 1, OptEnableOpt },
{ "--forget-inc-paths", 0, OptForgetIncPaths },

View File

@ -537,11 +537,32 @@ static void Compile (const char* File)
/* Set the target system */
CmdSetTarget (&CC65, Target);
/* If we won't assemble, this is the final step. In this case, set the
* output name.
*/
if (!DoAssemble && OutputName) {
CmdSetOutput (&CC65, OutputName);
/* Check if this is the final step */
if (DoAssemble) {
/* We will assemble this file later. If a dependency file is to be
* generated, set the dependency target to be the final object file,
* not the intermediate assembler file. But beware: There may be an
* output name specified for the assembler.
*/
if (DepName || FullDepName) {
/* Was an output name for the assembler specified? */
if (!DoLink && OutputName) {
/* Use this name as the dependency target */
CmdAddArg2 (&CC65, "--dep-target", OutputName);
} else {
/* Use the object file name as the dependency target */
char* ObjName = MakeFilename (File, ".o");
CmdAddArg2 (&CC65, "--dep-target", ObjName);
xfree (ObjName);
}
}
} else {
/* If we won't assemble, this is the final step. In this case, set
* the output name if it was given.
*/
if (OutputName) {
CmdSetOutput (&CC65, OutputName);
}
}
/* Add the file as argument for the compiler */