Ejemplo n.º 1
0
        /// <summary>
        /// Returns directory of the compilation result.
        /// </summary>
        /// <param name="platform">One of the target platforms.</param>
        /// <param name="configuration">One of the target configurations.</param>
        public virtual string GetOutputDir(TargetPlatform platform, TargetConfiguration configuration)
        {
            Debug.Assert(platform != TargetPlatform.Unknown);
            var outputDirectory = Path.Combine(BuildSystem.GetSdkLocation(), "Bin");

            if (configuration == TargetConfiguration.Release)
            {
                return(outputDirectory);
            }
            return(Path.Combine(outputDirectory, configuration.ToString()));
        }
Ejemplo n.º 2
0
        public virtual string ResolveDependency(TargetConfiguration Configuration)
        {
            string DependencyPCE = String.Format("*{0}.{1}{2}", Target.Platform.ToString(), Configuration.ToString(), Target.GetPlatformStaticLibraryExtension());
            if (Directory.GetFiles(this.Location, DependencyPCE).Length == 0)
            {   // Seams that library is build for all configurations into single library.
                string DependencyPE = String.Format("*{0}{1}", Target.Platform.ToString(), Target.GetPlatformStaticLibraryExtension());
                if (Directory.GetFiles(this.Location, DependencyPE).Length == 0)
                {   // Libary path on disk contains only extension
                    string DependencyE = "*" + Target.GetPlatformStaticLibraryExtension();
                    if (Directory.GetFiles(this.Location, DependencyE).Length == 0)
                    {   // Nothing found.
                        ConsoleOutput.WriteLine(Path.Combine(this.Location, ".gddep"), "warning: not static libraries was found this dependecy");
                        return "";
                    }

                    return Path.Combine(this.Location, DependencyE);
                }

                return Path.Combine(this.Location, DependencyPE);
            }

            return Path.Combine(this.Location, DependencyPCE);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the build options for the given target and the configuration.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="platform">The platform.</param>
        /// <param name="toolchain">The toolchain.</param>
        /// <param name="architecture">The build architecture.</param>
        /// <param name="configuration">The build configuration.</param>
        /// <param name="workingDirectory">The build workspace root folder path.</param>
        /// <param name="hotReloadPostfix">The output binaries postfix added for hot-reload builds in Editor to prevent file names collisions.</param>
        /// <returns>The build options.</returns>
        public static BuildOptions GetBuildOptions(Target target, Platform platform, Toolchain toolchain, TargetArchitecture architecture, TargetConfiguration configuration, string workingDirectory, string hotReloadPostfix = "")
        {
            var platformName      = platform.Target.ToString();
            var architectureName  = architecture.ToString();
            var configurationName = configuration.ToString();
            var options           = new BuildOptions
            {
                Target             = target,
                Platform           = platform,
                Toolchain          = toolchain,
                Architecture       = architecture,
                Configuration      = configuration,
                CompileEnv         = new CompileEnvironment(),
                LinkEnv            = new LinkEnvironment(),
                IntermediateFolder = Path.Combine(workingDirectory, Configuration.IntermediateFolder, target.Name, platformName, architectureName, configurationName),
                OutputFolder       = Path.Combine(workingDirectory, Configuration.BinariesFolder, target.Name, platformName, architectureName, configurationName),
                WorkingDirectory   = workingDirectory,
                HotReloadPostfix   = hotReloadPostfix,
            };

            toolchain?.SetupEnvironment(options);
            target.SetupTargetEnvironment(options);
            return(options);
        }
Ejemplo n.º 4
0
 public static string GetSolutionConfigurationName(TargetConfiguration targetConfiguration, TargetType targetType)
 {
     return(targetConfiguration.ToString() + (targetType == TargetType.Game ? "" : (" " + targetType.ToString())));
 }
Ejemplo n.º 5
0
 private static string GenerateCondition(TargetConfiguration Configuration)
 {
     string Platform = GetPlatformString();
     return string.Format(@"'$(Configuration)|$(Platform)'=='{0}|{1}'", Configuration.ToString(), Platform);
 }
Ejemplo n.º 6
0
        private static void BuildTargetDotNet(RulesAssembly rules, TaskGraph graph, Target target, Platform platform, TargetConfiguration configuration)
        {
            // Check if use custom project file
            if (!string.IsNullOrEmpty(target.CustomExternalProjectFilePath))
            {
                // Use msbuild to compile it
                var task = graph.Add <Task>();
                task.WorkingDirectory = Globals.Root;
                task.InfoMessage      = "Building " + Path.GetFileName(target.CustomExternalProjectFilePath);
                task.Cost             = 100;
                task.DisableCache     = true;
                task.CommandPath      = VCEnvironment.MSBuildPath;
                task.CommandArguments = string.Format("\"{0}\" /m /t:Build /p:Configuration=\"{1}\" /p:Platform=\"{2}\" {3} /nologo", target.CustomExternalProjectFilePath, configuration.ToString(), "AnyCPU", VCEnvironment.Verbosity);
                return;
            }

            // Warn if target has no valid modules
            if (target.Modules.Count == 0)
            {
                Log.Warning(string.Format("Target {0} has no modules to build", target.Name));
            }

            // Pick a project
            var project = Globals.Project;

            if (target is ProjectTarget projectTarget)
            {
                project = projectTarget.Project;
            }
            if (project == null)
            {
                throw new Exception($"Cannot build target {target.Name}. The project file is missing (.flaxproj located in the folder above).");
            }

            // Setup build environment for the target
            var targetBuildOptions = GetBuildOptions(target, platform, null, TargetArchitecture.AnyCPU, configuration, project.ProjectFolderPath);

            using (new ProfileEventScope("PreBuild"))
            {
                // Pre build
                target.PreBuild(graph, targetBuildOptions);
                PreBuild?.Invoke(graph, targetBuildOptions);

                // Ensure that target build directories exist
                if (!target.IsPreBuilt && !Directory.Exists(targetBuildOptions.IntermediateFolder))
                {
                    Directory.CreateDirectory(targetBuildOptions.IntermediateFolder);
                }
                if (!target.IsPreBuilt && !Directory.Exists(targetBuildOptions.OutputFolder))
                {
                    Directory.CreateDirectory(targetBuildOptions.OutputFolder);
                }
            }

            // Setup building common data container
            var buildData = new BuildData
            {
                Project       = project,
                Graph         = graph,
                Rules         = rules,
                Target        = target,
                TargetOptions = targetBuildOptions,
                Platform      = platform,
                Architecture  = TargetArchitecture.AnyCPU,
                Configuration = configuration,
            };

            // Collect all modules
            using (new ProfileEventScope("CollectModules"))
            {
                foreach (var moduleName in target.Modules)
                {
                    var module = rules.GetModule(moduleName);
                    if (module != null)
                    {
                        CollectModules(buildData, module, true);
                    }
                    else
                    {
                        Log.Warning(string.Format("Missing module {0} (or invalid name specified)", moduleName));
                    }
                }
            }

            // Build all modules from target binary modules but in order of collecting (from independent to more dependant ones)
            var sourceFiles = new List <string>();

            using (new ProfileEventScope("BuildModules"))
            {
                foreach (var module in buildData.ModulesOrderList)
                {
                    if (buildData.BinaryModules.Any(x => x.Contains(module)))
                    {
                        var moduleOptions = BuildModule(buildData, module);

                        // Get source files
                        sourceFiles.AddRange(moduleOptions.SourceFiles.Where(x => x.EndsWith(".cs")));

                        // Merge module into target environment
                        foreach (var e in moduleOptions.OutputFiles)
                        {
                            buildData.TargetOptions.LinkEnv.InputFiles.Add(e);
                        }
                        foreach (var e in moduleOptions.DependencyFiles)
                        {
                            buildData.TargetOptions.DependencyFiles.Add(e);
                        }
                        foreach (var e in moduleOptions.OptionalDependencyFiles)
                        {
                            buildData.TargetOptions.OptionalDependencyFiles.Add(e);
                        }
                        buildData.TargetOptions.Libraries.AddRange(moduleOptions.Libraries);
                        buildData.TargetOptions.DelayLoadLibraries.AddRange(moduleOptions.DelayLoadLibraries);
                        buildData.TargetOptions.ScriptingAPI.Add(moduleOptions.ScriptingAPI);
                    }
                }
            }

            // Build
            var outputTargetFilePath = target.GetOutputFilePath(targetBuildOptions);
            var outputPath           = Path.GetDirectoryName(outputTargetFilePath);

            using (new ProfileEventScope("Build"))
            {
                // Cleanup source files
                sourceFiles.RemoveAll(x => x.EndsWith(BuildFilesPostfix));
                sourceFiles.Sort();

                // Build assembly
                BuildDotNet(graph, buildData, targetBuildOptions, target.OutputName, sourceFiles);
            }

            // Deploy files
            if (!target.IsPreBuilt)
            {
                using (new ProfileEventScope("DeployFiles"))
                {
                    foreach (var srcFile in targetBuildOptions.OptionalDependencyFiles.Where(File.Exists).Union(targetBuildOptions.DependencyFiles))
                    {
                        var dstFile = Path.Combine(outputPath, Path.GetFileName(srcFile));
                        graph.AddCopyFile(dstFile, srcFile);
                    }
                }
            }

            using (new ProfileEventScope("PostBuild"))
            {
                // Post build
                PostBuild?.Invoke(graph, targetBuildOptions);
                target.PostBuild(graph, targetBuildOptions);
            }
        }
Ejemplo n.º 7
0
        private void ReadSettings()
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(_settingsFile);

            foreach (XmlNode curNode in doc.DocumentElement.ChildNodes)
            {
                XmlElement curElem = curNode as XmlElement;
                if (curElem == null)
                {
                    continue;
                }

                switch (curElem.Name)
                {
                case "scriptInfoDir":
                    SIsFSGameFolder = curElem.InnerText;
                    break;

                case "sourceRaw":
                    SourceRaw = curElem.GetAttribute("path");
                    if (!String.IsNullOrEmpty(SourceRaw))
                    {
                        _sourceRawFoldersSettings = curElem;
                        BuildSourceRawFolders(SourceRaw, _sourceRawFolders, curElem);
                    }
                    break;

                case "sourceFSGame":
                    SourceFSGame = curElem.GetAttribute("path");
                    if (!String.IsNullOrEmpty(SourceFSGame))
                    {
                        _sourceFSGameFoldersSettings = curElem;
                        BuildSourceRawFolders(SourceFSGame, _sourceFSGameFolders, curElem);
                    }
                    break;

                case "outputRaw":
                    _outputRaws.Add(OutputSetting.ParseFromXML(curElem, this));
                    break;

                case "outputFSGame":
                    _outputFSGames.Add(OutputSetting.ParseFromXML(curElem, this));
                    break;

                case "targetPlatform":
                    _targetPlatform = (TargetPlatform)Enum.Parse(typeof(TargetPlatform), curElem.InnerText);
                    break;

                case "targetConfiguration":
                    _targetConfiguration = (TargetConfiguration)Enum.Parse(typeof(TargetConfiguration), curElem.InnerText);
                    break;

                case "isVersionIntFromDate":
                    _isVersionIntFromDate = Boolean.Parse(curElem.InnerText);
                    break;

                case "versionInt":
                    _versionInt = String.IsNullOrEmpty(curElem.InnerText) ? 0 : Int32.Parse(curElem.InnerText);
                    break;

                case "versionStr":
                    _versionStr = curElem.InnerText;
                    break;

                default:
                    throw new XmlException("Unknown settings node '" + curElem.Name + "'");
                }
            }

            _scrManager.Trace.TraceEvent(TraceEventType.Verbose, 0, "Settings");
            _scrManager.Trace.TraceEvent(TraceEventType.Verbose, 0, "=========================");
            _scrManager.Trace.TraceEvent(TraceEventType.Verbose, 0, "WorkingPath: " + WorkingPath);
            _scrManager.Trace.TraceEvent(TraceEventType.Verbose, 0, "SIs' Path: " + SIsPath);
            _scrManager.Trace.TraceEvent(TraceEventType.Verbose, 0, "SIs' FSGame folder: " + SIsFSGameFolder);
            _scrManager.Trace.TraceEvent(TraceEventType.Verbose, 0, "GamePath: " + GamePath);

            _scrManager.Trace.TraceEvent(TraceEventType.Verbose, 0, "SourceFSGame Path: " + SourceFSGame);

            foreach (string curFolder in _sourceFSGameFolders)
            {
                _scrManager.Trace.TraceEvent(TraceEventType.Verbose, 0, "SourceFSGame: " + curFolder);
            }

            _scrManager.Trace.TraceEvent(TraceEventType.Verbose, 0, "SourceRaw Path: " + SourceRaw);

            foreach (string curFolder in _sourceRawFolders)
            {
                _scrManager.Trace.TraceEvent(TraceEventType.Verbose, 0, "SourceRaw: " + curFolder);
            }

            _scrManager.Trace.TraceEvent(TraceEventType.Verbose, 0, "TargetPlatform: " + TargetPlatform.ToString());
            _scrManager.Trace.TraceEvent(TraceEventType.Verbose, 0, "TargetConfiguration: " + TargetConfiguration.ToString());
            _scrManager.Trace.TraceEvent(TraceEventType.Verbose, 0, "IsVersionIntFromDate: " + IsVersionIntFromDate.ToString());
            _scrManager.Trace.TraceEvent(TraceEventType.Verbose, 0, "VersionInt: " + VersionInt.ToString());
            _scrManager.Trace.TraceEvent(TraceEventType.Verbose, 0, "VersionStr: " + VersionStr);

            _scrManager.Trace.TraceEvent(TraceEventType.Verbose, 0, "=========================");

            _scrManager.Trace.Flush();
        }