Example #1
0
        /// <summary>
        /// checks if the sdk is installed or has been synced
        /// </summary>
        /// <returns></returns>
        private bool HasAnySDK()
        {
            string NDKPath = Environment.GetEnvironmentVariable("NDKROOT");

            {
                var configCacheIni = new ConfigCacheIni("Engine", null);
                var AndroidEnv     = new Dictionary <string, string>();

                Dictionary <string, string> EnvVarNames = new Dictionary <string, string> {
                    { "ANDROID_HOME", "SDKPath" },
                    { "NDKROOT", "NDKPath" },
                    { "ANT_HOME", "ANTPath" },
                    { "JAVA_HOME", "JavaPath" }
                };

                string path;
                foreach (var kvp in EnvVarNames)
                {
                    if (configCacheIni.GetPath("/Script/AndroidPlatformEditor.AndroidSDKSettings", kvp.Value, out path) && !string.IsNullOrEmpty(path))
                    {
                        AndroidEnv.Add(kvp.Key, path);
                    }
                    else
                    {
                        var envValue = Environment.GetEnvironmentVariable(kvp.Key);
                        if (!String.IsNullOrEmpty(envValue))
                        {
                            AndroidEnv.Add(kvp.Key, envValue);
                        }
                    }
                }

                // If we are on Mono and we are still missing a key then go and find it from the .bash_profile
                if (Utils.IsRunningOnMono && !EnvVarNames.All(s => AndroidEnv.ContainsKey(s.Key)))
                {
                    string BashProfilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".bash_profile");
                    if (File.Exists(BashProfilePath))
                    {
                        string[] BashProfileContents = File.ReadAllLines(BashProfilePath);
                        foreach (string Line in BashProfileContents)
                        {
                            foreach (var kvp in EnvVarNames)
                            {
                                if (AndroidEnv.ContainsKey(kvp.Key))
                                {
                                    continue;
                                }

                                if (Line.StartsWith("export " + kvp.Key + "="))
                                {
                                    string PathVar = Line.Split('=')[1].Replace("\"", "");
                                    AndroidEnv.Add(kvp.Key, PathVar);
                                }
                            }
                        }
                    }
                }

                // Set for the process
                foreach (var kvp in AndroidEnv)
                {
                    Environment.SetEnvironmentVariable(kvp.Key, kvp.Value);
                }

                // See if we have an NDK path now...
                AndroidEnv.TryGetValue("NDKROOT", out NDKPath);
            }

            // we don't have an NDKROOT specified
            if (String.IsNullOrEmpty(NDKPath))
            {
                return(false);
            }

            NDKPath = NDKPath.Replace("\"", "");

            // need a supported llvm
            if (!Directory.Exists(Path.Combine(NDKPath, @"toolchains/llvm-3.5")) &&
                !Directory.Exists(Path.Combine(NDKPath, @"toolchains/llvm-3.3")) &&
                !Directory.Exists(Path.Combine(NDKPath, @"toolchains/llvm-3.1")))
            {
                return(false);
            }
            return(true);
        }
Example #2
0
        public static string PythonPath()
        {
            // find Python.
            EnsureConfigCacheIsReady();

            string PythonPath;

            if (ConfigCache.GetPath("/Script/HTML5PlatformEditor.HTML5SDKSettings", "Python", out PythonPath) && System.IO.File.Exists(PythonPath))
            {
                return(PythonPath);
            }

            if (bAllowFallbackSDKSettings)
            {
                // Check the ini first. Check for Python="path"
                bool ok = ConfigCache.GetString("HTML5SDKPaths", "Python", out PythonPath);
                if (ok && System.IO.File.Exists(PythonPath))
                {
                    return(PythonPath);
                }

                var EmscriptenSettings = ReadEmscriptenSettings();

                // check emscripten generated config file.
                if (EmscriptenSettings.ContainsKey("PYTHON") &&
                    System.IO.File.Exists(EmscriptenSettings["PYTHON"])
                    )
                {
                    return(EmscriptenSettings["PYTHON"]);
                }

                // It might be setup as a env variable.
                if (Environment.GetEnvironmentVariable("PYTHON") != null
                    &&
                    System.IO.File.Exists(Environment.GetEnvironmentVariable("PYTHON"))
                    )
                {
                    return(Environment.GetEnvironmentVariable("PYTHON"));
                }
            }

            // it might just be on path.
            ProcessStartInfo startInfo     = new ProcessStartInfo();
            Process          PythonProcess = new Process();

            startInfo.CreateNoWindow         = true;
            startInfo.RedirectStandardOutput = true;
            startInfo.RedirectStandardInput  = true;

            startInfo.Arguments       = "python";
            startInfo.UseShellExecute = false;

            if (!Utils.IsRunningOnMono)
            {
                startInfo.FileName = "C:\\Windows\\System32\\where.exe";
            }
            else
            {
                startInfo.FileName = "whereis";
            }


            PythonProcess.StartInfo = startInfo;
            PythonProcess.Start();
            PythonProcess.WaitForExit();

            string Apps = PythonProcess.StandardOutput.ReadToEnd();

            Apps = Apps.Replace('\r', '\n');
            string[] locations = Apps.Split('\n');

            return(locations[0]);
        }