Dependencies - What am I missing?

Help
2004-09-01
2004-09-02
  • Markus Wankus

    Markus Wankus - 2004-09-01

    Hi everyone,

    I am seeing something weird with my builds in terms of dependencies and rebuilds.  I have created my own compiler and linker, and have minimized things down to the following very simple, default build target:

    <target name="build">
        <cc debug="true" outfile="myApp">
            <fileset dir="C:/app" includes="*.ss"/>
        </cc>
    </target>

    My compiler builds ".ss" files, and my linker takes ".obj" files and compiles them to an executable.  If I run two successive builds of the above, the first build finds 6 ".ss" files in my /app folder and compiles them, and then links the executable.  The second build (without cleaning the dir) does what I expect and says:

    build:
         [cc] Starting dependency analysis for 6 files.
         [cc] 6 files are up to date.
         [cc] 0 files to be recompiled from dependency analysis.
         [cc] 0 total files to be compiled.
    BUILD SUCCESSFUL

    BUILD SUCCESSFUL
    Total time: 3 seconds

    Wonderful!  Now, if I do not want to link I simply remove the "outfile=" from my build target so it now is:

    <target name="build">
        <cc debug="true">
            <fileset dir="C:/app" includes="*.ss"/>
        </cc>
    </target>

    Now, I can rebuild as many times as I want (without cleaning the dir), and no matter what it always rebuilds all 6 ".ss" files.  What the heck?  They haven't changed.  Is there some method I am not implementing in my compiler class that is causing this?  Why is it that if I compile *AND* link, everything works fine??  FWIW - I have based my stuff mostly on the TI-DSP classes.

    Thanks in advance,
    Mark.

     
    • clem

      clem - 2004-09-01

      I believe for each build artifact a history.xml is created that stores all the dependency information along with when each file was last modified.  If there's no outfile, then most likely this file doesn't get created.

       
      • Markus Wankus

        Markus Wankus - 2004-09-01

        Ah, good call.  You're right.  Hmm...perhaps I should look at implementing a better method of telling my compiler  "do not link".

        Out of curiosity, how have other people handled this with say gcc or something?  What if you just want to compile a directory of files (with proper history.xml output) but not link them?

        Mark.

         
        • Curt Arnold

          Curt Arnold - 2004-09-01

          It might be that the call that writes the history file inadvertantly bypassed when not linking.  I would consider that an error, but I don't have time to look it right now.

           
          • Markus Wankus

            Markus Wankus - 2004-09-01

            I'd be willing to look at submitting a patch if you are strapped for time.

            Mark.

             
          • Markus Wankus

            Markus Wankus - 2004-09-01

            Well, I found the issue and a workaround.

            When not linking, for some reason the objdir of the CCTask object is null, and thus is initialized to "." - which happens to be the current working directory of the system (at least on Windows) and in my case was *not* my output folder.  Thus, when it came time to commit changes to the history file, the object files could not be found and it failed silently.  So, it was actually creating a history.xml (with no content due to the silent failures) in the current working directory of my system - which happened to be my compiler's bin folder.  CCTask._objdir *is* set correctly when linking because it then uses the parent folder of the output filename.

            Anyway, explicitly specifying "objdir=" attribute for my <cc> task causes the problem to go away.

            Thanks,
            Mark.

             
        • Curt Arnold

          Curt Arnold - 2004-09-02

          I thought that I had put in checks that either objdir or outfile had to be specified.  All that should be necessary is to find out how that check was bypassed.

           

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks