diff --git a/3rdparty/UnitTest++/src/Config.h b/3rdparty/UnitTest++/src/Config.h index 5deeb27..200833e 100644 --- a/3rdparty/UnitTest++/src/Config.h +++ b/3rdparty/UnitTest++/src/Config.h @@ -22,7 +22,8 @@ || defined(__NetBSD__) \ || defined(__OpenBSD__) \ || defined(__FreeBSD__) \ - || defined(__native_client__) + || defined(__native_client__) \ + || defined(__riscv) # define UNITTEST_POSIX #endif diff --git a/include/bx/platform.h b/include/bx/platform.h index d07e031..4ed4752 100644 --- a/include/bx/platform.h +++ b/include/bx/platform.h @@ -28,11 +28,12 @@ #define BX_PLATFORM_XBOX360 0 #define BX_PLATFORM_XBOXONE 0 -#define BX_CPU_ARM 0 -#define BX_CPU_JIT 0 -#define BX_CPU_MIPS 0 -#define BX_CPU_PPC 0 -#define BX_CPU_X86 0 +#define BX_CPU_ARM 0 +#define BX_CPU_JIT 0 +#define BX_CPU_MIPS 0 +#define BX_CPU_PPC 0 +#define BX_CPU_RISCV 0 +#define BX_CPU_X86 0 #define BX_ARCH_32BIT 0 #define BX_ARCH_64BIT 0 @@ -84,6 +85,12 @@ # undef BX_CPU_PPC # define BX_CPU_PPC 1 # define BX_CACHE_LINE_SIZE 128 +#elif defined(__riscv) || \ + defined(__riscv__) || \ + defined(RISCVEL) +# undef BX_CPU_RISCV +# define BX_CPU_RISCV 1 +# define BX_CACHE_LINE_SIZE 64 #elif defined(_M_IX86) || \ defined(_M_X64) || \ defined(__i386__) || \ @@ -103,7 +110,8 @@ defined(__64BIT__) || \ defined(__mips64) || \ defined(__powerpc64__) || \ - defined(__ppc64__) + defined(__ppc64__) || \ + defined(__LP64__) # undef BX_ARCH_64BIT # define BX_ARCH_64BIT 64 #else @@ -171,10 +179,12 @@ // RaspberryPi compiler defines __linux__ # undef BX_PLATFORM_RPI # define BX_PLATFORM_RPI 1 -#elif defined(__linux__) +#elif defined(__linux__) \ + || defined(__riscv__) # undef BX_PLATFORM_LINUX # define BX_PLATFORM_LINUX 1 -#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) || defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) +#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) \ + || defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) # undef BX_PLATFORM_IOS # define BX_PLATFORM_IOS 1 #elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) @@ -183,7 +193,7 @@ # define BX_PLATFORM_OSX __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ # else # define BX_PLATFORM_OSX 1 -# endif // defined(MAC_OS_X_VERSION_MAX_ALLOWED) +# endif // defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) #elif defined(__EMSCRIPTEN__) # undef BX_PLATFORM_EMSCRIPTEN # define BX_PLATFORM_EMSCRIPTEN 1 @@ -283,12 +293,14 @@ #if BX_CPU_ARM # define BX_CPU_NAME "ARM" +#elif BX_CPU_JIT +# define BX_CPU_NAME "JIT-VM" #elif BX_CPU_MIPS # define BX_CPU_NAME "MIPS" #elif BX_CPU_PPC # define BX_CPU_NAME "PowerPC" -#elif BX_CPU_JIT -# define BX_CPU_NAME "JIT-VM" +#elif BX_CPU_RISCV +# define BX_CPU_NAME "RISC-V" #elif BX_CPU_X86 # define BX_CPU_NAME "x86" #endif // BX_CPU_ diff --git a/scripts/toolchain.lua b/scripts/toolchain.lua index ef4ed31..4f37458 100755 --- a/scripts/toolchain.lua +++ b/scripts/toolchain.lua @@ -37,6 +37,7 @@ function toolchain(_buildDir, _libDir) { "ps4", "PS4" }, { "qnx-arm", "QNX/Blackberry - ARM" }, { "rpi", "RaspberryPi" }, + { "riscv", "RISC-V" }, }, } @@ -336,6 +337,13 @@ function toolchain(_buildDir, _libDir) elseif "rpi" == _OPTIONS["gcc"] then location (path.join(_buildDir, "projects", _ACTION .. "-rpi")) + + elseif "riscv" == _OPTIONS["gcc"] then + premake.gcc.cc = "/opt/riscv/bin/riscv64-unknown-elf-gcc" + premake.gcc.cxx = "/opt/riscv/bin/riscv64-unknown-elf-g++" + premake.gcc.ar = "/opt/riscv/bin/riscv64-unknown-elf-ar" + location (path.join(_buildDir, "projects", _ACTION .. "-riscv")) + end elseif _ACTION == "vs2012" or _ACTION == "vs2013" or _ACTION == "vs2015" then @@ -1128,6 +1136,17 @@ function toolchain(_buildDir, _libDir) "-Wl,--gc-sections", } + configuration { "riscv" } + targetdir (path.join(_buildDir, "riscv/bin")) + objdir (path.join(_buildDir, "riscv/obj")) + buildoptions { + "-Wunused-value", + "-Wundef", + } + buildoptions_cpp { + "-std=c++0x", + } + configuration {} -- reset configuration return true diff --git a/scripts/unittest++.lua b/scripts/unittest++.lua index 3a52b24..cf183c1 100644 --- a/scripts/unittest++.lua +++ b/scripts/unittest++.lua @@ -15,7 +15,7 @@ project "UnitTest++" "../3rdparty/UnitTest++/src/*.h", } - configuration { "linux or osx or android-* or *nacl* or ps4" } + configuration { "linux or osx or android-* or *nacl* or ps4 or rpi or riscv" } files { "../3rdparty/UnitTest++/src/Posix/**.cpp", "../3rdparty/UnitTest++/src/Posix/**.h",