Skip to content

Commit

Permalink
use absolute paths
Browse files Browse the repository at this point in the history
  • Loading branch information
cmnrd committed Jul 14, 2022
1 parent 57acfaf commit 64a0b8a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ ${" |"..crate.dependencies.asIterable().joinToString("\n") { (name, spec

private fun CargoDependencySpec.toToml(): String = mutableMapOf<String, String>().apply {
if (version != null) this["version"] = version.asStringLiteral()
if (localPath != null) this["path"] = Paths.get(localPath).toString().asStringLiteral()
if (localPath != null) this["path"] = Paths.get(localPath).toAbsolutePath().toString().asStringLiteral()
if (features != null) this["features"] = features.map { it.asStringLiteral() }.joinWithCommas("[", "]")
if (gitRepo != null) this["git"] = gitRepo.asStringLiteral()
if (rev != null) this["rev"] = rev.asStringLiteral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ abstract class RustEmitterBase {
/** Name of the runtime crate that is in its Cargo.toml.*/
const val runtimeCrateFullName = "reactor_rt"
const val runtimeGitUrl = "https://github.com/lf-lang/reactor-rust.git"
const val runtimeLocalPath = "../reactor-rs"

/** Qualification prefix to refer to a member of the runtime library crate. */
const val rsRuntime = "::$runtimeCrateFullName"
Expand Down
2 changes: 1 addition & 1 deletion org.lflang/src/org/lflang/generator/rust/RustGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class RustGenerator(
true
)

val gen = RustModelBuilder.makeGenerationInfo(targetConfig, reactors, errorReporter)
val gen = RustModelBuilder.makeGenerationInfo(targetConfig, fileConfig, reactors, errorReporter)
val codeMaps: Map<Path, CodeMap> = RustEmitter.generateRustProject(fileConfig, gen)

if (targetConfig.noCompile || errorsOccurred()) {
Expand Down
10 changes: 6 additions & 4 deletions org.lflang/src/org/lflang/generator/rust/RustModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -412,15 +412,15 @@ object RustModelBuilder {
/**
* Given the input to the generator, produce the model classes.
*/
fun makeGenerationInfo(targetConfig: TargetConfig, reactors: List<Reactor>, errorReporter: ErrorReporter): GenerationInfo {
fun makeGenerationInfo(targetConfig: TargetConfig, fileConfig: RustFileConfig, reactors: List<Reactor>, errorReporter: ErrorReporter): GenerationInfo {
val reactorsInfos = makeReactorInfos(reactors)
// todo how do we pick the main reactor? it seems like super.doGenerate sets that field...
val mainReactor = reactorsInfos.lastOrNull { it.isMain } ?: reactorsInfos.last()


val dependencies = targetConfig.rust.cargoDependencies.toMutableMap()
dependencies.compute(RustEmitterBase.runtimeCrateFullName) { _, spec ->
computeDefaultRuntimeConfiguration(spec, targetConfig, errorReporter)
computeDefaultRuntimeConfiguration(spec, targetConfig, fileConfig, errorReporter)
}

return GenerationInfo(
Expand Down Expand Up @@ -448,8 +448,10 @@ object RustModelBuilder {
private fun computeDefaultRuntimeConfiguration(
userSpec: CargoDependencySpec?,
targetConfig: TargetConfig,
fileConfig: RustFileConfig,
errorReporter: ErrorReporter
): CargoDependencySpec {
val defaultRuntimePath = fileConfig.srcGenBasePath.resolve(RustGenerator.runtimeName).toString()
if (userSpec == null) {
// default configuration for the runtime crate

Expand All @@ -467,14 +469,14 @@ object RustModelBuilder {
spec.gitRepo = RustEmitterBase.runtimeGitUrl
spec.rev = userRtVersion
} else {
spec.localPath = RustEmitterBase.runtimeLocalPath
spec.localPath = defaultRuntimePath
}

return spec
} else {
if (userSpec.localPath == null && userSpec.gitRepo == null) {
// default the location
userSpec.localPath = RustEmitterBase.runtimeLocalPath
userSpec.localPath = defaultRuntimePath
}

// override location
Expand Down

0 comments on commit 64a0b8a

Please sign in to comment.