Skip to content

Commit 38ddf62

Browse files
committed
Restore initial VS generator.
1 parent 9af9001 commit 38ddf62

File tree

9 files changed

+453
-405
lines changed

9 files changed

+453
-405
lines changed

src/sw/client/build.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ static auto fetch1(const SwContext &swctx, const path &fn, const FetchOptions &o
148148
{
149149
auto &t = tgts.begin()->second;
150150
if (t->sw_provided)
151+
continue;
152+
if (t->skip)
151153
continue;
152154
auto s = t->getSource().clone(); // make a copy!
153155
s->applyVersion(pkg.getVersion());
@@ -215,6 +217,8 @@ std::unique_ptr<Build> fetch_and_load(const SwContext &swctx, const path &file_o
215217
auto &t = tgts.begin()->second;
216218
if (t->sw_provided)
217219
continue;
220+
if (t->skip)
221+
continue;
218222
auto s = t->getSource().clone(); // make a copy!
219223
s->applyVersion(pkg.version);
220224
if (opts.apply_version_to_source)

src/sw/driver/build.cpp

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -630,10 +630,14 @@ void Build::build_and_resolve(int n_runs)
630630
sr.restoreNow(true);
631631

632632
sw_check_abi_version(getModuleStorage(*this).get(dll).sw_get_module_abi_version());
633-
getModuleStorage(*this).get(dll).check(*this, checker);
634-
// we can use new (clone of this) solution, then copy known targets
635-
// to allow multiple passes-builds
636-
getModuleStorage(*this).get(dll).build(*this);
633+
for (auto &s : settings)
634+
{
635+
current_settings = &s;
636+
getModuleStorage(*this).get(dll).check(*this, checker);
637+
// we can use new (clone of this) solution, then copy known targets
638+
// to allow multiple passes-builds
639+
getModuleStorage(*this).get(dll).build(*this);
640+
}
637641

638642
sr.restoreNow(true);
639643

@@ -842,9 +846,12 @@ void Build::resolvePass(const Target &t, const DependenciesType &deps) const
842846
auto i = h->getChildren().find(d->getPackage());
843847
if (i != h->getChildren().end())
844848
{
845-
auto t = std::static_pointer_cast<NativeTarget>(i->second.begin()->second);
846-
if (t)
847-
d->setTarget(*t);
849+
auto i2 = i->second.find(TargetSettings{ t.getSettings() });
850+
if (i2 == i->second.end())
851+
throw SW_RUNTIME_ERROR("no such target: " + d->getPackage().toString());
852+
auto t2 = std::static_pointer_cast<NativeTarget>(i2->second);
853+
if (t2)
854+
d->setTarget(*t2);
848855
else
849856
throw SW_RUNTIME_ERROR("bad target cast to NativeTarget during resolve");
850857

@@ -903,11 +910,9 @@ void Build::addFirstConfig()
903910
addSettings(ss);
904911
}
905912

906-
void Build::findCompiler()
913+
/*void Build::findCompiler()
907914
{
908-
SW_UNIMPLEMENTED;
909-
910-
/*Settings.init();
915+
Settings.init();
911916
912917
if (!disable_compiler_lookup)
913918
detectCompilers(*this);
@@ -1154,8 +1159,8 @@ void Build::findCompiler()
11541159
add_target("org.LLVM.clangpp");
11551160
}
11561161
1157-
setSettings();*/
1158-
}
1162+
setSettings();
1163+
}*/
11591164

11601165
static auto getFilesHash(const Files &files)
11611166
{
@@ -2612,7 +2617,7 @@ void Build::load_packages(const StringSet &pkgs)
26122617
// now we set ours TargetsToBuild to this object
26132618
// execute() will propagate them to solutions
26142619
for (auto &[porig, p] : m)
2615-
TargetsToBuild[p];
2620+
TargetsToBuild[p] = getChildren()[p];
26162621
}
26172622

26182623
void Build::build_packages(const StringSet &pkgs)
@@ -2887,10 +2892,9 @@ void Build::createSolutions(const path &dll, bool usedll)
28872892
// compiler
28882893
auto set_cl = [](auto &s, const String &compiler)
28892894
{
2890-
SW_UNIMPLEMENTED;
28912895
auto t = compilerTypeFromStringCaseI(compiler);
2892-
//if (toIndex(t))
2893-
//s.Native.CompilerType = t;
2896+
if (toIndex(t))
2897+
s.Native.CompilerType1 = t;
28942898
};
28952899

28962900
mult_and_action(compiler.size(), [&set_cl](auto &s, int i)
@@ -2941,12 +2945,10 @@ void Build::load_dll(const path &dll, bool usedll)
29412945
// add cc if needed
29422946
//getHostSolution();
29432947

2948+
// initiate libc
29442949
for (auto &s : settings)
29452950
{
2946-
// apply config settings
2947-
//s.findCompiler();
2948-
2949-
// initiate libc
2951+
current_settings = &s;
29502952
//if (s.Settings.Native.libc)
29512953
//{
29522954
// Resolver r;
@@ -3001,7 +3003,10 @@ void Build::load_dll(const path &dll, bool usedll)
30013003
if (usedll)
30023004
{
30033005
for (auto &s : settings)
3006+
{
3007+
current_settings = &s;
30043008
getModuleStorage(*this).get(dll).check(*this, checker);
3009+
}
30053010
}
30063011
}
30073012

src/sw/driver/build.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ struct SW_DRIVER_CPP_API Build : TargetBase
161161
path getSourceDir(const LocalPackage &p) const;
162162
std::optional<path> getSourceDir(const Source &s, const Version &v) const;
163163
bool skipTarget(TargetScope Scope) const;
164-
void findCompiler();
165164
//bool exists(const PackageId &p) const;
166165
TargetMap &getChildren() { return children; }
167166
const TargetMap &getChildren() const { return children; }

src/sw/driver/compiler.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,26 @@ void detectCompilers(Build &s)
147147
}
148148

149149
template <class T = PredefinedTarget>
150-
static decltype(auto) addProgram(Build &s, const PackagePath &pp, const std::shared_ptr<Program> &cl)
150+
static decltype(auto) addProgramNoFile(Build &s, const PackagePath &pp, const std::shared_ptr<Program> &p)
151151
{
152-
auto &t = s.add<T>(pp, cl->getVersion());
153-
t.program = cl;
152+
auto &t = s.add<T>(pp, p->getVersion());
153+
t.program = p;
154154
t.sw_provided = true;
155155
return t;
156156
}
157157

158+
template <class T = PredefinedTarget>
159+
static void addProgram(Build &s, const PackagePath &pp, const std::shared_ptr<Program> &p)
160+
{
161+
if (!fs::exists(p->file))
162+
{
163+
//throw SW_RUNTIME_ERROR("Program does not exist: " + normalize_path(p->file));
164+
LOG_TRACE(logger, "Program does not exist: " + normalize_path(p->file));
165+
return;
166+
}
167+
addProgramNoFile(s, pp, p);
168+
}
169+
158170
void detectDCompilers(Build &s)
159171
{
160172
path compiler;
@@ -420,6 +432,7 @@ void detectWindowsCompilers(Build &s)
420432
}
421433

422434
// ASM
435+
if (s.getSettings().TargetOS.Arch == ArchType::x86_64 || s.getSettings().TargetOS.Arch == ArchType::x86)
423436
{
424437
auto C = std::make_shared<VisualStudioASMCompiler>(s.swctx);
425438
C->Type = CompilerType::MSVC;
@@ -429,7 +442,6 @@ void detectWindowsCompilers(Build &s)
429442

430443
if (instance.version.isPreRelease())
431444
C->getVersion().getExtra() = instance.version.getExtra();
432-
//C->input_extensions = { ".asm", };
433445
addProgram(s, "com.Microsoft.VisualStudio.VC.ml", C);
434446
}
435447

@@ -456,7 +468,7 @@ void detectWindowsCompilers(Build &s)
456468
}
457469

458470
// now register
459-
addProgram(s, "com.Microsoft.VisualStudio", std::make_shared<VSInstance>(instance));
471+
addProgramNoFile(s, "com.Microsoft.VisualStudio", std::make_shared<VSInstance>(instance));
460472

461473
continue;
462474

src/sw/driver/compiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ struct SW_DRIVER_CPP_API NativeToolchain
131131
// rc (resource compiler)
132132
// ar, more tools...
133133
// more native compilers (cuda etc.)
134-
//::sw::CompilerType CompilerType = CompilerType::UnspecifiedCompiler;
134+
::sw::CompilerType CompilerType1 = CompilerType::UnspecifiedCompiler;
135135
//LinkerType LinkerType; // rename - use type from selected tool
136136
BuildLibrariesAs LibrariesType = LibraryType::Shared;
137137
::sw::ConfigurationType ConfigurationType = ConfigurationType::Release;

0 commit comments

Comments
 (0)