Merge pull request #648 from Ragora/bugfix-arm-compilation

BugFix: ARM Compilation
This commit is contained in:
Brian Roberts 2021-11-01 17:06:05 -05:00 committed by GitHub
commit a0e0e1f220
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 112 additions and 91 deletions

View file

@ -175,9 +175,4 @@ bool MacFileSystemChangeNotifier::internalRemoveNotification( const Torque::Path
Torque::FS::FileSystemRef Platform::FS::createNativeFS( const String &volume )
{
return new MacFileSystem( volume );
}
bool Torque::FS::VerifyWriteAccess(const Torque::Path &path)
{
return true;
}
}

View file

@ -0,0 +1,90 @@
#include "core/fileio.h"
#include "core/util/tVector.h"
#include "core/stringTable.h"
#include "console/console.h"
#include "core/strings/stringFunctions.h"
#include "util/tempAlloc.h"
#include "cinterface/c_controlInterface.h"
#include "core/volume.h"
/* these are for reading directors, getting stats, etc. */
#include <dirent.h>
#include <sys/stat.h>
const int MaxPath = PATH_MAX;
//------------------------------------------------------------------------------
// munge the case of the specified pathName. This means try to find the actual
// filename in with case-insensitive matching on the specified pathName, and
// store the actual found name.
bool ResolvePathCaseInsensitive(char* pathName, S32 pathNameSize, bool requiredAbsolute)
{
char tempBuf[MaxPath];
dStrncpy(tempBuf, pathName, pathNameSize);
// Check if we're an absolute path
if (pathName[0] != '/')
{
AssertFatal(!requiredAbsolute, "PATH must be absolute");
return false;
}
struct stat filestat;
const int MaxPathEl = 200;
char *currChar = pathName;
char testPath[MaxPath];
char pathEl[MaxPathEl];
bool done = false;
bool foundMatch = false;
dStrncpy(tempBuf, "/", MaxPath);
currChar++;
while (!done)
{
char* termChar = dStrchr(currChar, '/');
if (termChar == NULL)
termChar = dStrchr(currChar, '\0');
AssertFatal(termChar, "Can't find / or NULL terminator");
S32 pathElLen = (termChar - currChar);
dStrncpy(pathEl, currChar, pathElLen);
pathEl[pathElLen] = '\0';
dStrncpy(testPath, tempBuf, MaxPath);
dStrcat(testPath, pathEl, MaxPath);
if (stat(testPath, &filestat) != -1)
{
dStrncpy(tempBuf, testPath, MaxPath);
}
else
{
DIR *dir = opendir(tempBuf);
struct dirent* ent;
while (dir != NULL && (ent = readdir(dir)) != NULL)
{
if (dStricmp(pathEl, ent->d_name) == 0)
{
foundMatch = true;
dStrcat(tempBuf, ent->d_name, MaxPath);
break;
}
}
if (!foundMatch)
dStrncpy(tempBuf, testPath, MaxPath);
if (dir)
closedir(dir);
}
if (*termChar == '/')
{
dStrcat(tempBuf, "/", MaxPath);
termChar++;
currChar = termChar;
}
else
done = true;
}
dStrncpy(pathName, tempBuf, pathNameSize);
return foundMatch;
}

View file

@ -20,7 +20,8 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "platformX86UNIX/platformX86UNIX.h"
#include "platform/types.h"
#include "platform/platformMemory.h"
#include "core/volume.h"
#include <sys/types.h>
@ -54,4 +55,4 @@ ssize_t x86UNIXWrite(int fd, const void *buf, size_t nbytes)
bool Torque::FS::VerifyWriteAccess(const Torque::Path &path)
{
return true;
}
}

View file

