Skip to content

Commit 4d9eec4

Browse files
committed
Continue to improve vs generator. Remove group number from driver's Build.
1 parent 566a460 commit 4d9eec4

29 files changed

+614
-208
lines changed

src/sw/client/generator/generator.cpp

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ String toPathString(GeneratorType t)
4141
{
4242
case GeneratorType::VisualStudio:
4343
return "vs";
44-
case GeneratorType::VisualStudioNMake:
45-
return "vs_nmake";
46-
case GeneratorType::VisualStudioUtility:
47-
return "vs_util";
48-
case GeneratorType::VisualStudioNMakeAndUtility:
49-
return "vs_nmake_util";
5044
case GeneratorType::Ninja:
5145
return "ninja";
5246
case GeneratorType::Batch:
@@ -66,18 +60,29 @@ String toPathString(GeneratorType t)
6660
}
6761
}
6862

63+
String toPathString(VsGeneratorType t)
64+
{
65+
switch (t)
66+
{
67+
case VsGeneratorType::VisualStudio:
68+
return "vs";
69+
case VsGeneratorType::VisualStudioNMake:
70+
return "vs_nmake";
71+
case VsGeneratorType::VisualStudioUtility:
72+
return "vs_util";
73+
case VsGeneratorType::VisualStudioNMakeAndUtility:
74+
return "vs_nmake_util";
75+
default:
76+
throw SW_LOGIC_ERROR("not implemented");
77+
}
78+
}
79+
6980
static String toString(GeneratorType t)
7081
{
7182
switch (t)
7283
{
7384
case GeneratorType::VisualStudio:
7485
return "Visual Studio";
75-
case GeneratorType::VisualStudioNMake:
76-
return "Visual Studio NMake";
77-
case GeneratorType::VisualStudioUtility:
78-
return "Visual Studio Utility";
79-
case GeneratorType::VisualStudioNMakeAndUtility:
80-
return "Visual Studio NMake and Utility";
8186
case GeneratorType::Ninja:
8287
return "Ninja";
8388
case GeneratorType::Batch:
@@ -97,19 +102,30 @@ static String toString(GeneratorType t)
97102
}
98103
}
99104

105+
static String toString(VsGeneratorType t)
106+
{
107+
switch (t)
108+
{
109+
case VsGeneratorType::VisualStudio:
110+
return "Visual Studio";
111+
case VsGeneratorType::VisualStudioNMake:
112+
return "Visual Studio NMake";
113+
case VsGeneratorType::VisualStudioUtility:
114+
return "Visual Studio Utility";
115+
case VsGeneratorType::VisualStudioNMakeAndUtility:
116+
return "Visual Studio NMake and Utility";
117+
default:
118+
throw SW_LOGIC_ERROR("not implemented");
119+
}
120+
}
121+
100122
static GeneratorType fromString(const String &s)
101123
{
102124
// make icasecmp
103125
if (0)
104126
;
105127
else if (boost::istarts_with(s, "VS_IDE") || boost::istarts_with(s, "VS"))
106128
return GeneratorType::VisualStudio;
107-
else if (boost::istarts_with(s, "VS_NMake"))
108-
return GeneratorType::VisualStudioNMake;
109-
else if (boost::istarts_with(s, "VS_Utility") || boost::istarts_with(s, "VS_Util"))
110-
return GeneratorType::VisualStudioUtility;
111-
else if (boost::istarts_with(s, "VS_NMakeAndUtility") || boost::istarts_with(s, "VS_NMakeAndUtil") || boost::istarts_with(s, "VS_NMakeUtil"))
112-
return GeneratorType::VisualStudioNMakeAndUtility;
113129
else if (boost::iequals(s, "Ninja"))
114130
return GeneratorType::Ninja;
115131
else if (boost::iequals(s, "Make") || boost::iequals(s, "Makefile"))
@@ -125,7 +141,23 @@ static GeneratorType fromString(const String &s)
125141
else if (boost::iequals(s, "SwExPlan"))
126142
return GeneratorType::SwExecutionPlan;
127143
//else if (boost::iequals(s, "qtc"))
128-
//return GeneratorType::qtc;
144+
//return GeneratorType::qtc;
145+
throw SW_RUNTIME_ERROR("Unknown generator: " + s);
146+
}
147+
148+
static VsGeneratorType fromStringVs(const String &s)
149+
{
150+
// make icasecmp
151+
if (0)
152+
;
153+
else if (boost::istarts_with(s, "VS_IDE") || boost::istarts_with(s, "VS"))
154+
return VsGeneratorType::VisualStudio;
155+
else if (boost::istarts_with(s, "VS_NMake"))
156+
return VsGeneratorType::VisualStudioNMake;
157+
else if (boost::istarts_with(s, "VS_Utility") || boost::istarts_with(s, "VS_Util"))
158+
return VsGeneratorType::VisualStudioUtility;
159+
else if (boost::istarts_with(s, "VS_NMakeAndUtility") || boost::istarts_with(s, "VS_NMakeAndUtil") || boost::istarts_with(s, "VS_NMakeUtil"))
160+
return VsGeneratorType::VisualStudioNMakeAndUtility;
129161
throw SW_RUNTIME_ERROR("Unknown generator: " + s);
130162
}
131163

