Merge with COM-113

COM-121
Volker Birk 2020-07-02 07:47:56 +02:00
commit b3a9ee13be
4 changed files with 64 additions and 21 deletions

View File

@ -13,6 +13,14 @@
using namespace ATL;
using namespace std;
#ifndef NDEBUG
// Stuff for the JSON server follows.
#include <boost/filesystem/path.hpp>
#include <boost/program_options.hpp>
namespace po = boost::program_options;
std::string logfile = "";
#endif
void CpEpCOMServerAdapterModule::gatekeeper(CpEpCOMServerAdapterModule * self)
{
pEp::GateKeeper keeper(self);
@ -27,6 +35,53 @@ CMainWindow mainWindow;
extern "C" int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/,
LPTSTR lpCmdLine, int nShowCmd)
{
#ifndef NDEBUG
std::ios::sync_with_stdio(false);
// Command line options and console output are for debug only.
// Some Windows acrobatics so we can use this even with a command line
// and get some output onto the console.
if (AttachConsole(ATTACH_PARENT_PROCESS)) {
FILE *f;
freopen_s(&f, "conout$", "w", stdout);
freopen_s(&f, "conout$", "w", stderr);
}
po::options_description desc("Program options for the JSON Server Adapter");
desc.add_options()
("help,h", "print this help messages")
("debug,d", "debug,d ignored, only works in JSON mini adapter")
("logfile,l", po::value<std::string>(&logfile)->default_value(logfile),
"Name of the logfile. Can be \"stderr\" for log to stderr or empty for no log.")
;
po::variables_map vm;
try {
std::vector<std::wstring> args = po::split_winmain(lpCmdLine);
po::store(po::wcommand_line_parser(args).options(desc).run(), vm);
po::notify(vm);
} catch (const po::error& e) {
std::cerr << "Cannot parse command line: " << e.what() << "\n\n" << desc << std::endl;
return 2;
}
if (vm.count("help")) {
std::cout << desc << "\n";
return 0;
}
if (logfile.empty()) {
Logger::setDefaultTarget(Logger::Target::None);
} else if (logfile == "stderr") {
Logger::setDefaultTarget(Logger::Target::Console);
} else {
Logger::setDefaultTarget(Logger::Target::File);
}
Logger::start("JsonAdapter", logfile);
#endif
_AtlModule.hModule(hInstance);
_AtlModule.start_gatekeeper();

View File

@ -202,11 +202,12 @@ xcopy /y "..\Dependencies\zlib\zlib1.dll" "$(OutDir)"
<ProjectReference Include="..\pEpEngine\build-windows\pEpEngine.vcxproj">
<Project>{146e69f8-e1da-456a-b048-6dd29d9acf6b}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Library Include="..\Debug\libpEpAdapter.lib" />
<Library Include="..\Debug\libpEpWebserver.lib" />
<Library Include="..\Debug\pEpJSONServerAdapterLibrary.lib" />
<ProjectReference Include="..\pEpJSONServerAdapter\build-windows\pEpJSONServerAdapter\pEpJSONServerAdapterLibrary.vcxproj">
<Project>{644d1ba4-084c-47b2-8a9e-00a8d9f9a35c}</Project>
</ProjectReference>
<ProjectReference Include="..\pEpJSONServerAdapter\build-windows\pEp\libpEpWebserver\libpEpWebserver.vcxproj">
<Project>{0d25734e-a71b-4536-8dc4-60e945382fc5}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Image Include="logo.ico" />
@ -219,6 +220,7 @@ xcopy /y "..\Dependencies\zlib\zlib1.dll" "$(OutDir)"
<Import Project="..\packages\boost_filesystem-vc142.1.72.0.0\build\boost_filesystem-vc142.targets" Condition="Exists('..\packages\boost_filesystem-vc142.1.72.0.0\build\boost_filesystem-vc142.targets')" />
<Import Project="..\packages\boost_thread-vc142.1.72.0.0\build\boost_thread-vc142.targets" Condition="Exists('..\packages\boost_thread-vc142.1.72.0.0\build\boost_thread-vc142.targets')" />
<Import Project="..\packages\boost_chrono-vc142.1.72.0.0\build\boost_chrono-vc142.targets" Condition="Exists('..\packages\boost_chrono-vc142.1.72.0.0\build\boost_chrono-vc142.targets')" />
<Import Project="..\packages\boost_program_options-vc142.1.72.0.0\build\boost_program_options-vc142.targets" Condition="Exists('..\packages\boost_program_options-vc142.1.72.0.0\build\boost_program_options-vc142.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
@ -230,5 +232,6 @@ xcopy /y "..\Dependencies\zlib\zlib1.dll" "$(OutDir)"
<Error Condition="!Exists('..\packages\boost_filesystem-vc142.1.72.0.0\build\boost_filesystem-vc142.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\boost_filesystem-vc142.1.72.0.0\build\boost_filesystem-vc142.targets'))" />
<Error Condition="!Exists('..\packages\boost_thread-vc142.1.72.0.0\build\boost_thread-vc142.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\boost_thread-vc142.1.72.0.0\build\boost_thread-vc142.targets'))" />
<Error Condition="!Exists('..\packages\boost_chrono-vc142.1.72.0.0\build\boost_chrono-vc142.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\boost_chrono-vc142.1.72.0.0\build\boost_chrono-vc142.targets'))" />
<Error Condition="!Exists('..\packages\boost_program_options-vc142.1.72.0.0\build\boost_program_options-vc142.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\boost_program_options-vc142.1.72.0.0\build\boost_program_options-vc142.targets'))" />
</Target>
</Project>

View File

@ -46,9 +46,6 @@
<ClCompile Include="LocalJSONAdapter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="CMainWindow.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
@ -87,9 +84,6 @@
<ClInclude Include="..\pEpJSONServerAdapter\server\adapter-library.hh">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="CMainWindow.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="pEpCOMServerAdapter.rc">
@ -118,14 +112,4 @@
<Filter>Source Files</Filter>
</Midl>
</ItemGroup>
<ItemGroup>
<Library Include="..\Debug\pEpJSONServerAdapterLibrary.lib" />
<Library Include="..\Debug\libpEpWebserver.lib" />
<Library Include="..\Debug\libpEpAdapter.lib" />
</ItemGroup>
<ItemGroup>
<Image Include="logo.ico">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
</Project>

View File

@ -4,6 +4,7 @@
<package id="boost_chrono-vc142" version="1.72.0.0" targetFramework="native" />
<package id="boost_date_time-vc142" version="1.72.0.0" targetFramework="native" />
<package id="boost_filesystem-vc142" version="1.72.0.0" targetFramework="native" />
<package id="boost_program_options-vc142" version="1.72.0.0" targetFramework="native" />
<package id="boost_regex-vc142" version="1.72.0.0" targetFramework="native" />
<package id="boost_thread-vc142" version="1.72.0.0" targetFramework="native" />
</packages>