// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. using System.Collections.Generic; using Flax.Build.NativeCpp; namespace Flax.Build.Projects { /// /// The project file data for generator. /// public class Project { private string _path; /// /// The project generator that created this project. /// public ProjectGenerator Generator; /// /// The project name. /// public string Name; /// /// The project type. Overrides the type of the target. /// public TargetType? Type; /// /// The project output type. Overrides the output type of the target. /// public TargetOutputType? OutputType; /// /// The project file path. /// public virtual string Path { get => _path; set => _path = value; } /// /// The workspace root directory path. /// public string WorkspaceRootPath; /// /// The project source files directories. /// public List SourceDirectories; /// /// The project source files. /// public List SourceFiles; /// /// The project source files that are generated by the build system. Can be hidden in project tree but are relevant for the project. /// public List GeneratedSourceFiles; /// /// The targets used in the project. Non-empty and non-null collection of one or more valid projects. /// public Target[] Targets; /// /// The source code build defines. /// public HashSet Defines = new HashSet(); /// /// The additional included source files path. /// public string[] SearchPaths; /// /// The project dependencies. /// public HashSet Dependencies = new HashSet(); /// /// The custom name of the project group. Useful to group the project in the solution eg. by category or the project name. /// public string GroupName = string.Empty; /// /// Gets the source folder path (or workspace root if no source directory is assigned). /// public string SourceFolderPath => SourceDirectories != null && SourceDirectories.Count > 0 ? SourceDirectories[0] : WorkspaceRootPath; /// /// The configuration data. /// public struct ConfigurationData { /// /// The name of the configuration (eg. Editor.Windows.Debug|x64). /// public string Name; /// /// The configuration text (eg.Editor.Windows.Debug). /// public string Text; /// /// The platform. /// public TargetPlatform Platform; /// /// The platform name. /// public string PlatformName; /// /// The architecture. /// public TargetArchitecture Architecture; /// /// The architecture name. /// public string ArchitectureName; /// /// The configuration. /// public TargetConfiguration Configuration; /// /// The configuration name. /// public string ConfigurationName; /// /// The target. /// public Target Target; /// /// The target build options merged from the modules (fake project build environment). /// public BuildOptions TargetBuildOptions; /// /// The list of modules for build (fake project build environment). /// public Dictionary Modules; /// /// Initializes a new instance of the struct. /// /// The target. /// The project. /// The platform. /// The architecture. /// The configuration. public ConfigurationData(Target target, Project project, Platform platform, TargetArchitecture architecture, TargetConfiguration configuration) { var targetName = target.ConfigurationName ?? target.Name; var platformName = platform.Target.ToString(); var configurationName = configuration.ToString(); var configurationText = targetName + '.' + platformName + '.' + configurationName; var architectureName = architecture.ToString(); if (platform is IProjectCustomizer customizer) customizer.GetProjectArchitectureName(project, platform, architecture, ref architectureName); Name = configurationText + '|' + architectureName; Text = configurationText; Platform = platform.Target; PlatformName = platformName; Architecture = architecture; ArchitectureName = architectureName; Configuration = configuration; ConfigurationName = configurationName; Target = target; TargetBuildOptions = null; Modules = new Dictionary(); } /// public override string ToString() { return Name; } } /// /// The project configurations. /// public List Configurations = new List(); /// /// The native C++ project options. /// public struct NativeCppProject { } /// /// The native C++ project options. /// public NativeCppProject NativeCpp; /// /// The native C# project options. /// public struct CSharpProject { /// /// If set to true, the generated project will use Flax.VS extension for scripts debugging, otherwise it will be generic C# project. /// public bool UseFlaxVS; /// /// The system libraries references. /// public HashSet SystemReferences; /// /// The .Net libraries references (dll or exe files paths). /// public HashSet FileReferences; /// /// The output folder path (optional). /// public string OutputPath; /// /// The intermediate output folder path (optional). /// public string IntermediateOutputPath; } /// /// The native C# project options. /// public CSharpProject CSharp = new CSharpProject { SystemReferences = new HashSet(), FileReferences = new HashSet(), }; /// /// Generates the project. /// public virtual void Generate() { Generator.GenerateProject(this); } /// public override string ToString() { return $"{Name} ({Path})"; } } }