aboutsummaryrefslogtreecommitdiff
path: root/src/bextutil
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2020-08-01 10:20:31 -0600
committerSean Hall <r.sean.hall@gmail.com>2020-08-09 10:47:30 -0600
commita37013d41f0702cbdf2aee6dce95d26dafc069b4 (patch)
tree16cc67c99f5319279a32a07c1fd1b52dccd13867 /src/bextutil
parent2ded319a01a9ec42b637a677813d394cd7eda6b9 (diff)
downloadwix-a37013d41f0702cbdf2aee6dce95d26dafc069b4.tar.gz
wix-a37013d41f0702cbdf2aee6dce95d26dafc069b4.tar.bz2
wix-a37013d41f0702cbdf2aee6dce95d26dafc069b4.zip
WIXFEAT:4763 Change "string" variable type to literal and add "formatted".
Diffstat (limited to 'src/bextutil')
-rw-r--r--src/bextutil/BextBundleExtensionEngine.cpp21
-rw-r--r--src/bextutil/bextutil.cpp50
-rw-r--r--src/bextutil/bextutil.vcxproj8
-rw-r--r--src/bextutil/inc/IBundleExtensionEngine.h8
-rw-r--r--src/bextutil/inc/bextutil.h20
-rw-r--r--src/bextutil/packages.config4
6 files changed, 77 insertions, 34 deletions
diff --git a/src/bextutil/BextBundleExtensionEngine.cpp b/src/bextutil/BextBundleExtensionEngine.cpp
index 02070a6f..a78b3130 100644
--- a/src/bextutil/BextBundleExtensionEngine.cpp
+++ b/src/bextutil/BextBundleExtensionEngine.cpp
@@ -225,23 +225,6 @@ public: // IBundleExtensionEngine
225 return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_LOG, &args, &results, m_pvBundleExtensionEngineProcContext); 225 return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_LOG, &args, &results, m_pvBundleExtensionEngineProcContext);
226 } 226 }
227 227
228 virtual STDMETHODIMP SetVariableLiteralString(
229 __in_z LPCWSTR wzVariable,
230 __in_z_opt LPCWSTR wzValue
231 )
232 {
233 BUNDLE_EXTENSION_ENGINE_SETVARIABLELITERALSTRING_ARGS args = { };
234 BUNDLE_EXTENSION_ENGINE_SETVARIABLELITERALSTRING_RESULTS results = { };
235
236 args.cbSize = sizeof(args);
237 args.wzVariable = wzVariable;
238 args.wzValue = wzValue;
239
240 results.cbSize = sizeof(results);
241
242 return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLELITERALSTRING, &args, &results, m_pvBundleExtensionEngineProcContext);
243 }
244
245 virtual STDMETHODIMP SetVariableNumeric( 228 virtual STDMETHODIMP SetVariableNumeric(
246 __in_z LPCWSTR wzVariable, 229 __in_z LPCWSTR wzVariable,
247 __in LONGLONG llValue 230 __in LONGLONG llValue
@@ -261,7 +244,8 @@ public: // IBundleExtensionEngine
261 244
262 virtual STDMETHODIMP SetVariableString( 245 virtual STDMETHODIMP SetVariableString(
263 __in_z LPCWSTR wzVariable, 246 __in_z LPCWSTR wzVariable,
264 __in_z_opt LPCWSTR wzValue 247 __in_z_opt LPCWSTR wzValue,
248 __in BOOL fFormatted
265 ) 249 )
266 { 250 {
267 BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_ARGS args = { }; 251 BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_ARGS args = { };
@@ -270,6 +254,7 @@ public: // IBundleExtensionEngine
270 args.cbSize = sizeof(args); 254 args.cbSize = sizeof(args);
271 args.wzVariable = wzVariable; 255 args.wzVariable = wzVariable;
272 args.wzValue = wzValue; 256 args.wzValue = wzValue;
257 args.fFormatted = fFormatted;
273 258
274 results.cbSize = sizeof(results); 259 results.cbSize = sizeof(results);
275 260
diff --git a/src/bextutil/bextutil.cpp b/src/bextutil/bextutil.cpp
index baf35591..4b22d502 100644
--- a/src/bextutil/bextutil.cpp
+++ b/src/bextutil/bextutil.cpp
@@ -119,6 +119,29 @@ DAPIV_(HRESULT) BextLog(
119{ 119{
120 HRESULT hr = S_OK; 120 HRESULT hr = S_OK;
121 va_list args; 121 va_list args;
122
123 if (!vpEngine)
124 {
125 hr = E_POINTER;
126 ExitOnRootFailure(hr, "BextInitialize() must be called first.");
127 }
128
129 va_start(args, szFormat);
130 hr = BextLogArgs(level, szFormat, args);
131 va_end(args);
132
133LExit:
134 return hr;
135}
136
137
138DAPI_(HRESULT) BextLogArgs(
139 __in BUNDLE_EXTENSION_LOG_LEVEL level,
140 __in_z __format_string LPCSTR szFormat,
141 __in va_list args
142 )
143{
144 HRESULT hr = S_OK;
122 LPSTR sczFormattedAnsi = NULL; 145 LPSTR sczFormattedAnsi = NULL;
123 LPWSTR sczMessage = NULL; 146 LPWSTR sczMessage = NULL;
124 147
@@ -128,9 +151,7 @@ DAPIV_(HRESULT) BextLog(
128 ExitOnRootFailure(hr, "BextInitialize() must be called first."); 151 ExitOnRootFailure(hr, "BextInitialize() must be called first.");
129 } 152 }
130 153
131 va_start(args, szFormat);
132 hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); 154 hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args);
133 va_end(args);
134 ExitOnFailure(hr, "Failed to format log string."); 155 ExitOnFailure(hr, "Failed to format log string.");
135 156
136 hr = StrAllocStringAnsi(&sczMessage, sczFormattedAnsi, 0, CP_UTF8); 157 hr = StrAllocStringAnsi(&sczMessage, sczFormattedAnsi, 0, CP_UTF8);
@@ -153,6 +174,29 @@ DAPIV_(HRESULT) BextLogError(
153{ 174{
154 HRESULT hr = S_OK; 175 HRESULT hr = S_OK;
155 va_list args; 176 va_list args;
177
178 if (!vpEngine)
179 {
180 hr = E_POINTER;
181 ExitOnRootFailure(hr, "BextInitialize() must be called first.");
182 }
183
184 va_start(args, szFormat);
185 hr = BextLogErrorArgs(hrError, szFormat, args);
186 va_end(args);
187
188LExit:
189 return hr;
190}
191
192
193DAPI_(HRESULT) BextLogErrorArgs(
194 __in HRESULT hrError,
195 __in_z __format_string LPCSTR szFormat,
196 __in va_list args
197 )
198{
199 HRESULT hr = S_OK;
156 LPSTR sczFormattedAnsi = NULL; 200 LPSTR sczFormattedAnsi = NULL;
157 LPWSTR sczMessage = NULL; 201 LPWSTR sczMessage = NULL;
158 202
@@ -162,9 +206,7 @@ DAPIV_(HRESULT) BextLogError(
162 ExitOnRootFailure(hr, "BextInitialize() must be called first."); 206 ExitOnRootFailure(hr, "BextInitialize() must be called first.");
163 } 207 }
164 208
165 va_start(args, szFormat);
166 hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); 209 hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args);
167 va_end(args);
168 ExitOnFailure(hr, "Failed to format error log string."); 210 ExitOnFailure(hr, "Failed to format error log string.");
169 211
170 hr = StrAllocFormatted(&sczMessage, L"Error 0x%08x: %S", hrError, sczFormattedAnsi); 212 hr = StrAllocFormatted(&sczMessage, L"Error 0x%08x: %S", hrError, sczFormattedAnsi);
diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj
index 78ff290d..32518202 100644
--- a/src/bextutil/bextutil.vcxproj
+++ b/src/bextutil/bextutil.vcxproj
@@ -2,8 +2,8 @@
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. --> 2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3 3
4<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 4<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
5 <Import Project="..\..\packages\WixToolset.BootstrapperCore.Native.4.0.31\build\WixToolset.BootstrapperCore.Native.props" Condition="Exists('..\..\packages\WixToolset.BootstrapperCore.Native.4.0.31\build\WixToolset.BootstrapperCore.Native.props')" /> 5 <Import Project="..\..\packages\WixToolset.BootstrapperCore.Native.4.0.33\build\WixToolset.BootstrapperCore.Native.props" Condition="Exists('..\..\packages\WixToolset.BootstrapperCore.Native.4.0.33\build\WixToolset.BootstrapperCore.Native.props')" />
6 <Import Project="..\..\packages\WixToolset.DUtil.4.0.45\build\WixToolset.DUtil.props" Condition="Exists('..\..\packages\WixToolset.DUtil.4.0.45\build\WixToolset.DUtil.props')" /> 6 <Import Project="..\..\packages\WixToolset.DUtil.4.0.49\build\WixToolset.DUtil.props" Condition="Exists('..\..\packages\WixToolset.DUtil.4.0.49\build\WixToolset.DUtil.props')" />
7 7
8 <ItemGroup Label="ProjectConfigurations"> 8 <ItemGroup Label="ProjectConfigurations">
9 <ProjectConfiguration Include="Debug|ARM"> 9 <ProjectConfiguration Include="Debug|ARM">
@@ -95,8 +95,8 @@
95 <PropertyGroup> 95 <PropertyGroup>
96 <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> 96 <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
97 </PropertyGroup> 97 </PropertyGroup>
98 <Error Condition="!Exists('..\..\packages\WixToolset.BootstrapperCore.Native.4.0.31\build\WixToolset.BootstrapperCore.Native.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.BootstrapperCore.Native.4.0.31\build\WixToolset.BootstrapperCore.Native.props'))" /> 98 <Error Condition="!Exists('..\..\packages\WixToolset.BootstrapperCore.Native.4.0.33\build\WixToolset.BootstrapperCore.Native.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.BootstrapperCore.Native.4.0.33\build\WixToolset.BootstrapperCore.Native.props'))" />
99 <Error Condition="!Exists('..\..\packages\WixToolset.DUtil.4.0.45\build\WixToolset.DUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.DUtil.4.0.45\build\WixToolset.DUtil.props'))" /> 99 <Error Condition="!Exists('..\..\packages\WixToolset.DUtil.4.0.49\build\WixToolset.DUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.DUtil.4.0.49\build\WixToolset.DUtil.props'))" />
100 <Error Condition="!Exists('..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets'))" /> 100 <Error Condition="!Exists('..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets'))" />
101 </Target> 101 </Target>
102</Project> 102</Project>
diff --git a/src/bextutil/inc/IBundleExtensionEngine.h b/src/bextutil/inc/IBundleExtensionEngine.h
index 869c6695..7772b016 100644
--- a/src/bextutil/inc/IBundleExtensionEngine.h
+++ b/src/bextutil/inc/IBundleExtensionEngine.h
@@ -42,11 +42,6 @@ DECLARE_INTERFACE_IID_(IBundleExtensionEngine, IUnknown, "9D027A39-F6B6-42CC-973
42 __in_z LPCWSTR wzMessage 42 __in_z LPCWSTR wzMessage
43 ) = 0; 43 ) = 0;
44 44
45 STDMETHOD(SetVariableLiteralString)(
46 __in_z LPCWSTR wzVariable,
47 __in_z_opt LPCWSTR wzValue
48 ) = 0;
49
50 STDMETHOD(SetVariableNumeric)( 45 STDMETHOD(SetVariableNumeric)(
51 __in_z LPCWSTR wzVariable, 46 __in_z LPCWSTR wzVariable,
52 __in LONGLONG llValue 47 __in LONGLONG llValue
@@ -54,7 +49,8 @@ DECLARE_INTERFACE_IID_(IBundleExtensionEngine, IUnknown, "9D027A39-F6B6-42CC-973
54 49
55 STDMETHOD(SetVariableString)( 50 STDMETHOD(SetVariableString)(
56 __in_z LPCWSTR wzVariable, 51 __in_z LPCWSTR wzVariable,
57 __in_z_opt LPCWSTR wzValue 52 __in_z_opt LPCWSTR wzValue,
53 __in BOOL fFormatted
58 ) = 0; 54 ) = 0;
59 55
60 STDMETHOD(SetVariableVersion)( 56 STDMETHOD(SetVariableVersion)(
diff --git a/src/bextutil/inc/bextutil.h b/src/bextutil/inc/bextutil.h
index e80d3944..ac9c0062 100644
--- a/src/bextutil/inc/bextutil.h
+++ b/src/bextutil/inc/bextutil.h
@@ -72,6 +72,16 @@ DAPIV_(HRESULT) BextLog(
72 ); 72 );
73 73
74/******************************************************************* 74/*******************************************************************
75 BextLogArgs - logs a message with the engine.
76
77********************************************************************/
78DAPI_(HRESULT) BextLogArgs(
79 __in BUNDLE_EXTENSION_LOG_LEVEL level,
80 __in_z __format_string LPCSTR szFormat,
81 __in va_list args
82 );
83
84/*******************************************************************
75 BextLogError - logs an error message with the engine. 85 BextLogError - logs an error message with the engine.
76 86
77********************************************************************/ 87********************************************************************/
@@ -81,6 +91,16 @@ DAPIV_(HRESULT) BextLogError(
81 ... 91 ...
82 ); 92 );
83 93
94/*******************************************************************
95 BextLogErrorArgs - logs an error message with the engine.
96
97********************************************************************/
98DAPI_(HRESULT) BextLogErrorArgs(
99 __in HRESULT hr,
100 __in_z __format_string LPCSTR szFormat,
101 __in va_list args
102 );
103
84#ifdef __cplusplus 104#ifdef __cplusplus
85} 105}
86#endif 106#endif
diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config
index 56f0cea3..e8417860 100644
--- a/src/bextutil/packages.config
+++ b/src/bextutil/packages.config
@@ -1,6 +1,6 @@
1<?xml version="1.0" encoding="utf-8"?> 1<?xml version="1.0" encoding="utf-8"?>
2<packages> 2<packages>
3 <package id="Nerdbank.GitVersioning" version="2.1.65" targetFramework="native" developmentDependency="true" /> 3 <package id="Nerdbank.GitVersioning" version="2.1.65" targetFramework="native" developmentDependency="true" />
4 <package id="WixToolset.BootstrapperCore.Native" version="4.0.31" targetFramework="native" /> 4 <package id="WixToolset.BootstrapperCore.Native" version="4.0.33" targetFramework="native" />
5 <package id="WixToolset.DUtil" version="4.0.45" targetFramework="native" /> 5 <package id="WixToolset.DUtil" version="4.0.49" targetFramework="native" />
6</packages> \ No newline at end of file 6</packages> \ No newline at end of file