Skip to content

Commit

Permalink
Remove windows loader helper (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThadHouse authored Nov 11, 2024
1 parent 297feaa commit b07b871
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 237 deletions.
28 changes: 0 additions & 28 deletions WindowsLoaderHelper/build.gradle

This file was deleted.

50 changes: 0 additions & 50 deletions WindowsLoaderHelper/src/main/cpp/LoaderHelper.cpp

This file was deleted.

26 changes: 2 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group 'edu.wpi.first'
version '1.3.0'
version '2.0.0'

if (project.hasProperty('publishVersion')) {
version = project.publishVersion
Expand All @@ -26,28 +26,6 @@ java {
targetCompatibility = JavaVersion.VERSION_17
}

if (OperatingSystem.current().isWindows()) {
def generateNativeResources = tasks.register("generateNativeResources", Copy) {
into "$buildDir/assembledResources"
duplicatesStrategy = DuplicatesStrategy.EXCLUDE

from (project(":WindowsLoaderHelper").tasks.named("linkReleaseAarch64")) {
include "**/*.dll"
into "/arm64"
}
from (project(":WindowsLoaderHelper").tasks.named("linkReleaseX86")) {
include "**/*.dll"
into "/x86"
}
from (project(":WindowsLoaderHelper").tasks.named("linkReleaseX86-64")) {
include "**/*.dll"
into "/x86-64"
}
}

sourceSets.main.output.dir generateNativeResources, builtBy: generateNativeResources
}

gradlePlugin {
website = 'https://github.com/wpilibsuite/wpilib-tool-plugin'
vcsUrl = 'https://github.com/wpilibsuite/wpilib-tool-plugin'
Expand All @@ -73,5 +51,5 @@ tasks.withType(JavaCompile) {
}

wrapper {
gradleVersion = '8.4'
gradleVersion = '8.10.2'
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
22 changes: 12 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
7 changes: 0 additions & 7 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@
import org.gradle.internal.os.OperatingSystem;

if (OperatingSystem.current().isWindows()) {
include 'WindowsLoaderHelper'
}


42 changes: 0 additions & 42 deletions src/main/java/edu/wpi/first/tools/ExtractConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import org.gradle.api.Action;
import org.gradle.api.DefaultTask;
import org.gradle.api.Task;
import org.gradle.api.artifacts.ArtifactView;
import org.gradle.api.artifacts.ArtifactView.ViewConfiguration;
import org.gradle.api.artifacts.type.ArtifactTypeDefinition;
Expand All @@ -21,15 +20,11 @@
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.file.FileCollection;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.OutputDirectory;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.TaskProvider;
import org.gradle.internal.os.OperatingSystem;

public class ExtractConfiguration extends DefaultTask {
private final ArtifactViewAction viewAction = new ArtifactViewAction();
Expand Down Expand Up @@ -63,13 +58,6 @@ public DirectoryProperty getOutputDirectory() {
return outputDirectory;
}

private final Property<Boolean> skipWindowsHelperLibrary;

@Input
public Property<Boolean> getSkipWindowsHelperLibrary() {
return skipWindowsHelperLibrary;
}

@InputFiles
public ConfigurableFileCollection getConfigurationFiles() {
return configurations;
Expand All @@ -85,30 +73,15 @@ public RegularFileProperty getVersionsFile() {
return versionsFile;
}

private TaskProvider<Task> extractTask;

@Inject
public ExtractConfiguration() {
outputDirectory = getProject().getObjects().directoryProperty();

skipWindowsHelperLibrary = getProject().getObjects().property(Boolean.class);

skipWindowsHelperLibrary.set(false);

versionsFile = getProject().getObjects().fileProperty();

configurations = getProject().getObjects().fileCollection();

views = new ArrayList<>();

if (OperatingSystem.current().isWindows()) {
TaskProvider<Task> extractTask = getProject().getRootProject().getTasks()
.named("extractEmbeddedWindowsHelpers");

dependsOn(extractTask);
this.extractTask = extractTask;
}

}

public void addConfigurationToView(String configurationName) {
Expand All @@ -134,21 +107,6 @@ public void execute() throws IOException {
spec.exclude("**/*.so.debug");
});

if (OperatingSystem.current().isWindows() && !getSkipWindowsHelperLibrary().getOrElse(false)) {

ExtractEmbeddedWindowsHelpers resolvedExtractTask = (ExtractEmbeddedWindowsHelpers) extractTask.get();
getProject().copy(spec -> {
spec.from(resolvedExtractTask.getOutputFile(), copy -> {
String arch = "x86-64";
if (ExtractEmbeddedWindowsHelpers.is32BitIntel()) {
arch = "x86";
}
copy.into("/windows/" + arch + "/shared");
});
spec.into(outputDirectory);
});
}

var versionFile = versionsFile.get().getAsFile();
List<String> versions = new ArrayList<>();

Expand Down

This file was deleted.

2 changes: 2 additions & 0 deletions src/main/java/edu/wpi/first/tools/FixupNativeResources.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ public void execute(CopySpec copySpec) {
for (String fixupFile : filesToFixup) {
String outputName = fixupFile;
// Handle the special case of opencv libraries already containing rpath
System.out.println(outputName);
if (outputName.startsWith("@rpath/")) {
System.out.println("Replaciong");
outputName = outputName.substring("@rpath/".length());
}
String outputNameFinal = outputName;
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/edu/wpi/first/tools/WpilibTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,10 @@

import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.UnknownTaskException;
import org.gradle.internal.os.OperatingSystem;

public class WpilibTools implements Plugin<Project> {
@Override
public void apply(Project project) {
if (OperatingSystem.current().isWindows()) {
var extractTaskName = "extractEmbeddedWindowsHelpers";
try {
project.getRootProject().getTasks().named(extractTaskName);
} catch (UnknownTaskException notfound) {
project.getRootProject().getTasks().register(extractTaskName, ExtractEmbeddedWindowsHelpers.class);
}
}

project.getDependencies().registerTransform(UnzipTransform.class, transform -> {
transform.getFrom().attribute(ARTIFACT_TYPE_ATTRIBUTE, ZIP_TYPE);
transform.getTo().attribute(ARTIFACT_TYPE_ATTRIBUTE, DIRECTORY_TYPE);
Expand Down

0 comments on commit b07b871

Please sign in to comment.