Skip to content

Commit 82b53dc

Browse files
committed
Allow disabling generation of winrt configurations.
Fixes #48
1 parent 39ae187 commit 82b53dc

File tree

6 files changed

+88
-35
lines changed

6 files changed

+88
-35
lines changed

source/Templates.rc

80 Bytes
Binary file not shown.

source/configGenerator_build.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -998,8 +998,6 @@ void ConfigGenerator::buildReservedValues(vector<string>& reservedItems)
998998
reservedItems.emplace_back("small");
999999
reservedItems.emplace_back("lto");
10001000
reservedItems.emplace_back("pic");
1001-
reservedItems.emplace_back("uwp");
1002-
reservedItems.emplace_back("winrt");
10031001
}
10041002

10051003
void ConfigGenerator::buildAdditionalDependencies(DependencyList& additionalDependencies)

source/helperFunctions.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
# include <Windows.h>
3232
#else
3333
# include <dirent.h>
34-
extern char _binary_template_sln_start[];
35-
extern char _binary_template_sln_end[];
34+
extern char _binary_template_sln_winrt_start[];
35+
extern char _binary_template_sln_winrt_end[];
3636
extern char _binary_template_vcxproj_start[];
3737
extern char _binary_template_vcxproj_end[];
3838
extern char _binary_template_vcxproj_filters_start[];
@@ -51,14 +51,18 @@ extern char _binary_template_props_winrt_start[];
5151
extern char _binary_template_props_winrt_end[];
5252
extern char _binary_template_file_props_start[];
5353
extern char _binary_template_file_props_end[];
54-
const char* pp_cStartArray[] = {_binary_template_sln_start, _binary_template_vcxproj_start,
54+
extern char _binary_template_sln_nowinrt_start[];
55+
extern char _binary_template_sln_nowinrt_end[];
56+
const char* pp_cStartArray[] = {_binary_template_sln_winrt_start, _binary_template_vcxproj_start,
5557
_binary_template_vcxproj_filters_start, _binary_template_program_vcxproj_start,
5658
_binary_template_program_vcxproj_filters_start, _binary_template_bat_start, _binary_template_vcxproj_winrt_start,
57-
_binary_template_props_start, _binary_template_props_winrt_start, _binary_template_file_props_start};
58-
const char* pp_cEndArray[] = {_binary_template_sln_end, _binary_template_vcxproj_end,
59+
_binary_template_props_start, _binary_template_props_winrt_start, _binary_template_file_props_start,
60+
_binary_template_sln_nowinrt_start};
61+
const char* pp_cEndArray[] = {_binary_template_sln_winrt_end, _binary_template_vcxproj_end,
5962
_binary_template_vcxproj_filters_end, _binary_template_program_vcxproj_end,
6063
_binary_template_program_vcxproj_filters_end, _binary_template_bat_end, _binary_template_vcxproj_winrt_end,
61-
_binary_template_props_end, _binary_template_props_winrt_end, _binary_template_file_props_end};
64+
_binary_template_props_end, _binary_template_props_winrt_end, _binary_template_file_props_end,
65+
_binary_template_sln_nowinrt_end};
6266
#endif
6367

6468
#if _DEBUG

source/projectGenerator.cpp

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <sstream>
2626
#include <utility>
2727

28-
#define TEMPLATE_SLN_ID 101
28+
#define TEMPLATE_SLN_WINRT_ID 101
2929
#define TEMPLATE_VCXPROJ_ID 102
3030
#define TEMPLATE_FILTERS_ID 103
3131
#define TEMPLATE_PROG_VCXPROJ_ID 104
@@ -35,6 +35,7 @@
3535
#define TEMPLATE_PROPS_ID 108
3636
#define TEMPLATE_PROPS_WINRT_ID 109
3737
#define TEMPLATE_FILE_PROPS_ID 110
38+
#define TEMPLATE_SLN_NOWINRT_ID 111
3839

3940
bool ProjectGenerator::passAllMake()
4041
{
@@ -247,9 +248,12 @@ bool ProjectGenerator::outputProject()
247248
if (!writeToFile(outFiltersFile, filtersFile, true)) {
248249
return false;
249250
}
250-
outFiltersFile = m_configHelper.m_solutionDirectory + m_projectName + "_winrt.vcxproj.filters";
251-
if (!writeToFile(outFiltersFile, filtersFile, true)) {
252-
return false;
251+
const bool winrtEnabled = m_configHelper.isConfigOptionEnabled("winrt") || m_configHelper.isConfigOptionEnabled("uwp");
252+
if (winrtEnabled) {
253+
outFiltersFile = m_configHelper.m_solutionDirectory + m_projectName + "_winrt.vcxproj.filters";
254+
if (!writeToFile(outFiltersFile, filtersFile, true)) {
255+
return false;
256+
}
253257
}
254258

255259
// Open the input temp project file
@@ -311,8 +315,11 @@ bool ProjectGenerator::outputProject()
311315
if (!writeToFile(outProjectFile, projectFile, true)) {
312316
return false;
313317
}
314-
outProjectFile = m_configHelper.m_solutionDirectory + m_projectName + "_winrt.vcxproj";
315-
return writeToFile(outProjectFile, projectFileWinRT, true);
318+
if (winrtEnabled) {
319+
outProjectFile = m_configHelper.m_solutionDirectory + m_projectName + "_winrt.vcxproj";
320+
return writeToFile(outProjectFile, projectFileWinRT, true);
321+
}
322+
return true;
316323
}
317324

318325
bool ProjectGenerator::outputProgramProject(const string& destinationFile, const string& destinationFilterFile)
@@ -457,10 +464,18 @@ bool ProjectGenerator::outputSolution()
457464
}
458465

