Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into zepyhr-kconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
erlingrj committed Apr 12, 2024
2 parents bb445c0 + 2179837 commit 3a64507
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 48 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/lsp-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ jobs:
path: ~/.pnpm-store
key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('core/src/main/resources/lib/ts/package.json') }}
- name: Setup Rust
uses: ATiltedTree/setup-rust@v1
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
rust-version: nightly
toolchain: stable
components: clippy
rustflags: "" # don't use -D warnings
- name: Install Dependencies Ubuntu
run: |
sudo apt-get install libprotobuf-dev protobuf-compiler libprotobuf-c-dev protobuf-c-compiler
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/rs-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,22 @@ jobs:
if: inputs.runtime-ref
- name: Setup Rust
id: rustup
uses: ATiltedTree/setup-rust@v1
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
rust-version: ${{ matrix.rust }}
toolchain: ${{ matrix.rust }}
components: clippy
rustflags: "" # don't use -D warnings
continue-on-error: true
- name: Delete rustup cache
run: rm -r ~/.rustup
if: ${{ steps.rustup.outcome }} != "success"
- name: Setup Rust (again)
if: ${{ steps.rustup.outcome }} != "success"
uses: ATiltedTree/setup-rust@v1
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
rust-version: ${{ matrix.rust }}
toolchain: ${{ matrix.rust }}
components: clippy
rustflags: "" # don't use -D warnings
- name: Run Rust tests
run: ./gradlew targetTest -Ptarget=Rust
- name: Report to CodeCov
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public boolean doGenerate(Resource resource, LFGeneratorContext context) throws
});

context.finish(Status.COMPILED, codeMapMap);
return false;
return context.getErrorReporter().getErrorsOccurred();
}

