/
generator.h
102 lines (81 loc) · 2.19 KB
/
generator.h
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Copyright (C) 2017-2018 Egor Pugin <egor.pugin@gmail.com>
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#pragma once
#include <cppan_version.h>
#include <package_path.h>
#include <primitives/emitter.h>
#include <primitives/filesystem.h>
namespace sw
{
struct Build;
enum class GeneratorType
{
UnspecifiedGenerator,
Batch,
CMake,
CompilationDatabase,
Make,
NMake,
Ninja,
QMake,
Shell,
VisualStudio,
VisualStudioNMake,
VisualStudioUtility,
VisualStudioNMakeAndUtility,
};
struct Generator
{
GeneratorType type = GeneratorType::UnspecifiedGenerator;
//path dir;
path file;
virtual ~Generator() = default;
virtual void generate(const Build &b) = 0;
void generate(const path &file, const Build &b);
virtual void createSolutions(Build &b) {}
virtual void initSolutions(Build &b) {}
static std::unique_ptr<Generator> create(const String &s);
};
struct VSGenerator : Generator
{
Version version;
String cwd;
path dir;
const path projects_dir = "projects";
const InsecurePath deps_subdir = "Dependencies";
const InsecurePath overridden_deps_subdir = "Overridden Packages";
const String predefined_targets_dir = ". SW Predefined Targets"s;
const String all_build_name = "ALL_BUILD"s;
const String build_dependencies_name = "BUILD_DEPENDENCIES"s;
VSGenerator();
void generate(const Build &b) override;
void createSolutions(Build &b) override;
void initSolutions(Build &b) override;
};
struct NinjaGenerator : Generator
{
void generate(const Build &b) override;
};
struct MakeGenerator : Generator
{
void generate(const Build &b) override;
};
struct ShellGenerator : Generator
{
void generate(const Build &b) override;
};
struct BatchGenerator : Generator
{
void generate(const Build &b) override;
};
struct CompilationDatabaseGenerator : Generator
{
void generate(const Build &b) override;
};
String toString(GeneratorType Type);
String toPathString(GeneratorType Type);
GeneratorType fromString(const String &ss);
}