This is an automated email from the ASF dual-hosted git repository.
Harbs pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push:
new fe4310b0ca Add code graph generation, validation, and consumption
documentation
fe4310b0ca is described below
commit fe4310b0ca833dcc9ffbc5c7d86b7ad0ad9ea810
Author: Harbs <[email protected]>
AuthorDate: Mon Aug 3 13:36:46 2026 +0300
Add code graph generation, validation, and consumption documentation
---
CODEGRAPH_CONSUMPTION.md | 202 +++++++++++++++++++++++++
CODEGRAPH_FRAMEWORK_DEVELOPMENT.md | 190 +++++++++++++++++++++++
README.md | 42 ++---
distribution/pom.xml | 132 ++++++++--------
frameworks/codegraphs.xml | 6 +
frameworks/projects/pom.xml | 33 ++--
frameworks/scripts/generate-codegraph-index.js | 14 +-
frameworks/scripts/verify-codegraph-package.js | 8 +-
pom.xml | 2 +
9 files changed, 497 insertions(+), 132 deletions(-)
diff --git a/CODEGRAPH_CONSUMPTION.md b/CODEGRAPH_CONSUMPTION.md
new file mode 100644
index 0000000000..b8c055c628
--- /dev/null
+++ b/CODEGRAPH_CONSUMPTION.md
@@ -0,0 +1,202 @@
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+
+# Consuming Royale Code Graphs
+
+## What Code Graphs Provide
+
+A code graph describes the public declarations and type relationships that the
+Royale compiler resolves for a specific framework version and target. It
+contains stable IDs, callable signatures, inheritance, metadata, ASDoc, source
+provenance, and explicit references to symbols in other libraries. The
aggregate
+also maps Maven dependencies and MXML namespace tags.
+
+Editors can use this data for completion and navigation, documentation tools
can
+render APIs without recompiling source, compatibility tools can compare stable
+symbols between releases, and AI-assisted tools can answer API questions from
+compiler facts instead of source-text guesses. Separate JavaScript and SWF
+graphs prevent tools from recommending APIs unavailable on the active target.
+
+Code graphs describe public declarations, not runtime control flow. They do not
+contain method bodies or application call graphs.
+
+Code graphs are build-time metadata. Do not embed them in framework SWCs, copy
+the full aggregate into each application repository, or deploy them with an
+application.
+
+## Locating the Graphs
+
+Use the graph bundle that matches the application's Royale framework version.
+Consumers should search in this order:
+
+1. An explicitly configured codegraph directory.
+2. The active package-manager dependency or cache.
+3. The active Royale SDK at `$ROYALE_HOME/frameworks/codegraphs`.
+4. A shared local cache keyed by framework version and graph schema version.
+
+Release artifacts expose the same aggregate through these locations:
+
+| Installation | Location |
+| --- | --- |
+| Binary SDK | `$ROYALE_HOME/frameworks/codegraphs` |
+| npm SDK | `<package>/royale-asjs/frameworks/codegraphs` |
+| Maven | `org.apache.royale.framework:distribution:zip:codegraphs:<version>` |
+
+Maven-based tools should resolve and unpack the classifier into their own
cache.
+They should not add its contents to application resources or distribution
+assemblies.
+
+## Reading an Aggregate
+
+1. Read `index.json` and reject unsupported schema major versions.
+2. Select `js` or `swf` to match the compiler target.
+3. Select modules from the application's direct and transitive framework
+ dependencies.
+4. Load only the selected module shards.
+5. Verify each shard against the SHA-256 value in `index.json`.
+6. Read `mxml.json` when namespace and tag completion is required.
+
+A module may not contain every target. Consumers must inspect `module.targets`
+instead of assuming both `js` and `swf` exist. Symbol and member IDs are stable
+semantic identities and should be used as keys. File paths are provenance, not
+identity.
+
+External references may point to symbols in another loaded module or library.
+Resolve them by stable ID first. Preserve explicit unresolved references and
+surface them to users instead of guessing a type from its simple name.
+
+## Application and Third-Party Graphs
+
+Applications do not need a graph merely to compile or run. Generate an
+application or third-party library graph only when a tool needs to understand
+that project's public API.
+
+### Maven
+
+Maven projects can invoke the compiler plugin explicitly:
+
+```xml
+<plugin>
+ <groupId>org.apache.royale.compiler</groupId>
+ <artifactId>royale-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>codegraph</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>compile-codegraph</goal>
+ </goals>
+ </execution>
+ </executions>
+</plugin>
+```
+
+The output is written under `target/codegraph`. Keep this project-owned graph
+separate from dependency bundles. A consumer can compose them in memory through
+stable references; no physical merged copy is required.
+
+### Ant
+
+Ant applications and libraries can invoke the same compiler client with a
+`<java>` task. Reuse the compiler configuration that builds the project so the
+source paths, libraries, namespaces, and includes match the compiled artifact.
+
+```xml
+<property environment="env"/>
+<property name="ROYALE_HOME" value="${env.ROYALE_HOME}"/>
+<property name="ROYALE_COMPILER_HOME" value="${env.ROYALE_COMPILER_HOME}"/>
+
+<target name="codegraph-js">
+ <mkdir dir="${basedir}/target/codegraph/js"/>
+ <java jar="${ROYALE_COMPILER_HOME}/lib/codegraph.jar"
+ fork="true" failonerror="true">
+ <jvmarg value="-Xmx512m"/>
+ <jvmarg value="-Droyalecompiler=${ROYALE_COMPILER_HOME}"/>
+ <jvmarg value="-Droyalelib=${ROYALE_HOME}/frameworks"/>
+ <arg
value="-load-config=${basedir}/src/main/config/compile-js-config.xml"/>
+ <arg value="-compiler.define+=COMPILE::JS,true"/>
+ <arg value="-compiler.define+=COMPILE::SWF,false"/>
+ <arg value="-keep-asdoc=true"/>
+ <arg
value="-output=${basedir}/target/codegraph/js/MyApplication.json"/>
+ <arg value="${basedir}/src/main/royale/MyApplication.mxml"/>
+ </java>
+</target>
+```
+
+For a SWF target, load the SWF config, set `COMPILE::JS` to `false` and
+`COMPILE::SWF` to `true`, and write to `target/codegraph/swf`. A project that
+uses a positional main source file may add it as the final `<arg>`; library
+projects commonly rely on `include-sources` and `include-classes` from their
+existing config.
+
+Generating an application graph does not copy framework graphs into the
+application. Tools should resolve the matching framework aggregate separately
+and compose the graphs by stable symbol ID.
+
+### Command Line
+
+The installed compiler provides `bin/codegraph` (`bin/codegraph.bat` on
+Windows). In an SDK, it is normally available at
+`$ROYALE_HOME/js/bin/codegraph`.
+
+```bash
+$ROYALE_COMPILER_HOME/bin/codegraph \
+ -load-config=/path/to/compile-js-config.xml \
+ -compiler.define+=COMPILE::JS,true \
+ -compiler.define+=COMPILE::SWF,false \
+ -keep-asdoc=true \
+ -output=target/codegraph/js/MyApplication.json \
+ src/main/royale/MyApplication.mxml
+```
+
+The final positional file is optional. When present, its base name becomes the
+module name and it is included as a graph root. Without it, configure roots
with
+`-include-sources` or `-include-classes`; the output file's base name becomes
the
+module name.
+
+Common arguments:
+
+| Argument | Meaning |
+| --- | --- |
+| `-load-config=<file>` | Load a compiler config; use `-load-config+=<file>`
to append one. |
+| `-output=<file>` | JSON output path. |
+| `-compiler.define+=NAME,VALUE` | Supply conditional compilation values,
including `COMPILE::JS` and `COMPILE::SWF`. |
+| `-include-sources+=<path>` | Include a source file or directory as a graph
root. |
+| `-include-classes+=<name>` | Include a qualified class as a graph root. |
+| `-keep-asdoc=true` | Include parsed ASDoc. |
+| `-create-target-with-errors=true` | Permit output despite compiler errors;
avoid this for trusted release metadata. |
+
+All normal compiler path, namespace, define, and external-library options are
+accepted. Use the same values as the corresponding application or library
+compile so the graph represents the artifact users actually run.
+
+Third-party library publishers should eventually attach a version-matched
+codegraph sidecar to each SWC. Until that convention is standardized, tools may
+accept an explicit graph location and cache it by library coordinates.
+
+## Caching
+
+Treat released graph artifacts as immutable. A cache key should include the
+artifact coordinates, target, schema version, and indexed SHA-256 value. Never
+reuse a graph from a different framework version simply because the module name
+matches.
+
+The complete aggregate is approximately 120 MB unpacked but about 6 MB
+compressed. Resolve it once per framework version and share the cache between
+projects rather than copying it into every workspace.
\ No newline at end of file
diff --git a/CODEGRAPH_FRAMEWORK_DEVELOPMENT.md
b/CODEGRAPH_FRAMEWORK_DEVELOPMENT.md
new file mode 100644
index 0000000000..17e50cb7a3
--- /dev/null
+++ b/CODEGRAPH_FRAMEWORK_DEVELOPMENT.md
@@ -0,0 +1,190 @@
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+
+# Code Graphs for Framework Developers
+
+## What a Code Graph Is
+
+A code graph is a deterministic, compiler-resolved JSON description of a
+module's public API for one target. It contains public classes, interfaces,
+package definitions, members, callable signatures, ASDoc, metadata, inheritance
+and implementation edges, resolved type references, and source provenance.
+Aggregate indexes add Maven dependencies, content hashes, and MXML namespace
and
+tag mappings.
+
+This is more reliable than parsing ActionScript or MXML source because the
+compiler has already resolved imports, external SWCs, visibility, inheritance,
+metadata, and conditional compilation. JavaScript and SWF graphs are separate,
+so tools see the API that actually exists for each target.
+
+Code graphs support editors, documentation generators, API browsers,
+compatibility checks, static analysis, and AI-assisted development. They are
+public declaration and type graphs, not runtime call graphs or method-body
+dependency graphs. They are build metadata and are not linked into SWCs or
+deployed applications.
+
+## Maven Lifecycle
+
+Code graph generation is bound to `prepare-package` for every module under
+`frameworks/projects`. A normal Maven build generates the JavaScript graph. The
+`option-with-swf` profile generates both JavaScript and SWF graphs.
+
+```bash
+./mvnw prepare-package
+./mvnw -Poption-with-swf prepare-package
+```
+
+Module shards are written to:
+
+```text
+frameworks/projects/<module>/target/codegraph/<js|swf>/<module>.json
+```
+
+When `with-distribution` is active, Maven also creates and verifies the
+aggregate classifier:
+
+```bash
+./mvnw -Pwith-distribution verify
+./mvnw -Pwith-distribution,option-with-swf verify
+```
+
+The attached artifact is:
+
+```text
+org.apache.royale.framework:distribution:zip:codegraphs:<version>
+```
+
+Use `-Droyale.skipCodeGraph=true` for a local build that intentionally skips
+generation. Release and CI builds should not use this override.
+
+## Ant Lifecycle
+
+The Ant build requires `ROYALE_COMPILER_HOME` to point to a compiler containing
+`lib/codegraph.jar`. Set `AIR_HOME` to generate SWF graphs; without it, the
+framework driver generates JavaScript graphs only.
+
+From the repository root, generate all available module graphs and the
aggregate
+index with one command:
+
+```bash
+ant codegraphs
+```
+
+The Ant binary release targets invoke `codegraphs` automatically before
+packaging:
+
+```bash
+ant binary-release
+ant binary-release-noclean
+```
+
+The equivalent framework-level commands are:
+
+```bash
+ant -f frameworks/build.xml codegraphs
+ant -f frameworks/build.xml validate-codegraphs
+ant -f frameworks/build.xml codegraph-index
+```
+
+Generate or validate one module while developing it:
+
+```bash
+ant -Dcodegraph.module=Basic -f frameworks/build.xml codegraph
+ant -Dcodegraph.module=Basic -f frameworks/build.xml validate-codegraph
+ant -Dcodegraph.module=Basic -f frameworks/build.xml
validate-codegraph-determinism
+```
+
+`codegraphs` writes module shards beneath
+`frameworks/projects/<module>/target/codegraph`. `codegraph-index` validates
the
+available target set, copies the shards to `frameworks/target/codegraphs`, and
+writes `index.json` and `mxml.json`.
+
+## Standalone Command Line
+
+The binary compiler distribution provides `bin/codegraph` and
+`bin/codegraph.bat`; the SDK compiler is normally under `js/bin`. The scripts
+invoke `lib/codegraph.jar` and pass through normal compiler arguments.
+
+```bash
+$ROYALE_COMPILER_HOME/bin/codegraph \
+ -load-config=/path/to/compile-config.xml \
+ -compiler.define+=COMPILE::JS,true \
+ -compiler.define+=COMPILE::SWF,false \
+ -keep-asdoc=true \
+ -output=target/codegraph/js/MyLibrary.json
+```
+
+For SWF, reverse the two defines and use the SWF compiler configuration and
+output directory. The most relevant arguments are:
+
+| Argument | Purpose |
+| --- | --- |
+| `-load-config=<file>` | Loads the project's normal compiler configuration.
Use `+=` to append another config. |
+| `-output=<file>` | Sets the JSON output file. The default is
`codegraph.json`, or `<target>.codegraph.json` when a target file is supplied. |
+| `-compiler.define+=COMPILE::JS,<boolean>` | Selects JavaScript conditional
declarations. |
+| `-compiler.define+=COMPILE::SWF,<boolean>` | Selects SWF conditional
declarations and the graph target label. |
+| `-include-sources+=<path>` | Adds source files or directories when no
positional target file supplies the roots. |
+| `-include-classes+=<qualified-name>` | Includes configured top-level classes
using normal SWC target semantics. |
+| `-keep-asdoc=true` | Preserves parsed ASDoc descriptions and tags. |
+| `-create-target-with-errors=true` | Allows output after compiler errors;
omit this for normal validation and release builds. |
+
+A positional source file may be supplied after the options. Its base name is
+used as the graph's module name. Without a positional target, the output file's
+base name becomes the module name.
+
+## Aggregate Layout
+
+The aggregate is staged at `frameworks/target/codegraphs` and contains:
+
+```text
+index.json
+mxml.json
+<version>/<module>/<target>/<module>.json
+```
+
+`index.json` records module coordinates, dependencies, available targets,
+counts, paths, and SHA-256 hashes. `mxml.json` maps namespace tags to graph
+symbols for each available target. A JS-only aggregate contains 39 files; a
+JS/SWF aggregate contains 76 files.
+
+Validate an extracted or staged aggregate independently:
+
+```bash
+node frameworks/scripts/verify-codegraph-package.js --root
<codegraph-directory>
+```
+
+## Adding or Changing Framework APIs
+
+1. Build the affected module and inspect both target graphs when the API is
+ target-specific.
+2. Check stable IDs, resolved type references, ASDoc, metadata, and MXML tags.
+3. Run the one-module determinism check.
+4. Run the full aggregate validation before merging changes that affect shared
+ base classes, manifests, or dependencies.
+
+Graph schema changes must follow the schema compatibility policy in the
+compiler repository. Update the model version, packaged schema, writer, and
+golden tests together.
+
+## Release Checks
+
+Release builds must use `option-with-swf`, verify the 76-file classifier, and
+confirm that the same aggregate is present under `frameworks/codegraphs` in the
+binary SDK and npm archives. Normal Apache checksum, signature, and RAT checks
+also apply.
\ No newline at end of file
diff --git a/README.md b/README.md
index 82e85e2af5..7ef4c0acec 100644
--- a/README.md
+++ b/README.md
@@ -261,46 +261,30 @@ Listing of `option-with-` profiles:
# Code Graphs
-Royale can generate deterministic JSON code graphs of the public framework API
for both JavaScript and SWF targets. The graphs contain public types and
members, ASDoc, metadata, inheritance and reference relationships,
target-specific APIs, Maven dependencies, and MXML tag mappings.
+A Royale code graph is a deterministic JSON description of the public API that
the compiler resolves for one target. It records classes, interfaces,
functions, members, signatures, ASDoc, metadata, inheritance, type references,
Maven dependencies, and MXML tag mappings. Separate JavaScript and SWF graphs
accurately represent conditional APIs.
-Generate and validate every framework module with Ant:
+Code graphs let editors, documentation generators, API browsers,
static-analysis tools, and AI-assisted development tools understand Royale
libraries without parsing source code or guessing how imports, inheritance,
metadata, or conditional compilation resolve. They describe declarations and
type relationships; they are not runtime call graphs and are not deployed with
applications.
+
+The standard Maven lifecycle generates JavaScript code graphs. Add
`option-with-swf` to generate both targets, and `with-distribution` to package
and verify the aggregate classifier:
```bash
-ant -f frameworks/build.xml codegraphs
-node frameworks/scripts/validate-codegraphs.js
+./mvnw prepare-package
+./mvnw -Poption-with-swf prepare-package
+./mvnw -Pwith-distribution,option-with-swf verify
```
-Generate one module, or only rebuild the aggregate indexes:
+Ant framework builds provide the same full and focused workflows. The root
`binary-release`, `binary-release-jenkins`, and `binary-release-noclean`
targets generate and package codegraphs automatically:
```bash
+ant codegraphs
+ant -f frameworks/build.xml codegraphs
ant -Dcodegraph.module=Basic -f frameworks/build.xml codegraph
+ant -Dcodegraph.module=Basic -f frameworks/build.xml validate-codegraph
+ant -Dcodegraph.module=Basic -f frameworks/build.xml
validate-codegraph-determinism
ant -f frameworks/build.xml codegraph-index
```
-The Maven build provides the same graphs through the opt-in `codegraphs`
profile. Include `option-with-swf` when building the framework modules so that
both target artifacts are available:
-
-```bash
-./mvnw -f frameworks/projects/pom.xml -Pcodegraphs,option-with-swf -DskipTests
prepare-package
-./mvnw -f distribution/pom.xml -Pcodegraphs -DskipTests verify
-```
-
-The distribution build attaches the graphs as:
-
-```text
-org.apache.royale.framework:distribution:zip:codegraphs:<version>
-```
-
-Binary SDK and npm distributions place the aggregate tree in
`frameworks/codegraphs`. The Maven classifier has the same tree at the archive
root. `index.json` lists module coordinates, target dependencies, shard paths,
counts, and SHA-256 hashes. `mxml.json` maps MXML namespaces and tags to graph
symbols. Graph shards use this layout:
-
-```text
-<version>/<module>/<js|swf>/<module>.json
-```
-
-To verify an extracted aggregate tree independently, run:
-
-```bash
-node frameworks/scripts/verify-codegraph-package.js --root <path-to-codegraphs>
-```
+See [Code Graphs for Framework Developers](CODEGRAPH_FRAMEWORK_DEVELOPMENT.md)
for generation, validation, and release procedures. See [Consuming Royale Code
Graphs](CODEGRAPH_CONSUMPTION.md) for SDK, npm, Maven, editor, and
application-tool integration.
# Using Royale
diff --git a/distribution/pom.xml b/distribution/pom.xml
index 6814ebf1a5..9fa04f6543 100644
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -45,7 +45,7 @@
<assembly.bin>bin-without-swf.xml</assembly.bin>
<assembly.dir>dir-without-swf.xml</assembly.dir>
<assembly.sdk-description>royale-sdk-description.xml</assembly.sdk-description>
-
<codegraphs.directory>${project.build.directory}/no-codegraphs</codegraphs.directory>
+
<codegraphs.directory>${project.build.directory}/codegraphs</codegraphs.directory>
</properties>
<modules>
@@ -207,6 +207,52 @@
</dependency>
</dependencies>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>3.1.0</version>
+ <executions>
+ <execution>
+ <id>stage-codegraphs</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <target>
+ <ant antfile="${project.basedir}/../frameworks/build.xml"
+ target="codegraph-index"
+ inheritAll="false">
+ <property name="codegraph.targets"
value="${royale.codegraph.targets}"/>
+ </ant>
+ <delete dir="${project.build.directory}/codegraphs"/>
+ <copy todir="${project.build.directory}/codegraphs">
+ <fileset
dir="${project.basedir}/../frameworks/target/codegraphs"/>
+ </copy>
+ </target>
+ </configuration>
+ </execution>
+ <execution>
+ <id>verify-codegraph-artifact</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <target>
+ <delete
dir="${project.build.directory}/codegraphs-verification"/>
+ <unzip
src="${project.build.directory}/${distributionFileName}-codegraphs.zip"
+
dest="${project.build.directory}/codegraphs-verification"/>
+ <exec executable="node" failonerror="true">
+ <arg
value="${project.basedir}/../frameworks/scripts/verify-codegraph-package.js"/>
+ <arg value="--root"/>
+ <arg
value="${project.build.directory}/codegraphs-verification"/>
+ </exec>
+ </target>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
@@ -223,6 +269,18 @@
</descriptors>
</configuration>
</execution>
+ <execution>
+ <id>attach-codegraphs</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/codegraphs.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
</executions>
</plugin>
</plugins>
@@ -675,78 +733,6 @@
</dependencies>
<profiles>
- <profile>
- <id>codegraphs</id>
- <properties>
-
<codegraphs.directory>${project.build.directory}/codegraphs</codegraphs.directory>
- </properties>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>3.1.0</version>
- <executions>
- <execution>
- <id>stage-codegraphs</id>
- <phase>prepare-package</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <target>
- <ant antfile="${project.basedir}/../frameworks/build.xml"
- target="codegraph-index"
- inheritAll="false"/>
- <copy todir="${project.build.directory}/codegraphs">
- <fileset
dir="${project.basedir}/../frameworks/target/codegraphs"/>
- </copy>
- </target>
- </configuration>
- </execution>
- <execution>
- <id>verify-codegraph-artifact</id>
- <phase>verify</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <target>
- <delete
dir="${project.build.directory}/codegraphs-verification"/>
- <unzip
src="${project.build.directory}/${distributionFileName}-codegraphs.zip"
-
dest="${project.build.directory}/codegraphs-verification"/>
- <exec executable="node" failonerror="true">
- <arg
value="${project.basedir}/../frameworks/scripts/verify-codegraph-package.js"/>
- <arg value="--root"/>
- <arg
value="${project.build.directory}/codegraphs-verification"/>
- </exec>
- </target>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-codegraphs</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <descriptors>
- <descriptor>src/main/assembly/codegraphs.xml</descriptor>
- </descriptors>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
<profile>
<id>apache-release</id>
<build>
diff --git a/frameworks/codegraphs.xml b/frameworks/codegraphs.xml
index e8ae15dac2..6013de3959 100644
--- a/frameworks/codegraphs.xml
+++ b/frameworks/codegraphs.xml
@@ -19,6 +19,8 @@
-->
<project name="codegraphs" default="codegraphs" basedir=".">
+ <property name="codegraph.targets" value="js,swf"/>
+
<property name="ROYALE_HOME" location=".."/>
<property file="${ROYALE_HOME}/env.properties"/>
<property environment="env"/>
@@ -112,6 +114,8 @@
<arg value="${basedir}/projects"/>
<arg value="--output"/>
<arg value="${basedir}/target/codegraphs"/>
+ <arg value="--targets"/>
+ <arg value="${codegraph.targets}"/>
</exec>
</target>
@@ -131,6 +135,8 @@
<arg value="${basedir}/scripts/validate-codegraphs.js"/>
<arg value="--root"/>
<arg value="${basedir}/projects"/>
+ <arg value="--targets"/>
+ <arg value="${codegraph.targets}"/>
</exec>
</target>
diff --git a/frameworks/projects/pom.xml b/frameworks/projects/pom.xml
index 2b0f370b54..a4b3596d65 100644
--- a/frameworks/projects/pom.xml
+++ b/frameworks/projects/pom.xml
@@ -94,7 +94,17 @@
<forceSwcExternalLibraryPath>true</forceSwcExternalLibraryPath>
<additionalCompilerOptions>${project.compiler.options}</additionalCompilerOptions>
<targets>${royale.targets}</targets>
+ <skipAS>${royale.skipAS}</skipAS>
</configuration>
+ <executions>
+ <execution>
+ <id>codegraphs</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>compile-codegraph</goal>
+ </goals>
+ </execution>
+ </executions>
</plugin>
</plugins>
</build>
@@ -122,27 +132,4 @@
</dependency>
</dependencies>
- <profiles>
- <profile>
- <id>codegraphs</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.royale.compiler</groupId>
- <artifactId>royale-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>codegraphs</id>
- <phase>prepare-package</phase>
- <goals>
- <goal>compile-codegraph</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
</project>
diff --git a/frameworks/scripts/generate-codegraph-index.js
b/frameworks/scripts/generate-codegraph-index.js
index 9692b98db3..c363ccfbd9 100644
--- a/frameworks/scripts/generate-codegraph-index.js
+++ b/frameworks/scripts/generate-codegraph-index.js
@@ -25,16 +25,22 @@ function parseArguments(args) {
const options = {
metadata: path.resolve(__dirname,
"../target/codegraph-index-metadata.tsv"),
root: path.resolve(__dirname, "../projects"),
- output: path.resolve(__dirname, "../target/codegraphs")
+ output: path.resolve(__dirname, "../target/codegraphs"),
+ targets: ["js", "swf"]
};
for (let index = 0; index < args.length; index++) {
const argument = args[index];
if (argument === "--metadata" || argument === "--root" || argument ===
"--output") {
options[argument.substring(2)] = path.resolve(args[++index]);
+ } else if (argument === "--targets") {
+ options.targets = args[++index].split(",");
} else {
throw new Error(`Unknown argument: ${argument}`);
}
}
+ if (options.targets.length === 0 || options.targets.some(target => target
!== "js" && target !== "swf")) {
+ throw new Error(`Unsupported codegraph targets:
${options.targets.join(",")}`);
+ }
return options;
}
@@ -110,10 +116,10 @@ function main() {
fs.rmSync(options.output, { recursive: true, force: true });
fs.mkdirSync(versionRoot, { recursive: true });
- const symbolsByTarget = { js: new Map(), swf: new Map() };
+ const symbolsByTarget = Object.fromEntries(options.targets.map(target =>
[target, new Map()]));
const indexModules = modules.map(module => {
const targets = {};
- ["js", "swf"].forEach(target => {
+ options.targets.forEach(target => {
const source = graphPath(options.root, module.name, target);
const contents = fs.readFileSync(source);
const graph = JSON.parse(contents.toString("utf8"));
@@ -139,7 +145,7 @@ function main() {
const mxmlTargets = {};
let unavailableTags = 0;
- ["js", "swf"].forEach(target => {
+ options.targets.forEach(target => {
mxmlTargets[target] = [];
modules.forEach(module => module.namespaces
.filter(namespace => namespaceSupportsTarget(namespace, target))
diff --git a/frameworks/scripts/verify-codegraph-package.js
b/frameworks/scripts/verify-codegraph-package.js
index 20c1ecad46..f5b5eda0b0 100644
--- a/frameworks/scripts/verify-codegraph-package.js
+++ b/frameworks/scripts/verify-codegraph-package.js
@@ -62,8 +62,10 @@ function main() {
if (!index.version || mxml.version !== index.version ||
!Array.isArray(index.modules)) {
throw new Error("Codegraph index versions are missing or
inconsistent");
}
- if (!mxml.targets || !Array.isArray(mxml.targets.js) ||
!Array.isArray(mxml.targets.swf)) {
- throw new Error("MXML index must contain JS and SWF target mappings");
+ const targets = mxml.targets && Object.keys(mxml.targets);
+ if (!targets || targets.length === 0 || targets.some(target =>
+ (target !== "js" && target !== "swf") ||
!Array.isArray(mxml.targets[target]))) {
+ throw new Error("MXML index must contain at least one supported target
mapping");
}
const expectedFiles = new Set(["index.json", "mxml.json"]);
@@ -73,7 +75,7 @@ function main() {
throw new Error(`Missing or duplicate module name:
${module.name}`);
}
moduleNames.add(module.name);
- ["js", "swf"].forEach(target => {
+ targets.forEach(target => {
const targetIndex = module.targets && module.targets[target];
if (!targetIndex || !targetIndex.path || !targetIndex.sha256) {
throw new Error(`${module.name} is missing its ${target} graph
index`);
diff --git a/pom.xml b/pom.xml
index 255070715c..fbc28b78db 100644
--- a/pom.xml
+++ b/pom.xml
@@ -60,6 +60,7 @@
<royale.targets>JSRoyale</royale.targets>
<royale.skipAS>true</royale.skipAS>
+ <royale.codegraph.targets>js</royale.codegraph.targets>
<royale.debug>true</royale.debug>
<repo.compiler.options />
@@ -409,6 +410,7 @@
<properties>
<royale.targets>SWF,JSRoyale</royale.targets>
<royale.skipAS>false</royale.skipAS>
+ <royale.codegraph.targets>js,swf</royale.codegraph.targets>
</properties>
<dependencies>
<dependency>