armips: Update to UTF-8/c++17 armips.

This commit is contained in:
Unknown W. Brackets 2022-01-17 11:13:24 -08:00
parent 8b7ccfeca5
commit ac335ad61a
11 changed files with 63 additions and 29 deletions

View File

@ -1,11 +1,11 @@
# vim:noexpandtab:
cmake_minimum_required(VERSION 3.6)
cmake_minimum_required(VERSION 3.8)
project(PPSSPP)
enable_testing()
#This is supposed to work but doesn't!
if(NOT ANDROID)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
@ -323,7 +323,7 @@ if(NOT MSVC)
add_definitions(-DPNG_ARM_NEON_OPT=0)
if(ANDROID)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17")
endif()
if(CLANG)
add_definitions(-Wno-nullability-completeness)
@ -2066,6 +2066,8 @@ endif()
target_link_libraries(${CoreLibName} Common native kirk cityhash sfmt19937 xbrz xxhash ${GlslangLibs}
${CoreExtraLibs} ${OPENGL_LIBRARIES} ${X11_LIBRARIES} ${CMAKE_DL_LIBS})
target_compile_features(${CoreLibName} PUBLIC cxx_std_17)
if(FFmpeg_FOUND)
target_compile_definitions(${CoreLibName} PRIVATE USE_FFMPEG=1)
set_target_properties(${CoreLibName} PROPERTIES NO_SYSTEM_FROM_IMPORTED true)

View File

@ -148,6 +148,7 @@
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<ForcedIncludeFiles>Common/DbgNew.h</ForcedIncludeFiles>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -172,6 +173,7 @@
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<ForcedIncludeFiles>Common/DbgNew.h</ForcedIncludeFiles>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -196,6 +198,7 @@
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<ForcedIncludeFiles>Common/DbgNew.h</ForcedIncludeFiles>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -221,6 +224,7 @@
<ForcedIncludeFiles>
</ForcedIncludeFiles>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -247,6 +251,7 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -281,6 +286,7 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<StringPooling>true</StringPooling>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -312,6 +318,7 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<StringPooling>true</StringPooling>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -343,6 +350,7 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<StringPooling>true</StringPooling>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>

View File

@ -31,6 +31,7 @@
#include <algorithm>
#include <memory>
#include <string_view>
#include <unordered_map>
#include "zlib.h"
@ -1037,8 +1038,9 @@ void SymbolMap::GetLabels(std::vector<LabelDefinition> &dest) {
for (auto it = activeLabels.begin(); it != activeLabels.end(); it++) {
LabelDefinition entry;
entry.value = it->first;
entry.name = ConvertUTF8ToWString(it->second.name);
std::transform(entry.name.begin(), entry.name.end(), entry.name.begin(), ::towlower);
std::string name = it->second.name;
std::transform(name.begin(), name.end(), name.begin(), ::tolower);
entry.name = Identifier(name);
dest.push_back(entry);
}
}

View File

