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

Fix handling of header-only projects when publishing HDVL sources archives #146

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading