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

CCpp target #513

Merged
merged 63 commits into from
Sep 22, 2021
Merged

CCpp target #513

merged 63 commits into from
Sep 22, 2021

Conversation

Soroosh129
Copy link
Contributor

This (re)adds the CCpp target as a way to mix C/C++ code in the C target.
This feature has been documented here.

…ing marked in the Eclipse IDE in the C/CCpp target
@Soroosh129 Soroosh129 marked this pull request as ready for review September 19, 2021 16:38
super.setTargetConfig(context);
// Set defaults for the compiler after parsing the target properties
// of the main .lf file.
if(this.CCppMode && targetConfig.useCmake == false && targetConfig.compiler.isNullOrEmpty) {
Copy link
Member

Choose a reason for hiding this comment

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

Better not to repeat the same conditional twice. Cleaner to have something like:

if (targetConfig.useCmake == false && targetConfig.compiler.isNullOrEmpty) {
  if (this.CCppMode) {
    // ..
  } else {
    // .. 
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, that's a great suggestion.

@@ -549,7 +549,7 @@ class LFValidatorImpl extends AbstractLFValidator {

@Check(FAST)
def checkDeadline(Deadline deadline) {
if (this.target == Target.C &&
if ((this.target == Target.C || this.target == Target.CCPP) &&
Copy link
Member

Choose a reason for hiding this comment

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

The fact that this has to be repeated everywhere is a bit inelegant, but it is an unavoidable consequence of the CCpp target approach. With the cmake-force-cpp proposal this would not have been the case...

Copy link
Collaborator

Choose a reason for hiding this comment

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

The conditions became really difficult to parse with the nested or operation. Maybe we could introduce a small method that does the check? For instance, isCTarget() or isCBasedTarget()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a great suggestion. Thanks.

Copy link
Collaborator

@cmnrd cmnrd left a comment

Choose a reason for hiding this comment

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

This looks pretty good. I only added a few minor comments

@@ -21,11 +21,10 @@
*
* @author Soroush Bateni <[email protected]>
*/
target C {
target CCpp {
cmake: true, // Only CMake is supported
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it this exampke or the CCpp target that only supports cmake? In the latter case, do we need this line and should we even allow the cmake property in this target?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the target CCpp works without CMake. We have tests for that in this branch.

ROS Serialization on the other hand only works with CMake. That's a great point. I will add a check.

* Change the target name to 'newTargetName'.
* For example, change C to CCpp.
*/
static def boolean changeTargetName(Resource resource, String newTargetName) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems dangerous. I assume it is needed by the test that compile C tests as CCpp? I wouldn't expose this function here if we don't have a use-case for it. Maybe it would be better placed in the test package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assume it is needed by the test that compile C tests as CCpp?

Correct.

Maybe it would be better placed in the test package.

I think semantically, it belongs to ASTUtils because it is an AST transformation after all.
I think in terms of being dangerous, there will be validation and compiler errors if a target name is changed to an incompatible language, so it might be relatively safe perhaps.

org.lflang/src/org/lflang/validation/LFValidatorImpl.xtend Outdated Show resolved Hide resolved
@@ -549,7 +549,7 @@ class LFValidatorImpl extends AbstractLFValidator {

@Check(FAST)
def checkDeadline(Deadline deadline) {
if (this.target == Target.C &&
if ((this.target == Target.C || this.target == Target.CCPP) &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

The conditions became really difficult to parse with the nested or operation. Maybe we could introduce a small method that does the check? For instance, isCTarget() or isCBasedTarget()

@Soroosh129 Soroosh129 merged commit 7887666 into ROS-serialization Sep 22, 2021
@Soroosh129 Soroosh129 deleted the ccpp-target branch September 22, 2021 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants