summaryrefslogtreecommitdiffstats
path: root/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ApiSolutionGenerator.cs
blob: bfae2afc1341b8175417a9304684be731fd372ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System.Collections.Generic;
using System.IO;

namespace GodotTools.ProjectEditor
{
    public static class ApiSolutionGenerator
    {
        public static void GenerateApiSolution(string solutionDir,
            string coreProjDir, IEnumerable<string> coreCompileItems,
            string editorProjDir, IEnumerable<string> editorCompileItems)
        {
            var solution = new DotNetSolution(ApiAssemblyNames.SolutionName);

            solution.DirectoryPath = solutionDir;

            // GodotSharp project

            const string coreApiAssemblyName = ApiAssemblyNames.Core;

            string coreGuid = ProjectGenerator.GenCoreApiProject(coreProjDir, coreCompileItems);

            var coreProjInfo = new DotNetSolution.ProjectInfo
            {
                Guid = coreGuid,
                PathRelativeToSolution = Path.Combine(coreApiAssemblyName, $"{coreApiAssemblyName}.csproj")
            };
            coreProjInfo.Configs.Add("Debug");
            coreProjInfo.Configs.Add("Release");

            solution.AddNewProject(coreApiAssemblyName, coreProjInfo);

            // GodotSharpEditor project

            const string editorApiAssemblyName = ApiAssemblyNames.Editor;

            string editorGuid = ProjectGenerator.GenEditorApiProject(editorProjDir,
                $"../{coreApiAssemblyName}/{coreApiAssemblyName}.csproj", editorCompileItems);

            var editorProjInfo = new DotNetSolution.ProjectInfo();
            editorProjInfo.Guid = editorGuid;
            editorProjInfo.PathRelativeToSolution = Path.Combine(editorApiAssemblyName, $"{editorApiAssemblyName}.csproj");
            editorProjInfo.Configs.Add("Debug");
            editorProjInfo.Configs.Add("Release");

            solution.AddNewProject(editorApiAssemblyName, editorProjInfo);

            // Save solution

            solution.Save();
        }
    }
}