MacOSX: First native Apple M1 support

This commit is contained in:
Mounir IDRASSI 2021-08-15 00:51:06 +02:00
parent 33baca7261
commit 8ae5a715d6
No known key found for this signature in database
GPG Key ID: 02C30AE90FAE4A6F
7 changed files with 33 additions and 20 deletions

View File

@ -56,9 +56,13 @@ namespace VeraCrypt
#elif defined (TC_MACOSX) #elif defined (TC_MACOSX)
# ifdef __x86_64__ # ifdef __x86_64__
faultingInstructionAddress = context->uc_mcontext->__ss.__rip; faultingInstructionAddress = context->uc_mcontext->__ss.__rip;
# else
# ifdef __aarch64__
faultingInstructionAddress = context->uc_mcontext->__ss.__pc;
# else # else
faultingInstructionAddress = context->uc_mcontext->__ss.__eip; faultingInstructionAddress = context->uc_mcontext->__ss.__eip;
# endif # endif
# endif
#endif #endif
wstringstream vars; wstringstream vars;

View File

@ -282,7 +282,7 @@ namespace VeraCrypt
VolumeStaticBoxSizer->Detach (VolumeGridBagSizer); VolumeStaticBoxSizer->Detach (VolumeGridBagSizer);
VolumeStaticBoxSizer->Add (VolumeGridBagSizer, 1, wxEXPAND, 0); VolumeStaticBoxSizer->Add (VolumeGridBagSizer, 1, wxEXPAND, 0);
ExitButton->SetLabel (LangString["CLOSE"]); ExitButton->SetLabel (LangString["IDCLOSE"]);
MountAllDevicesButton->SetLabel (LangString["LINUX_MOUNT_ALL_DEV"]); MountAllDevicesButton->SetLabel (LangString["LINUX_MOUNT_ALL_DEV"]);
#endif #endif

View File

@ -1,4 +1,4 @@
#ifdef TC_LINUX #ifndef TC_WINDOWS
#include "Main/LanguageStrings.h" #include "Main/LanguageStrings.h"
#undef _ #undef _
#define _(key) LangString[key] #define _(key) LangString[key]

View File

