From a362a64d62d696d1c219ad59bb639b7f966a2c3f Mon Sep 17 00:00:00 2001 From: David Crocker Date: Sat, 22 Jan 2022 22:42:23 +0000 Subject: [PATCH 1/6] Ported Bossa to 64bit MSVC 2019 Replaced variable-length arrays (gcc extension) by std::vector Added Visual Studio project and solution files Added missing include files --- .gitignore | 11 + Bossa.sln | 31 ++ Bossa.vcxproj | 218 ++++++++++++++ src/BossaForm.cpp | 2 +- src/BossaWindow.cpp | 4 + src/CmdOpts.cpp | 11 +- src/Command.cpp | 50 ++-- src/Device.cpp | 2 +- src/Flasher.cpp | 36 +-- src/PortFactory.h | 2 +- src/Samba.cpp | 4 +- src/Shell.cpp | 6 +- src/WinPortFactory.cpp | 7 +- src/WinPortFactory.h | 2 +- src/bossac.cpp | 8 +- src/msvc/getopt.h | 653 +++++++++++++++++++++++++++++++++++++++++ src/msvc/strings.h | 3 + src/msvc/sys/time.h | 51 ++++ src/msvc/unistd.h | 18 ++ 19 files changed, 1058 insertions(+), 61 deletions(-) create mode 100644 Bossa.sln create mode 100644 Bossa.vcxproj create mode 100644 src/msvc/getopt.h create mode 100644 src/msvc/strings.h create mode 100644 src/msvc/sys/time.h create mode 100644 src/msvc/unistd.h diff --git a/.gitignore b/.gitignore index b5b1cb42..eb3e6d84 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,14 @@ tags *.bak install/*.crt install/*.p12 + +# Extras for building with MSVC +x64/ +ipch/ +*.sdf +*.suo +*.user +*.filters +*.unsuccessfulbuild +*.cache +*.lastbuildstate diff --git a/Bossa.sln b/Bossa.sln new file mode 100644 index 00000000..eb983cb3 --- /dev/null +++ b/Bossa.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32002.261 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Bossac", "Bossa.vcxproj", "{51FD357A-201B-79B1-66FC-17DB8D3027E6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {51FD357A-201B-79B1-66FC-17DB8D3027E6}.Debug|Win32.ActiveCfg = Debug|Win32 + {51FD357A-201B-79B1-66FC-17DB8D3027E6}.Debug|Win32.Build.0 = Debug|Win32 + {51FD357A-201B-79B1-66FC-17DB8D3027E6}.Debug|x64.ActiveCfg = Debug|x64 + {51FD357A-201B-79B1-66FC-17DB8D3027E6}.Debug|x64.Build.0 = Debug|x64 + {51FD357A-201B-79B1-66FC-17DB8D3027E6}.Release|Win32.ActiveCfg = Release|Win32 + {51FD357A-201B-79B1-66FC-17DB8D3027E6}.Release|Win32.Build.0 = Release|Win32 + {51FD357A-201B-79B1-66FC-17DB8D3027E6}.Release|x64.ActiveCfg = Release|x64 + {51FD357A-201B-79B1-66FC-17DB8D3027E6}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B309DC9E-03CE-4FAD-9EE3-8AC9318C2FF8} + EndGlobalSection +EndGlobal diff --git a/Bossa.vcxproj b/Bossa.vcxproj new file mode 100644 index 00000000..69ce3727 --- /dev/null +++ b/Bossa.vcxproj @@ -0,0 +1,218 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + Win32Proj + {51FD357A-201B-79B1-66FC-17DB8D3027E6} + 10.0 + Bossa + + + + Application + true + v142 + + + Application + true + v142 + + + Application + false + v142 + + + Application + false + v142 + + + + + + + + + + + + + + + + + + + true + + + true + + + true + + + false + + + + WIN32;_DEBUG;_WINDOWS;__WIN32__;VERSION="0.0";%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS + MultiThreadedDebugDLL + Level3 + ProgramDatabase + Disabled + C:\Users\David\Documents\GitHub\BOSSA\src\msvc;C:\wxWidgets-3.1.5\include;C:\wxWidgets-3.1.5\include\msvc;%(AdditionalIncludeDirectories) + + + MachineX86 + true + Windows + + + + + WIN64;_DEBUG;_WINDOWS;__WIN64__;VERSION="0.0";_CRT_SECURE_NO_WARNINGS;wxMSVC_VERSION=142;_UNICODE;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + Level3 + ProgramDatabase + Disabled + C:\Users\David\Documents\GitHub\BOSSA\src\msvc;C:\wxWidgets-3.1.5\include;C:\wxWidgets-3.1.5\include\msvc;%(AdditionalIncludeDirectories) + + + true + Windows + C:\wxWidgets-3.1.5\lib\vc142_x64_lib;%(AdditionalLibraryDirectories) + setupapi.lib;%(AdditionalDependencies) + + + C:\wxWidgets-3.1.5\include;%(AdditionalIncludeDirectories) + + + + + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS + MultiThreadedDLL + Level3 + ProgramDatabase + C:\Users\David\Documents\GitHub\BOSSA\src\msvc;%(AdditionalIncludeDirectories) + + + MachineX86 + true + Windows + true + true + + + + + WIN32;NDEBUG;_WINDOWS;VERSION="0.0";_CRT_SECURE_NO_WARNINGS;wxMSVC_VERSION=142;_UNICODE;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + ProgramDatabase + C:\Users\David\Documents\GitHub\BOSSA\src\msvc;C:\wxWidgets-3.1.5\include;C:\wxWidgets-3.1.5\include\msvc;%(AdditionalIncludeDirectories) + + + true + Windows + true + true + C:\wxWidgets-3.1.5\lib\vc142_x64_lib;%(AdditionalLibraryDirectories) + setupapi.lib;%(AdditionalDependencies) + + + C:\wxWidgets-3.1.5\include;%(AdditionalIncludeDirectories) + + + + + + + + + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/BossaForm.cpp b/src/BossaForm.cpp index ecda8792..915466fd 100644 --- a/src/BossaForm.cpp +++ b/src/BossaForm.cpp @@ -230,7 +230,7 @@ ProgressDialog::ProgressDialog( wxWindow* parent, wxWindowID id, const wxString& _infoStaticText = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); _infoStaticText->Wrap( -1 ); - _progressBoxSizer->Add( _infoStaticText, 0, wxALIGN_CENTER|wxALL|wxEXPAND, 5 ); + _progressBoxSizer->Add( _infoStaticText, 0, wxALL|wxEXPAND, 5 ); // DC do not use wxALIGN_CENTER with wxEXPAND, it triggers an assertion failure in wxWidgets _statusGauge = new wxGauge( this, wxID_ANY, 100, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL ); _statusGauge->SetValue( 0 ); diff --git a/src/BossaWindow.cpp b/src/BossaWindow.cpp index eb046e8e..f3a45674 100644 --- a/src/BossaWindow.cpp +++ b/src/BossaWindow.cpp @@ -36,6 +36,10 @@ #include #include +#if defined(_WIN32) || defined(_WIN64) +#define F_OK 0 // test file for existence only when calling access() +#define access(...) _access(__VA_ARGS__) +#endif using namespace std; diff --git a/src/CmdOpts.cpp b/src/CmdOpts.cpp index 675f7e1d..27be30ab 100644 --- a/src/CmdOpts.cpp +++ b/src/CmdOpts.cpp @@ -27,10 +27,11 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /////////////////////////////////////////////////////////////////////////////// #include -#include #include #include +#include +#include #include "CmdOpts.h" CmdOpts::CmdOpts(int argc, char* argv[], int numOpts, Option* opts) : @@ -83,9 +84,9 @@ CmdOpts::usage(FILE* out) int CmdOpts::parse() { - struct option long_opts[_numOpts + 1]; - char optstring[_numOpts * 3 + 1]; - char* optPtr = optstring; + std::vector