From 5aedb627a91f72f2606a12d904177ef9a481c77e Mon Sep 17 00:00:00 2001 From: Aditya Mandaleeka Date: Tue, 15 Sep 2015 16:04:19 -0700 Subject: [PATCH] Enable building coreclr tests on Linux --- CMakeLists.txt | 30 ++++++++++++++++------------- build.sh | 15 ++++++++++----- src/pal/tools/gen-buildsys-clang.sh | 6 ++++++ tests/CMakeLists.txt | 4 ++++ tests/src/Common/Platform/platformdefines.h | 19 +++++++++++++++--- 5 files changed, 53 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e490c43..12ac902 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,28 +43,28 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux) endif(CMAKE_SYSTEM_NAME STREQUAL Linux) if(CMAKE_SYSTEM_NAME STREQUAL Darwin) - set(CLR_CMAKE_PLATFORM_UNIX 1) - set(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64 1) - set(CLR_CMAKE_PLATFORM_DARWIN 1) - set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_C_COMPILER} -o -c ") + set(CLR_CMAKE_PLATFORM_UNIX 1) + set(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64 1) + set(CLR_CMAKE_PLATFORM_DARWIN 1) + set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_C_COMPILER} -o -c ") endif(CMAKE_SYSTEM_NAME STREQUAL Darwin) if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD) - set(CLR_CMAKE_PLATFORM_UNIX 1) - set(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64 1) - set(CLR_CMAKE_PLATFORM_FREEBSD 1) + set(CLR_CMAKE_PLATFORM_UNIX 1) + set(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64 1) + set(CLR_CMAKE_PLATFORM_FREEBSD 1) endif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD) if(CMAKE_SYSTEM_NAME STREQUAL OpenBSD) - set(CLR_CMAKE_PLATFORM_UNIX 1) - set(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64 1) - set(CLR_CMAKE_PLATFORM_OPENBSD 1) + set(CLR_CMAKE_PLATFORM_UNIX 1) + set(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64 1) + set(CLR_CMAKE_PLATFORM_OPENBSD 1) endif(CMAKE_SYSTEM_NAME STREQUAL OpenBSD) if(CMAKE_SYSTEM_NAME STREQUAL NetBSD) - set(CLR_CMAKE_PLATFORM_UNIX 1) - set(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64 1) - set(CLR_CMAKE_PLATFORM_NETBSD 1) + set(CLR_CMAKE_PLATFORM_UNIX 1) + set(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64 1) + set(CLR_CMAKE_PLATFORM_NETBSD 1) endif(CMAKE_SYSTEM_NAME STREQUAL NetBSD) if(CLR_CMAKE_PLATFORM_UNIX_TARGET_ARM) @@ -630,6 +630,10 @@ else () clr_unknown_arch() endif () +if(CLR_CMAKE_BUILD_TESTS) + add_subdirectory(tests) +endif(CLR_CMAKE_BUILD_TESTS) + add_definitions(-D_SKIP_IF_SIMULATOR_) add_definitions(-D_SECURE_SCL=0) add_definitions(-D_NEW_SDK=1) diff --git a/build.sh b/build.sh index a3d5fe5..6a02dce 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ usage() { - echo "Usage: $0 [BuildArch] [BuildType] [clean] [verbose] [coverage] [cross] [clangx.y] [skipmscorlib]" + echo "Usage: $0 [BuildArch] [BuildType] [clean] [verbose] [coverage] [cross] [clangx.y] [skipmscorlib] [includetests]" echo "BuildArch can be: x64, ARM" echo "BuildType can be: Debug, Release" echo "clean - optional argument to force a clean build." @@ -12,6 +12,7 @@ usage() echo "cross - optional argument to signify cross compilation," echo " - will use ROOTFS_DIR environment variable if set." echo "skipmscorlib - do not build mscorlib.dll even if mono is installed." + echo "includetests - build the tests in the 'tests' subdirectory as well." exit 1 } @@ -63,7 +64,7 @@ build_coreclr() # Regenerate the CMake solution echo "Invoking cmake with arguments: \"$__ProjectRoot\" $__BuildType $__CodeCoverage" - "$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh" "$__ProjectRoot" $__ClangMajorVersion $__ClangMinorVersion $__BuildArch $__BuildType $__CodeCoverage + "$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh" "$__ProjectRoot" $__ClangMajorVersion $__ClangMinorVersion $__BuildArch $__BuildType $__CodeCoverage $__IncludeTests # Check that the makefiles were created. @@ -76,9 +77,9 @@ build_coreclr() # Other techniques such as `nproc` only get the number of # processors available to a single process. if [ `uname` = "FreeBSD" ]; then - NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'` + NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'` else - NumProc=$(($(getconf _NPROCESSORS_ONLN)+1)) + NumProc=$(($(getconf _NPROCESSORS_ONLN)+1)) fi # Build CoreCLR @@ -186,6 +187,7 @@ esac __MSBuildBuildArch=x64 __BuildType=Debug __CodeCoverage= +__IncludeTests= # Set the various build properties here so that CMake and MSBuild can pick them up __ProjectDir="$__ProjectRoot" @@ -259,6 +261,9 @@ for i in "$@" skipmscorlib) __SkipMSCorLib=1 ;; + includetests) + __IncludeTests=Include_Tests + ;; *) __UnprocessedBuildArgs="$__UnprocessedBuildArgs $i" esac @@ -283,7 +288,7 @@ fi # Configure environment if we are doing a verbose build if [ $__VerboseBuild == 1 ]; then - export VERBOSE=1 + export VERBOSE=1 fi # Configure environment if we are doing a cross compile. diff --git a/src/pal/tools/gen-buildsys-clang.sh b/src/pal/tools/gen-buildsys-clang.sh index b63a3fb..790014e 100755 --- a/src/pal/tools/gen-buildsys-clang.sh +++ b/src/pal/tools/gen-buildsys-clang.sh @@ -36,6 +36,7 @@ fi build_arch="$4" buildtype=DEBUG code_coverage=OFF +build_tests=OFF for i in "${@:5}"; do upperI="$(echo $i | awk '{print toupper($0)}')" @@ -48,6 +49,10 @@ for i in "${@:5}"; do echo "Code coverage is turned on for this build." code_coverage=ON ;; + INCLUDE_TESTS) + echo "Including tests directory in build." + build_tests=ON + ;; *) echo "Ignoring unknown arg '$i'" esac @@ -129,5 +134,6 @@ cmake \ "-DCMAKE_OBJDUMP=$llvm_objdump" \ "-DCMAKE_BUILD_TYPE=$buildtype" \ "-DCMAKE_ENABLE_CODE_COVERAGE=$code_coverage" \ + "-DCLR_CMAKE_BUILD_TESTS=$build_tests" \ $cmake_extra_defines \ "$1" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 408e029..2021fd1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -12,6 +12,10 @@ if (WIN32) add_compile_options(-wd4820) endif() +if(CLR_CMAKE_PLATFORM_UNIX) + add_compile_options(-fPIC) +endif(CLR_CMAKE_PLATFORM_UNIX) + MACRO(SUBDIRLIST result curdir) FILE(GLOB children RELATIVE ${curdir} ${curdir}/*) SET(dirlist "") diff --git a/tests/src/Common/Platform/platformdefines.h b/tests/src/Common/Platform/platformdefines.h index e04fa10..7853a3b 100644 --- a/tests/src/Common/Platform/platformdefines.h +++ b/tests/src/Common/Platform/platformdefines.h @@ -5,6 +5,7 @@ #include #include +#include #ifndef _PLATFORMDEFINES__H #define _PLATFORMDEFINES__H @@ -14,7 +15,6 @@ // #ifdef WINDOWS #include -#include #define FS_SEPERATOR L"\\" #define PATH_DELIMITER L";" @@ -25,8 +25,22 @@ typedef unsigned error_t; typedef HANDLE THREAD_ID; #else // !WINDOWS -#include #include + +typedef char16_t WCHAR; +typedef unsigned long DWORD; +typedef int BOOL; +typedef WCHAR *LPWSTR, *PWSTR; +typedef const WCHAR *LPCWSTR, *PCWSTR; + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + #define WINAPI _cdecl #ifndef __stdcall #if __i386__ @@ -63,7 +77,6 @@ typedef void* ULONG_PTR; typedef unsigned error_t; typedef void* LPVOID; typedef char BYTE; -typedef long long __int64; typedef WCHAR OLECHAR; #endif -- 2.7.4