From c572db591c54e2a5f2d3ed5102013c722bb7408e Mon Sep 17 00:00:00 2001 From: Tudor Timi Date: Sun, 26 May 2024 18:41:57 +0200 Subject: [PATCH 1/2] Fix handling of header-only projects when publishing HDVL sources archives As with exported headers, we have to ensure whether there actually are any private header directories, as the source set will, by default, be instructed to look in `src/main/sv`, even when this directory doesn't exist. --- .../SystemVerilogPluginSpec.groovy | 63 +++++++++++++++++++ .../systemverilog/SystemVerilogPlugin.java | 2 +- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/src/functTest/groovy/com/verificationgentleman/gradle/hdvl/systemverilog/SystemVerilogPluginSpec.groovy b/src/functTest/groovy/com/verificationgentleman/gradle/hdvl/systemverilog/SystemVerilogPluginSpec.groovy index bafa273..d410e2e 100644 --- a/src/functTest/groovy/com/verificationgentleman/gradle/hdvl/systemverilog/SystemVerilogPluginSpec.groovy +++ b/src/functTest/groovy/com/verificationgentleman/gradle/hdvl/systemverilog/SystemVerilogPluginSpec.groovy @@ -1175,4 +1175,67 @@ class SystemVerilogPluginSpec extends Specification { line.contains('-incdir') && line.endsWith('src/main/sv_headers') } } + + def "can consume source archive with only exported header directory"() { + File dependencyProjectBuildFile = newStandardProject('dependency-project') + dependencyProjectBuildFile << """ + plugins { + id 'maven-publish' + } + + group = "org.example" + version = "1.0.0" + + publishing { + repositories { + maven { + name = 'dummy' + url = layout.buildDirectory.dir('dummy-repo') + } + } + } + """ + + File dependencyProjectSvDir = new File(dependencyProjectBuildFile.parentFile, 'src/main/sv') + dependencyProjectSvDir.deleteDir() + + File dependencyProjectExportedHeaderDir = new File(dependencyProjectBuildFile.parentFile, 'src/main/sv_headers') + dependencyProjectExportedHeaderDir.mkdir() + File dependencyProjectPrivateHeader = new File(dependencyProjectExportedHeaderDir, 'dependency-project-exported-header.svh') + dependencyProjectPrivateHeader.text = "dummy" + + GradleRunner.create() + .withProjectDir(dependencyProjectBuildFile.parentFile) + .withPluginClasspath() + .withArguments(':publish') + .build() + + File mainProjectBuildFile = newStandardProject('main-project') + mainProjectBuildFile << """ + dependencies { + compile 'org.example:dependency-project:1.0.0' + } + + repositories { + maven { + url = layout.projectDirectory.dir('../dependency-project/build/dummy-repo') + } + } + """ + + when: + def result = GradleRunner.create() + .withProjectDir(mainProjectBuildFile.parentFile) + .withPluginClasspath() + .withDebug(true) + .withArguments(':genFullXrunArgsFile') + .build() + + then: + def lines = new File(mainProjectBuildFile.parentFile, 'build/full_xrun_args.f').text.split("\n") + def xrunArgsForDependencyProject = new File(lines[0].split(/\s+/)[1]) + Files.lines(xrunArgsForDependencyProject.toPath()).anyMatch { line -> + line.contains('-incdir') && line.endsWith('src/main/sv_headers') + } + } } diff --git a/src/main/java/com/verificationgentleman/gradle/hdvl/systemverilog/SystemVerilogPlugin.java b/src/main/java/com/verificationgentleman/gradle/hdvl/systemverilog/SystemVerilogPlugin.java index c7ea562..3803b07 100644 --- a/src/main/java/com/verificationgentleman/gradle/hdvl/systemverilog/SystemVerilogPlugin.java +++ b/src/main/java/com/verificationgentleman/gradle/hdvl/systemverilog/SystemVerilogPlugin.java @@ -54,7 +54,7 @@ public void execute(SourceSet sourceSet) { if (sourceSet.getName() == "main") { project.getTasks().withType(WriteCompileSpecFile.class, task -> { task.getSvSource().from(svSourceSet.getSv()); - task.getSvSPrivateIncludeDirs().from(svSourceSet.getSv().getSourceDirectories()); + task.getSvSPrivateIncludeDirs().from(svSourceSet.getSv().getSourceDirectories().filter(File::exists)); task.getSvExportedHeaderDirs().from(svSourceSet.getSvHeaders().getSourceDirectories().filter(File::exists)); }); project.getTasks().getByName("hdvlSourcesArchive", task -> { From 532a16507a41a7cc219d00e1677c7d707d259e60 Mon Sep 17 00:00:00 2001 From: Tudor Timi Date: Sun, 26 May 2024 18:43:55 +0200 Subject: [PATCH 2/2] Fix typo in task property name --- .../gradle/hdvl/internal/WriteCompileSpecFile.java | 10 +++++----- .../gradle/hdvl/systemverilog/SystemVerilogPlugin.java | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/verificationgentleman/gradle/hdvl/internal/WriteCompileSpecFile.java b/src/main/java/com/verificationgentleman/gradle/hdvl/internal/WriteCompileSpecFile.java index 2847c22..db37a35 100644 --- a/src/main/java/com/verificationgentleman/gradle/hdvl/internal/WriteCompileSpecFile.java +++ b/src/main/java/com/verificationgentleman/gradle/hdvl/internal/WriteCompileSpecFile.java @@ -12,14 +12,14 @@ public class WriteCompileSpecFile extends DefaultTask { private final RegularFileProperty destination; private final ConfigurableFileCollection svSourceFiles; - private final ConfigurableFileCollection svSPrivateIncludeDirs; + private final ConfigurableFileCollection svPrivateIncludeDirs; private final ConfigurableFileCollection svExportedHeaderDirs; public WriteCompileSpecFile() { destination = getProject().getObjects().fileProperty(); svSourceFiles = getProject().getObjects().fileCollection(); - svSPrivateIncludeDirs = getProject().getObjects().fileCollection(); + svPrivateIncludeDirs = getProject().getObjects().fileCollection(); svExportedHeaderDirs = getProject().getObjects().fileCollection(); } @@ -38,8 +38,8 @@ public ConfigurableFileCollection getSvSource() { @InputFiles @SkipWhenEmpty @PathSensitive(PathSensitivity.ABSOLUTE) - public ConfigurableFileCollection getSvSPrivateIncludeDirs() { - return svSPrivateIncludeDirs; + public ConfigurableFileCollection getSvPrivateIncludeDirs() { + return svPrivateIncludeDirs; } @InputFiles @@ -52,7 +52,7 @@ public ConfigurableFileCollection getSvExportedHeaderDirs() { @TaskAction protected void generate() { DefaultHDVLCompileSpec compileSpec = new DefaultHDVLCompileSpec(getSvSource().getFiles(), - svSPrivateIncludeDirs.getFiles(), svExportedHeaderDirs.getFiles()); + svPrivateIncludeDirs.getFiles(), svExportedHeaderDirs.getFiles()); try { JAXBContext jaxbContext = JAXBContext.newInstance(DefaultHDVLCompileSpec.class); Marshaller marshaller = jaxbContext.createMarshaller(); diff --git a/src/main/java/com/verificationgentleman/gradle/hdvl/systemverilog/SystemVerilogPlugin.java b/src/main/java/com/verificationgentleman/gradle/hdvl/systemverilog/SystemVerilogPlugin.java index 3803b07..a47e242 100644 --- a/src/main/java/com/verificationgentleman/gradle/hdvl/systemverilog/SystemVerilogPlugin.java +++ b/src/main/java/com/verificationgentleman/gradle/hdvl/systemverilog/SystemVerilogPlugin.java @@ -54,7 +54,7 @@ public void execute(SourceSet sourceSet) { if (sourceSet.getName() == "main") { project.getTasks().withType(WriteCompileSpecFile.class, task -> { task.getSvSource().from(svSourceSet.getSv()); - task.getSvSPrivateIncludeDirs().from(svSourceSet.getSv().getSourceDirectories().filter(File::exists)); + task.getSvPrivateIncludeDirs().from(svSourceSet.getSv().getSourceDirectories().filter(File::exists)); task.getSvExportedHeaderDirs().from(svSourceSet.getSvHeaders().getSourceDirectories().filter(File::exists)); }); project.getTasks().getByName("hdvlSourcesArchive", task -> {