Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend export tests #105

Open
wants to merge 10 commits into
base: mps2021.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,31 @@ task<Jar>("javadocJar") {
archiveClassifier.set("javadoc")
}

task<Exec>("testCmdlineExport-library") {
task<Exec>("testCmdLineExport-library") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these work (on unix machines)? I think I never tried ...

Copy link
Contributor Author

@dslmeinte dslmeinte Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They do run. In CI not to completion, though — see /~https://github.com/LionWeb-io/lionweb-mps/actions/runs/11139777271/job/30957126805?pr=106 —, but that's another problem. (Locally, they run — at least, for me.)

workingDir("./test-project")
commandLine("./test-scripts/export-library.sh")
commandLine("./scripts/export-library.sh")
}

task<Exec>("testCmdlineExport-multiple") {
task<Exec>("testCmdLineExport-multiple") {
workingDir("./test-project")
commandLine("./test-scripts/export-multiple.sh")
commandLine("./scripts/export-multiple.sh")
}

task<Exec>("testCmdLineExport-foo") {
workingDir("./test-project")
commandLine("./scripts/export-foo.sh")
}

task<Exec>("testCmdLineExport-DependsOnMpsExtension") {
workingDir("./test-project-externalLib")
commandLine("./scripts/export-DependsOnMpsExtensions.sh")
}

task("testCmdLineExport") {
dependsOn("testCmdlineExport-library")
dependsOn("testCmdlineExport-multiple")
dependsOn("testCmdLineExport-library")
dependsOn("testCmdLineExport-multiple")
dependsOn("testCmdLineExport-foo")
dependsOn("testCmdLineExport-DependsOnMpsExtension")
}


Expand Down
37 changes: 37 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2867,6 +2867,43 @@
<zipfileset file="${lionweb-mps.home}/solutions/io.lionweb.mps.json.test.support/io.lionweb.mps.json.test.support.msd" prefix="module" />
<zipfileset dir="${build.tmp}/customProcessors/copyModels/solutions-io.lionweb.mps.json.test.support-models" prefix="module/models" />
</jar>
<mkdir dir="${build.tmp}/default/io.lionweb.mps.build.jar" />
<mkdir dir="${build.tmp}/default/io.lionweb.mps.build.jar/META-INF" />
<echoxml file="${build.tmp}/default/io.lionweb.mps.build.jar/META-INF/module.xml">
<module namespace="io.lionweb.mps.build" type="solution" uuid="bf3c8943-8801-4969-9ac2-7403444bbefa">
<dependencies>
<module ref="422c2909-59d6-41a9-b318-40e6256b250f(jetbrains.mps.ide.build)" kind="cl" />
</dependencies>
<uses>
<language id="l:798100da-4f0a-421a-b991-71f8c50ce5d2:jetbrains.mps.build" />
<language id="l:0cf935df-4699-4e9c-a132-fa109541cba3:jetbrains.mps.build.mps" />
<language id="l:3600cb0a-44dd-4a5b-9968-22924406419e:jetbrains.mps.build.mps.tests" />
<language id="l:ceab5195-25ea-4f22-9b92-103b95ca8c0c:jetbrains.mps.lang.core" />
</uses>
<classpath>
<entry path="." />
</classpath>
<sources jar="io.lionweb.mps.build-src.jar" descriptor="io.lionweb.mps.build.msd" />
</module>
</echoxml>
<jar destfile="${build.layout}/io.lionweb.mps.build.jar" duplicate="preserve">
<fileset dir="${build.tmp}/java/out/io.lionweb.mps.build" />
<fileset dir="${lionweb-mps.home}/solutions/io.lionweb.mps.build/source_gen" includes="**/trace.info, **/exports, **/*.mps, **/checkpoints" />
<fileset dir="${build.tmp}/default/io.lionweb.mps.build.jar" />
</jar>
<copyModels todir="${build.tmp}/customProcessors/copyModels/solutions-io.lionweb.mps.build-models">
<fileset dir="${lionweb-mps.home}/solutions/io.lionweb.mps.build/models" includes="**/*.mps, **/*.mpsr, **/.model" />
</copyModels>
<jar destfile="${build.layout}/io.lionweb.mps.build-src.jar" duplicate="preserve">
<fileset dir="${lionweb-mps.home}/solutions/io.lionweb.mps.build/source_gen">
<exclude name="**/trace.info" />
<exclude name="**/exports" />
<exclude name="**/checkpoints" />
<exclude name="**/*.mps" />
</fileset>
<zipfileset file="${basedir}/solutions/io.lionweb.mps.build/io.lionweb.mps.build.msd" prefix="module" />
<zipfileset dir="${build.tmp}/customProcessors/copyModels/solutions-io.lionweb.mps.build-models" prefix="module/models" />
</jar>
<mkdir dir="${build.tmp}/default/io.lionweb.mps.lang.test.jar" />
<mkdir dir="${build.tmp}/default/io.lionweb.mps.lang.test.jar/META-INF" />
<echoxml file="${build.tmp}/default/io.lionweb.mps.lang.test.jar/META-INF/module.xml">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@
<ref role="m_rDy" node="3RxvfZg815U" resolve="io.lionweb.mps.tests.contributions" />
<node concept="pUk6x" id="24OSoZ60eqB" role="pUk7w" />
</node>
<node concept="L2wRC" id="2yij8JWwvCz" role="39821P">
<ref role="L2wRA" node="oIR8hQg5OW" resolve="io.lionweb.mps.build" />
</node>
<node concept="L2wRC" id="24OSoZ61CZr" role="39821P">
<ref role="L2wRA" node="24OSoZ5UmCW" resolve="io.lionweb.mps.lang.test" />
</node>
Expand Down
38 changes: 30 additions & 8 deletions solutions/io.lionweb.mps.cmdline/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# LionWeb MPS Command-Line Language Exporter
# LionWeb MPS Command Line Exporter

## Usage
Gradle requires some workarounds to pass arguments, so we have to wrap our command-line arguments in `-Pargs`:
Expand Down Expand Up @@ -38,6 +38,13 @@ usage: lionweb-export-language <project-dir> [<config-file>] <output-file>

* _scope:_ Defines the export [scope as explained for converter languages](../../docs/reference/converter-lang.adoc#language-json-export).

**Note** that we assume that your to-be-exported languages are built within MPS, i.e. have resulted in files in `classes_gen/` directories, and MPS doesn't show “(generation required)” next to the language module(s).
This also requires that the required external dependencies are downloaded first.
This is typically done by running the Gradle `resolveGenerationDependencies` task, as follows:

```shell
./gradlew resolveGenerationDependencies
```

### Examples

Expand Down Expand Up @@ -75,20 +82,35 @@ Contents of `config-file.json`:

#### Test exports

The directory `test-project/` can be used to test the command-line exporter.
Run
The directories `test-project/` and `test-project-externalLib` contain MPS projects that can be used to test the command-line exporter.

Within `test-project/`, run

```shell
source scripts/export-library.sh
source scripts/export-multiple.sh
source scripts/export-foo.sh
```

(or a similar incantation suitable for your OS and shell) to export three example languages, and compare the exports to the reference exports in `expected/`.
The languages' exports end up in the `actual/` directory.
The `FooLanguage` language resides within the project, but the `library` and `multi` language are bundled.
The `export-multiple.sh` script also demonstrates the use of a JSON configuration file — in this case [`export-multiple.config.json`](../../test-project/export-multiple.config.json).

Within `test-project-externalLib`, run

dslmeinte marked this conversation as resolved.
Show resolved Hide resolved
```shell
source test-scripts/export-library.sh
source test-scripts/export-multiple.sh
source scripts/export-DependsOnMpsExtensions.sh
source scripts/export-foo.sh
```

to export two example languages, and compare the exports to the reference exports in `test-references/`.
(or a similar incantation suitable for your OS and shell) to export two example languages in the same way as in the `test-project`.
The `FooLanguage` language resides within the `test-project/` MPS project, and the `DependsOnMpsExtensions` depends on the `de.slisson.mps.richtext` language from the MPS extensions.


## Setup

We assume the MPS project that contains your to-be-exported languages is built with gradle.
We assume the MPS project that contains your to-be-exported languages is built with Gradle.

Create or adjust the following contents of `build.gradle.kts` (Kotlin dialect):

Expand Down Expand Up @@ -172,4 +194,4 @@ All contents of package `io.lionweb.mps.cmdline` run _outside MPS classloaders_.
Once we pass _into MPS_, we're using contents of package `io.lionweb.mps.cmdline.cmd`.

Outside and while crossing the boundary, we can only use classes that originate from _common_ classloaders.
This includes Java standard library and core MPS, and excludes all LionWeb classes.
This includes Java standard library and core MPS, and excludes all LionWeb classes.
9 changes: 9 additions & 0 deletions test-project-externalLib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Ignore Gradle project-specific cache directory
/.gradle/

# Ignore Gradle build output directory
/build/

# Ignore downloaded dependencies
/dependencies/

3 changes: 3 additions & 0 deletions test-project-externalLib/.mps/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml
25 changes: 25 additions & 0 deletions test-project-externalLib/.mps/libraries.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectLibraryManager">
<option name="libraries">
<map>
<entry key="LionWeb">
<value>
<Library>
<option name="name" value="lionweb-mps.home" />
<option name="path" value="$PROJECT_DIR$/build/dependencies/io.lionweb.mps" />
</Library>
</value>
</entry>
<entry key="mpsExtensions">
<value>
<Library>
<option name="name" value="mpsExtensions" />
<option name="path" value="$PROJECT_DIR$/build/dependencies/de.itemis.mps.extensions" />
</Library>
</value>
</entry>
</map>
</option>
</component>
</project>
9 changes: 9 additions & 0 deletions test-project-externalLib/.mps/modules.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MPSProject">
<projectModules>
<modulePath path="$PROJECT_DIR$/languages/DependsOnMpsExtensions/DependsOnMpsExtensions.mpl" folder="" />
<modulePath path="$PROJECT_DIR$/solutions/testProjectExternalLib.build/testProjectExternalLib.build.msd" folder="" />
</projectModules>
</component>
</project>
6 changes: 6 additions & 0 deletions test-project-externalLib/.mps/vcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
3 changes: 3 additions & 0 deletions test-project-externalLib/actual/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Test files
/*.lw-lang.json

56 changes: 56 additions & 0 deletions test-project-externalLib/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// based on /~https://github.com/specificlanguages/mps-gradle-plugin-sample

plugins {
id("com.specificlanguages.mps")
`maven-publish`
}

val mpsVersionSuffix: String by project
val lionwebRelease: String by project
val mpsVersion: String by project
val lionwebVersion: String by project
val mpsExtensionsVersion: String by project

repositories {
mavenLocal()
maven(url = "https://artifacts.itemis.cloud/repository/maven-mps")
mavenCentral()
}

dependencies {
"mps"("com.jetbrains:mps:$mpsVersion")
"generation"("io.lionweb.lionweb-mps:lionweb-mps-$mpsVersionSuffix-lw$lionwebRelease:$lionwebVersion")
"generation"("de.itemis.mps:extensions:$mpsExtensionsVersion")
}

tasks.assembleMps {
antProperties.putAll(antProperties.get())
antProperties.put("mps-extensions.home", "${projectDir.resolve("build/dependencies/de.itemis.mps.extensions")}")
}

task<JavaExec>("runCommandLineTool") {
dependsOn("resolveGenerationDependencies")

val mpsHome = configurations
.getByName("mps")
.incoming
.artifactView { attributes.attribute(Attribute.of("artifactType", String::class.java), "unzipped-mps-distribution") }
.files
.elements
.map { it.single().asFile }
.get()
project.logger.info("mpsHome: $mpsHome")
val cmdLinePath = "build/dependencies/io.lionweb.mps/io.lionweb.mps.cmdline/languages/lionweb-mps.cmdline/io.lionweb.mps.cmdline.jar"
project.logger.info("cmdLinePath: $cmdLinePath")
classpath(
file(cmdLinePath), // Location of CommandLineTool.class
fileTree("$mpsHome/lib") // $mps_home points to the MPS installation
)
mainClass.set("io.lionweb.mps.cmdline.CommandLineTool")

val propArgs: String? = project.findProperty("args") as String?
project.logger.info("propArgs: $propArgs")
if (propArgs != null) {
setArgsString(propArgs)
}
}
Loading
Loading