From 659a64fb43c12affb1d676e27c2c68406aa0dea6 Mon Sep 17 00:00:00 2001 From: Tim Hughes Date: Thu, 20 Feb 2014 20:55:45 +0000 Subject: [PATCH] VS2013 project and fixes for Alethzero. --- alethzero/MainWin.cpp | 53 +++++++- alethzero/MainWin.h | 6 +- alethzero/main.cpp | 2 +- windows/Alethzero.vcxproj | 217 ++++++++++++++++++++++++++++++ windows/Alethzero.vcxproj.filters | 27 ++++ windows/Ethereum.sln | 10 ++ windows/WinMain.cpp | 72 ++++++++++ windows/moc.lua | 38 ++++++ 8 files changed, 416 insertions(+), 9 deletions(-) create mode 100644 windows/Alethzero.vcxproj create mode 100644 windows/Alethzero.vcxproj.filters create mode 100644 windows/WinMain.cpp create mode 100644 windows/moc.lua diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 6c7c8d103..6d2931997 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -1,17 +1,54 @@ #include -#include -#include +#include +#include +#include +#include #include #include #include #include "MainWin.h" #include "ui_Main.h" using namespace std; -using namespace eth; + +// types +using eth::bytes; +using eth::bytesConstRef; +using eth::h160; +using eth::h256; +using eth::u160; +using eth::u256; +using eth::Address; +using eth::BlockInfo; +using eth::Client; +using eth::Instruction; +using eth::KeyPair; +using eth::NodeMode; +using eth::PeerInfo; +using eth::RLP; +using eth::Secret; +using eth::Transaction; + +// functions +using eth::asHex; +using eth::assemble; +using eth::compileLisp; +using eth::disassemble; +using eth::formatBalance; +using eth::fromUserHex; +using eth::right160; +using eth::simpleDebugOut; +using eth::toLog2; +using eth::toString; +using eth::units; + +// vars +using eth::g_logPost; +using eth::g_logVerbosity; +using eth::c_instructionInfo; static void initUnits(QComboBox* _b) { - for (int n = units().size() - 1; n >= 0; --n) + for (auto n = (::uint)units().size(); n-- != 0; ) _b->addItem(QString::fromStdString(units()[n].second), n); _b->setCurrentIndex(6); } @@ -130,7 +167,7 @@ void Main::writeSettings() if (m_client->peerServer()) { bytes d = m_client->peerServer()->savePeers(); - m_peers = QByteArray((char*)d.data(), d.size()); + m_peers = QByteArray((char*)d.data(), (int)d.size()); } s.setValue("peers", m_peers); @@ -546,3 +583,9 @@ void Main::on_create_triggered() m_myKeys.append(KeyPair::create()); m_keysChanged = true; } + +// include moc file on VS, ofuscated to hide from automoc +#ifdef _MSC_VER +#include\ +"moc_MainWin.cpp" +#endif diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h index 89ff2667a..787ab72fb 100644 --- a/alethzero/MainWin.h +++ b/alethzero/MainWin.h @@ -2,9 +2,9 @@ #define MAIN_H #include -#include -#include -#include +#include +#include +#include #include namespace Ui { diff --git a/alethzero/main.cpp b/alethzero/main.cpp index ce37f9905..42afd5e66 100644 --- a/alethzero/main.cpp +++ b/alethzero/main.cpp @@ -1,5 +1,5 @@ #include "MainWin.h" -#include +#include int main(int argc, char *argv[]) { diff --git a/windows/Alethzero.vcxproj b/windows/Alethzero.vcxproj new file mode 100644 index 000000000..aab2ef67b --- /dev/null +++ b/windows/Alethzero.vcxproj @@ -0,0 +1,217 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + Win32Proj + Alethzero + Alethzero + {BFCFFC46-78A3-4350-9938-0EA3A2B1CCCD} + + + + Application + true + v120 + + + Application + true + v120 + + + Application + false + true + v120 + + + Application + false + true + v120 + + + + + + + + + + + + + + + + + + + + + + + true + + + + false + + + false + + + + Use + Disabled + WIN32;_DEBUG;%(PreprocessorDefinitions) + MultiThreadedDebug + true + $(IntDir);..;$(QT_PATH)/$(Platform)/include;%(AdditionalIncludeDirectories) + stdafx.h + + + Windows + true + true + $(QT_PATH)/$(Platform)/lib;%(AdditionalLibraryDirectories) + Qt5Cored.lib;Qt5GUId.lib;Qt5Widgetsd.lib;Qt5Networkd.lib;%(AdditionalDependencies) + + + + + Use + Disabled + WIN32;_DEBUG;%(PreprocessorDefinitions) + MultiThreadedDebug + true + $(IntDir);..;$(QT_PATH)/$(Platform)/include;%(AdditionalIncludeDirectories) + stdafx.h + + + Windows + true + $(QT_PATH)/$(Platform)/lib;%(AdditionalLibraryDirectories) + Qt5Cored.lib;Qt5GUId.lib;Qt5Widgetsd.lib;Qt5Networkd.lib;%(AdditionalDependencies) + + + + + Use + MaxSpeed + true + true + WIN32;NDEBUG;%(PreprocessorDefinitions) + MultiThreaded + true + AnySuitable + $(IntDir);..;$(QT_PATH)/$(Platform)/include;%(AdditionalIncludeDirectories) + stdafx.h + + + Windows + true + true + true + true + $(QT_PATH)/$(Platform)/lib;%(AdditionalLibraryDirectories) + Qt5Core.lib;Qt5GUI.lib;Qt5Widgets.lib;Qt5Network.lib;%(AdditionalDependencies) + + + + + Use + MaxSpeed + true + true + WIN32;NDEBUG;%(PreprocessorDefinitions) + MultiThreaded + true + AnySuitable + $(IntDir);..;$(QT_PATH)/$(Platform)/include;%(AdditionalIncludeDirectories) + stdafx.h + + + Windows + true + true + true + $(QT_PATH)/$(Platform)/lib;%(AdditionalLibraryDirectories) + Qt5Core.lib;Qt5GUI.lib;Qt5Widgets.lib;Qt5Network.lib;%(AdditionalDependencies) + + + + + {826e68cb-d3ee-4a8a-b540-59a8c3f38d4f} + + + + + + + + Create + Create + Create + Create + + + + + ..\..\bin\lua52 moc.lua "$(QT_PATH)/$(Platform)/bin/moc" "$(IntDir)moc_%(FileName).cpp" "@(ClCompile->'%(AdditionalIncludeDirectories)');$(IncludePath)" "@(ClCompile->'%(PreprocessorDefinitions)');_MSC_VER=1800" "%(FullPath)" + $(IntDir)moc_%(FileName).cpp + + + ..\..\bin\lua52 moc.lua "$(QT_PATH)/$(Platform)/bin/moc" "$(IntDir)moc_%(FileName).cpp" "@(ClCompile->'%(AdditionalIncludeDirectories)');$(IncludePath)" "@(ClCompile->'%(PreprocessorDefinitions)');_MSC_VER=1800" "%(FullPath)" + + + ..\..\bin\lua52 moc.lua "$(QT_PATH)/$(Platform)/bin/moc" "$(IntDir)moc_%(FileName).cpp" "@(ClCompile->'%(AdditionalIncludeDirectories)');$(IncludePath)" "@(ClCompile->'%(PreprocessorDefinitions)');_MSC_VER=1800" "%(FullPath)" + + + ..\..\bin\lua52 moc.lua "$(QT_PATH)/$(Platform)/bin/moc" "$(IntDir)moc_%(FileName).cpp" "@(ClCompile->'%(AdditionalIncludeDirectories)');$(IncludePath)" "@(ClCompile->'%(PreprocessorDefinitions)');_MSC_VER=1800" "%(FullPath)" + + + $(IntDir)moc_%(FileName).cpp + $(IntDir)moc_%(FileName).cpp + $(IntDir)moc_%(FileName).cpp + + + + + + Document + "$(QT_PATH)/$(Platform)/bin/uic" -o "$(IntDir)ui_%(FileName).h" "%(FullPath)" + "$(QT_PATH)/$(Platform)/bin/uic" -o "$(IntDir)ui_%(FileName).h" "%(FullPath)" + $(IntDir)ui_%(FileName).h + "$(QT_PATH)/$(Platform)/bin/uic" -o "$(IntDir)ui_%(FileName).h" "%(FullPath)" + "$(QT_PATH)/$(Platform)/bin/uic" -o "$(IntDir)ui_%(FileName).h" "%(FullPath)" + $(IntDir)ui_%(FileName).h + "$(QT_PATH)/$(Platform)/bin/uic" -o "$(IntDir)ui_%(FileName).h" "%(FullPath)" + "$(QT_PATH)/$(Platform)/bin/uic" -o "$(IntDir)ui_%(FileName).h" "%(FullPath)" + $(IntDir)ui_%(FileName).h + "$(QT_PATH)/$(Platform)/bin/uic" -o "$(IntDir)ui_%(FileName).h" "%(FullPath)" + "$(QT_PATH)/$(Platform)/bin/uic" -o "$(IntDir)ui_%(FileName).h" "%(FullPath)" + $(IntDir)ui_%(FileName).h + + + + + + \ No newline at end of file diff --git a/windows/Alethzero.vcxproj.filters b/windows/Alethzero.vcxproj.filters new file mode 100644 index 000000000..5ecab5b85 --- /dev/null +++ b/windows/Alethzero.vcxproj.filters @@ -0,0 +1,27 @@ + + + + + + + Windows + + + Windows + + + + + Windows + + + + + {049fb46c-1677-45cb-95ae-3a2d9e3090be} + + + + + + + \ No newline at end of file diff --git a/windows/Ethereum.sln b/windows/Ethereum.sln index f489ede53..1be0ab848 100644 --- a/windows/Ethereum.sln +++ b/windows/Ethereum.sln @@ -23,6 +23,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibCryptoPP", "LibCryptoPP. EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibMiniUPnPc", "LibMiniUPnPc.vcxproj", "{1B1CA20E-39C3-4D9B-AC37-3783048E6672}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Alethzero", "Alethzero.vcxproj", "{BFCFFC46-78A3-4350-9938-0EA3A2B1CCCD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -95,6 +97,14 @@ Global {1B1CA20E-39C3-4D9B-AC37-3783048E6672}.Release|Win32.Build.0 = Release|Win32 {1B1CA20E-39C3-4D9B-AC37-3783048E6672}.Release|x64.ActiveCfg = Release|x64 {1B1CA20E-39C3-4D9B-AC37-3783048E6672}.Release|x64.Build.0 = Release|x64 + {BFCFFC46-78A3-4350-9938-0EA3A2B1CCCD}.Debug|Win32.ActiveCfg = Debug|Win32 + {BFCFFC46-78A3-4350-9938-0EA3A2B1CCCD}.Debug|Win32.Build.0 = Debug|Win32 + {BFCFFC46-78A3-4350-9938-0EA3A2B1CCCD}.Debug|x64.ActiveCfg = Debug|x64 + {BFCFFC46-78A3-4350-9938-0EA3A2B1CCCD}.Debug|x64.Build.0 = Debug|x64 + {BFCFFC46-78A3-4350-9938-0EA3A2B1CCCD}.Release|Win32.ActiveCfg = Release|Win32 + {BFCFFC46-78A3-4350-9938-0EA3A2B1CCCD}.Release|Win32.Build.0 = Release|Win32 + {BFCFFC46-78A3-4350-9938-0EA3A2B1CCCD}.Release|x64.ActiveCfg = Release|x64 + {BFCFFC46-78A3-4350-9938-0EA3A2B1CCCD}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/windows/WinMain.cpp b/windows/WinMain.cpp new file mode 100644 index 000000000..44680c47f --- /dev/null +++ b/windows/WinMain.cpp @@ -0,0 +1,72 @@ +// http://www.flipcode.com/archives/WinMain_Command_Line_Parser.shtml +// COTD Entry submitted by Max McGuire [amcguire@andrew.cmu.edu] + +#include + +extern int main(int argc, char* argv[]); + +int WINAPI WinMain(HINSTANCE instance, HINSTANCE prev_instance, char* command_line, int show_command) +{ + int argc; + char** argv; + char* arg; + int index; + int result; + + // count the arguments + argc = 1; + arg = command_line; + + while (arg[0] != 0) + { + while (arg[0] != 0 && arg[0] == ' ') + { + arg++; + } + if (arg[0] != 0) + { + argc++; + while (arg[0] != 0 && arg[0] != ' ') + { + arg++; + } + } + } + + // tokenize the arguments + argv = (char**)malloc(argc * sizeof(char*)); + arg = command_line; + index = 1; + + while (arg[0] != 0) + { + while (arg[0] != 0 && arg[0] == ' ') + { + arg++; + } + if (arg[0] != 0) + { + argv[index] = arg; + index++; + while (arg[0] != 0 && arg[0] != ' ') + { + arg++; + } + if (arg[0] != 0) + { + arg[0] = 0; + arg++; + } + } + } + + // put the program name into argv[0] + char filename[_MAX_PATH]; + GetModuleFileName(NULL, filename, _MAX_PATH); + argv[0] = filename; + + // call the user specified main function + result = main(argc, argv); + free(argv); + return result; +} diff --git a/windows/moc.lua b/windows/moc.lua new file mode 100644 index 000000000..8a129eeae --- /dev/null +++ b/windows/moc.lua @@ -0,0 +1,38 @@ + +local function quote(x) + return '"' .. x .. '"' +end + +local function toForward(x) + return x:gsub('\\', '/') +end + +-- arguments are in this order +local cmd = arg[1] +local outFile = arg[2] +local includes = toForward(arg[3]) +local defines = arg[4] +local inFile = arg[5] + +-- build list of includes +local includes2 = "" +for i in string.gmatch(includes, "[^;]+") do + includes2 = includes2.." -I "..quote(i) +end +includes = includes2; + +-- build list of defines +local defines2 = "" +for i in string.gmatch(defines, "[^;]+") do + defines2 = defines2.." -D"..i +end +defines = defines2 + +-- moc doesn't compile boost correctly, so skip those headers +workarounds=' -DBOOST_MP_CPP_INT_HPP -DBOOST_THREAD_WEK01082003_HPP' + +-- build command +cmd = quote(cmd).." -o "..quote(outFile)..includes..defines..workarounds..' '..quote(inFile) +print(cmd) +os.execute(quote(cmd)) +