Skip to content

Commit d7ff5b9

Browse files
benhillisBen Hillis
andauthored
Refactor: trim unnecessary DLL deps from COMMON_LINK_LIBRARIES (#14426)
* Refactor: trim unnecessary DLL deps from COMMON_LINK_LIBRARIES - Split MSI/Wintrust install functions from wslutil.cpp into install.cpp - Remove MI.lib, wsldeps.lib, msi.lib, Wintrust.lib, computecore.lib, computenetwork.lib, Iphlpapi.lib from COMMON_LINK_LIBRARIES - Add per-target MSI_LINK_LIBRARIES, HCS_LINK_LIBRARIES, SERVICE_LINK_LIBRARIES - Delay-load msi.dll and WINTRUST.dll for wsl.exe and wslg.exe - Result: wslhost, wslrelay, wslcsdk, testplugin lose msi/wintrust startup imports; wsl.exe and wslg.exe defer msi/wintrust loading until actually needed; wslservice is the only target that imports computecore/computenetwork/Iphlpapi * minor fixes to install.cpp that were caught during PR * move to wsl::windows::common::install namespace --------- Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
1 parent 6425aa8 commit d7ff5b9

17 files changed

Lines changed: 531 additions & 433 deletions

File tree

CMakeLists.txt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,19 @@ set(COMMON_LINK_LIBRARIES
250250
Shlwapi.lib
251251
synchronization.lib
252252
Bcrypt.lib
253-
Iphlpapi.lib
254-
icu.lib
253+
icu.lib)
254+
255+
set(MSI_LINK_LIBRARIES
256+
Wintrust.lib
257+
msi.lib)
258+
259+
set(HCS_LINK_LIBRARIES
255260
computecore.lib
256261
computenetwork.lib
262+
Iphlpapi.lib)
263+
264+
set(SERVICE_LINK_LIBRARIES
257265
MI.lib
258-
Wintrust.lib
259-
msi.lib
260266
wsldeps.lib)
261267

262268
# Linux

src/windows/common/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ set(SOURCES
4545
WslTelemetry.cpp
4646
VirtioNetworking.cpp
4747
wslutil.cpp
48+
install.cpp
4849
notifications.cpp)
4950

5051
set(HEADERS

src/windows/common/WslClient.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Module Name:
1313
--*/
1414

1515
#include "precomp.h"
16+
#include "install.h"
1617
#include "WslInstall.h"
1718
#include "HandleConsoleProgressBar.h"
1819
#include "Distribution.h"
@@ -156,7 +157,7 @@ int BashMain(_In_ std::wstring_view commandLine)
156157
// Call the MSI package if we're in an MSIX context
157158
if (wsl::windows::common::wslutil::IsRunningInMsix())
158159
{
159-
return wsl::windows::common::wslutil::CallMsiPackage();
160+
return wsl::windows::common::install::CallMsiPackage();
160161
}
161162

162163
const auto options = ParseLegacyArguments(commandLine);
@@ -1265,7 +1266,7 @@ int UpdatePackage(std::wstring_view commandLine)
12651266
parser.AddArgument(NoOp(), WSL_UPDATE_ARG_PROMPT_OPTION_LONG);
12661267
parser.Parse();
12671268

1268-
return wsl::windows::common::wslutil::UpdatePackage(preRelease, false);
1269+
return wsl::windows::common::install::UpdatePackage(preRelease, false);
12691270
}
12701271

12711272
int Uninstall()
@@ -1274,7 +1275,7 @@ int Uninstall()
12741275
auto clearLogs =
12751276
wil::scope_exit_log(WI_DIAGNOSTICS_INFO, [&logFile]() { LOG_IF_WIN32_BOOL_FALSE(DeleteFile(logFile.c_str())); });
12761277

1277-
const auto exitCode = wsl::windows::common::wslutil::UninstallViaMsi(logFile.c_str(), &wsl::windows::common::wslutil::MsiMessageCallback);
1278+
const auto exitCode = wsl::windows::common::install::UninstallViaMsi(logFile.c_str(), &wsl::windows::common::install::MsiMessageCallback);
12781279

12791280
if (exitCode != 0)
12801281
{
@@ -1311,7 +1312,7 @@ int WslconfigMain(_In_ int argc, _In_reads_(argc) LPWSTR* argv)
13111312
// Call the MSI package if we're in an MSIX context
13121313
if (wsl::windows::common::wslutil::IsRunningInMsix())
13131314
{
1314-
return wsl::windows::common::wslutil::CallMsiPackage();
1315+
return wsl::windows::common::install::CallMsiPackage();
13151316
}
13161317

13171318
using wsl::shared::string::IsEqual;
@@ -1524,7 +1525,7 @@ int WslMain(_In_ std::wstring_view commandLine)
15241525
// Call the MSI package if we're in an MSIX context
15251526
if (wsl::windows::common::wslutil::IsRunningInMsix())
15261527
{
1527-
return wsl::windows::common::wslutil::CallMsiPackage();
1528+
return wsl::windows::common::install::CallMsiPackage();
15281529
}
15291530

15301531
// Use exit code -1 so invokers of wsl.exe can distinguish between a Linux

0 commit comments

Comments
 (0)