Skip to content

Commit 35c0b68

Browse files
Change/Remove Properties to annotation (#341)
* Changed properties to Annotation Timout Logging ClockSync - Changed TimoutProperty to Annotation - Changed Logging Property to Annotation - Chnaged ClockSync Property to Annotation * Removed Properties The following properties are removed - BuildTypeProperty - PlatformProperty - NoCompileProperty - FilesProperty - CmakeIncludeProperty * Update test from properties to attributes - Added more platform types as attribute - Updated test from properties to attributes * Updated Tests and Benchmark from properties to attributes * Update keepalive to boolean attribute * Revert Format Changes * Fix merge error * Update tests for RIOT,PATMOS,Fed examples -Fix changes for failing tests * Make format * Fix for review comments * removing a lot more target properties * removing all target properties * add build_type annotation * more stuff * fix is compiled --------- Co-authored-by: tanneberger <github@tanneberger.me>
1 parent ef57a23 commit 35c0b68

252 files changed

Lines changed: 1064 additions & 5005 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ a CMake project and compile it natively. E.g.
3737

3838
```sh
3939
cat > HelloWorld.lf << EOF
40-
target uC {
41-
platform: Native
42-
}
40+
target uC
4341
42+
@platform("native")
4443
main reactor {
4544
reaction(startup) {=
4645
printf("Hello World!\n");

benchmarks/src/PingPongUc.lf

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@
1818
*
1919
* @author Edward A. Lee
2020
*/
21-
target uC {
22-
platform: Native,
23-
fast: true,
24-
build-type: Release
25-
}
21+
target uC
2622

2723
import BenchmarkRunner from "./BenchmarkRunnerUc.lf"
2824

@@ -68,6 +64,8 @@ reactor Pong(expected: size_t = 1000000) {
6864
=}
6965
}
7066

67+
@platform("Native")
68+
@fast(true)
7169
main reactor
7270
{
7371
runner = new BenchmarkRunner(num_iterations=12);
@@ -79,4 +77,4 @@ main reactor
7977
ping.finished -> pong.finish;
8078
ping.send -> pong.receive;
8179
pong.send -> ping.receive;
82-
}
80+
}

benchmarks/src/ReactionLatencyUc.lf

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
target uC {
2-
build-type: Release,
3-
platform: Native,
4-
}
1+
target uC
52

63

74
reactor LatencyProbe(num_iterations: size_t = 10000){
@@ -41,7 +38,7 @@ preamble {=
4138
=}
4239
}
4340

44-
41+
@platform("Native")
4542
main reactor {
4643
probe = new LatencyProbe(num_iterations=10000);
47-
}
44+
}

examples/flexpret/src/Smoke.lf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
target uC {
2-
platform: FlexPRET
3-
}
1+
target uC
42

53
reactor R1 {
64
output out: int
@@ -23,8 +21,9 @@ reactor R2 {
2321
=}
2422
}
2523

24+
@platform("flexpret")
2625
main reactor {
2726
r1 = new R1()
2827
r2 = new R2()
2928
r1.out -> r2.in
30-
}
29+
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
target uC {
2-
platform: Patmos
3-
}
1+
target uC
42

3+
@platform("Patmos")
54
main reactor {
65
reaction(startup) {=
76
printf("Hello LF on PATMOS!\n");
87
=}
9-
}
8+
}

examples/patmos/s4noc_fed_lf/src/S4NoCFedLF.lf

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
target uC {
2-
platform: PATMOS,
3-
clock-sync: OFF,
4-
keepalive: true,
5-
build-type: debug,
6-
timeout: 120 sec
7-
}
1+
target uC
82

93
reactor Src(id: int = 0) {
104
output out: int
@@ -47,6 +41,10 @@ reactor Dst {
4741
=}
4842
}
4943

44+
@platform("PATMOS")
45+
@clock_sync("off")
46+
@keepalive(true)
47+
@timeout(120s)
5048
federated reactor {
5149
@interface_s4noc(core=2)
5250
r1 = new Src(id=42)

examples/riot/coap_federated_lf/src/CoapFederatedLF.lf

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
target uC {
2-
platform: RIOT,
3-
timeout: 1sec
4-
}
1+
target uC
52

63
reactor Src(id: int = 0) {
74
output out: int
@@ -29,6 +26,8 @@ reactor Dst {
2926
=}
3027
}
3128

29+
@platform("RIOT")
30+
@timeout(1s)
3231
federated reactor {
3332
@interface_coap(name="if1", address="fe80::44e5:1bff:fee4:dac8")
3433
r1 = new Src(id=42)
@@ -38,4 +37,4 @@ federated reactor {
3837

3938
@link(left="if1", right="if1")
4039
r1.out -> r2.in
41-
}
40+
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
target uC {
2-
platform: RIOT
3-
}
1+
target uC
42

3+
@platform("RIOT")
54
main reactor {
65
reaction(startup) {=
76
printf("Hello from LF my!\n");
87
=}
9-
}
8+
}

lfc/cli/lfc/src/main/java/org/lflang/cli/Lfc.java

Lines changed: 1 addition & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,9 @@
1111
import org.eclipse.xtext.util.CancelIndicator;
1212
import org.lflang.FileConfig;
1313
import org.lflang.ast.ASTUtils;
14-
import org.lflang.generator.Argument;
1514
import org.lflang.generator.GeneratorArguments;
1615
import org.lflang.generator.LFGeneratorContext;
1716
import org.lflang.generator.MainContext;
18-
import org.lflang.target.property.BuildTypeProperty;
19-
import org.lflang.target.property.NoCompileProperty;
20-
import org.lflang.target.property.type.BuildTypeType;
21-
import org.lflang.target.property.type.BuildTypeType.BuildType;
22-
import org.lflang.target.property.type.LoggingType;
23-
import org.lflang.target.property.type.LoggingType.LogLevel;
24-
import org.lflang.target.property.type.SchedulerType;
25-
import org.lflang.target.property.type.SchedulerType.Scheduler;
2617
import picocli.CommandLine.ArgGroup;
2718
import picocli.CommandLine.Command;
2819
import picocli.CommandLine.Option;
@@ -263,36 +254,6 @@ private Path getActualOutputPath(Path root, Path path) {
263254
}
264255
}
265256

266-
/**
267-
* Return a build type if one has been specified via the CLI arguments, or {@code null} otherwise.
268-
*/
269-
private BuildType getBuildType() {
270-
BuildType resolved = null;
271-
if (buildType != null) {
272-
// Validate build type.
273-
resolved = new BuildTypeType().forName(buildType);
274-
if (resolved == null) {
275-
reporter.printFatalErrorAndExit(buildType + ": Invalid build type.");
276-
}
277-
}
278-
return resolved;
279-
}
280-
281-
/**
282-
* Return a log level if one has been specified via the CLI arguments, or {@code null} otherwise.
283-
*/
284-
private LogLevel getLogging() {
285-
LogLevel resolved = null;
286-
if (logging != null) {
287-
// Validate log level.
288-
resolved = new LoggingType().forName(logging);
289-
if (resolved == null) {
290-
reporter.printFatalErrorAndExit(logging + ": Invalid log level.");
291-
}
292-
}
293-
return resolved;
294-
}
295-
296257
/**
297258
* Return a URI that points to the RTI if one has been specified via the CLI arguments, or {@code
298259
* null} otherwise.
@@ -309,19 +270,6 @@ private URI getRtiUri() {
309270
return uri;
310271
}
311272

312-
/** Return a scheduler one has been specified via the CLI arguments, or {@code null} otherwise. */
313-
private Scheduler getScheduler() {
314-
Scheduler resolved = null;
315-
if (scheduler != null) {
316-
// Validate scheduler.
317-
resolved = new SchedulerType().forName(scheduler);
318-
if (resolved == null) {
319-
reporter.printFatalErrorAndExit(scheduler + ": Invalid scheduler.");
320-
}
321-
}
322-
return resolved;
323-
}
324-
325273
/**
326274
* Return a URI that points to an external runtime if one has been specified via the CLI
327275
* arguments, or {@code null} otherwise.
@@ -334,31 +282,6 @@ private URI getExternalRuntimeUri() {
334282
return externalRuntimeUri;
335283
}
336284

337-
/**
338-
* Return tracing options if tracing has been explicitly disabled or enabled via the CLI
339-
* arguments, or {@code null} otherwise.
340-
*/
341-
342-
/** Return the single threaded mode has been specified, or {@code null} if none was specified. */
343-
private Boolean getSingleThreaded() {
344-
Boolean singleThreaded = null;
345-
// Set one of the mutually-exclusive threading options.
346-
if (threading != null) {
347-
singleThreaded = threading.singleThreaded;
348-
}
349-
return singleThreaded;
350-
}
351-
352-
/** Return the number of workers specified, or {@code null} if none was specified. */
353-
private Integer getWorkers() {
354-
Integer workers = null;
355-
// Set one of the mutually-exclusive threading options.
356-
if (threading != null) {
357-
workers = threading.workers;
358-
}
359-
return workers;
360-
}
361-
362285
/** Check the values of the commandline arguments and return them. */
363286
public GeneratorArguments getArgs() {
364287

@@ -372,8 +295,6 @@ public GeneratorArguments getArgs() {
372295
getRtiUri(),
373296
genFedTemplates != null,
374297
runtimeSymlink != null,
375-
List.of(
376-
new Argument<>(BuildTypeProperty.INSTANCE, getBuildType()),
377-
new Argument<>(NoCompileProperty.INSTANCE, noCompile)));
298+
List.of());
378299
}
379300
}

lfc/core/src/main/java/org/lflang/AttributeUtils.java

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import org.eclipse.emf.ecore.EObject;
1010
import org.lflang.ast.ASTUtils;
1111
import org.lflang.lf.*;
12-
import org.lflang.target.property.type.PlatformType;
12+
import org.lflang.target.PlatformType;
1313
import org.lflang.util.StringUtil;
1414

1515
/**
@@ -274,15 +274,48 @@ public static void setEnclaveAttribute(Instantiation node) {
274274
}
275275
}
276276

277-
public static PlatformType.Platform getFederatePlatform(Instantiation node) {
277+
// public static PlatformType.Platform getFederatePlatform(EObject node) {
278+
public static PlatformType.Platform getPlatform(EObject node) {
278279
if (findAttributeByName(node, "platform_native") != null) {
279280
return PlatformType.Platform.NATIVE;
280281
} else if (findAttributeByName(node, "platform_riot") != null) {
281282
return PlatformType.Platform.RIOT;
282283
} else if (findAttributeByName(node, "platform_zephyr") != null) {
283284
return PlatformType.Platform.ZEPHYR;
284285
} else {
285-
return PlatformType.Platform.AUTO;
286+
Attribute attr = findAttributeByName(node, "platform");
287+
if (attr != null) {
288+
switch (StringUtil.removeQuotes(attr.getAttrParms().get(0).getValue()).toUpperCase()) {
289+
case "NATIVE":
290+
return PlatformType.Platform.NATIVE;
291+
case "NRF52":
292+
return PlatformType.Platform.NRF52;
293+
case "RP2040":
294+
return PlatformType.Platform.RP2040;
295+
case "LINUX":
296+
return PlatformType.Platform.LINUX;
297+
case "DARWIN":
298+
return PlatformType.Platform.MAC;
299+
case "ZEPHYR":
300+
return PlatformType.Platform.ZEPHYR;
301+
case "RIOT":
302+
return PlatformType.Platform.RIOT;
303+
case "FLEXPRET":
304+
return PlatformType.Platform.FLEXPRET;
305+
case "WINDOWS":
306+
return PlatformType.Platform.WINDOWS;
307+
case "PATMOS":
308+
return PlatformType.Platform.PATMOS;
309+
case "ESP-IDF":
310+
return PlatformType.Platform.ESPIDF;
311+
case "FREERTOS":
312+
return PlatformType.Platform.FREERTOS;
313+
case "ARDUINO":
314+
return PlatformType.Platform.ARDUINO;
315+
default:
316+
return PlatformType.Platform.AUTO;
317+
}
318+
} else return PlatformType.Platform.AUTO;
286319
}
287320
}
288321

@@ -294,6 +327,39 @@ public static Attribute getClockSyncAttr(Instantiation inst) {
294327
return findAttributeByName(inst, "clock_sync");
295328
}
296329

330+
public static String getClockSyncAttrValue(Reactor node) {
331+
Attribute attr = findAttributeByName(node, "clock_sync");
332+
if (attr != null) {
333+
return StringUtil.removeQuotes(attr.getAttrParms().get(0).getValue());
334+
} else {
335+
return "";
336+
}
337+
}
338+
339+
/*
340+
* Return the Logging Attribute value set on the main reactor
341+
*/
342+
public static String getLoggingAttrValue(Reactor node) {
343+
Attribute attr = findAttributeByName(node, "logging");
344+
if (attr != null) {
345+
return StringUtil.removeQuotes(attr.getAttrParms().get(0).getValue());
346+
} else {
347+
return "";
348+
}
349+
}
350+
351+
/*
352+
* Return the Fast Attribute value set on the main reactor
353+
*/
354+
public static boolean getFastAttrValue(Reactor node) {
355+
Attribute attr = findAttributeByName(node, "fast");
356+
if (attr != null) {
357+
return attr.getAttrParms().get(0).getValue().equalsIgnoreCase("true");
358+
} else {
359+
return false;
360+
}
361+
}
362+
297363
/**
298364
* Return the value of the `@maxwait` attribute of the given node or TimeValue.ZERO if does not
299365
* have one.

0 commit comments

Comments
 (0)