Skip to content

Commit 007e619

Browse files
authored
Allow filtering which symbols are exported (#178)
1 parent 5b6aca5 commit 007e619

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ targetCompatibility = 11
1212

1313
allprojects {
1414
group = "edu.wpi.first"
15-
version = "2024.3.2"
15+
version = "2024.4.0"
1616

1717
if (project.hasProperty('publishVersion')) {
1818
version = project.publishVersion

src/main/java/edu/wpi/first/nativeutils/exports/ExportsConfig.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package edu.wpi.first.nativeutils.exports;
22

3+
import java.io.File;
34
import java.util.List;
45

56
import org.gradle.api.Action;
67
import org.gradle.api.Named;
78
import org.gradle.api.provider.ListProperty;
89
import org.gradle.api.provider.Property;
10+
import org.gradle.api.specs.Spec;
11+
12+
import groovy.lang.Closure;
913

1014
public interface ExportsConfig extends Named {
1115
ListProperty<String> getArm64ExcludeSymbols();
@@ -21,4 +25,8 @@ public interface ExportsConfig extends Named {
2125
Property<Action<List<String>>> getX86SymbolFilter();
2226

2327
Property<Action<List<String>>> getX64SymbolFilter();
28+
29+
Property<Spec<File>> getObjectFilter();
30+
31+
Property<Closure<?>> getObjectFilterClosure();
2432
}

src/main/java/edu/wpi/first/nativeutils/exports/ExportsGenerationTask.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
import org.gradle.api.DefaultTask;
1313
import org.gradle.api.file.ConfigurableFileCollection;
1414
import org.gradle.api.file.RegularFileProperty;
15+
import org.gradle.api.specs.Spec;
1516
import org.gradle.api.tasks.Internal;
1617
import org.gradle.api.tasks.InputFile;
1718
import org.gradle.api.tasks.InputFiles;
1819
import org.gradle.api.tasks.OutputFile;
1920
import org.gradle.api.tasks.TaskAction;
2021
import org.gradle.process.ExecSpec;
2122

23+
import groovy.lang.Closure;
24+
2225
public abstract class ExportsGenerationTask extends DefaultTask implements Action<ExecSpec> {
2326

2427
@InputFiles
@@ -110,7 +113,16 @@ public void execute() {
110113
public void execute(ExecSpec exec) {
111114
exec.setExecutable(getDefFileGenerator().get().getAsFile().toString());
112115
exec.args(getDefFile().get().getAsFile().toString());
113-
exec.args(getSourceFiles());
116+
117+
Spec<File> objectFilter = getExportsConfig().getObjectFilter().getOrElse(null);
118+
Closure<?> objectFilterClosure = getExportsConfig().getObjectFilterClosure().getOrElse(null);
119+
if (objectFilter == null && objectFilterClosure == null) {
120+
exec.args(getSourceFiles());
121+
} else if (objectFilterClosure == null) {
122+
exec.args(getSourceFiles().filter(objectFilter));
123+
} else {
124+
exec.args(getSourceFiles().filter(objectFilterClosure));
125+
}
114126
}
115127

116128
}

testing/cpp/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import edu.wpi.first.toolchain.NativePlatforms
22

33
plugins {
44
id "cpp"
5-
id "edu.wpi.first.NativeUtils" version "2024.3.2"
5+
id "edu.wpi.first.NativeUtils" version "2024.4.0"
66
}
77

88
nativeUtils.addWpiNativeUtils()

0 commit comments

Comments
 (0)