Java Code Examples for com.android.SdkConstants#CURRENT_PLATFORM

The following examples show how to use com.android.SdkConstants#CURRENT_PLATFORM . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RenderScriptProcessor.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public void build(@NonNull CommandLineLauncher launcher)
        throws IOException, InterruptedException {

    // get the env var
    Map<String, String> env = Maps.newHashMap();
    if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_DARWIN) {
        env.put("DYLD_LIBRARY_PATH", mBuildToolInfo.getLocation().getAbsolutePath());
    } else if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_LINUX) {
        env.put("LD_LIBRARY_PATH", mBuildToolInfo.getLocation().getAbsolutePath());
    }

    doMainCompilation(launcher, env);

    if (mSupportMode) {
        createSupportFiles(launcher, env);
    }
}
 
Example 2
Source File: PlatformLoader.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
private synchronized void init(@NonNull ILogger logger) {
    if (mSdkInfo == null) {
        String host;
        if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_DARWIN) {
            host = "darwin-x86";
        } else if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_LINUX) {
            host = "linux-x86";
        } else {
            throw new IllegalStateException(
                    "Windows is not supported for platform development");
        }

        mSdkInfo = new SdkInfo(
                new File(mTreeLocation, "out/host/" + host + "/framework/annotations.jar")  );
    }
}
 
Example 3
Source File: StdLogger.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
private void printMessage(String msg, PrintStream stream) {
    if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_WINDOWS &&
            !msg.endsWith("\r\n") &&
            msg.endsWith("\n")) {
        // remove last \n so that println can use \r\n as needed.
        msg = msg.substring(0, msg.length() - 1);
    }

    stream.print(msg);

    if (!msg.endsWith("\n")) {
        stream.println();
    }
}
 
Example 4
Source File: StdLogger.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
private void printMessage(String msg, PrintStream stream) {
    if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_WINDOWS &&
            !msg.endsWith("\r\n") &&
            msg.endsWith("\n")) {
        // remove last \n so that println can use \r\n as needed.
        msg = msg.substring(0, msg.length() - 1);
    }

    stream.print(msg);

    if (!msg.endsWith("\n")) {
        stream.println();
    }
}
 
Example 5
Source File: FileOp.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Helper to delete a file or a directory.
 * For a directory, recursively deletes all of its content.
 * Files that cannot be deleted right away are marked for deletion on exit.
 * It's ok for the file or folder to not exist at all.
 * The argument can be null.
 */
@Override
public void deleteFileOrFolder(@NonNull File fileOrFolder) {
    if (fileOrFolder != null) {
        if (isDirectory(fileOrFolder)) {
            // Must delete content recursively first
            File[] files = fileOrFolder.listFiles();
            if (files != null) {
                for (File item : files) {
                    deleteFileOrFolder(item);
                }
            }
        }

        // Don't try to delete it if it doesn't exist.
        if (!exists(fileOrFolder)) {
            return;
        }

        if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_WINDOWS) {
            // Trying to delete a resource on windows might fail if there's a file
            // indexer locking the resource. Generally retrying will be enough to
            // make it work.
            //
            // Try for half a second before giving up.

            for (int i = 0; i < 5; i++) {
                if (fileOrFolder.delete()) {
                    return;
                }

                try {
                    Thread.sleep(100 /*ms*/);
                } catch (InterruptedException e) {
                    // Ignore.
                }
            }

            fileOrFolder.deleteOnExit();

        } else {
            // On Linux or Mac, just straight deleting it should just work.

            if (!fileOrFolder.delete()) {
                fileOrFolder.deleteOnExit();
            }
        }
    }
}
 
Example 6
Source File: FileOp.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Helper to delete a file or a directory.
 * For a directory, recursively deletes all of its content.
 * Files that cannot be deleted right away are marked for deletion on exit.
 * It's ok for the file or folder to not exist at all.
 * The argument can be null.
 */
@Override
public void deleteFileOrFolder(@NonNull File fileOrFolder) {
    if (fileOrFolder != null) {
        if (isDirectory(fileOrFolder)) {
            // Must delete content recursively first
            File[] files = fileOrFolder.listFiles();
            if (files != null) {
                for (File item : files) {
                    deleteFileOrFolder(item);
                }
            }
        }

        // Don't try to delete it if it doesn't exist.
        if (!exists(fileOrFolder)) {
            return;
        }

        if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_WINDOWS) {
            // Trying to delete a resource on windows might fail if there's a file
            // indexer locking the resource. Generally retrying will be enough to
            // make it work.
            //
            // Try for half a second before giving up.

            for (int i = 0; i < 5; i++) {
                if (fileOrFolder.delete()) {
                    return;
                }

                try {
                    Thread.sleep(100 /*ms*/);
                } catch (InterruptedException e) {
                    // Ignore.
                }
            }

            fileOrFolder.deleteOnExit();

        } else {
            // On Linux or Mac, just straight deleting it should just work.

            if (!fileOrFolder.delete()) {
                fileOrFolder.deleteOnExit();
            }
        }
    }
}