コード例 #1
0
ファイル: InstallCommand.cs プロジェクト: yongaru/fuse-studio
        Optional <AbsoluteDirectoryPath> TryToFindAndroidSdk(AndroidSDKValidator sdkValidator, IProgress <InstallerEvent> progress)
        {
            var searchPaths = GetAndroidSDKSearchPaths(Observer.Create <string>(Console.WriteLine));

            foreach (var searchPath in searchPaths)
            {
                if (sdkValidator.IsInstalledAt(searchPath, progress))
                {
                    return(searchPath);
                }
            }

            return(Optional.None());
        }
コード例 #2
0
        public static OptionalSdkConfigOptions VerifyInstallation(IFileSystem fs, OptionalSdkConfigOptions config, IProgress <InstallerEvent> progress)
        {
            // Verify everything
            var javaValidator = new JavaValidator(fs);

            if (!IsInstalled(config.JavaJdkDirectory, javaValidator.IsInstalledAt, progress))
            {
                config.JavaJdkDirectory = Optional.None();
            }

            var androidSdkValidator = new AndroidSDKValidator(fs);

            if (!IsInstalled(config.AndroidSdkDirectory, androidSdkValidator.IsInstalledAt, progress))
            {
                config.AndroidSdkDirectory = Optional.None();
            }

            config.HaveAllSdkPackages = IsInstalled(config.AndroidSdkDirectory, androidSdkValidator.AreRequiredPackagesInstalled, progress);

            return(config);
        }
コード例 #3
0
ファイル: InstallCommand.cs プロジェクト: yongaru/fuse-studio
        void Install(OptionalSdkConfigOptions config, InstallOptions opts)
        {
            // Remove old NDK installation
            config.AndroidNdkDirectory.Do(ndkPath => BackwardCompatibility.RemoveOldNdk(_fs, ndkPath));

            if (config.JavaJdkDirectory.HasValue == false)
            {
                var javaValidator = new JavaValidator(_fs);
                config.JavaJdkDirectory = TryToFindJdk(_fs, javaValidator, _progress)
                                          .Or(() => opts.Noninteractive ? Optional.None() : AskUserToProvidePath("Java Development Kit", javaValidator, _progress));
            }

            if (config.AndroidSdkDirectory.HasValue == false)
            {
                var androidSdkValidator = new AndroidSDKValidator(_fs);
                config.AndroidSdkDirectory = TryToFindAndroidSdk(androidSdkValidator, _progress)
                                             .Or(() => opts.Noninteractive ? Optional.None() : AskUserToProvidePath("Android SDK", androidSdkValidator, _progress));
            }

            // Then install based on configuration
            config.JavaJdkDirectory = config.JavaJdkDirectory.MatchWith(
                _ => _,
                () =>
            {
                var defaultPath = Platform.OperatingSystem == OS.Windows
                                                ? PathExtensions.GetEnvironmentPath(Environment.SpecialFolder.ProgramFiles)
                                  / new DirectoryName("Java")
                                  / new DirectoryName("jdk1.8.0_40")
                                                : AbsoluteDirectoryPath.Parse("/Library/Java/JavaVirtualMachines")
                                  / new DirectoryName("jdk1.8.0_40.jdk")
                                  / new DirectoryName("Contents")
                                  / new DirectoryName("Home");

                var installer = new JavaInstaller(_fs);
                installer.Install(CancellationToken.None, _dialog, _progress, opts);
                return(defaultPath);
            });

            config.JavaJdkDirectory.Do(jdk => Environment.SetEnvironmentVariable("JAVA_HOME", jdk.NativePath, EnvironmentVariableTarget.Process));

            config.AndroidSdkDirectory = config.AndroidSdkDirectory.MatchWith(
                _ => _,
                () =>
            {
                var defaultPath = Platform.OperatingSystem == OS.Mac
                                                ? PathExtensions.GetEnvironmentPath(Environment.SpecialFolder.Personal)
                                  / new DirectoryName("Library")
                                  / new DirectoryName("Android")
                                  / new DirectoryName("sdk")
                                                : PathExtensions.GetEnvironmentPath(Environment.SpecialFolder.LocalApplicationData)
                                  / new DirectoryName("Fusetools")
                                  / new DirectoryName("Fuse")
                                  / new DirectoryName("Android")
                                  / new DirectoryName("AndroidSDK");

                var installer = new AndroidSDKInstaller(defaultPath, _fs);
                installer.Install(CancellationToken.None, _dialog, _progress, opts);
                return(defaultPath);
            });

            config.AndroidSdkDirectory.Do(
                androidRoot =>
            {
                if (config.HaveAllSdkPackages &&
                    config.AndroidNdkDirectory.HasValue)
                {
                    return;
                }

                var installer = new AndroidSDKPackageInstaller(
                    _fs,
                    androidRoot,
                    Platform.OperatingSystem == OS.Windows
                                                        ? androidRoot / new DirectoryName("tools") / new FileName("android.bat")
                                                        : androidRoot / new DirectoryName("tools") / new FileName("android"),
                    Platform.OperatingSystem == OS.Windows
                                                        ? androidRoot / new DirectoryName("tools") / new DirectoryName("bin") / new FileName("sdkmanager.bat")
                                                        : androidRoot / new DirectoryName("tools") / new DirectoryName("bin") / new FileName("sdkmanager"));

                var result = installer.Install(CancellationToken.None, _dialog, _progress);

                config.AndroidNdkDirectory = result.NdkBundle;
            });
        }