예제 #1
0
        public CMakeRunnerFixture(FilePath toolPath = null, bool defaultToolExist = true)
        {
            Process = Substitute.For <IProcess>();
            Process.GetExitCode().Returns(0);

            ProcessRunner = Substitute.For <IProcessRunner>();
            ProcessRunner.Start(Arg.Any <FilePath>(), Arg.Any <ProcessSettings>()).Returns(Process);

            Environment = Substitute.For <ICakeEnvironment>();
            Environment.WorkingDirectory = "/Working";
            Environment.IsUnix().Returns(false);

            Globber    = Substitute.For <IGlobber>();
            FileSystem = Substitute.For <IFileSystem>();

            if (defaultToolExist)
            {
                Globber.Match("./tools/**/cmake.exe").Returns(new[] { (FilePath)"/Working/tools/cmake.exe" });
                FileSystem.Exist(Arg.Is <FilePath>(a => a.FullPath == "/Working/tools/cmake.exe")).Returns(true);
            }

            if (toolPath != null)
            {
                FileSystem.Exist(Arg.Is <FilePath>(a => a.FullPath == toolPath.FullPath)).Returns(true);
            }

            SourcePath = "./source";
            Settings   = new CMakeSettings();
        }
        public CMakeRunnerFixture(FilePath toolPath = null, bool defaultToolExist = true)
        {
            Process = Substitute.For<IProcess>();
            Process.GetExitCode().Returns(0);

            ProcessRunner = Substitute.For<IProcessRunner>();
            ProcessRunner.Start(Arg.Any<FilePath>(), Arg.Any<ProcessSettings>()).Returns(Process);

            Environment = Substitute.For<ICakeEnvironment>();
            Environment.WorkingDirectory = "/Working";
            Environment.IsUnix().Returns(false);

            Globber = Substitute.For<IGlobber>();
            FileSystem = Substitute.For<IFileSystem>();

            if (defaultToolExist)
            {
                Globber.Match("./tools/**/cmake.exe").Returns(new[] { (FilePath)"/Working/tools/cmake.exe" });
                FileSystem.Exist(Arg.Is<FilePath>(a => a.FullPath == "/Working/tools/cmake.exe")).Returns(true);
            }

            if (toolPath != null)
            {
                FileSystem.Exist(Arg.Is<FilePath>(a => a.FullPath == toolPath.FullPath)).Returns(true);
            }

            SourcePath = "./source";
            Settings = new CMakeSettings();
        }
예제 #3
0
        public static void CMake(this ICakeContext context, DirectoryPath sourcePath, CMakeSettings settings)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var runner = new CMakeRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Globber);
            runner.Run(sourcePath, settings);
        }
예제 #4
0
        private CMakeConfiguration GetActiveConfiguration()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            string solutionPath = EditorUtils.GetSolutionPath();

            if (solutionPath == null || solutionPath.Length == 0)
            {
                return(null);
            }

            string settingsFilename = solutionPath + "CMakeSettings.json";

            if (File.Exists(settingsFilename))
            {
                CMakeSettings settings = null;

                try
                {
                    string jsonString = File.ReadAllText(settingsFilename);
                    settings = JsonConvert.DeserializeObject <CMakeSettings>(jsonString);
                }
                catch (Exception e)
                {
                    OutputLog.Error(e.Message);
                }

                string activeConfigName = GetActiveConfigurationName();
                if (activeConfigName != null && activeConfigName.Length > 0 && settings != null && settings.configurations != null)
                {
                    foreach (CMakeConfiguration config in settings.configurations)
                    {
                        if (config.name == activeConfigName)
                        {
                            return(config);
                        }
                    }
                }
            }

            return(null);
        }