@ -179,82 +179,6 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
return sgPrefDir;
}
//------------------------------------------------------------------------------
// munge the case of the specified pathName. This means try to find the actual
// filename in with case-insensitive matching on the specified pathName, and
// store the actual found name.
bool ResolvePathCaseInsensitive(char* pathName, S32 pathNameSize, bool requiredAbsolute)
{
char tempBuf[MaxPath];
dStrncpy(tempBuf, pathName, pathNameSize);
// Check if we're an absolute path
if (pathName[0] != '/')
{
AssertFatal(!requiredAbsolute, "PATH must be absolute");
return false;
}
struct stat filestat;
const int MaxPathEl = 200;
char *currChar = pathName;
char testPath[MaxPath];
char pathEl[MaxPathEl];
bool done = false;
bool foundMatch = false;
dStrncpy(tempBuf, "/", MaxPath);
currChar++;
while (!done)
{
char* termChar = dStrchr(currChar, '/');
if (termChar == NULL)
termChar = dStrchr(currChar, '\0');
AssertFatal(termChar, "Can't find / or NULL terminator");
S32 pathElLen = (termChar - currChar);
dStrncpy(pathEl, currChar, pathElLen);
pathEl[pathElLen] = '\0';
dStrncpy(testPath, tempBuf, MaxPath);
dStrcat(testPath, pathEl, MaxPath);
if (stat(testPath, &filestat) != -1)
{
dStrncpy(tempBuf, testPath, MaxPath);
}
else
{
DIR *dir = opendir(tempBuf);
struct dirent* ent;
while (dir != NULL && (ent = readdir(dir)) != NULL)
{
if (dStricmp(pathEl, ent->d_name) == 0)
{
foundMatch = true;
dStrcat(tempBuf, ent->d_name, MaxPath);
break;
}
}
if (!foundMatch)
dStrncpy(tempBuf, testPath, MaxPath);
if (dir)
closedir(dir);
}
if (*termChar == '/')
{
dStrcat(tempBuf, "/", MaxPath);
termChar++;
currChar = termChar;
}
else
done = true;
}
dStrncpy(pathName, tempBuf, pathNameSize);
return foundMatch;
}
//-----------------------------------------------------------------------------
// Returns true if the pathname exists, false otherwise. If isFile is true,
// the pathname is assumed to be a file path, and only the directory part

View file

@ -29,14 +29,25 @@ if(UNIX)
#set(CXX_FLAG32 "-m32") #uncomment for build x32 on OSx64
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_FLAG32} -Wundef -msse -pipe -Wfatal-errors -Wno-return-type-c-linkage -Wno-unused-local-typedef ${TORQUE_ADDITIONAL_LINKER_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CXX_FLAG32} -Wundef -msse -pipe -Wfatal-errors -Wno-return-type-c-linkage -Wno-unused-local-typedef ${TORQUE_ADDITIONAL_LINKER_FLAGS}")
else()
# default compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_FLAG32} -Wundef -msse -pipe -Wfatal-errors -no-pie ${TORQUE_ADDITIONAL_LINKER_FLAGS} -Wl,-rpath,'$ORIGIN'")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CXX_FLAG32} -Wundef -msse -pipe -Wfatal-errors ${TORQUE_ADDITIONAL_LINKER_FLAGS} -Wl,-rpath,'$ORIGIN'")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_FLAG32} -Wundef -pipe -Wfatal-errors -Wno-return-type-c-linkage -Wno-unused-local-typedef ${TORQUE_ADDITIONAL_LINKER_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CXX_FLAG32} -Wundef -pipe -Wfatal-errors -Wno-return-type-c-linkage -Wno-unused-local-typedef ${TORQUE_ADDITIONAL_LINKER_FLAGS}")
endif()
# Only use SSE on x86 devices
if (TORQUE_CPU_X32 OR TORQUE_CPU_X64)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse")
endif()
else()
# default compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_FLAG32} -Wundef -pipe -Wfatal-errors -no-pie ${TORQUE_ADDITIONAL_LINKER_FLAGS} -Wl,-rpath,'$ORIGIN'")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CXX_FLAG32} -Wundef -pipe -Wfatal-errors ${TORQUE_ADDITIONAL_LINKER_FLAGS} -Wl,-rpath,'$ORIGIN'")
# Only use SSE on x86 devices
if (TORQUE_CPU_X32 OR TORQUE_CPU_X64)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse")
endif()
endif()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()