@@ -136,12 +168,10 @@ std::unique_ptr<Generator> Generator::create(const String &s)
136168
switch (t)
137169
{
138170
case GeneratorType::VisualStudio:
139-
case GeneratorType::VisualStudioNMake:
140-
case GeneratorType::VisualStudioUtility:
141-
case GeneratorType::VisualStudioNMakeAndUtility:
142171
{
143172
auto g1 = std::make_unique<VSGenerator>();
144173
g1->version = Version(vsVersionFromString(s));
174+
g1->vstype = fromStringVs(s);
145175
g = std::move(g1);
146176
break;
147177
}

src/sw/client/generator/generator.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,24 @@ enum class GeneratorType
4242
QMake,
4343
Shell,
4444
VisualStudio,
45+
46+
SwExecutionPlan,
47+
};
48+
49+
enum class VsGeneratorType
50+
{
51+
VisualStudio,
4552
VisualStudioNMake,
4653
VisualStudioUtility,
4754
VisualStudioNMakeAndUtility,
48-
49-
SwExecutionPlan,
5055
};
5156

5257
struct Generator
5358
{
5459
virtual ~Generator() = default;
5560

5661
virtual void generate(const sw::SwBuild &) = 0;
57-
5862
static std::unique_ptr<Generator> create(const String &s);
59-
6063
GeneratorType getType() const { return type; }
6164

6265
private:
@@ -67,6 +70,7 @@ struct VSGenerator : Generator
6770
{
6871
sw::Version version;
6972
path sln_root;
73+
VsGeneratorType vstype;
7074

7175
void generate(const sw::SwBuild &b) override;
7276
};

src/sw/client/generator/vs/project_emitter.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static String toString(LibraryType t)
9696

9797
} // namespace generator
9898

99-
static std::string getVsToolset(const Version &v)
99+
std::string getVsToolset(const Version &v)
100100
{
101101
switch (v.getMajor())
102102
{
@@ -105,7 +105,7 @@ static std::string getVsToolset(const Version &v)
105105
case 15:
106106
return "v141";
107107
case 14:
108-
return "v14";
108+
return "v140";
109109
case 12:
110110
return "v12";
111111
case 11:
@@ -241,8 +241,9 @@ void ProjectEmitter::addPropertyGroupConfigurationTypes(const Project &p)
241241
{
242242
for (auto &s : p.getSettings())
243243
{
244+
auto &d = p.getData(s);
244245
beginBlockWithConfiguration("PropertyGroup", s, {{"Label", "Configuration"}});
245-
addConfigurationType((int)p.type);
246+
addConfigurationType((int)d.type);
246247
//addBlock("UseDebugLibraries", generator::toString(s.Settings.Native.ConfigurationType));
247248
if (toolset.empty())
248249
{

src/sw/client/generator/vs/project_emitter.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ namespace sw
2626
{
2727

2828
struct BuildSettings;
29+
struct Version;
2930

3031
}
3132

@@ -65,3 +66,5 @@ struct ProjectEmitter : XmlEmitter
6566
};
6667

6768
String get_configuration(const sw::BuildSettings &s);
69+
std::string getVsToolset(const sw::Version &v);
70+

src/sw/client/generator/vs/solution_emitter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@ struct SolutionEmitter : primitives::Emitter
5858
void endProjectSection();
5959
};
6060

61-
static path vs_project_dir = "projects";
62-
static String vs_project_ext = ".vcxproj";
61+
static const path vs_project_dir = "projects";
62+
static const String vs_project_ext = ".vcxproj";

0 commit comments

Comments
 (0)