Skip to content

Commit cfb156a

Browse files
committed
* Improve exception messages and debug logging
* Update vcpkg dependencies, ExifTool version and MSVC compiler
1 parent f6077f3 commit cfb156a

15 files changed

Lines changed: 207 additions & 79 deletions

File tree

.github/workflows/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ on: push
22

33
jobs:
44
build:
5-
runs-on: windows-2022
5+
runs-on: windows-2025-VS2026
66
steps:
77
- uses: actions/checkout@v4
88
- run: ./build.ps1

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ var content = st.Decode(Blob, encoding);
334334

335335
# How to build
336336
## Build requirements
337-
* Visual Studio 2022 or higher (you need to run it as an admin to build the solution)
337+
* Visual Studio 2026 or higher (you need to run it as an admin to build the solution)
338338
* [HeatWave for VS2022](https://marketplace.visualstudio.com/items?itemName=FireGiant.FireGiantHeatWaveDev17) plugin
339339

340340
## Build instructions
@@ -343,7 +343,6 @@ var content = st.Decode(Blob, encoding);
343343
## Notes
344344
* `vcpkg_overlay_ports\boost-asio` is an original port with the custom `increase_pipe_buffer.diff` patch. This is a workaround for the issue: [[Windows] Setting the capacity of the underline pipe #470
345345
](https://github.com/boostorg/process/issues/470)
346-
* libmediainfo is set to a version `25.3` because of the bug: [[v25.04] MediaInfo::Open hangs on a specific MXF file](https://github.com/MediaArea/MediaInfoLib/issues/2340)
347346

348347
# References
349348
* Discussion of this project on DOpus forum: [DOpus-Scripting-Extensions project](https://resource.dopus.com/t/dopus-scripting-extensions-project-wild-idea/55000)

src/DOpusScriptingExtensions/DOpusScriptingExtensions.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "pch.h"
22
#include "resource.h"
33
#include "DOpusScriptingExtensions_i.h"
4+
#include "Utils/Logger.h"
45
#include "Utils/StringUtils.h"
56
#include "Utils/Exceptions.h"
67
#include "Utils/ComUtils.h"

src/DOpusScriptingExtensions/DOpusScriptingExtensions.vcxproj

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
2121
<ConfigurationType>DynamicLibrary</ConfigurationType>
2222
<UseDebugLibraries>true</UseDebugLibraries>
23-
<PlatformToolset>v143</PlatformToolset>
23+
<PlatformToolset>v145</PlatformToolset>
2424
<CharacterSet>Unicode</CharacterSet>
2525
</PropertyGroup>
2626
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
2727
<ConfigurationType>DynamicLibrary</ConfigurationType>
2828
<UseDebugLibraries>false</UseDebugLibraries>
29-
<PlatformToolset>v143</PlatformToolset>
29+
<PlatformToolset>v145</PlatformToolset>
3030
<CharacterSet>Unicode</CharacterSet>
3131
</PropertyGroup>
3232
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -45,11 +45,13 @@
4545
<IgnoreImportLibrary>true</IgnoreImportLibrary>
4646
<LinkIncremental>true</LinkIncremental>
4747
<IncludePath>$(MSBuildProjectDirectory);$(IncludePath)</IncludePath>
48+
<RunCodeAnalysis>false</RunCodeAnalysis>
4849
</PropertyGroup>
4950
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
5051
<IgnoreImportLibrary>true</IgnoreImportLibrary>
5152
<LinkIncremental>false</LinkIncremental>
5253
<IncludePath>$(MSBuildProjectDirectory);$(IncludePath)</IncludePath>
54+
<RunCodeAnalysis>false</RunCodeAnalysis>
5355
</PropertyGroup>
5456
<PropertyGroup Label="Vcpkg">
5557
<VcpkgEnableManifest>true</VcpkgEnableManifest>
@@ -95,7 +97,7 @@
9597
<SubSystem>Windows</SubSystem>
9698
<ModuleDefinitionFile>.\DOpusScriptingExtensions.def</ModuleDefinitionFile>
9799
<RegisterOutput>true</RegisterOutput>
98-
<AdditionalDependencies>$(CoreLibraryDependencies);%(AdditionalDependencies);ntdll.lib;crypt32.lib</AdditionalDependencies>
100+
<AdditionalDependencies>$(CoreLibraryDependencies);%(AdditionalDependencies);ntdll.lib;crypt32.lib;secur32.lib;Iphlpapi.lib</AdditionalDependencies>
99101
</Link>
100102
</ItemDefinitionGroup>
101103
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -112,6 +114,7 @@
112114
<ExternalWarningLevel>TurnOffAllWarnings</ExternalWarningLevel>
113115
<DisableAnalyzeExternal>true</DisableAnalyzeExternal>
114116
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
117+
<WholeProgramOptimization>true</WholeProgramOptimization>
115118
</ClCompile>
116119
<Midl>
117120
<MkTypLibCompatible>false</MkTypLibCompatible>
@@ -135,7 +138,7 @@
135138
<EnableCOMDATFolding>true</EnableCOMDATFolding>
136139
<OptimizeReferences>true</OptimizeReferences>
137140
<RegisterOutput>true</RegisterOutput>
138-
<AdditionalDependencies>$(CoreLibraryDependencies);%(AdditionalDependencies);ntdll.lib;crypt32.lib</AdditionalDependencies>
141+
<AdditionalDependencies>$(CoreLibraryDependencies);%(AdditionalDependencies);ntdll.lib;crypt32.lib;secur32.lib;Iphlpapi.lib</AdditionalDependencies>
139142
</Link>
140143
</ItemDefinitionGroup>
141144
<ItemGroup>
@@ -157,6 +160,7 @@
157160
<ClInclude Include="UCharDet\UCharDetWrapper.h" />
158161
<ClInclude Include="utils\ComUtils.h" />
159162
<ClInclude Include="Utils\Exceptions.h" />
163+
<ClInclude Include="Utils\Logger.h" />
160164
<ClInclude Include="Utils\StringUtils.h" />
161165
<ClInclude Include="Utils\WinApiUtils.h" />
162166
</ItemGroup>
@@ -200,19 +204,19 @@
200204
</Target>
201205
<!-- Download ExifTool binaries -->
202206
<Target Name="DownloadExifTool" AfterTargets="Build" Condition="!Exists('$(BuildFolder)exiftool.zip')">
203-
<DownloadFile SourceUrl="https://netix.dl.sourceforge.net/project/exiftool/exiftool-13.33_64.zip?viasf=1" DestinationFolder="$(BuildFolder)" DestinationFileName="exiftool.zip" />
207+
<DownloadFile SourceUrl="https://netix.dl.sourceforge.net/project/exiftool/exiftool-13.50_64.zip?viasf=1" DestinationFolder="$(BuildFolder)" DestinationFileName="exiftool.zip" />
204208
<Unzip SourceFiles="$(BuildFolder)exiftool.zip" DestinationFolder="$(BuildFolder)" />
205209
</Target>
206210
<Target Name="CopyExifToolToOutputFolder" AfterTargets="DownloadExifTool" Condition="!Exists('$(OutputPath)exiftool')">
207-
<Exec Command="robocopy &quot;$(BuildFolder)exiftool-13.33_64&quot; &quot;$(OutputPath)exiftool&quot; /e &gt; nul" ContinueOnError="True" />
211+
<Exec Command="robocopy &quot;$(BuildFolder)exiftool-13.50_64&quot; &quot;$(OutputPath)exiftool&quot; /e &gt; nul" ContinueOnError="True" />
208212
<Exec Command="ren &quot;$(OutputPath)exiftool\exiftool(-k).exe&quot; &quot;exiftool.exe&quot;" />
209213
</Target>
210214
<!-- Download language files for MediaInfoLib -->
211215
<Target Name="DownloadMediaInfo" AfterTargets="Build" Condition="!Exists('$(BuildFolder)MediaInfo.zip')">
212-
<DownloadFile SourceUrl="https://github.com/MediaArea/MediaInfo/archive/refs/tags/v25.04.zip" DestinationFolder="$(BuildFolder)" DestinationFileName="MediaInfo.zip" />
216+
<DownloadFile SourceUrl="https://github.com/MediaArea/MediaInfo/archive/refs/tags/v26.01.zip" DestinationFolder="$(BuildFolder)" DestinationFileName="MediaInfo.zip" />
213217
<Unzip SourceFiles="$(BuildFolder)MediaInfo.zip" DestinationFolder="$(BuildFolder)" />
214218
</Target>
215219
<Target Name="CopyMediaInfoLanguagesToOutputFolder" AfterTargets="DownloadMediaInfo" Condition="!Exists('$(OutputPath)MediaInfoLanguages')">
216-
<Exec Command="robocopy &quot;$(BuildFolder)MediaInfo-25.04/Source/Resource/Plugin/Language&quot; &quot;$(OutputPath)MediaInfoLanguages&quot; /e &gt; nul" ContinueOnError="True" />
220+
<Exec Command="robocopy &quot;$(BuildFolder)MediaInfo-26.01/Source/Resource/Plugin/Language&quot; &quot;$(OutputPath)MediaInfoLanguages&quot; /e &gt; nul" ContinueOnError="True" />
217221
</Target>
218-
</Project>
222+
</Project>

src/DOpusScriptingExtensions/DOpusScriptingExtensions.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@
8282
<ClInclude Include="ExifTool\ExifToolCommandArgsGenerator.h">
8383
<Filter>ExifTool</Filter>
8484
</ClInclude>
85+
<ClInclude Include="Utils\Logger.h">
86+
<Filter>Utils</Filter>
87+
</ClInclude>
8588
</ItemGroup>
8689
<ItemGroup>
8790
<ClCompile Include="DOpusScriptingExtensions.cpp" />

src/DOpusScriptingExtensions/Utils/Exceptions.h

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
#define CATCH_ALL_EXCEPTIONS() \
44
catch (const HResultException& ex) { \
5-
AtlReportError(GetObjectCLSID(), ex.LMessage().data(), __uuidof(IUnknown), ex.HResult()); \
5+
AtlReportError(GetObjectCLSID(), ex.LMessage(), __uuidof(IUnknown), ex.HResult()); \
66
return ex.HResult(); \
77
} \
88
catch (const WException& ex) { \
9-
AtlReportError(GetObjectCLSID(), ex.LMessage().data(), __uuidof(IUnknown), E_FAIL); \
9+
AtlReportError(GetObjectCLSID(), ex.LMessage(), __uuidof(IUnknown), E_FAIL); \
1010
return E_FAIL; \
1111
} \
1212
catch (const std::exception& ex) { \
@@ -18,19 +18,14 @@
1818
return E_FAIL; \
1919
}
2020

21-
#define DEBUG_LOG(...) \
22-
do { \
23-
ATLTRACE(std::format(__VA_ARGS__).c_str()); \
24-
} while (0)
25-
2621
#define THROW_WEXCEPTION(...) \
2722
do { \
28-
throw WException(std::format(__VA_ARGS__)); \
23+
throw WException(std::format(__VA_ARGS__), LINE_INFO); \
2924
} while (0)
3025

3126
#define THROW_HRESULT(hr, ...) \
3227
do { \
33-
throw HResultException((hr), std::format(__VA_ARGS__)); \
28+
throw HResultException((hr), std::format(__VA_ARGS__), LINE_INFO); \
3429
} while (0)
3530

3631
#define THROW_IF_FAILED_MSG(hr, ...) \
@@ -44,10 +39,10 @@
4439
class WException : public std::exception
4540
{
4641
public:
47-
WException(const std::wstring_view msg, const std::source_location& loc = std::source_location::current())
48-
: msg(std::format(L"{}:{}: {}", std::filesystem::path(loc.file_name()).filename(), loc.line(), msg)) { }
42+
WException(const std::wstring_view msg, const std::wstring_view lineInfo)
43+
: msg(std::format(L"{}: {}", lineInfo, msg)) { }
4944

50-
std::wstring_view LMessage() const { return msg; }
45+
auto LMessage() const { return msg.data(); }
5146

5247
private:
5348
std::wstring msg;
@@ -56,14 +51,13 @@ class WException : public std::exception
5651
class HResultException : public WException
5752
{
5853
public:
59-
HResultException(const HRESULT res) :
60-
HResultException(res, L"Failed") { }
61-
62-
HResultException(const HRESULT res, const std::wstring_view msg) :
63-
WException(std::format(L"{}. HRESULT=0x{:X}: {}", msg, static_cast<unsigned long>(res), _com_error(res).ErrorMessage())),
54+
HResultException(const HRESULT res, const std::wstring_view msg, const std::wstring_view lineInfo) :
55+
WException(
56+
std::format(L"{}. HRESULT=0x{:08X}({}): {}", msg, static_cast<unsigned long>(res), static_cast<unsigned long>(res), _com_error(res).ErrorMessage()),
57+
lineInfo),
6458
res(res) { }
6559

66-
HRESULT HResult() const { return res; }
60+
auto HResult() const { return res; }
6761

6862
private:
6963
HRESULT res;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma once
2+
3+
#define LINE_INFO std::format(L"{}:{}:{}", \
4+
std::filesystem::path(__builtin_FILE()).filename(), \
5+
ToUtf16(__builtin_FUNCTION()), \
6+
__builtin_LINE())
7+
8+
#ifdef DEBUG
9+
#define DEBUG_LOG(...) \
10+
do { \
11+
OutputDebugStringW( \
12+
std::format(L"DOpusScriptingExtensions(threadId={}):{}: {}", \
13+
std::this_thread::get_id(), \
14+
LINE_INFO, \
15+
std::format(__VA_ARGS__).c_str()).c_str()); \
16+
} while (0)
17+
#else
18+
#define DEBUG_LOG(...) (void)(__VA_ARGS__)
19+
#endif

src/DOpusScriptingExtensions/Utils/WinApiUtils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
inline boost::filesystem::path ExpandPathWithEnvironmentVariables(const wchar_t* const path) {
4-
const auto len = ExpandEnvironmentStrings(path, nullptr, 0);
4+
const auto len = ExpandEnvironmentStrings(path, nullptr, 0); // len is the number of TCHARs stored in the destination buffer, including the terminating null character
55

66
if (!len) {
77
THROW_WEXCEPTION(L"Failed to calculate length for expanding the path '{}'", path);
@@ -13,5 +13,5 @@ inline boost::filesystem::path ExpandPathWithEnvironmentVariables(const wchar_t*
1313
THROW_WEXCEPTION(L"Failed to expand '{}'", path);
1414
}
1515

16-
return boost::filesystem::path{ buffer.get() };
16+
return boost::filesystem::path{ buffer.get(), buffer.get() + len - 1 }; // -1 to exclude the terminating null character
1717
}

src/Test/test.js

-612 Bytes
Binary file not shown.

vcpkg.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"vcpkg-configuration": {
33
"default-registry": {
44
"kind": "git",
5-
"baseline": "47313591da1d14a8a9b209f4bee39d29acc39b31",
5+
"baseline": "ac7af7424cbaf9057cb246b620f455303dccd6ed",
66
"repository": "https://github.com/microsoft/vcpkg"
77
},
88
"registries": [
@@ -24,9 +24,5 @@
2424
"libmagic",
2525
"libmediainfo",
2626
"uchardet"
27-
],
28-
29-
"overrides": [
30-
{ "name": "libmediainfo", "version": "25.3" }
3127
]
3228
}

0 commit comments

Comments
 (0)