459466
outputLine(" Generating solution file...");
467+
const bool winrtEnabled =
468+
m_configHelper.isConfigOptionEnabled("winrt") || m_configHelper.isConfigOptionEnabled("uwp");
460469
// Open the input temp project file
461470
string solutionFile;
462-
if (!loadFromResourceFile(TEMPLATE_SLN_ID, solutionFile)) {
463-
return false;
471+
if (winrtEnabled) {
472+
if (!loadFromResourceFile(TEMPLATE_SLN_WINRT_ID, solutionFile)) {
473+
return false;
474+
}
475+
} else {
476+
if (!loadFromResourceFile(TEMPLATE_SLN_NOWINRT_ID, solutionFile)) {
477+
return false;
478+
}
464479
}
465480

466481
map<string, string> keys;
@@ -488,9 +503,9 @@ bool ProjectGenerator::outputSolution()
488503
for (const auto& i : m_projectLibs) {
489504
// Check if this is a library or a program
490505
if (programList.find(i.first) == programList.end()) {
491-
for (uint winrt = 0; winrt < 2; ++winrt) {
506+
for (uint winrt = 0; winrt < (winrtEnabled ? 2 : 1); ++winrt) {
492507
string name = i.first;
493-
if (winrt) {
508+
if (winrt > 0) {
494509
name += "_winrt";
495510
}
496511
// Check if this library has a known key (to lazy to auto generate at this time)
@@ -510,14 +525,14 @@ bool ProjectGenerator::outputSolution()
510525
projectAdd += projectEnd;
511526

512527
// Add the key to the used key list
513-
addedKeys.emplace_back(keys[name], winrt);
528+
addedKeys.emplace_back(keys[name], winrt > 0);
514529

515530
// Add the dependencies
516531
if (i.second.size() > 0) {
517532
projectAdd += depend;
518533
for (auto& j : i.second) {
519534
string name2 = j;
520-
if (winrt) {
535+
if (winrt > 0) {
521536
name2 += "_winrt";
522537
}
523538
// Check if this library has a known key
@@ -601,20 +616,26 @@ bool ProjectGenerator::outputSolution()
601616
string configPlatform = "\r\n {";
602617
string configPlatform2 = "}.";
603618
string configPlatform3 = "|";
604-
string buildConfigs[10] = {"Debug", "DebugDLL", "DebugDLLWinRT", "DebugWinRT", "Release", "ReleaseDLL",
619+
vector<string> buildConfigs = {"Debug", "DebugDLL", "DebugDLLWinRT", "DebugWinRT", "Release", "ReleaseDLL",
605620
"ReleaseDLLStaticDeps", "ReleaseDLLWinRT", "ReleaseDLLWinRTStaticDeps", "ReleaseWinRT"};
606-
string buildConfigsNoWinRT[10] = {"Debug", "DebugDLL", "DebugDLL", "Debug", "Release", "ReleaseDLL",
621+
vector<string> buildConfigsNoWinRT = {"Debug", "DebugDLL", "DebugDLL", "Debug", "Release", "ReleaseDLL",
607622
"ReleaseDLLStaticDeps", "ReleaseDLL", "ReleaseDLLStaticDeps", "Release"};
608-
string buildConfigsWinRT[10] = {"DebugWinRT", "DebugDLLWinRT", "DebugDLLWinRT", "DebugWinRT", "ReleaseWinRT",
623+
vector<string> buildConfigsWinRT = {"DebugWinRT", "DebugDLLWinRT", "DebugDLLWinRT", "DebugWinRT",
624+
"ReleaseWinRT",
609625
"ReleaseDLLWinRT", "ReleaseDLLWinRTStaticDeps", "ReleaseDLLWinRT", "ReleaseDLLWinRTStaticDeps", "ReleaseWinRT"};
626+
if (!winrtEnabled) {
627+
buildConfigs = {"Debug", "DebugDLL", "Release", "ReleaseDLL", "ReleaseDLLStaticDeps"};
628+
buildConfigsNoWinRT = buildConfigs;
629+
buildConfigsWinRT = buildConfigs;
630+
}
610631
string buildArchsSol[2] = {"x86", "x64"};
611632
string buildArchs[2] = {"Win32", "x64"};
612633
string buildTypes[2] = {".ActiveCfg = ", ".Build.0 = "};
613634
string addPlatform;
614635
// Add the lib keys
615636
for (const auto& i : addedKeys) {
616637
// loop over build configs
617-
for (uint j = 0; j < sizeof(buildConfigs) / sizeof(buildConfigs[0]); j++) {
638+
for (uint j = 0; j < buildConfigs.size(); j++) {
618639
// loop over build archs
619640
for (uint k = 0; k < sizeof(buildArchsSol) / sizeof(buildArchsSol[0]); k++) {
620641
// loop over build types
@@ -641,7 +662,7 @@ bool ProjectGenerator::outputSolution()
641662
// Add the program keys
642663
for (const auto& i : addedPrograms) {
643664
// Loop over build configs
644-
for (uint j = 0; j < sizeof(buildConfigs) / sizeof(buildConfigs[0]); j++) {
665+
for (uint j = 0; j < buildConfigs.size(); j++) {
645666
// Loop over build archs
646667
for (uint k = 0; k < sizeof(buildArchsSol) / sizeof(buildArchsSol[0]); k++) {
647668
// Loop over build types

templates/template_in.sln

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,12 @@ Global
1313
Debug|x86 = Debug|x86
1414
DebugDLL|x64 = DebugDLL|x64
1515
DebugDLL|x86 = DebugDLL|x86
16-
DebugDLLWinRT|x64 = DebugDLLWinRT|x64
17-
DebugDLLWinRT|x86 = DebugDLLWinRT|x86
18-
DebugWinRT|x64 = DebugWinRT|x64
19-
DebugWinRT|x86 = DebugWinRT|x86
2016
Release|x64 = Release|x64
2117
Release|x86 = Release|x86
2218
ReleaseDLL|x64 = ReleaseDLL|x64
2319
ReleaseDLL|x86 = ReleaseDLL|x86
2420
ReleaseDLLStaticDeps|x64 = ReleaseDLLStaticDeps|x64
2521
ReleaseDLLStaticDeps|x86 = ReleaseDLLStaticDeps|x86
26-
ReleaseDLLWinRT|x64 = ReleaseDLLWinRT|x64
27-
ReleaseDLLWinRT|x86 = ReleaseDLLWinRT|x86
28-
ReleaseDLLWinRTStaticDeps|x64 = ReleaseDLLWinRTStaticDeps|x64
29-
ReleaseDLLWinRTStaticDeps|x86 = ReleaseDLLWinRTStaticDeps|x86
30-
ReleaseWinRT|x64 = ReleaseWinRT|x64
31-
ReleaseWinRT|x86 = ReleaseWinRT|x86
3222
EndGlobalSection
3323
GlobalSection(ProjectConfigurationPlatforms) = postSolution
3424
EndGlobalSection

templates/template_in_winrt.sln

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
VisualStudioVersion = 12.0.30501.0
4+
MinimumVisualStudioVersion = 12.0.30501.0
5+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{33ACD422-DFB7-46FF-8734-7031CCFF9247}"
6+
ProjectSection(SolutionItems) = preProject
7+
readme.txt = readme.txt
8+
EndProjectSection
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|x64 = Debug|x64
13+
Debug|x86 = Debug|x86
14+
DebugDLL|x64 = DebugDLL|x64
15+
DebugDLL|x86 = DebugDLL|x86
16+
DebugDLLWinRT|x64 = DebugDLLWinRT|x64
17+
DebugDLLWinRT|x86 = DebugDLLWinRT|x86
18+
DebugWinRT|x64 = DebugWinRT|x64
19+
DebugWinRT|x86 = DebugWinRT|x86
20+
Release|x64 = Release|x64
21+
Release|x86 = Release|x86
22+
ReleaseDLL|x64 = ReleaseDLL|x64
23+
ReleaseDLL|x86 = ReleaseDLL|x86
24+
ReleaseDLLStaticDeps|x64 = ReleaseDLLStaticDeps|x64
25+
ReleaseDLLStaticDeps|x86 = ReleaseDLLStaticDeps|x86
26+
ReleaseDLLWinRT|x64 = ReleaseDLLWinRT|x64
27+
ReleaseDLLWinRT|x86 = ReleaseDLLWinRT|x86
28+
ReleaseDLLWinRTStaticDeps|x64 = ReleaseDLLWinRTStaticDeps|x64
29+
ReleaseDLLWinRTStaticDeps|x86 = ReleaseDLLWinRTStaticDeps|x86
30+
ReleaseWinRT|x64 = ReleaseWinRT|x64
31+
ReleaseWinRT|x86 = ReleaseWinRT|x86
32+
EndGlobalSection
33+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
34+
EndGlobalSection
35+
GlobalSection(SolutionProperties) = preSolution
36+
HideSolutionNode = FALSE
37+
EndGlobalSection
38+
GlobalSection(NestedProjects) = preSolution
39+
EndGlobalSection
40+
EndGlobal

0 commit comments

Comments
 (0)