Browse Source

build script updates

Roberto Parolin 6 years ago
parent
commit
14c2267f0a
5 changed files with 102 additions and 3 deletions
  1. 3 0
      .gitmodules
  2. 9 0
      CMakeLists.txt
  3. 66 0
      test/CMakeLists.txt
  4. 1 0
      test/packages/EABase
  5. 23 3
      test/thread/source/TestThread.cpp

+ 3 - 0
.gitmodules

@@ -13,3 +13,6 @@
 [submodule "test/packages/EASTL"]
 [submodule "test/packages/EASTL"]
 	path = test/packages/EASTL
 	path = test/packages/EASTL
 	url = [email protected]:electronicarts/EASTL.git
 	url = [email protected]:electronicarts/EASTL.git
+[submodule "test/packages/EABase"]
+	path = test/packages/EABase
+	url = [email protected]:electronicarts/EABase.git

+ 9 - 0
CMakeLists.txt

@@ -4,12 +4,21 @@
 cmake_minimum_required(VERSION 3.1)
 cmake_minimum_required(VERSION 3.1)
 project(EAThread CXX)
 project(EAThread CXX)
 
 
+#-------------------------------------------------------------------------------------------
+# Options
+#-------------------------------------------------------------------------------------------
+option(EATHREAD_BUILD_TESTS "Enable generation of build files for tests" OFF)
+
 #-------------------------------------------------------------------------------------------
 #-------------------------------------------------------------------------------------------
 # Library definition
 # Library definition
 #-------------------------------------------------------------------------------------------
 #-------------------------------------------------------------------------------------------
 file(GLOB EATHREAD_SOURCES "source/*.cpp")
 file(GLOB EATHREAD_SOURCES "source/*.cpp")
 add_library(EAThread ${EATHREAD_SOURCES})
 add_library(EAThread ${EATHREAD_SOURCES})
 
 
+if(EATHREAD_BUILD_TESTS)
+    add_subdirectory(test)
+endif()
+
 #-------------------------------------------------------------------------------------------
 #-------------------------------------------------------------------------------------------
 # Defines
 # Defines
 #-------------------------------------------------------------------------------------------
 #-------------------------------------------------------------------------------------------

+ 66 - 0
test/CMakeLists.txt

@@ -0,0 +1,66 @@
+#-------------------------------------------------------------------------------------------
+# Copyright (C) Electronic Arts Inc.  All rights reserved.
+#-------------------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------------------
+# CMake info
+#-------------------------------------------------------------------------------------------
+cmake_minimum_required(VERSION 3.1)
+project(EAThreadTest CXX)
+include(CTest)
+
+#-------------------------------------------------------------------------------------------
+# Defines
+#-------------------------------------------------------------------------------------------
+add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+add_definitions(-D_SCL_SECURE_NO_WARNINGS)
+add_definitions(-D_CHAR16T)
+add_definitions(-DEA_OPENSOURCE)
+
+#-------------------------------------------------------------------------------------------
+# Compiler Flags
+#-------------------------------------------------------------------------------------------
+set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/../../EASTL/scripts/CMake")
+include(CommonCppFlags)
+
+#-------------------------------------------------------------------------------------------
+# Source files
+#-------------------------------------------------------------------------------------------
+file(GLOB EATHREADTEST_SOURCES "thread/source/*.cpp")
+set(SOURCES ${EATHREADTEST_SOURCES})
+
+
+#-------------------------------------------------------------------------------------------
+# Executable definition
+#-------------------------------------------------------------------------------------------
+add_executable(EAThreadTest ${SOURCES})
+
+#-------------------------------------------------------------------------------------------
+# Include directories
+#-------------------------------------------------------------------------------------------
+target_include_directories(EAThreadTest PUBLIC include)
+
+#-------------------------------------------------------------------------------------------
+# Dependencies 
+#-------------------------------------------------------------------------------------------
+add_subdirectory(packages/EAAssert)
+add_subdirectory(packages/EABase)
+add_subdirectory(packages/EAMain)
+add_subdirectory(packages/EASTL)
+add_subdirectory(packages/EAStdC)
+add_subdirectory(packages/EATest)
+
+target_link_libraries(EAThreadTest EAAssert)
+target_link_libraries(EAThreadTest EABase)
+target_link_libraries(EAThreadTest EAMain)
+target_link_libraries(EAThreadTest EASTL)
+target_link_libraries(EAThreadTest EAStdC)
+target_link_libraries(EAThreadTest EATest)
+target_link_libraries(EAThreadTest EAThread)
+
+#-------------------------------------------------------------------------------------------
+# Run Unit tests and verify the results.
+#-------------------------------------------------------------------------------------------
+add_test(EAThreadTestRuns EAThreadTest)
+set_tests_properties (EAThreadTestRuns PROPERTIES PASS_REGULAR_EXPRESSION "RETURNCODE=0")
+

+ 1 - 0
test/packages/EABase

@@ -0,0 +1 @@
+Subproject commit 24900cce16ee32e0c48c17671fe2731498e31a0c

+ 23 - 3
test/thread/source/TestThread.cpp

@@ -17,9 +17,27 @@
 	#define EA_MEMORY_GCC_USE_FINALIZE
 	#define EA_MEMORY_GCC_USE_FINALIZE
 #endif
 #endif
 
 
-#include <MemoryMan/MemoryMan.inl>
-#include <MemoryMan/CoreAllocator.inl>
-#include <coreallocator/icoreallocator_interface.h>
+#ifndef EA_OPENSOURCE
+	#include <MemoryMan/MemoryMan.inl>
+	#include <MemoryMan/CoreAllocator.inl>
+	#include <coreallocator/icoreallocator_interface.h>
+#endif
+
+
+#ifdef EA_OPENSOURCE
+void* operator new[](size_t size, const char* /*pName*/, int /*flags*/,
+					 unsigned /*debugFlags*/, const char* /*file*/, int /*line*/)
+{
+	return operator new[](size);
+}
+
+void* operator new[](size_t size, size_t /*alignment*/, size_t /*alignmentOffset*/, const char* /*pName*/,
+					 int /*flags*/, unsigned /*debugFlags*/, const char* /*file*/, int /*line*/)
+{
+	return operator new[](size);
+}
+#endif
+
 
 
 #ifdef EA_DLL
 #ifdef EA_DLL
 	#include <MemoryMan/MemoryManDLL.h>
 	#include <MemoryMan/MemoryManDLL.h>
@@ -152,7 +170,9 @@ int EAMain(int argc, char** argv)
 	#endif
 	#endif
 
 
 	//Set EAThread to use the Default Allocator to keep track of our memory usage
 	//Set EAThread to use the Default Allocator to keep track of our memory usage
+#ifndef EA_OPENSOURCE
 	EA::Thread::SetAllocator(EA::Allocator::ICoreAllocator::GetDefaultAllocator());
 	EA::Thread::SetAllocator(EA::Allocator::ICoreAllocator::GetDefaultAllocator());
+#endif
 	EA::Thread::InitCallstack();
 	EA::Thread::InitCallstack();
 
 
 	// Print ThreadId for this primary thread.
 	// Print ThreadId for this primary thread.