This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Building a project twice

I need some help!  I want to make it "easy" to click Build in CCS and have the following happen:

  • Build/link the project.
  • Run a perl script which interrogates the map file (xml version) and changes a few values in a file as a result (e.g. to reflect the size of a given section).
  • Build/link the project again.

If you're wondering why on earth anyone would do this please see the following thread:

Symbol to Unallocated Memory

Right now I'm invoking a batch file as the post-build step.  The batch file runs the perl script and then uses the command line build syntax to kick off another build.  The problem with this approach is that you get an infinite build sequence because the build that gets kicked off runs a post-build step which in turn kicks off another and another and another...  So I'm trying to find a way around it.  Ideas?

For example:

  • Is there a way to suppress the post-build step when doing the automated build?
  • Is there a way to delete (and later re-create) the post-build step when doing the command line build?
  • ?

Thanks,

Brad

  • If your batch file is a regular old DOS-type .bat file, then you can use "if" and "goto" to bypass the contents of the batch file when the repeat happens:

    psuedo batch file said:
    if exist repeat.txt goto done
    echo repeating > repeat.txt

    perl-script...
    2nd pass of compiler

    goto exit

    :done
    erase repeat.txt

    :exit

     

    ---------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question.
    ---------------------------------------------------------------------------------------------------------

  • Randy,

    Thanks for the great idea.  However, I can't get it to work properly.  I think there might be some limitation in terms of not being able to use the headless build while CCS is already open and in the midst of a build.

    Any other ideas?

    Thanks,
    Brad

  • "can't get it to work properly" and "headless build" do not tell me much. Expand if you need to for this thread, but I am curious about the latter anyway.

    Here are some other ideas that do not require multiple passes:

    1. Since the linker allocates in order of largest to smallest, create a 1-byte section ".endofthis" (and .endofthat if you have 2 memory components to flag) so it will be the last one. You can have a global address allocated in that section which gives you the address of the end of memory. If your particular case has any other tiny sections that interfere by getting allocated after .endofthis, artificially waste some space by adding 2 to 4 bytes to the other tiny section(s) so they get allocated earlier. Your post-processing Perl script can check to see if anything got allocated after .endofthis, and scream out that you need to do some more manual edits to enlarge another tiny section  - but that should be very rare.

    2. Give more power to your Perl script by letting it edit the .out file to explicitly place the right value for the global symbol you use for the end of memory. There might be licensing issues for a COFF writer, but maybe not for a DWARF writer. Hopefully, the format of a DWARF file is as well-defined as is the format for a COFF file.

    3. Fill all memory in the first or second stage of the bootloader, or in the OnPreFileLoaded() GEL function. Then whatever does not get loaded will have been initialized already.

    4. Have your Perl script generate a GEL script or a file that a GEL function can read, and let the GEL OnFileLoaded() function set the end-of-memory symbol.

    After you shoot these down with vague phrases and terms I do not understand, I will try to find more.

  • Headless build = command line build

    Funny term.  I think I picked that up from our documentation somewhere but it's a bad term.  We should simply say "command line build"!  :)

    Sorry for the vague details.  I tried the following experiment:

    • Open CCS
    • Open a command prompt.
    • Try building the project from the command line.
    • Run the build command from the command line -- nothing.
    • Close CCS.
    • Run the build command from the command line again -- normal build occurs.

    So it seems to me that you cannot invoke a command line build while CCS is already running.  Therefore I don't think it's possible right now for me to do this as a post-build step.  I think the best option would probably be to just write a straight-up makefile (or batch file) that does what I need it to do.  A makefile is probably better though because it will integrate better in CCS, i.e. standard make project.

    Brad

  • Do you consider your 4th bullet to be a CCS bug to be fixed or a feature that has to be lived with?

    You did not shoot down my #1 above, so does that mean you are not just trying to solve the problem in the thread you referenced but now are trying to figure out a way to do a two-pass build? FYI to #1, you can also turn off the size-ordered link and then add new sections at the end with your end-of-memory symbols defined there.

    Would you consider a Perl post-build step that:

    1. reads the .map file to generate the symbols needed,
    2. reads the existing file of symbols,
    3. compares the existing symbol values to the ones you now want to write,
    4. if the values are the same, does not write the file again and displays a message that all is good, or
    5. if the values are different, writes the file and displays a message that a re-build is needed and try to throw an error?

    This would let you edit your source files and click Re-build once. If the symbols needed to change, you will see a message saying to re-build. One more click of Re-build, and you are done. Or maybe that is what you are doing now and you are looking for a way to do it with one click instead of two?