8 Replies Latest reply on Jan 24, 2008 3:40 PM by tinylion_uk

    Compiler Variables

    tinylion_uk Level 2
      Hi all,

      Just a quick question (or wish list it i think)

      I assume from reading and lots of google search that you can't get the compiler to return 'compile date/time', size etc back to variables in the application swf,

      if you can please let me know, if not (as i expect), please add this to my wish list.

      cheers
      gleen
        • 1. Re: Compiler Variables
          klouise80
          Hi,

          What kind of values from compiler are you looking for? Can you explain more the context of the usage of these values for your app?

          Thanks,
          kristen
          • 2. Re: Compiler Variables
            tinylion_uk Level 2
            Only simple things really;

            Compile Date/time
            Compiled size

            I may be thinking of my problem in the wrong way, there may be a much better solution. What I want is a way for the swf to have versioning information be visable during dev and test. Rather than having to manually add these values, which is easy to forget or just do wrong. I need th4e clients reviewing the dev process to be able to know which build version they are looking at.

            Are there other tools I should be using to make this simpler?

            would also like builder to produce COMPILE_DEBUG true false on Export Realse version/
            • 3. Re: Compiler Variables
              klouise80 Level 1
              Conditional compilation seems to be what you're looking for. How it works is that you can pass values of constants at compile time using the compiler option -compiler.define. You can find documentation of this feature here: http://blogs.adobe.com/flexdoc/2007/10/conditional_compilation_in_mox_1.html

              But as mentioned in one of the comments in the doc link, one thing that's not supported yet is the option to pass current date string using -compiler.define options in the 'Additional compiler options' in Flexbuilder.

              An enhancement request has been submitted for this. Check out https://bugs.adobe.com/jira/browse/FB-10283 and vote for it if you want to see this in the next feature list.

              As a workaround, you can probably pass the build time using ANT script and conditional compilation.
              Example:

              /---Simple.mxml--/
              <?xml version="1.0" encoding="utf-8"?>
              <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" >
              <mx:Label text="{build_time}" />
              <mx:Script >
              [Bindable]
              public var build_time:String = CONFIG::buildTime;
              </mx:Script>
              </mx:Application>

              /--build.xml--/
              <project name="Test" default="main" basedir=".">
              <property name="sdk.dir" value="${sdkDir}" />
              <taskdef resource="flexTasks.tasks" classpath="${sdk.dir}/ant/lib/flexTasks.jar"/>

              <target name="main" depends="build" >
              <mxmlc file="Simple.mxml" output="Simple.swf" >
              <compiler.define name="CONFIG::buildTime" value="'${build.time}'" />
              </mxmlc>
              </target>

              <target name="build">
              <buildnumber file="mybuild.number" />
              <tstamp prefix="build"/>
              <tstamp>
              <format property="build.time" pattern="MMM dd yy hh:mm aa" unit="hour"/>
              </tstamp>
              </target>
              </project>
              • 4. Re: Compiler Variables
                tinylion_uk Level 2
                thanks again,

                I know I really do need to start to get my head into using ANT. I've had a quick read though the docs with flex antTasks, and so far I'm lost. lol. just need to take some time out to work it out. It's seem's like a great system and really what I'm looking for. It's just hard to find time at the moment to learn it's use.

                Thanks again for getting back to me about this though. It's always nice to feel someone out there is actually listening to what users are saying.

                cheers
                g
                • 5. Re: Compiler Variables
                  tinylion_uk Level 2
                  also,

                  while I rememeber.

                  When using 'Export Realse Version', is it documented anywhere extactly whats happening. I can see that 'debug code is removed', but i assume that is talking about Builders debug and profile interface, It won't for example remove trace(''") statements etc, which would be nice.

                  It would be a help if the differences in these compile types were listed in more detail (and if anything expanded upon at some stage)

                  thanks again

                  g
                  • 6. Re: Compiler Variables
                    klouise80 Level 1
                    Here's a link to the documentation on Export Release Wizard.
                    http://livedocs.adobe.com/labs/flex3/html/help.html?content=build_05.html#166537

                    The release SWF created here is basically same as the debug SWF but with extra post-processing done to make it compact, (e.g removal of debugging information).
                    If you feel that the documentation is not enough to explain the differences, please feel free to log a request against Flex documentation in http://bugs.adobe.com/flex/

                    One way to remove trace() statements is to use conditional compilation. For example, in your 'Additional Compiler Arguments', you can set :
                    -compiler.define CONFIG::debug true

                    Then in your code, you can enclose your trace statements on conditions like:
                    if (CONFIG::debug) {
                    trace("me");
                    }

                    And when you're ready to build a release SWF, just change the compiler argument to -compiler:define CONFIG::debug false

                    hope this helps.
                    regards,
                    kristen
                    • 7. Re: Compiler Variables
                      tinylion_uk Level 2
                      Thanks,

                      that's what I've been doing too date.

                      Just thought it would be cool to have this change to the compiler vars done for us, see ing as we already have two different compile triggers in builder. maybe this could be a function in 4.

                      thanks again tho.

                      xx
                      g
                      • 8. Re: Compiler Variables
                        tinylion_uk Level 2
                        also, i thought i should mention why i wanted this feature. ' the conditional compile from release version' one.

                        you see, i'm having to compile two versions very often. one on my local server, and then every other day or so onto my clients server - for which i'm using 'export release' this is way i would have liked to have an auto generated compiler const. I so often just plan forget to change the inline compiler options. if it was only a matter of being able to just do the development, then do a release compile at the final stages before a true release it wouldn't be a problem. i suppose the latter is the usual use case, so i understand why my needs are not typical.

                        cheers
                        h