Пример #1
0
    /// <summary>
    ///     Gets the library file name prefix for a <see cref="RuntimeOperatingSystem" />.
    /// </summary>
    /// <param name="targetOperatingSystem">The runtime platform.</param>
    /// <returns>
    ///     A <see cref="string" /> containing the library file name prefix for the
    ///     <paramref name="targetOperatingSystem" />.
    /// </returns>
    /// <exception cref="NotImplementedException"><paramref name="targetOperatingSystem" /> is not available yet with .NET 5.</exception>
    /// <exception cref="ArgumentOutOfRangeException"><paramref name="targetOperatingSystem" /> is not a known valid value.</exception>
    public static string LibraryFileNamePrefix(RuntimeOperatingSystem targetOperatingSystem)
    {
        switch (targetOperatingSystem)
        {
        case RuntimeOperatingSystem.Windows:
        case RuntimeOperatingSystem.Xbox:
            return(string.Empty);

        case RuntimeOperatingSystem.macOS:
        case RuntimeOperatingSystem.tvOS:
        case RuntimeOperatingSystem.iOS:
        case RuntimeOperatingSystem.Linux:
        case RuntimeOperatingSystem.FreeBSD:
        case RuntimeOperatingSystem.Android:
        case RuntimeOperatingSystem.PlayStation:
            return("lib");

        case RuntimeOperatingSystem.Browser:
        case RuntimeOperatingSystem.Switch:
        case RuntimeOperatingSystem.Unknown:
            throw new NotImplementedException();

        default:
            throw new ArgumentOutOfRangeException(nameof(targetOperatingSystem), targetOperatingSystem, null);
        }
    }
Пример #2
0
    private void SetupClang(RuntimeOperatingSystem operatingSystem)
    {
        BeginStep();

        if (operatingSystem == RuntimeOperatingSystem.macOS)
        {
            _clangNativeLibraryPath = "/Library/Developer/CommandLineTools/usr/lib/libclang.dylib";
            if (!File.Exists(_clangNativeLibraryPath))
            {
                throw new ClangException(
                          "Please install CommandLineTools for macOS. This will install `libclang.dylib`. Use the command `xcode-select --install`.");
            }
        }
        else if (operatingSystem == RuntimeOperatingSystem.Linux)
        {
            _clangNativeLibraryPath = Path.Combine(AppContext.BaseDirectory, "libclang.so");
            if (!File.Exists(_clangNativeLibraryPath))
            {
                DownloadLibClang("ubuntu.20.04-x64", _clangNativeLibraryPath);
            }
        }
        else if (operatingSystem == RuntimeOperatingSystem.Windows)
        {
            _clangNativeLibraryPath = Path.Combine(AppContext.BaseDirectory, "libclang.dll");
            if (!File.Exists(_clangNativeLibraryPath))
            {
                DownloadLibClang("win-x64", _clangNativeLibraryPath);
            }
        }

        EndStep();
Пример #3
0
    /// <summary>
    ///     Gets the library file name extension given a <see cref="RuntimeOperatingSystem" />.
    /// </summary>
    /// <param name="operatingSystem">The runtime platform.</param>
    /// <returns>
    ///     A <see cref="string" /> containing the library file name extension for the <paramref name="operatingSystem" />
    ///     .
    /// </returns>
    /// <exception cref="NotImplementedException"><paramref name="operatingSystem" /> is not available yet with .NET 5.</exception>
    /// <exception cref="ArgumentOutOfRangeException"><paramref name="operatingSystem" /> is not a known valid value.</exception>
    public static string LibraryFileNameExtension(RuntimeOperatingSystem operatingSystem)
    {
        switch (operatingSystem)
        {
        case RuntimeOperatingSystem.Windows:
        case RuntimeOperatingSystem.Xbox:
            return(".dll");

        case RuntimeOperatingSystem.macOS:
        case RuntimeOperatingSystem.tvOS:
        case RuntimeOperatingSystem.iOS:
            return(".dylib");

        case RuntimeOperatingSystem.Linux:
        case RuntimeOperatingSystem.FreeBSD:
        case RuntimeOperatingSystem.Android:
        case RuntimeOperatingSystem.PlayStation:
            return(".so");

        case RuntimeOperatingSystem.Browser:
        case RuntimeOperatingSystem.Switch:
        case RuntimeOperatingSystem.Unknown:
            throw new NotImplementedException();

        default:
            throw new ArgumentOutOfRangeException(nameof(operatingSystem), operatingSystem, null);
        }
    }
Пример #4
0
    private static void AddSystemTypes(
        int bitness,
        RuntimeOperatingSystem operatingSystem,
        Dictionary <string, string> aliases)
    {
        aliases.Add("wchar_t", string.Empty); // remove

        switch (operatingSystem)
        {
        case RuntimeOperatingSystem.Windows:
            AddSystemTypesWindows(aliases);
            break;

        case RuntimeOperatingSystem.Linux:
            AddSystemTypesLinux(bitness, aliases);
            break;

        case RuntimeOperatingSystem.macOS:
        case RuntimeOperatingSystem.iOS:
        case RuntimeOperatingSystem.tvOS:
            AddSystemTypesDarwin(bitness, aliases);
            break;

        case RuntimeOperatingSystem.Unknown:
            throw new PlatformNotSupportedException();

        case RuntimeOperatingSystem.FreeBSD:
        case RuntimeOperatingSystem.Android:
        case RuntimeOperatingSystem.Browser:
        case RuntimeOperatingSystem.PlayStation:
        case RuntimeOperatingSystem.Xbox:
        case RuntimeOperatingSystem.Switch:
            throw new NotImplementedException();

        default:
            throw new ArgumentOutOfRangeException(nameof(operatingSystem), operatingSystem, null);
        }
    }