Skip to content

Commit

Permalink
Add NativeLibraryArtifact for deploying shared libraries (#25)
Browse files Browse the repository at this point in the history
* First pass at adding NativeLibraryArtifact

Based off NativeExecutableArtifact

* fix
  • Loading branch information
spacey-sooty authored Sep 10, 2024
1 parent 2e7c8ca commit 2e1b86d
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ buildScan {
}

group = "edu.wpi.first"
version = "2025.0.0"
version = "2025.1.0"

base {
archivesName = "DeployUtils"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package edu.wpi.first.deployutils.deploy.artifact;

import java.io.File;

import javax.inject.Inject;

import org.gradle.api.provider.Property;
import org.gradle.api.tasks.util.PatternFilterable;
import org.gradle.api.tasks.util.PatternSet;
import org.gradle.nativeplatform.SharedLibraryBinarySpec;
import org.gradle.api.Task;
import org.gradle.api.provider.Provider;

import edu.wpi.first.deployutils.deploy.cache.CacheMethod;
import edu.wpi.first.deployutils.deploy.context.DeployContext;
import edu.wpi.first.deployutils.deploy.target.RemoteTarget;

public class NativeLibraryArtifact extends AbstractArtifact implements CacheableArtifact {

private final Property<CacheMethod> cacheMethod;

@Inject
public NativeLibraryArtifact(String name, RemoteTarget target) {
super(name, target);
filename = target.getProject().getObjects().property(String.class);
binarySpec = target.getProject().getObjects().property(SharedLibraryBinarySpec.class);
cacheMethod = target.getProject().getObjects().property(CacheMethod.class);

linkTaskProvider = target.getProject().getProviders().provider(() -> {
return binarySpec.get().getTasks().getLink();
});

dependsOn(linkTaskProvider);
}

private final Provider<Task> linkTaskProvider;

@Override
public Property<CacheMethod> getCacheMethod() {
return cacheMethod;
}

private final Property<String> filename;

public Property<String> getFilename() {
return filename;
}

private Property<SharedLibraryBinarySpec> binarySpec;

public Property<SharedLibraryBinarySpec> getBinary() {
return binarySpec;
}

private final PatternFilterable libraryFilter = new PatternSet();

public PatternFilterable getLibraryFilter() {
return libraryFilter;
}

protected File getDeployedFile() {
return binarySpec.get().getSharedLibraryFile();
}

@Override
public void deploy(DeployContext context) {
CacheMethod cm = cacheMethod.getOrElse(null);

File libFile = getDeployedFile();
context.put(libFile, getFilename().getOrElse(libFile.getName()), cm);
}
}
2 changes: 1 addition & 1 deletion testing/cpp/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "edu.wpi.first.DeployUtils" version "2025.0.0"
id "edu.wpi.first.DeployUtils" version "2025.1.0"
}

deploy {
Expand Down

0 comments on commit 2e1b86d

Please sign in to comment.