Using include-libraries in custom compiler configuration files

We have a Flex library project which is compiled to SWC. We manually maintain a Flex compiler config XML and tell IDEA to use it (Use IDE Builder & Use default SDK compiler & Use custom compiler configuration file all checked). We love this feature because it allows us to use a single XML compiler config for the CI server and the IDE, which eliminates a whole bunch of local-vs-CI config problems. This works fine except for one issue where the include-libraries compiler tag seem to be ignored when the IDE uses it. The flex-config.xml contains a tag similar to this one:

<include-libraries append="true">
    <library>libs/somelibrary.swc</library>
<include-libraries>


The IDE build behavior:
  • With the correct config that compiles with Ant/compc the needed classes won't be found in the IDE build and the build fails
  • When we modify the libs/somelibrary.swc to a location that doesn't exist the IDE build complains that the file isn't found (this verifies that the build above at least saw the include-libraries tag)
  • When we move the necessary libs from the include-libraries tag to the library-path tag then the compile is successful but doesn't produce the required result (it just merges references classes instead of the entire lib)

When running this from the IDE it prints out:

/usr/lib/jvm/java-6-sun-1.6.0.22/jre/bin/java -Dapplication.home=/opt/flex_sdk_4.1.0.16076 -Xmx384m -Dsun.io.useCanonCaches=false -Duser.language=en -Duser.region=en -Xmx512m -classpath /opt/idea-IU-95.66/plugins/flex/lib/idea-fcsh-fix.jar:/opt/flex_sdk_4.1.0.16076/lib/fcsh.jar com.intellij.flex.FcshLauncher
Adobe Flex Compiler SHell (fcsh)
Version 4.1.0 build 16076
Copyright (c) 2004-2007 Adobe Systems, Inc. All rights reserved.
compc -load-config+={name of IDEA project}/flex-config.xml
Loading configuration file /opt/flex_sdk_4.1.0.16076/frameworks/flex-config.xml
Loading configuration file /{path to IDEA project}/{name of IDEA module}/flex-config.xml
/** Compile errors about missing classes follow */



When running the exact same compc command that is printed in the IDEA consolefrom the command line in the IDEA project directory: {path to IDEA project}
/opt/flex_sdk_4.1.0.16076/bin/compc -load-config+=NSK-UTL/flex-config.xml


The compilation succeeds on the command line while it doesn't in the IDE. What's the difference? Thanks for any answers.


This

8 comments

To answer my own question: The main difference is the use of the Flex Compiler Shell. I'll tinker around with that. Are the argument that Intellij IDEA gives to fcsh configurable?

0

You can use compc compiler in IDEA as well (i.e. not fcsh). It is configured at File | Settings | Compiler | Flex Compiler. Please check if it makes difference.

0

Yes! Flipping the switch from fcsh to compc does the trick. It makes the library build correctly.

0

And indeed the problem is in Adobe's fcsh. See its source code and search for comment about 'include-libraries' http://opensource.adobe.com/svn/opensource/flex/sdk/branches/4.x/modules/compiler/src/java/flex2/tools/Fcsh.java :p

By the way can you please try latest IDEA 10 EAP and new built-in multithreaded compiler shell? http://confluence.jetbrains.net/display/IDEADEV/IDEA+X+EAP It should be faster then both fcsh and mxmlc/compc.

0

Alexander, you are awesome. The comments in Fcsh.java are ... interesting. :)

Using compc we now have our (pretty complex) project with 20+ modules compiling with the exactly same configuration in the IDE as in the CI server, which is huge for us, because we only need to maintain a single compiler configuration. Thanks, for the hint about IDEA 10, I'll make sure to try it out tonight and report back here.

0

I'm really excited about the prospect of getting the benefits of a compiler shell, multiple threads for compilation *and* a working include-libraries directive. I've just tried it with the IDEA 10 EAP and include-libraries is processed and the new Intellij compiler shell successfully creates the fat SWC with all the classes (manually confirmed the existence of classes in the SWC).

I did however run in to one small but fatal stumbling block that would prevent us from using the same configuration for the IDE and the CI system. All the paths in the compiler config XML are relative paths so they compile on different machines without modification. The Intellij compiler shell works with all of the relative paths, except for one.

The original configuration looks like the one below and compiles with command line compc, Ant-driven compc, IDEA-driven fcsh IDEA-driven and compc. It does not work with the new Intellij compiler shell, where it will complain that src directory is not found.

<compiler>

<source-path>

<path-element>src</path-element>

</source-path>
<compiler>


The new compiler shell compiles successfully if I hardcore the full path like this:

<compiler>

<source-path>

<path-element>{path to IDEA project}/{module name}/src</path-element>

</source-path>
<compiler>



When I do that, then all other relative path in the XML work fine.

I've noticed one difference in the logs. The new compiler shell calls compc will the full path for the compile config, while for fcsh and for bare-bones compc IDEA passes a relative path.

compc -load-config+={module name}/flex-config.xml

vs.

compc -load-config+={path to IDEA project}/{module name}/flex-config.xml


I'm glad having a current working solution with bare-bones compc currently, but I would sure love to get the speed of the new when we switch to IDEA 10. Any chance to make this work with relative source-paths?

0

Using relative path to config.xml doesn't make any defference. The reason is deeper. Please open an issue in YouTrack http://youtrack.jetbrains.net/dashboard#newissue=yes

0

Please sign in to leave a comment.