Skip to content

Commit

Permalink
Update to WiX 5
Browse files Browse the repository at this point in the history
  • Loading branch information
J5lx authored and chchwy committed Apr 29, 2024
1 parent d796ce3 commit e106ddc
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/actions/create-package/create-package.sh
Expand Up @@ -150,7 +150,7 @@ create_package_windows() {
-out "pencil2d-${platform}-$3.msi" \
../util/installer/pencil2d.wxs windeployqt.wxs resources.wxs
wix build -pdbtype none -arch "x${wordsize/32/86}" -dcl high -sw1133 -b ../util/installer -b Pencil2D \
-ext WixToolset.Util.wixext -ext WixToolset.Bal.wixext \
-ext WixToolset.Util.wixext -ext WixToolset.BootstrapperApplications.wixext \
$versiondefines \
-out "pencil2d-${platform}-$3.exe" \
../util/installer/pencil2d.bundle.wxs
Expand Down
10 changes: 5 additions & 5 deletions .github/actions/install-dependencies/install-dependencies.sh
Expand Up @@ -55,11 +55,11 @@ setup_windows() {
curl -fsSLO https://okapiframework.org/binaries/main/1.45.0/okapi-apps_win32-x86_64_1.45.0.zip
mkdir okapi
"${WINDIR}\\System32\\tar" xfC okapi-apps_win32-x86_64_1.45.0.zip okapi
dotnet tool install -g wix --version 4.0.4
wix extension add -g WixToolset.Util.wixext/4.0.4 WixToolset.Bal.wixext/4.0.4
nuget install -x -OutputDirectory util/installer WixToolset.BootstrapperCore.Native -Version 4.0.4
nuget install -x -OutputDirectory util/installer WixToolset.DUtil -Version 4.0.4
nuget install -x -OutputDirectory util/installer WixToolset.BalUtil -Version 4.0.4
dotnet tool install -g wix --version 5.0.0
wix extension add -g WixToolset.Util.wixext/5.0.0 WixToolset.BootstrapperApplications.wixext/5.0.0
nuget install -x -OutputDirectory util/installer WixToolset.DUtil -Version 5.0.0
nuget install -x -OutputDirectory util/installer WixToolset.BootstrapperApplicationApi -Version 5.0.0
nuget install -x -OutputDirectory util/installer WixToolset.WixStandardBootstrapperApplicationFunctionApi -Version 5.0.0
}

"setup_$(echo "${RUNNER_OS}" | tr '[A-Z]' '[a-z]')"
10 changes: 5 additions & 5 deletions docs/installer-development.md
Expand Up @@ -31,16 +31,16 @@ please first make sure MSVC is available on your system. Additionally, you will
make sure there are no warnings concerning po2rc. If qmake cannot find po2rc, you can also manually set the PO2RC
qmake variable to the path of the po2rc executable.
- Tikal from the [Okapi Framework](https://okapiframework.org/).
- The WiX Toolset as well as its Bal and Util extensions. Use the following commands to install these from the command
line:
- The WiX Toolset as well as its BootstrapperApplications and Util extensions. Use the following commands to install
these from the command line:

dotnet tool install -g wix
wix extension add -g WixToolset.Util.wixext WixToolset.Bal.wixext
wix extension add -g WixToolset.Util.wixext WixToolset.BootstrapperApplications.wixext

- WiX utility libraries. The build system expects these in the util/installer directory. Use the following command to
install them from the command line:

nuget install -x -OutputDirectory path\to\util\installer WixToolset.BalUtil
nuget install -x -OutputDirectory path\to\util\installer WixToolset.WixStandardBootstrapperApplicationFunctionApi

- The WiX theme viewer (optional), which can be useful when making changes to the installer's UI layout. It is available
from the [WiX Toolset GitHub releases](https://github.com/wixtoolset/wix/releases) through the WixAdditionalTools
Expand Down Expand Up @@ -135,7 +135,7 @@ Available LCIDs are listed in the
Finally, building the bootstrapper requires the same version information as the Windows Installer database. Use the
following command to build it:

wix build -arch x64 -sw1133 -b path\to\util\installer -b DISTDIR -ext WixToolset.Util.wixext -ext WixToolset.Bal.wixext -d Edition=Release -d Version=X.X.X -out pencil2d-win64-X.X.X.exe path\to\util\installer\pencil2d.bundle.wxs
wix build -arch x64 -sw1133 -b path\to\util\installer -b DISTDIR -ext WixToolset.Util.wixext -ext WixToolset.BootstrapperApplications.wixext -d Edition=Release -d Version=X.X.X -out pencil2d-win64-X.X.X.exe path\to\util\installer\pencil2d.bundle.wxs

Again, in order to build for something other than 64-bit x86, replace x64 and win64 accordingly. It may be necessary to
add the directories containing the Windows Installer database or pencil2d.dll to WiX’s search path using the `-b` option
Expand Down
1 change: 1 addition & 0 deletions util/installer/pencil2d.bundle.wxs
Expand Up @@ -44,6 +44,7 @@
<!-- Translations -->
<Payload SourceFile="pencil2d_de.wxl" Name="7\thm.wxl" />
<!-- Assets -->
<Payload SourceFile="pencil2d.ico" />
<Payload SourceFile="pencil2d.png" />
<Payload SourceFile="pencil2d@2x.png" />
<Payload SourceFile="cog.png" />
Expand Down
83 changes: 51 additions & 32 deletions util/installer/pencil2d.cpp
Expand Up @@ -13,8 +13,8 @@
#include "verutil.h"
#include "xmlutil.h"

#include "BootstrapperEngine.h"
#include "BootstrapperApplication.h"
#include "BootstrapperEngineTypes.h"
#include "BootstrapperApplicationTypes.h"
#include "BAFunctions.h"

#include "IBootstrapperEngine.h"
Expand All @@ -37,11 +37,8 @@ class Pencil2DBAFunctions : public CBalBaseBAFunctions
{
public:
Pencil2DBAFunctions(
__in HMODULE hModule,
__in IBootstrapperEngine* pEngine,
__in const BA_FUNCTIONS_CREATE_ARGS* pArgs,
__in WIX_LOCALIZATION* pWixLoc
) : CBalBaseBAFunctions(hModule, pEngine, pArgs), m_pWixLoc(pWixLoc)
__in HMODULE hModule
) : CBalBaseBAFunctions(hModule)
{
}

Expand All @@ -50,6 +47,47 @@ class Pencil2DBAFunctions : public CBalBaseBAFunctions
LocFree(m_pWixLoc);
}

virtual STDMETHODIMP OnCreate(
__in IBootstrapperEngine* pEngine,
__in BOOTSTRAPPER_COMMAND* pCommand
)
{
memcpy_s(&m_command, sizeof(m_command), pCommand, sizeof(BOOTSTRAPPER_COMMAND));

return __super::OnCreate(pEngine, pCommand);
}

virtual STDMETHODIMP OnThemeLoaded(
__in HWND hWnd
)
{
HRESULT hr = S_OK;
LPWSTR sczModulePath = NULL;
LPWSTR sczLanguage = NULL;
LPWSTR sczLocPath = NULL;

hr = PathRelativeToModule(&sczModulePath, NULL, m_hModule);
BalExitOnFailure(hr, "Failed to get module path.");

hr = BalGetStringVariable(L"WixStdBALanguageId", &sczLanguage);
BalExitOnFailure(hr, "Failed to get language id.");

hr = LocProbeForFile(sczModulePath, L"thm.wxl", sczLanguage, &sczLocPath);
BalExitOnFailure(hr, "Failed to probe for loc file: %ls in path: %ls", L"thm.wxl", sczModulePath);

hr = LocLoadFromFile(sczLocPath, &m_pWixLoc);
BalExitOnFailure(hr, "Failed to load loc file from path: %ls", sczLocPath);

hr = __super::OnThemeLoaded(hWnd);

LExit:
ReleaseStr(sczLanguage);
ReleaseStr(sczLocPath);
ReleaseStr(sczModulePath);

return hr;
}

virtual STDMETHODIMP OnThemeControlLoading(
__in LPCWSTR wzName,
__inout BOOL* pfProcessed,
Expand Down Expand Up @@ -311,6 +349,7 @@ class Pencil2DBAFunctions : public CBalBaseBAFunctions
}

WIX_LOCALIZATION *m_pWixLoc = NULL;
BOOTSTRAPPER_COMMAND m_command;
HWND m_hwndControlProgressActionText = NULL;
};

Expand Down Expand Up @@ -343,45 +382,25 @@ extern "C" HRESULT WINAPI BAFunctionsCreate(
)
{
HRESULT hr = S_OK;

IBootstrapperEngine* pEngine = NULL;
LPWSTR sczModulePath = NULL;
LPWSTR sczLanguage = NULL;
LPWSTR sczLocPath = NULL;
WIX_LOCALIZATION *pWixLoc = NULL;
Pencil2DBAFunctions* pBAFunctions = NULL;

hr = BalInitializeFromCreateArgs(pArgs->pBootstrapperCreateArgs, &pEngine);
ExitOnFailure(hr, "Failed to initialize Bal.");
BalInitialize(pArgs->pEngine);

hr = XmlInitialize();
BalExitOnFailure(hr, "Failed to initialize XML util.");

hr = PathRelativeToModule(&sczModulePath, NULL, vhInstance);
BalExitOnFailure(hr, "Failed to get module path.");

hr = BalGetStringVariable(L"WixStdBALanguageId", &sczLanguage);
BalExitOnFailure(hr, "Failed to get language id.");

hr = LocProbeForFile(sczModulePath, L"thm.wxl", sczLanguage, &sczLocPath);
BalExitOnFailure(hr, "Failed to probe for loc file: %ls in path: %ls", L"thm.wxl", sczModulePath);

hr = LocLoadFromFile(sczLocPath, &pWixLoc);
BalExitOnFailure(hr, "Failed to load loc file from path: %ls", sczLocPath);

pBAFunctions = new Pencil2DBAFunctions(vhInstance, pEngine, pArgs, pWixLoc);
pBAFunctions = new Pencil2DBAFunctions(vhInstance);
BalExitOnNull(pBAFunctions, hr, E_OUTOFMEMORY, "Failed to create new Pencil2DBAFunctions object.");

hr = pBAFunctions->OnCreate(pArgs->pEngine, pArgs->pCommand);
ExitOnFailure(hr, "Failed to call OnCreate Pencil2DBAFunctions.");

pResults->pfnBAFunctionsProc = BalBaseBAFunctionsProc;
pResults->pvBAFunctionsProcContext = pBAFunctions;
pBAFunctions = NULL;

LExit:
ReleaseObject(pBAFunctions);
ReleaseStr(sczLanguage);
ReleaseStr(sczLocPath);
ReleaseStr(sczModulePath);
ReleaseObject(pEngine);

return hr;
}
Expand Down
12 changes: 7 additions & 5 deletions util/installer/pencil2d.pro
Expand Up @@ -6,16 +6,18 @@ QMAKE_LFLAGS_RELEASE += /GUARD:CF
DEFINES += _WIN32_MSI=500 _WIN32_WINNT=0x0600
QT -= core gui
INCLUDEPATH += WixToolset.DUtil/build/native/include \
WixToolset.BALUtil/build/native/include \
WixToolset.BootstrapperCore.Native/build/native/include
WixToolset.BootstrapperApplicationApi/build/native/include \
WixToolset.WixStandardBootstrapperApplicationFunctionApi/lib/native/include
equals(QMAKE_TARGET.arch, "x86") {
LIBS += "-L$$PWD/WixToolset.DUtil/build/native/v14/x86" \
"-L$$PWD/WixToolset.BALUtil/build/native/v14/x86"
"-L$$PWD/WixToolset.BootstrapperApplicationApi/build/native/v14/x86" \
"-L$$PWD/WixToolset.WixStandardBootstrapperApplicationFunctionApi/lib/native/v14/x86"
}
equals(QMAKE_TARGET.arch, "x86_64") {
LIBS += "-L$$PWD/WixToolset.DUtil/build/native/v14/x64" \
"-L$$PWD/WixToolset.BALUtil/build/native/v14/x64"
"-L$$PWD/WixToolset.BootstrapperApplicationApi/build/native/v14/x64" \
"-L$$PWD/WixToolset.WixStandardBootstrapperApplicationFunctionApi/lib/native/v14/x64"
}
LIBS += User32.lib Advapi32.lib Ole32.lib OleAut32.lib Version.lib balutil.lib dutil.lib
LIBS += User32.lib Advapi32.lib Ole32.lib OleAut32.lib Version.lib Shell32.lib wixstdfn.lib balutil.lib dutil.lib
SOURCES += pencil2d.cpp
DEF_FILE = pencil2d.def
2 changes: 1 addition & 1 deletion util/installer/pencil2d.thm
Expand Up @@ -11,7 +11,7 @@
<AlternateResolution ImageFile="cog-hover@2x.png" />
</Image>

<Window Width="640" Height="413" HexStyle="100a0000" FontId="Normal" Caption="#(loc.Caption)">
<Window Width="640" Height="413" HexStyle="100a0000" FontId="Normal" IconFile="pencil2d.ico" Caption="#(loc.Caption)">
<ImageControl X="20" Y="20" Width="600" Height="175" ImageId="pencil2d" Visible="yes"/>
<Label Name="Version" X="20" Y="-22" Width="246" Height="17" FontId="Normal" DisablePrefix="yes" VisibleCondition="WixStdBAShowVersion">
<Text>#(loc.Version)</Text>
Expand Down

0 comments on commit e106ddc

Please sign in to comment.