Skip to content

Commit

Permalink
Refactor string formatting a little
Browse files Browse the repository at this point in the history
  • Loading branch information
erlingrj committed Feb 4, 2025
1 parent 22a2d2b commit baf2922
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ abstract class UcMakeGenerator(private val mainTarget: String, private val numEv
|REACTION_QUEUE_SIZE = ${max(numReactions, 1)}
|EVENT_QUEUE_SIZE = ${max(numEvents, 2)}
|
|
""".trimMargin()
}
}
Expand All @@ -43,15 +42,16 @@ class UcMakeGeneratorFederated(private val federate: UcFederate, targetConfig: T
: UcMakeGenerator(federate.codeType, numEvents, numReactions) {
override fun generateMake(sources: List<Path>): String {
val channelTypes = federate.interfaces.map { it.type }.toSet()

return """
${"|"..doGenerateMake(sources, federate.getCompileDefs())}
${channelTypes.map { when (it) {
val channelTypesCompileDefs = channelTypes.joinWithLn { when(it) {
NetworkChannelType.TCP_IP -> "|CFLAGS += -DNETWORK_CHANNEL_TCP_RIOT"
NetworkChannelType.COAP_UDP_IP -> "|CFLAGS += -DNETWORK_CHANNEL_COAP_RIOT" //TODO: Abstract RIOT away!
NetworkChannelType.NONE -> ""
NetworkChannelType.CUSTOM -> ""
}}.joinWithLn { it }}
} }

return """
|${doGenerateMake(sources, federate.getCompileDefs())}
|${channelTypesCompileDefs}
""".trimMargin()
}
}

0 comments on commit baf2922

Please sign in to comment.