Thanks for the explanation (and the history lesson).

I'm still confused because when I open Basic.swc I see the JS files as well. I 
thought libs typically contained code for both swf and js, so that's also how I 
configured my build...

> >What should happen if instead they were all included in external?

What I meant here was if all JS dependencies were in <js-external-library/> and 
all swf dependencies were in <external-library/>. I'm trying to avoid 
duplicating dependencies on Royale if there's more than one swc.

>So, for the first pass with the SWF target, COMPILE::SWF is true
>and COMPILE::JS is false. Then, in the second pass with the JSRoyale
>target, COMPILE::SWF is false and COMPILE::JS is true.

That's what gets me confused. Why does this code (note  flash.utils.IDataInput 
is in the SWF block)

COMPILE::JS{
import org.apache.royale.utils.net.IDataInput;
import org.apache.royale.utils.net.IDataOutput;
}
COMPILE::SWF{
import flash.utils.IDataInput;
import flash.utils.IDataOutput;
}

Give me

COMPCJSCRoyale

C:\dev\royale-utilities\Squiggly\main\libs\ApacheFlexSpellingFramework.swc
The definition flash.utils.IDataInput depended on by
com.adobe.linguistics.spelling.framework.ResourceTable in the SWC

C:\dev\royale-utilities\Squiggly\main\libs\ApacheFlexSpellingFramework.swc
could not be found

