Harmonize standardized platform naming between Native class and gradle.
This commit is contained in:
		@@ -79,18 +79,28 @@ library {
 | 
			
		||||
 | 
			
		||||
static String standardOperatingSystem(NativePlatform platform) {
 | 
			
		||||
    OperatingSystem os = platform.getOperatingSystem()
 | 
			
		||||
    if (os.isWindows()) {
 | 
			
		||||
    if (os.isWindows())
 | 
			
		||||
        return OperatingSystemFamily.WINDOWS
 | 
			
		||||
    } else if (os.isLinux()) {
 | 
			
		||||
        return OperatingSystemFamily.LINUX
 | 
			
		||||
    } else if (os.isMacOsX()) {
 | 
			
		||||
    else if (os.isMacOsX())
 | 
			
		||||
        return OperatingSystemFamily.MAC_OS
 | 
			
		||||
    }
 | 
			
		||||
    else if (os.isLinux())
 | 
			
		||||
        return OperatingSystemFamily.LINUX
 | 
			
		||||
 | 
			
		||||
    return os.name.toLowerCase()
 | 
			
		||||
    // Other systems will need to use a Linux compatibility layer for now.
 | 
			
		||||
    return OperatingSystemFamily.LINUX
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static String standardArchitecture(NativePlatform platform) {
 | 
			
		||||
    Architecture arch = platform.getArchitecture()
 | 
			
		||||
    return arch.name.toLowerCase().replaceAll( "-", "_" )
 | 
			
		||||
    if (arch.isArm())
 | 
			
		||||
        return "arm"
 | 
			
		||||
    else if (arch.name.toLowerCase( Locale.ROOT ).startsWith( "arm" ))
 | 
			
		||||
        return "arm64"
 | 
			
		||||
    else if (arch.isAmd64())
 | 
			
		||||
        return "x86_64"
 | 
			
		||||
    else if (arch.isI386())
 | 
			
		||||
        return "x86"
 | 
			
		||||
 | 
			
		||||
    // Other systems will need to be compatible with the x86 architecture.
 | 
			
		||||
    return "x86"
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -18,12 +18,16 @@
 | 
			
		||||
 | 
			
		||||
package com.lyndir.masterpassword.impl;
 | 
			
		||||
 | 
			
		||||
import static com.lyndir.lhunath.opal.system.util.ObjectUtils.*;
 | 
			
		||||
 | 
			
		||||
import com.google.common.base.Joiner;
 | 
			
		||||
import com.google.common.collect.ImmutableList;
 | 
			
		||||
import com.google.common.io.ByteStreams;
 | 
			
		||||
import com.lyndir.lhunath.opal.system.logging.Logger;
 | 
			
		||||
import java.io.*;
 | 
			
		||||
import java.util.Locale;
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -45,7 +49,8 @@ public final class Native {
 | 
			
		||||
        try {
 | 
			
		||||
            System.loadLibrary( name );
 | 
			
		||||
            return;
 | 
			
		||||
        } catch (@SuppressWarnings("ErrorNotRethrown") final UnsatisfiedLinkError ignored) {
 | 
			
		||||
        }
 | 
			
		||||
        catch (@SuppressWarnings("ErrorNotRethrown") final UnsatisfiedLinkError ignored) {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Try to find and open a stream to the packaged library resource.
 | 
			
		||||
@@ -82,10 +87,26 @@ public final class Native {
 | 
			
		||||
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    private static String getLibraryResource(final String library) {
 | 
			
		||||
        String system       = System.getProperty( "os.name" ).toLowerCase( Locale.ROOT );
 | 
			
		||||
        String architecture = System.getProperty( "os.arch" ).toLowerCase( Locale.ROOT );
 | 
			
		||||
        if ("Mac OS X".equalsIgnoreCase( system ))
 | 
			
		||||
        String system       = ifNotNullElse( System.getProperty( "os.name" ), "linux" ).toLowerCase( Locale.ROOT );
 | 
			
		||||
        String architecture = ifNotNullElse( System.getProperty( "os.arch" ), "x86" ).toLowerCase( Locale.ROOT );
 | 
			
		||||
 | 
			
		||||
        // Standardize system naming in accordance with masterpassword-core.
 | 
			
		||||
        if (system.contains( "windows" ))
 | 
			
		||||
            system = "windows";
 | 
			
		||||
        else if (system.contains( "mac os x" ) || system.contains( "darwin" ) || system.contains( "osx" ))
 | 
			
		||||
            system = "macos";
 | 
			
		||||
        else
 | 
			
		||||
            system = "linux";
 | 
			
		||||
 | 
			
		||||
        // Standardize architecture naming in accordance with masterpassword-core.
 | 
			
		||||
        if (ImmutableList.of( "arm", "arm-v7", "armv7", "arm32" ).contains( architecture ))
 | 
			
		||||
            architecture = "arm";
 | 
			
		||||
        else if (architecture.startsWith( "arm" ))
 | 
			
		||||
            architecture = "arm64";
 | 
			
		||||
        else if (ImmutableList.of( "x86_64", "amd64", "x64", "x86-64" ).contains( architecture ))
 | 
			
		||||
            architecture = "x86_64";
 | 
			
		||||
        else
 | 
			
		||||
            architecture = "x86";
 | 
			
		||||
 | 
			
		||||
        return Joiner.on( RESOURCE_SEPARATOR ).join( "", NATIVES_PATH, system, architecture, library );
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@ dependencies {
 | 
			
		||||
    compileOnly group: 'com.google.auto.value', name: 'auto-value', version: '1.2'
 | 
			
		||||
    apt group: 'com.google.auto.value', name: 'auto-value', version: '1.2'
 | 
			
		||||
 | 
			
		||||
    testCompile group: 'org.testng', name: 'testng', version: '6.8.5'
 | 
			
		||||
    testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.2'
 | 
			
		||||
    testImplementation group: 'org.testng', name: 'testng', version: '6.8.5'
 | 
			
		||||
    testImplementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.2'
 | 
			
		||||
}
 | 
			
		||||
test.useTestNG()
 | 
			
		||||
 
 | 
			
		||||
@@ -7,11 +7,11 @@ description = 'Master Password Test Suite'
 | 
			
		||||
dependencies {
 | 
			
		||||
    implementation group: 'com.lyndir.lhunath.opal', name: 'opal-system', version: '1.7-p2'
 | 
			
		||||
 | 
			
		||||
    compile project( ':masterpassword-algorithm' )
 | 
			
		||||
    compile project( ':masterpassword-model' )
 | 
			
		||||
    implementation project( ':masterpassword-algorithm' )
 | 
			
		||||
    implementation project( ':masterpassword-model' )
 | 
			
		||||
 | 
			
		||||
    testCompile group: 'org.testng', name: 'testng', version: '6.8.5'
 | 
			
		||||
    testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.2'
 | 
			
		||||
    testImplementation group: 'org.testng', name: 'testng', version: '6.8.5'
 | 
			
		||||
    testImplementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.2'
 | 
			
		||||
}
 | 
			
		||||
//tasks.withType(Test) {
 | 
			
		||||
//    systemProperty "java.library.path", "/Users/lhunath/Documents/workspace/lyndir/MasterPassword/core/java/algorithm/build/libs/mpw/shared"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user