Skip to content

Commit

Permalink
Merge pull request #146 from tudortimi/fix-handling-of-header-only-pr…
Browse files Browse the repository at this point in the history
…ojects-when-publishing-hdvl-sources-archives

Fix handling of header-only projects when publishing HDVL sources archives
  • Loading branch information
tudortimi authored May 26, 2024
2 parents 0b66a18 + 532a165 commit 04cc125
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -38,8 +38,8 @@ public ConfigurableFileCollection getSvSource() {
@InputFiles
@SkipWhenEmpty
@PathSensitive(PathSensitivity.ABSOLUTE)
public ConfigurableFileCollection getSvSPrivateIncludeDirs() {
return svSPrivateIncludeDirs;
public ConfigurableFileCollection getSvPrivateIncludeDirs() {
return svPrivateIncludeDirs;
}

@InputFiles
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.getSvPrivateIncludeDirs().from(svSourceSet.getSv().getSourceDirectories().filter(File::exists));
task.getSvExportedHeaderDirs().from(svSourceSet.getSvHeaders().getSourceDirectories().filter(File::exists));
});
project.getTasks().getByName("hdvlSourcesArchive", task -> {
Expand Down

0 comments on commit 04cc125

Please sign in to comment.