[simu] Fix Windows builds with SD-enabled targets; Centralize SD check condition. Make some compiler checks more specific (eg. !minGW). (#4144)

This commit is contained in:
Max Paperno
2016-12-17 13:41:16 +01:00
committed by Bertrand Songis
parent 5d5dc67605
commit 143f5ce05e
2 changed files with 15 additions and 10 deletions
+13 -8
View File
@@ -24,7 +24,7 @@
#include <stdarg.h>
#include <sys/stat.h>
#if !defined _MSC_VER
#if !defined _MSC_VER || defined __GNUC__
#include <sys/time.h>
#endif
@@ -34,6 +34,7 @@
#if defined(SIMU_AUDIO) && defined(CPUARM)
#include <SDL.h>
#undef main
#endif
#if defined(TRACE_SIMPGMSPACE)
@@ -43,6 +44,10 @@
#define TRACE_SIMPGMSPACE(...)
#endif
#if defined(SDCARD) && !defined(SKIP_FATFS_DECLARATION) && !defined(SIMU_DISKIO)
#define SIMU_USE_SDCARD
#endif
uint8_t MCUCSR, MCUSR, MCUCR;
volatile uint8_t pina=0xff, pinb=0xff, pinc=0xff, pind, pine=0xff, pinf=0xff, ping=0xff, pinh=0xff, pinj=0, pinl=0;
uint8_t portb, portc, porth=0, dummyport;
@@ -73,7 +78,7 @@ Dacc dacc;
Adc Adc0;
#endif
#if defined(SDCARD) && !defined(SKIP_FATFS_DECLARATION)
#if defined(SIMU_USE_SDCARD)
char simuSdDirectory[1024] = "";
#endif
@@ -308,9 +313,9 @@ void StartSimu(bool tests)
main_thread_running = (tests ? 1 : 2); // TODO rename to simu_run_mode with #define
#if defined(SDCARD)
#if defined(SIMU_USE_SDCARD)
if (strlen(simuSdDirectory) == 0) {
getcwd(simuSdDirectory, 1024);
f_getcwd(simuSdDirectory, 1024);
}
#endif
@@ -518,7 +523,7 @@ uint16_t stackAvailable()
return 500;
}
#if defined(SDCARD) && !defined(SKIP_FATFS_DECLARATION) && !defined(SIMU_DISKIO)
#if defined(SIMU_USE_SDCARD)
#if defined(_MSC_VER) || !defined(__GNUC__)
#include <direct.h>
#include <stdlib.h>
@@ -570,7 +575,7 @@ char *findTrueFileName(const char *path)
else {
//find file
//add to map
#if defined WIN32 || !defined __GNUC__
#if defined _MSC_VER || !defined __GNUC__
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
@@ -608,7 +613,7 @@ char *findTrueFileName(const char *path)
for (;;) {
struct simu::dirent * res = simu::readdir(dir);
if (res == 0) break;
#if defined(__APPLE__) || defined(__FreeBSD__)
#if defined(WIN32) || defined(__APPLE__) || defined(__FreeBSD__)
if ((res->d_type == DT_REG) || (res->d_type == DT_LNK)) {
#else
if ((res->d_type == simu::DT_REG) || (res->d_type == simu::DT_LNK)) {
@@ -960,7 +965,7 @@ int32_t Card_state = SD_ST_MOUNTED;
uint32_t Card_CSD[4]; // TODO elsewhere
#endif
#endif // #if defined(SDCARD) && !defined(SKIP_FATFS_DECLARATION) && !defined(SIMU_DISKIO)
#endif // #if defined(SIMU_USE_SDCARD)
#if defined(SIMU_DISKIO)