Skip to content

Commit

Permalink
Merge pull request #56 from tudortimi/fix-support-for-c-sources-in-qrun
Browse files Browse the repository at this point in the history
Fix support for C sources in qrun
  • Loading branch information
tudortimi authored Feb 27, 2022
2 parents 826f96a + 3229a01 commit 15b6ff1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,21 @@ class CPluginSpec extends Specification {
new File(testProjectDir.root, 'build/xrun_args.f').text.contains('src/main/c/dummy.c')
}

def "'genQrunArgsFile' task writes C files to args file"() {
File c = testProjectDir.newFolder('src', 'main', 'c')
new File(c, 'dummy.c').createNewFile()

when:
def result = GradleRunner.create()
.withProjectDir(testProjectDir.root)
.withPluginClasspath()
.withArguments('genQrunArgsFile')
.build()

then:
new File(testProjectDir.root, 'build/qrun_args.f').text.contains('src/main/c/dummy.c')
}

def "'genXrunArgsFile' task indents entries in makelib block"() {
File c = testProjectDir.newFolder('src', 'main', 'c')
new File(c, 'dummy.c').createNewFile()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@

package com.verificationgentleman.gradle.hdvl.c;

import com.verificationgentleman.gradle.hdvl.GenXrunArgsFile;
import com.verificationgentleman.gradle.hdvl.HDVLBasePlugin;
import com.verificationgentleman.gradle.hdvl.HDVLPluginExtension;
import com.verificationgentleman.gradle.hdvl.SourceSet;
import com.verificationgentleman.gradle.hdvl.*;
import com.verificationgentleman.gradle.hdvl.c.internal.DefaultCSourceSet;
import org.gradle.api.Action;
import org.gradle.api.NamedDomainObjectContainer;
Expand All @@ -28,6 +25,7 @@
import org.gradle.api.internal.plugins.DslObject;

public class CPlugin implements Plugin<Project> {

@Override
public void apply(Project project) {
project.getPluginManager().apply(HDVLBasePlugin.class);
Expand All @@ -41,9 +39,12 @@ public void execute(SourceSet sourceSet) {
// XXX WORKAROUND Not part of the public API
new DslObject(sourceSet).getConvention().getPlugins().put("c", cSourceSet);

GenXrunArgsFile genXrunArgsFile
= (GenXrunArgsFile) project.getTasks().getByName(sourceSet.getGenArgsFileTaskName("Xrun"));
genXrunArgsFile.setCSource(cSourceSet.getC());
String[] toolNames = {"Xrun", "Qrun"};
for (String toolName: toolNames) {
AbstractGenArgsFile genArgsFile
= (AbstractGenArgsFile) project.getTasks().getByName(sourceSet.getGenArgsFileTaskName(toolName));
genArgsFile.setCSource(cSourceSet.getC());
}
}
});
}
Expand Down

0 comments on commit 15b6ff1

Please sign in to comment.