Shop OBEX P1 Docs P2 Docs Learn Events
PROJECT: SPIN Conditional Compilation Managment (SCCuM) Utility — Parallax Forums

PROJECT: SPIN Conditional Compilation Managment (SCCuM) Utility

epmoyerepmoyer Posts: 314
edited 2007-06-20 05:02 in Propeller 1
This project was completed while at 40,000 feet while en-route to Scotland on business (three cheers for in-seat laptop power!). I'm still in Scotland right now but I'll do my best to support any early-adopter bug reports from the road. Share and Enjoy.

Overview
The Spin Conditional Compile Manager (SCCuM) utility is designed to support a conditional compilation syntax for SPIN programs. As of this writing, the Propeller IDE does not currently support a native conditional compilation syntax. The SCCuM syntax is designed to coexist unobtrusively in SPIN code, to allow conditional compilation options to be processed without the need to maintain intermediate files, and to facilitate the painless migration to a native SPIN syntax if and when one is implemented.

SPIN Syntax
The SCCuM Syntax supports three directives: Tag definition, Conditional Block Start, and Conditional Block End. The directives have the following syntax:
   '#DEFINE <Tag Name> = [noparse][[/noparse]TRUE,FALSE]
   '#IF [noparse][[/noparse]!]<Tag Name>
   '#ENDIF



Tag names must consist of contiguous alphanumeric characters . Please note that all directives are preceded by a single quote. This causes them to be ignored by the SPIN compiler as comments. Tag definitions may appear anywhere within a file. A tag may be defined only once in a file. Conditional blocks may not be nested.

Example
The following is an example of SPIN code containing SCCuM directives.
  '#DEFINE DEBUG_ENABLE = false

  PRI main
    '#IF DEBUG_ENABLE
    DumpDebugData
    '#ENDIF
    '#IF !DEBUG_ENABLE
    HydraPrint(@RELEASE_BUILD_STRING)
    '#ENDIF



After running the SCCuM utility on the SPIN code above it would become...
  '#DEFINE DEBUG_ENABLE = false

  PRI main
    '#IF DEBUG_ENABLE
    { '<added by SCCuM preprocessor utility>
    DumpDebugData
    } '<added by SCCuM preprocessor utility>
    '#ENDIF
    '#IF !DEBUG_ENABLE
    HydraPrint(@RELEASE_BUILD_STRING)
    '#ENDIF




Using SCCuM
To process a SPIN file either click the 'Process .SPIN File' button and select a .SPIN file using the file browser, or drag and drop it onto the SCCuM application window. SCCuM will parse the file and if no SCCuM syntax errors are found it will write a backup copy of the original file to <filename>.backup, and then will write the processed .SPIN file back over the original. If you are working on a .SPIN file in the Propeller IDE you should save your changes, close the file, process it with SCCuM, and then reload the file into the propeller IDE
.
Because SCCuM directives are preceded by a single quote they are ignored by the SPIN compiler. You only need to rerun SCCuM if you have created new SCCuM directives, or have modified the value of existing SCCuM tags.

While SCCuM has been tested for proper behavior in all anticipated error cases, and while SCCuM does create an automatic backup of the SPIN file it is processing, it is still advisable to back up your work when developing SPIN applications using SCCuM. SCCuM does overwrite SPIN files for a living, so be careful out there.

SCCuM uses the text '<added by SCCuM preprocessor utility>' to identify comment blocks which it has added to your SPIN code. If you edit that text then SCCuM will not recognize its own code and will add a new comment block the next time it runs. If you do accidentally corrupt a SCCuM comment block start or comment block end, just delete that line and rerun SCCuM. The comment block will be regenerated.

Open Issues:
1. SCCuM cannot process .SPIN files saved in Unicode (rather than text) format. If you add any of the special drawing symbols (lines, curves, resistors, etc) to your .SPIN file then the IDE will prompt you for Unicode conversion on the next save, and will convert your file. If you attempt to process a Unicode file with SCCuM, then it will report that it found no tags and will do nothing.

Post Edited (epmoyer) : 6/20/2007 5:08:29 AM GMT

Comments

  • epmoyerepmoyer Posts: 314
    edited 2007-06-20 05:02
    I just discovered that SCCuM does not work with .SPIN files if they have been saved in Unicode rather than text. I was using it for SpaceWar! this evening and when I added some special line drawing characters to the SPIN file the IDE converted the SPIN file to Unicode on the next save. SCCuM won't do any harm to a Unicode file, but it won't recognize the embedded tags and will stop without doing anything with the following message:

    No tags found!  Tags should be declared using '#DEFINE <TAGNAME> = [noparse][[/noparse]TRUE/FALSE].
     
    File processing complete.
    



    I have started a bug list and will fix that issue soon.
Sign In or Register to comment.