(Note COMPCJSCRoyale, which means it's in the JS pass)

For context, I am getting this message when building a new library which has 
ApacheFlexSpellingFramework.swc as a dependency. Compiling 
ApacheFlexSpellingFramework does not give any errors.


________________________________
From: Josh Tynjala <joshtynj...@bowlerhat.dev>
Sent: Tuesday, July 8, 2025 5:10 PM
To: dev@royale.apache.org <dev@royale.apache.org>
Subject: Re: Any Ideas What This compc Error is About?

>  I see that <external-library-path/> is used only for playerglobal.swc
while the rest of the framework/libs are added in <library-path/>
>  <js-external-library-path/> has only js.swc and GCL.swc and anything
under framework/js/libs (e.g. BasicJS.swc) is under <js-library-path/>

Yes. I feel like it might be a good idea to explain why the SWCs are added
in each of those options, just in case it isn't clear.

Before Royale, we had only library-path and external-library-path because
there was only one target: SWF. Traditionally, library-path was for SWCs
that contain full implementations of AS3 classes that don't exist in the
flash.* package. Meanwhile, external-library-path was for classes that
don't need to be compiled into the output, but the compiler needs to know
which symbols are available for type checking. playerglobal.swc doesn't
contain full AS3 implementations of the flash.* classes compiled into it.
It's just stubs of the classes in the flash.* package (which is similar to
Royale's JS externs/typedefs). You could also use external-library-path for
classes that might be available from a different SWF at run-time, and you
don't want to duplicate them to save on file size.

In Royale/FlexJS, we added swf-library-path, swf-external-library-path,
js-library-path, and js-external-library-path.

   - If swf-library-path is defined, it will take precedence over
   library-path, but only when targeting SWF.
   - If swf-external-library-path is defined, it will take precedence over
   external-library-path, but only when targeting SWF.
   - If js-library-path is defined, it will take precedence over
   library-path, but only when targeting JS.
   - If js-external-library-path is defined, it will take precedence over
   external-library-path, but only when targeting JS.

As I understand it, in royale-config.xml, we decided to keep using
library-path and external-library-path for the SWF target. Probably because
that's how it worked before Royale, and changing to use swf-library-path
and swf-external-library-path might break existing SWF-only projects if
they tried to switch to the Royale compiler from the Flex SDK or AIR SDK
compilers.

However, we need to provide SWCs in the same royale-config.xml for the JS
target too. Those JS SWCs should be ignored when targeting SWF, so we can't
just add them all to library-path and external-library-path. With that in
mind, for JS, we use js-library-path and js-external-library-path.

js.swc and GCL.swc are the JS equivalent of playerglobal.swc. They don't
contain the actual classes, but just define the APIs so that the compiler
can typecheck. That's why they're external.

The frameworks/js/libs SWCs are for JS only and contain full
implementations of the Royale framework, similar to how the frameworks/libs
SWCs are SWF only and contain full implementations.

> What should happen if instead they were all included in external?

js.swc and playerglobal.swc in the same external-library-path? It would
make symbols meant for just one target available to both targets, from the
compiler's perspective. So the compiler might think that
flash.display.Sprite is available in JS. Or HTMLDivElement is available in
SWF. We don't want that.

> Also, why are the JS.swc included in <js-library-path/> instead of the
regular swc ones?

The frameworks/js/libs/*JS.swc files are the full implementations of the
Royale framework, but targeting JS only. So they are added to
js-library-path. That's similar to frameworks/libs/*.swc that are
full implementations for SWF being added to library-path (or, in theory,
they could be added to swf-library-path).

> I get the same result with asconfigc with the following conf:
>  "targets": [
>            "SWF",
>           "JSRoyale"
>        ],

By default, COMPILE::SWF and COMPILE::JS are both set to AUTO. When the
target is SWF, the AUTO value means that COMPILE::SWF is true and
COMPILE::JS is false. When the target is JSRoyale, the AUTO value means
that COMPILE::SWF is false and COMPILE::JS is true.

It's important to understand that when you have multiple values in the
targets compiler option, the compiler internally restarts fresh for each
target. So, for the first pass with the SWF target, COMPILE::SWF is true
and COMPILE::JS is false. Then, in the second pass with the JSRoyale
target, COMPILE::SWF is false and COMPILE::JS is true.

If you're making a SWC that is intended for JS only, you don't actually
want to use the default AUTO value. AUTO is good for when you're building
an app with Royale, but not for a library. For a JS-only library you
actually need to force COMPILE::SWF to false and COMPILE::JS to true.

You can see that we do that for the JS SWCs in royale-asjs:

https://github.com/apache/royale-asjs/blob/5b52c04/frameworks/js/projects/BasicJS/src/main/config/compile-js-config.xml#L38-L45

And for the SWF-only SWCs, we set them to the opposite values:

https://github.com/apache/royale-asjs/blob/5b52c04/frameworks/projects/Basic/src/main/config/compile-swf-config.xml#L49-L56

--
Josh Tynjala
Bowler Hat LLC
https://bowlerhat.dev/


On Tue, Jul 8, 2025 at 8:24 AM Yishay Weiss <yishayj...@hotmail.com> wrote:

> > In my experience, it is usually because either swf-external-library-path
> or
> js-external-library-path is set
>
> When I look at royale-config.xml I see that <external-library-path/> is
> used only for playerglobal.swc while the rest of the framework/libs are
> added in <library-path/>
>
> <js-external-library-path/> has only js.swc and GCL.swc and anything under
> framework/js/libs (e.g. BasicJS.swc) is under <js-library-path/>
>
> What should happen if instead they were all included in external? Also,
> why are the JS.swc included in <js-library-path/> instead of the regular
> swc ones?
>
> >I saw that you are compiling for the SWF target. Note it prints
> COMPCJSCRoyale before giving the error.
>
> I get the same result with asconfigc with the following conf:
>
> {
>     "config": "royale",
>     "type": "lib",
>     "compilerOptions": {
>         "targets": [
>             "SWF",
>             "JSRoyale"
>         ],
>         "source-path": [
>             "src"
>         ],
>         "output": "../libs/ApacheFlexSpellingUI.swc",
>         "library-path": [
>             "../libs/"
>         ],
>         "js-library-path": [
>             "../libs/"
>         ]
>     },
>     "files": [
>         "src"
>         ]
> }
>
>
>
>
> ________________________________
> From: Josh Tynjala <joshtynj...@bowlerhat.dev>
> Sent: Tuesday, July 8, 2025 2:57 PM
> To: dev@royale.apache.org <dev@royale.apache.org>
> Subject: Re: Any Ideas What This compc Error is About?
>
> > It looks like the trick is to use -library-path instead of
> -external-library-path. I am not sure why external is not enough.
>
> Sometimes, external-library-path seems like it isn't working properly. In
> my experience, it is usually because either swf-external-library-path or
> js-external-library-path is set, and they are designed to take precedence
> over external-library-path. It's worth mentioning that you may not be the
> one setting them in your own project's compiler options. They might be set
> as a default in royale-config.xml.
>
> >  Does that mean that the JS compile is trying to use the COMPILE::SWF
> block?
>
> In your original message, I saw that you are compiling for the SWF target
> (so I would expect COMPILE::SWF to be true, in that case):
>
> <arg value="-targets=SWF" />
>
>
> --
> Josh Tynjala
> Bowler Hat LLC
> https://bowlerhat.dev/
>
>
> On Tue, Jul 8, 2025 at 6:46 AM Yishay Weiss <yishayj...@hotmail.com>
> wrote:
>
> > It looks like the trick is to use -library-path instead of
> > -external-library-path. I am not sure why external is not enough.
> >
> > Following that I have an issue with a class that has this:
> >
> > COMPILE::JS{
> > import org.apache.royale.utils.net.IDataInput;
> > import org.apache.royale.utils.net.IDataOutput;
> > }
> > COMPILE::SWF{
> > import flash.utils.IDataInput;
> > import flash.utils.IDataOutput;
> > }
> >
> > When referencing that class from a different library, I get:
> >
> > COMPCJSCRoyale
> >
> C:\dev\royale-utilities\Squiggly\main\libs\ApacheFlexSpellingFramework.swc
> > The definition flash.utils.IDataInput depended on by
> > com.adobe.linguistics.spelling.framework.ResourceTable in the SWC
> >
> C:\dev\royale-utilities\Squiggly\main\libs\ApacheFlexSpellingFramework.swc
> > could not be found
> >
> > Does that mean that the JS compile is trying to use the COMPILE::SWF
> block?
> >
> >
> > ________________________________
> > From: Yishay Weiss <yishayj...@hotmail.com>
> > Sent: Tuesday, July 8, 2025 10:29 AM
> > To: Apache Royale Development <dev@royale.apache.org>
> > Subject: Re: Any Ideas What This compc Error is About?
> >
> >
> > Adding
> > <jvmarg value="-Droyalelib=${ROYALE_HOME}/frameworks" />
> >
> > And removing
> >
> > <arg value="-library-path+=${ROYALE_HOME}/frameworks/libs/Core.swc" />
> > <arg
> >
> value="-library-path+=${ROYALE_HOME}/frameworks/projects/Basic/target/Basic.swc"
> > />
> >
> > Fixed it for now...
> >
> > ________________________________
> > From: Yishay Weiss <yishayj...@hotmail.com>
> > Sent: Tuesday, July 8, 2025 9:34 AM
> > To: Apache Royale Development <dev@royale.apache.org>
> > Subject: Re: Any Ideas What This compc Error is About?
> >
> > T1.as looks like this:
> >
> > package
> > {
> > import org.apache.royale.core.UIBase;
> >
> > public class T1 extends UIBase
> > {
> > }
> > }
> > ________________________________
> > From: Yishay Weiss <yishayj...@hotmail.com>
> > Sent: Tuesday, July 8, 2025 9:29 AM
> > To: Apache Royale Development <dev@royale.apache.org>
> > Subject: Any Ideas What This compc Error is About?
> >
> > I'm getting this [1] error when running this [2] ant task
> >
> > [1] compileframework:
> >      [java] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
> >      [java] args:
> >      [java] -external-library-path
> >      [java] C:\dev\player/11.1/playerglobal.swc
> >      [java]
> >
> -library-path+=C:\dev\full_royale_sdk\royale-asjs/frameworks/libs/Core.swc
> >      [java]
> >
> -library-path+=C:\dev\full_royale_sdk\royale-asjs/frameworks/projects/Basic/target/Basic.swc
> >      [java] -targets=SWF
> >      [java] -output
> >      [java] libs/ApacheFlexSpellingFramework.swc
> >      [java] -source-path
> >      [java] SpellingFramework/src2
> >      [java] -include-classes
> >      [java] T1
> >      [java] -dump-config
> >      [java] sq_dump
> >      [java] COMPC
> >      [java]
> >      [java] 1.1542501 seconds
> >      [java] Error: interface method dispatchEvent in interface
> > IEventDispatcher is implemented with an incompatible signature in class
> T1
> >      [java]
> >      [java]
> >      [java] interface method dispatchEvent in interface IEventDispatcher
> > is implemented with an incompatible signature in class T1
> >      [java]
> >      [java]
> >
> > [2]
> > <target name="compileframework" depends="init">
> > <java jar="${COMPC.JAR}" fork="true" failonerror="true">
> > <jvmarg value="-Xmx384m" />
> > <jvmarg value="-Dsun.io.useCanonCaches=false" />
> > <arg value="-external-library-path"/>
> > <arg
> > value="${PLAYERGLOBAL_HOME}/${playerglobal.version}/playerglobal.swc"/>
> > <arg value="-library-path+=${ROYALE_HOME}/frameworks/libs/Core.swc" />
> > <arg
> >
> value="-library-path+=${ROYALE_HOME}/frameworks/projects/Basic/target/Basic.swc"
> > />
> > <arg value="-targets=SWF" />
> > <arg value="-output"/>
> > <arg value="${OUTPUT_DIR}/ApacheFlexSpellingFramework.swc"/>
> > <arg value="-source-path"/>
> > <arg value="SpellingFramework/src2"/>
> > <arg value="-include-classes"/>
> > <arg value="T1"/>
> > <arg value="-dump-config"/>
> > <arg value="sq_dump"/>
> > </java>
> > </target>
> >
>

Reply via email to