@ -29,6 +29,9 @@ namespace VeraCrypt
{ {
if (Map.count (key) > 0) if (Map.count (key) > 0)
return wxString (Map.find (key)->second); return wxString (Map.find (key)->second);
// return "VeraCrypt" as it is
if (key == "VeraCrypt")
return L"VeraCrypt";
return wxString (L"?") + StringConverter::ToWide (key) + L"?"; return wxString (L"?") + StringConverter::ToWide (key) + L"?";
} }
@ -40,7 +43,6 @@ namespace VeraCrypt
void LanguageStrings::Init () void LanguageStrings::Init ()
{ {
#ifdef TC_LINUX
static byte LanguageXml[] = static byte LanguageXml[] =
{ {
# include "Common/Language.xml.h" # include "Common/Language.xml.h"
@ -53,7 +55,7 @@ namespace VeraCrypt
text.Replace (L"\\n", L"\n"); text.Replace (L"\\n", L"\n");
Map[StringConverter::ToSingle (wstring (node.Attributes[L"key"]))] = text; Map[StringConverter::ToSingle (wstring (node.Attributes[L"key"]))] = text;
} }
#endif
foreach (XmlNode node, XmlParser (Resources::GetLanguageXml()).GetNodes (L"entry")) foreach (XmlNode node, XmlParser (Resources::GetLanguageXml()).GetNodes (L"entry"))
{ {
wxString text = node.InnerText; wxString text = node.InnerText;

View File

@ -178,6 +178,7 @@ endif
ifeq "$(PLATFORM)" "MacOSX" ifeq "$(PLATFORM)" "MacOSX"
prepare: $(APPNAME) prepare: $(APPNAME)
mkdir -p $(APPNAME).app/Contents/MacOS $(APPNAME).app/Contents/Resources/doc/HTML mkdir -p $(APPNAME).app/Contents/MacOS $(APPNAME).app/Contents/Resources/doc/HTML
mkdir -p $(APPNAME).app/Contents/MacOS $(APPNAME).app/Contents/Resources/languages
-rm -f $(APPNAME).app/Contents/MacOS/$(APPNAME) -rm -f $(APPNAME).app/Contents/MacOS/$(APPNAME)
-rm -f $(APPNAME).app/Contents/MacOS/$(APPNAME)_console -rm -f $(APPNAME).app/Contents/MacOS/$(APPNAME)_console
@ -200,6 +201,7 @@ endif
cp $(BASE_DIR)/Resources/Icons/VeraCrypt.icns $(APPNAME).app/Contents/Resources cp $(BASE_DIR)/Resources/Icons/VeraCrypt.icns $(APPNAME).app/Contents/Resources
cp $(BASE_DIR)/Resources/Icons/VeraCrypt_Volume.icns $(APPNAME).app/Contents/Resources cp $(BASE_DIR)/Resources/Icons/VeraCrypt_Volume.icns $(APPNAME).app/Contents/Resources
cp $(BASE_DIR)/../doc/html/* $(APPNAME).app/Contents/Resources/doc/HTML cp $(BASE_DIR)/../doc/html/* $(APPNAME).app/Contents/Resources/doc/HTML
cp $(BASE_DIR)/../Translations/* $(APPNAME).app/Contents/Resources/languages
echo -n APPLTRUE >$(APPNAME).app/Contents/PkgInfo echo -n APPLTRUE >$(APPNAME).app/Contents/PkgInfo
ifdef VC_LEGACY_BUILD ifdef VC_LEGACY_BUILD

View File

@ -14,16 +14,17 @@
#include "Platform/Platform.h" #include "Platform/Platform.h"
#include "Resources.h" #include "Resources.h"
#ifdef TC_LINUX #ifdef TC_WINDOWS
#include "Main/resource.h"
#else
#ifdef TC_MACOSX
#include "Application.h"
#endif
#include "Platform/File.h" #include "Platform/File.h"
#include "Platform/StringConverter.h" #include "Platform/StringConverter.h"
#include <stdio.h> #include <stdio.h>
#endif #endif
#ifdef TC_WINDOWS
#include "Main/resource.h"
#endif
namespace VeraCrypt namespace VeraCrypt
{ {
@ -54,13 +55,17 @@ namespace VeraCrypt
strBuf.Zero(); strBuf.Zero();
strBuf.CopyFrom (res); strBuf.CopyFrom (res);
return string (reinterpret_cast <char *> (strBuf.Ptr())); return string (reinterpret_cast <char *> (strBuf.Ptr()));
#elif TC_LINUX #else
// get language from env LANG // get language from env LANG
// support: C,POSIX, // support: C,POSIX,
// support for e.g. german: de_DE.UTF-8, de.UTF8, de_DE, de // support for e.g. german: de_DE.UTF-8, de.UTF8, de_DE, de
// not support e.g.: de@Euro // not support e.g.: de@Euro
string defaultLang("en"); string defaultLang("en");
#if defined (TC_MACOSX)
string filenamePrefix = StringConverter::ToSingle (Application::GetExecutableDirectory()) + "/../Resources/languages/Language.";
#else
string filenamePrefix("/usr/share/veracrypt/languages/Language."); string filenamePrefix("/usr/share/veracrypt/languages/Language.");
#endif
string filenamePost(".xml"); string filenamePost(".xml");
string filename = filenamePrefix + defaultLang + filenamePost; string filename = filenamePrefix + defaultLang + filenamePost;
if(const char* env_p = getenv("LANG")){ if(const char* env_p = getenv("LANG")){
@ -126,14 +131,6 @@ namespace VeraCrypt
, 0 , 0
}; };
return string ((const char*) LanguageXml);
#else
static byte LanguageXml[] =
{
# include "Common/Language.xml.h"
, 0
};
return string ((const char*) LanguageXml); return string ((const char*) LanguageXml);
#endif #endif
} }

View File

@ -274,6 +274,10 @@ ifeq "$(shell uname -s)" "Darwin"
ifeq "$(CPU_ARCH)" "x64" ifeq "$(CPU_ARCH)" "x64"
CPU_ARCH = x86 CPU_ARCH = x86
endif endif
ifeq "$(CPU_ARCH)" "arm64"
CPU_ARCH = x86
endif
CFLAGS += -msse2 CFLAGS += -msse2
CXXFLAGS += -msse2 CXXFLAGS += -msse2
@ -302,14 +306,18 @@ ifeq "$(shell uname -s)" "Darwin"
C_CXX_FLAGS += -gfull -arch x86_64 C_CXX_FLAGS += -gfull -arch x86_64
LFLAGS += -Wl,-dead_strip -arch x86_64 LFLAGS += -Wl,-dead_strip -arch x86_64
WX_CONFIGURE_FLAGS += --without-libpng --disable-gif --disable-pcx --disable-tga --disable-iff --disable-gif --disable-svg
#----- Legacy build: we build both 32-bit and 64-bit ---- #----- Legacy build: we build both 32-bit and 64-bit ----
ifdef VC_LEGACY_BUILD ifdef VC_LEGACY_BUILD
C_CXX_FLAGS += -arch i386 C_CXX_FLAGS += -arch i386
LFLAGS += -arch i386 LFLAGS += -arch i386
WX_CONFIGURE_FLAGS += --enable-universal_binary=i386,x86_64 WX_CONFIGURE_FLAGS += --enable-universal_binary=i386,x86_64
else else
CXXFLAGS += -std=c++11 CXXFLAGS += -std=c++11
WX_CONFIGURE_FLAGS += --disable-universal_binary C_CXX_FLAGS += -arch arm64
LFLAGS += -arch arm64
WX_CONFIGURE_FLAGS += --enable-universal_binary=arm64,x86_64
endif endif
WXCONFIG_CFLAGS += -gfull WXCONFIG_CFLAGS += -gfull