/**
Expand All @@ -218,9 +218,14 @@ private void buildUsingDocker(LFGeneratorContext context, List<SubContext> subCo
dockerGen.writeDockerComposeFile(createDockerFiles(context, subContexts));
if (dockerGen.build()) {
dockerGen.createLauncher();
} else {
context.getErrorReporter().nowhere().error("Docker build failed.");
}
} catch (IOException e) {
context.getErrorReporter().nowhere().error("Unsuccessful Docker build.");
context
.getErrorReporter()
.nowhere()
.error("Docker build failed due to invalid file system state.");
}
}

Expand All @@ -237,8 +242,7 @@ private void prepareRtiBuildEnvironment(LFGeneratorContext context) {
try {
Files.createDirectories(dest);
// 2. Copy reactor-c source files into it
FileUtil.copyFromClassPath("/lib/c/reactor-c/core", dest, true, false);
FileUtil.copyFromClassPath("/lib/c/reactor-c/include", dest, true, false);
FileUtil.copyFromClassPath("/lib/c/reactor-c", dest, true, true);
// 3. Generate a Dockerfile for the rti
new RtiDockerGenerator(context).generateDockerData(dest).writeDockerFile();
} catch (IOException e) {
Expand Down
11 changes: 9 additions & 2 deletions core/src/main/java/org/lflang/generator/c/CGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,10 @@ public void doGenerate(Resource resource, LFGeneratorContext context) {
context.getMode());
context.finish(GeneratorResult.Status.COMPILED, null);
} else if (dockerBuild.enabled()) {
buildUsingDocker();
boolean success = buildUsingDocker();
if (!success) {
context.unsuccessfulFinish();
}
} else {
var cleanCode = code.removeLines("#line");
var cCompiler = new CCompiler(targetConfig, fileConfig, messageReporter, cppMode);
Expand Down Expand Up @@ -557,7 +560,7 @@ public void doGenerate(Resource resource, LFGeneratorContext context) {
}

/** Create Dockerfiles and docker-compose.yml, build, and create a launcher. */
private void buildUsingDocker() {
private boolean buildUsingDocker() {
// Create docker file.
var dockerCompose = new DockerComposeGenerator(context);
var dockerData = getDockerGenerator(context).generateDockerData();
Expand All @@ -568,9 +571,13 @@ private void buildUsingDocker() {
throw new RuntimeException("Error while writing Docker files", e);
}
var success = dockerCompose.build();
if (!success) {
messageReporter.nowhere().error("Docker-compose build failed.");
}
if (success && mainDef != null) {
dockerCompose.createLauncher();
}
return success;
}

private void generateCodeFor(String lfModuleName) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ public void createLauncher() {
var fileConfig = context.getFileConfig();
var packageRoot = fileConfig.srcPkgPath;
var srcGenPath = fileConfig.getSrcGenPath();
var file = fileConfig.binPath.resolve(fileConfig.name).toFile();
var binPath = fileConfig.binPath;
FileUtil.createDirectoryIfDoesNotExist(binPath.toFile());
var file = binPath.resolve(fileConfig.name).toFile();
var script =
"""
#!/bin/bash
Expand All @@ -142,7 +144,9 @@ public void createLauncher() {
writer.write(script);
writer.close();
} catch (IOException e) {
messageReporter.nowhere().warning("Unable to write launcher to: " + file.getAbsolutePath());
messageReporter
.nowhere()
.warning("Unable to write launcher to " + file.getAbsolutePath() + " with error: " + e);
}

if (!file.setExecutable(true, false)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package org.lflang.generator.docker;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.stream.Collectors;
import org.lflang.generator.LFGeneratorContext;

/**
Expand All @@ -15,24 +19,12 @@ public RtiDockerGenerator(LFGeneratorContext context) {

@Override
protected String generateDockerFileContent() {
return """
# Docker file for building the image of the rti
FROM %s
COPY core /reactor-c/core
COPY include /reactor-c/include
WORKDIR /reactor-c/core/federated/RTI
%s
RUN rm -rf build && \\
mkdir build && \\
cd build && \\
cmake ../ && \\
make && \\
make install
# Use ENTRYPOINT not CMD so that command-line arguments go through
ENTRYPOINT ["RTI"]
"""
.formatted(baseImage(), generateRunForBuildDependencies());
InputStream stream =
RtiDockerGenerator.class.getResourceAsStream(
"/lib/c/reactor-c/core/federated/RTI/rti.Dockerfile");
return new BufferedReader(new InputStreamReader(stream))
.lines()
.collect(Collectors.joining("\n"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public TSDockerGenerator(LFGeneratorContext context) {
/** Return the content of the docker file for [tsFileName]. */
public String generateDockerFileContent() {
return """
|FROM %s
|WORKDIR /linguafranca/$name
|%s
|COPY . .
|ENTRYPOINT ["node", "dist/%s.js"]
FROM %s
WORKDIR /linguafranca/$name
%s
COPY . .
ENTRYPOINT ["node", "dist/%s.js"]
"""
.formatted(baseImage(), generateRunForBuildDependencies(), context.getFileConfig().name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ ${" |"..gen.crate.modulesToIncludeInMain.joinWithLn { "mod ${it.fileName
|
|struct CliParseResult(SchedulerOptions, __MainParams, LevelFilter);
|
|const DEFAULT_LOG_LEVEL: LevelFilter = LevelFilter::Warn;
|
|fn main() {
| let CliParseResult(options, main_args, log_level) = cli::parse();
|
Expand Down Expand Up @@ -139,7 +137,7 @@ ${" | "..mainReactor.ctorParams.joinWithCommasLn { (it.default
| );
|
| let level_by_env = std::env::var("RUST_LOG").ok().and_then(|e| e.as_str().parse::<::log::LevelFilter>().ok());
| let log_level = level_by_env.unwrap_or(DEFAULT_LOG_LEVEL);
| let log_level = level_by_env.unwrap_or(LevelFilter::Warn);
|
| CliParseResult(options, main_args, log_level)
| }
Expand Down
14 changes: 7 additions & 7 deletions core/src/testFixtures/java/org/lflang/tests/TestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,13 @@ private void prepare(LFTest test, Transformer transformer, Configurator configur
FileConfig.findPackageRoot(test.getSrcPath(), s -> {})
.resolve(FileConfig.DEFAULT_SRC_GEN_DIR)
.toString());

// Update the test by applying the transformation.
if (transformer != null) {
if (!transformer.transform(resource)) {
throw new TestError("Test transformation unsuccessful.", Result.TRANSFORM_FAIL);
}
}
var context =
new MainContext(
LFGeneratorContext.Mode.STANDALONE,
Expand All @@ -391,13 +398,6 @@ private void prepare(LFTest test, Transformer transformer, Configurator configur
fileAccess,
fileConfig -> new DefaultMessageReporter());

// Update the test by applying the transformation.
if (transformer != null) {
if (!transformer.transform(resource)) {
throw new TestError("Test transformation unsuccessful.", Result.TRANSFORM_FAIL);
}
}

// Reload the context because properties may have changed as part of the transformation.
test.loadContext(context);

Expand Down

0 comments on commit 3a64507

Please # to comment.