/*
 * Copyright (c) 2019 NumberFour AG.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   NumberFour AG - Initial API and implementation
 */

import * as path from "path";
import * as url from "url";



export public const JAVA_DEFAULT = "java";
export public const JAVA_VM_XMX = "-Xmx";
export public const JAVA_VM_XMX_DEFAULT = "4096m";

const DIRNAME = path.dirname(url.fileURLToPath(import.meta.url));

export public const BIN_DIR = path.resolve(DIRNAME, "..", "bin");
export public const RESOURCES_DIR = path.resolve(DIRNAME, "..", "resources");
export public const JRE_DIR = path.resolve(BIN_DIR, "jre");
export public const N4JSC_JAR = path.resolve(BIN_DIR, "n4jsc.jar");
export public const N4JS_CLI_CONFIG = "n4js-cli.config";
export public const JRE_URL_DIR = "https://github.com/AdoptOpenJDK/openjdk17-binaries/releases/download/jdk-2021-05-07-13-31/";
export public const JRE_INFO_MAP = new Map<Platform, JreInfo>([
    [Platform.x64_aix,     null],
    [Platform.x64_darwin,  {bin: "Contents/Home/bin/java", name: "OpenJDK-jre_x64_mac_hotspot_2021-05-06-23-30.tar.gz"}],
    [Platform.arm64_darwin,  {bin: "Contents/Home/bin/java", name: "OpenJDK-jre_arm64_mac_hotspot_2021-05-06-23-30.tar.gz"}],
    [Platform.x64_freebsd, {bin: "bin/java", name: "OpenJDK-jre_x64_linux_hotspot_2021-05-06-23-30.tar.gz"}],
    [Platform.x64_linux,   {bin: "bin/java", name: "OpenJDK-jre_x64_linux_hotspot_2021-05-06-23-30.tar.gz"}],
    [Platform.x64_linux_alpine,   {bin: "bin/java", name: "OpenJDK-jre_x64_alpine-linux_hotspot_2021-05-06-23-30.tar.gz"}],
    [Platform.x64_openbsd, {bin: "bin/java", name: "OpenJDK-jre_x64_linux_hotspot_2021-05-06-23-30.tar.gz"}],
    [Platform.x64_sunos,   null],
    [Platform.x32_win32,   {bin: "bin/java.exe", name: "OpenJDK-jre_x86-32_windows_hotspot_2021-05-06-23-30.zip"}],
    [Platform.x64_win32,   {bin: "bin/java.exe", name: "OpenJDK-jre_x64_windows_hotspot_2021-05-06-23-30.zip"}]]
    );


@StringBased
export enum Platform {
    x64_aix,
    x64_darwin,
    arm64_darwin,
    x64_freebsd,
    x64_linux,
    x64_linux_alpine,
    x64_openbsd,
    x64_sunos,
    x32_win32,
    x64_win32
}

export interface ~JreInfo {
    public bin: string;
    public name: string;
}