@ -482,7 +482,7 @@ void WebSocketDisasmState::Assemble(DebuggerRequest &req) {
return;
if (!MIPSAsm::MipsAssembleOpcode(code.c_str(), currentDebugMIPS, address))
return req.Fail(StringFromFormat("Could not assemble: %s", ConvertWStringToUTF8(MIPSAsm::GetAssembleError()).c_str()));
return req.Fail(StringFromFormat("Could not assemble: %s", MIPSAsm::GetAssembleError().c_str()));
JsonWriter &json = req.Respond();
Reporting::NotifyDebugger();

View File

@ -1,6 +1,7 @@
#include <cstdarg>
#include <cstring>
#include <memory>
#include <string_view>
#include <vector>
#include "Common/CommonTypes.h"
@ -15,9 +16,9 @@
namespace MIPSAsm
{
static std::wstring errorText;
static std::string errorText;
std::wstring GetAssembleError()
std::string GetAssembleError()
{
return errorText;
}
@ -62,16 +63,15 @@ private:
fs::path dummyFilename_;
};
bool MipsAssembleOpcode(const char* line, DebugInterface* cpu, u32 address)
{
std::vector<std::wstring> errors;
bool MipsAssembleOpcode(const char *line, DebugInterface *cpu, u32 address) {
std::vector<std::string> errors;
wchar_t str[64];
swprintf(str,64,L".psp\n.org 0x%08X\n",address);
char str[64];
snprintf(str, 64, ".psp\n.org 0x%08X\n", address);
ArmipsArguments args;
args.mode = ArmipsMode::MEMORY;
args.content = str + ConvertUTF8ToWString(line);
args.content = str + std::string(line);
args.silent = true;
args.memoryFile.reset(new PspAssemblerFile());
args.errorsResult = &errors;
@ -80,14 +80,14 @@ bool MipsAssembleOpcode(const char* line, DebugInterface* cpu, u32 address)
g_symbolMap->GetLabels(args.labels);
}
errorText = L"";
errorText = "";
if (!runArmips(args))
{
for (size_t i = 0; i < errors.size(); i++)
{
errorText += errors[i];
if (i != errors.size()-1)
errorText += L"\n";
if (i != errors.size() - 1)
errorText += "\n";
}
return false;

View File

@ -4,5 +4,5 @@
namespace MIPSAsm {
bool MipsAssembleOpcode(const char* line, DebugInterface* cpu, u32 address);
std::wstring GetAssembleError();
std::string GetAssembleError();
}

View File

@ -326,7 +326,7 @@ void CtrlDisAsmView::assembleOpcode(u32 address, std::string defaultText)
redraw();
} else {
std::wstring error = MIPSAsm::GetAssembleError();
std::wstring error = ConvertUTF8ToWString(MIPSAsm::GetAssembleError());
MessageBox(wnd,error.c_str(),L"Error",MB_OK);
}
}

@ -1 +1 @@
Subproject commit 0b13ef32c566781f0566b027ad5681d9320bddf7
Subproject commit b4335f04fa62c1b4f7833c70fbb15505b6772274

View File

@ -261,7 +261,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>armips</AdditionalIncludeDirectories>
<ForcedIncludeFiles>
@ -281,7 +281,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>armips</AdditionalIncludeDirectories>
<OmitFramePointers>false</OmitFramePointers>
@ -303,7 +303,7 @@
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>armips</AdditionalIncludeDirectories>
<OmitFramePointers>false</OmitFramePointers>
@ -311,6 +311,7 @@
</ForcedIncludeFiles>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -324,7 +325,7 @@
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>armips</AdditionalIncludeDirectories>
<OmitFramePointers>false</OmitFramePointers>
@ -332,6 +333,7 @@
</ForcedIncludeFiles>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -372,6 +374,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>armips</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -386,6 +389,7 @@
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>armips</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -398,7 +402,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>armips</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
@ -419,7 +423,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>armips</AdditionalIncludeDirectories>
<BufferSecurityCheck>false</BufferSecurityCheck>
@ -443,7 +447,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>armips</AdditionalIncludeDirectories>
<BufferSecurityCheck>false</BufferSecurityCheck>
@ -451,6 +455,7 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<OmitFramePointers>false</OmitFramePointers>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -466,7 +471,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>armips</AdditionalIncludeDirectories>
<BufferSecurityCheck>false</BufferSecurityCheck>
@ -474,6 +479,7 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<OmitFramePointers>false</OmitFramePointers>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -516,11 +522,13 @@
<ClCompile Include="armips\Core\ELF\ElfFile.cpp" />
<ClCompile Include="armips\Core\ELF\ElfRelocator.cpp" />
<ClCompile Include="armips\Core\Expression.cpp" />
<ClCompile Include="armips\Core\ExpressionFunctionHandler.cpp" />
<ClCompile Include="armips\Core\ExpressionFunctions.cpp" />
<ClCompile Include="armips\Core\FileManager.cpp" />
<ClCompile Include="armips\Core\Misc.cpp" />
<ClCompile Include="armips\Core\SymbolData.cpp" />
<ClCompile Include="armips\Core\SymbolTable.cpp" />
<ClCompile Include="armips\Core\Types.cpp" />
<ClCompile Include="armips\Parser\DirectivesParser.cpp" />
<ClCompile Include="armips\Parser\ExpressionParser.cpp" />
<ClCompile Include="armips\Parser\Parser.cpp" />
@ -567,11 +575,13 @@
<ClInclude Include="armips\Core\ELF\ElfRelocator.h" />
<ClInclude Include="armips\Core\ELF\ElfTypes.h" />
<ClInclude Include="armips\Core\Expression.h" />
<ClInclude Include="armips\Core\ExpressionFunctionHandler.h" />
<ClInclude Include="armips\Core\ExpressionFunctions.h" />
<ClInclude Include="armips\Core\FileManager.h" />
<ClInclude Include="armips\Core\Misc.h" />
<ClInclude Include="armips\Core\SymbolData.h" />
<ClInclude Include="armips\Core\SymbolTable.h" />
<ClInclude Include="armips\Core\Types.h" />
<ClInclude Include="armips\ext\tinyformat\tinyformat.h" />
<ClInclude Include="armips\Parser\DirectivesParser.h" />
<ClInclude Include="armips\Parser\ExpressionParser.h" />

View File

@ -177,6 +177,12 @@
<ClCompile Include="armips\Util\FileSystem.cpp">
<Filter>Util</Filter>
</ClCompile>
<ClCompile Include="armips\Core\Types.cpp">
<Filter>Core</Filter>
</ClCompile>
<ClCompile Include="armips\Core\ExpressionFunctionHandler.cpp">
<Filter>Core</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="armips\Archs\Architecture.h">
@ -329,5 +335,11 @@
<ClInclude Include="armips\Util\FileSystem.h">
<Filter>Util</Filter>
</ClInclude>
<ClInclude Include="armips\Core\Types.h">
<Filter>Core</Filter>
</ClInclude>
<ClInclude Include="armips\Core\ExpressionFunctionHandler.h">
<Filter>Core</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -150,7 +150,7 @@ bool TestJit() {
for (size_t j = 0; j < ARRAY_SIZE(lines); ++j) {
p++;
if (!MIPSAsm::MipsAssembleOpcode(lines[j], currentDebugMIPS, addr)) {
printf("ERROR: %ls\n", MIPSAsm::GetAssembleError().c_str());
printf("ERROR: %s\n", MIPSAsm::GetAssembleError().c_str());
compileSuccess = false;
}
addr += 4;