예제 #1
0
 public virtual void CompileCSharpProject(CSharpEnvironment CompileEnvironment, string ProjectFileName, string DestinationFile)
 {
 }
예제 #2
0
        /// <summary>
        /// Builds the binary.
        /// </summary>
        /// <param name="ToolChain">The toolchain to use for building</param>
        /// <param name="CompileEnvironment">The environment to compile the binary in</param>
        /// <param name="LinkEnvironment">The environment to link the binary in</param>
        /// <returns></returns>
        public override IEnumerable<FileItem> Build(ISTToolChain ToolChain, CPPEnvironment CompileEnvironment, LinkEnvironment LinkEnvironment)
        {
            var ProjectCSharpEnviroment = new CSharpEnvironment();
            if (LinkEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Debug)
            {
                ProjectCSharpEnviroment.TargetConfiguration = CSharpTargetConfiguration.Debug;
            }
            else
            {
                ProjectCSharpEnviroment.TargetConfiguration = CSharpTargetConfiguration.Development;
            }
            ProjectCSharpEnviroment.EnvironmentTargetPlatform = LinkEnvironment.Config.Target.Platform;

            // Currently only supported by windows...
            STToolChain.GetPlatformToolChain(CPPTargetPlatform.Win64).CompileCSharpProject(
                ProjectCSharpEnviroment, Config.ProjectFilePath, Config.OutputFilePath);

            return new FileItem[] { FileItem.GetItemByPath(Config.OutputFilePath) };
        }
예제 #3
0
        public override void CompileCSharpProject(CSharpEnvironment CompileEnvironment, string ProjectFileName, string DestinationFile)
        {
            // Initialize environment variables required for spawned tools.
            var EnvVars = VCEnvironment.SetEnvironment(CompileEnvironment.EnvironmentTargetPlatform);

            var BuildProjectAction = new Action(ActionType.BuildProject);

            // Specify the source file (prerequisite) for the action
            var ProjectFileItem = FileItem.GetExistingItemByPath(ProjectFileName);
            if (ProjectFileItem == null)
            {
                throw new BuildException("Expected C# project file {0} to exist.", ProjectFileName);
            }

            // Add the project and the files contained to the prerequisites.
            BuildProjectAction.PrerequisiteItems.Add(ProjectFileItem);
            var ProjectFile = new VCSharpProjectFile(Utils.MakePathRelativeTo(ProjectFileName, ProjectFileGenerator.MasterProjectRelativePath));
            var ProjectPreReqs = ProjectFile.GetCSharpDependencies();
            var ProjectFolder = Path.GetDirectoryName(ProjectFileName);
            foreach (string ProjectPreReqRelativePath in ProjectPreReqs)
            {
                string ProjectPreReqAbsolutePath = Path.Combine(ProjectFolder, ProjectPreReqRelativePath);
                var ProjectPreReqFileItem = FileItem.GetExistingItemByPath(ProjectPreReqAbsolutePath);
                if (ProjectPreReqFileItem == null)
                {
                    throw new BuildException("Expected C# dependency {0} to exist.", ProjectPreReqAbsolutePath);
                }
                BuildProjectAction.PrerequisiteItems.Add(ProjectPreReqFileItem);
            }

            // We might be able to distribute this safely, but it doesn't take any time.
            BuildProjectAction.bCanExecuteRemotely = false;

            // Setup execution via MSBuild.
            BuildProjectAction.WorkingDirectory = Path.GetFullPath(".");
            BuildProjectAction.StatusDescription = Path.GetFileName(ProjectFileName);
            BuildProjectAction.CommandPath = EnvVars.MSBuildPath;
            if (CompileEnvironment.TargetConfiguration == CSharpTargetConfiguration.Debug)
            {
                BuildProjectAction.CommandArguments = " /target:rebuild /property:Configuration=Debug";
            }
            else
            {
                BuildProjectAction.CommandArguments = " /target:rebuild /property:Configuration=Development";
            }

            // Be less verbose
            BuildProjectAction.CommandArguments += " /nologo /verbosity:minimal";

            // Add project
            BuildProjectAction.CommandArguments += String.Format(" \"{0}\"", ProjectFileItem.AbsolutePath);

            // Specify the output files.
            string PDBFilePath = Path.Combine(Path.GetDirectoryName(DestinationFile), Path.GetFileNameWithoutExtension(DestinationFile) + ".pdb");
            FileItem PDBFile = FileItem.GetItemByPath(PDBFilePath);
            BuildProjectAction.ProducedItems.Add(FileItem.GetItemByPath(DestinationFile));
            BuildProjectAction.ProducedItems.Add(PDBFile);
        }