Commit 30b6b59d by Ben Clayton

Yarn: Add CMake build rules (disabled by default) and stub tests

Bug: b/139010488 Change-Id: Ie5f753df22a55dd2718b0e6ee24e48678d6a956c Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/34808 Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com>
parent ff6e8c01
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
project(SwiftShader C CXX) project(SwiftShader C CXX ASM)
# On Windows we use custom solution and project files, except for certain third- # On Windows we use custom solution and project files, except for certain third-
# party projects which use CMake-generated ones. They are manually (re)generated # party projects which use CMake-generated ones. They are manually (re)generated
...@@ -79,6 +79,8 @@ if(NOT CMAKE_BUILD_TYPE) ...@@ -79,6 +79,8 @@ if(NOT CMAKE_BUILD_TYPE)
endif() endif()
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release MinSizeRel RelWithDebInfo) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release MinSizeRel RelWithDebInfo)
option(BUILD_YARN "Build yarn" 0)
option(BUILD_EGL "Build the EGL library" 1) option(BUILD_EGL "Build the EGL library" 1)
option(BUILD_GLESv2 "Build the OpenGL ES 2 library" 1) option(BUILD_GLESv2 "Build the OpenGL ES 2 library" 1)
option(BUILD_GLES_CM "Build the OpenGL ES 1.1 library" 1) option(BUILD_GLES_CM "Build the OpenGL ES 1.1 library" 1)
...@@ -262,6 +264,7 @@ endif() ...@@ -262,6 +264,7 @@ endif()
########################################################### ###########################################################
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(YARN_DIR ${SOURCE_DIR}/Yarn)
set(OPENGL_DIR ${SOURCE_DIR}/OpenGL) set(OPENGL_DIR ${SOURCE_DIR}/OpenGL)
set(OPENGL_COMPILER_DIR ${OPENGL_DIR}/compiler) set(OPENGL_COMPILER_DIR ${OPENGL_DIR}/compiler)
set(VULKAN_DIR ${SOURCE_DIR}/Vulkan) set(VULKAN_DIR ${SOURCE_DIR}/Vulkan)
...@@ -279,6 +282,9 @@ set(HELLO2_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/PowerVR_SDK/Examples/Begi ...@@ -279,6 +282,9 @@ set(HELLO2_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/PowerVR_SDK/Examples/Begi
# Compile flags # Compile flags
########################################################### ###########################################################
# Run assembly files through the C preprocessor.
SET(CMAKE_ASM_FLAGS "-x assembler-with-cpp -DBUILD_ASM=1")
# Flags for project code (non 3rd party) # Flags for project code (non 3rd party)
set(SWIFTSHADER_COMPILE_OPTIONS "") set(SWIFTSHADER_COMPILE_OPTIONS "")
...@@ -303,6 +309,7 @@ if(MSVC) ...@@ -303,6 +309,7 @@ if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_SCL_SECURE_NO_WARNINGS) add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(-D_SBCS) # Single Byte Character Set (ASCII) add_definitions(-D_SBCS) # Single Byte Character Set (ASCII)
add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE) # Disable MSVC warnings about std::aligned_storage being broken before VS 2017 15.8
if(WARNINGS_AS_ERRORS) if(WARNINGS_AS_ERRORS)
set_cpp_flag("/WX") # Treat all warnings as errors set_cpp_flag("/WX") # Treat all warnings as errors
...@@ -1753,6 +1760,24 @@ file(GLOB_RECURSE VULKAN_LIST ...@@ -1753,6 +1760,24 @@ file(GLOB_RECURSE VULKAN_LIST
${CMAKE_CURRENT_SOURCE_DIR}/include/vulkan/*.h} ${CMAKE_CURRENT_SOURCE_DIR}/include/vulkan/*.h}
) )
if(BUILD_YARN)
file(GLOB YARN_FULL_LIST
${YARN_DIR}/*.cpp
${YARN_DIR}/*.hpp
${YARN_DIR}/*.c
)
if (NOT MSVC)
file(GLOB YARN_ASSEMBLY_LIST ${YARN_DIR}/*.s)
list(APPEND YARN_FULL_LIST ${YARN_ASSEMBLY_LIST})
endif(NOT MSVC)
set(YARN_LIST ${YARN_FULL_LIST})
set(YARN_TEST_LIST ${YARN_FULL_LIST})
list(FILTER YARN_LIST EXCLUDE REGEX ".*_test\\..*")
list(FILTER YARN_TEST_LIST INCLUDE REGEX ".*_test\\..*")
endif(BUILD_YARN)
########################################################### ###########################################################
# Append OS specific files to lists # Append OS specific files to lists
########################################################### ###########################################################
...@@ -1841,6 +1866,17 @@ endif() ...@@ -1841,6 +1866,17 @@ endif()
# SwiftShader Targets # SwiftShader Targets
########################################################### ###########################################################
if(BUILD_YARN)
add_library(Yarn STATIC ${YARN_LIST})
set_target_properties(Yarn PROPERTIES
POSITION_INDEPENDENT_CODE 1
FOLDER "Core"
COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS}"
COMPILE_DEFINITIONS "NO_SANITIZE_FUNCTION=;"
)
target_link_libraries(Yarn ${OS_LIBS})
endif(BUILD_YARN)
add_library(SwiftShader STATIC ${SWIFTSHADER_LIST}) add_library(SwiftShader STATIC ${SWIFTSHADER_LIST})
set_target_properties(SwiftShader PROPERTIES set_target_properties(SwiftShader PROPERTIES
INCLUDE_DIRECTORIES "${COMMON_INCLUDE_DIR}" INCLUDE_DIRECTORIES "${COMMON_INCLUDE_DIR}"
...@@ -2135,7 +2171,31 @@ if(BUILD_TESTS) ...@@ -2135,7 +2171,31 @@ if(BUILD_TESTS)
if(ANDROID) if(ANDROID)
target_link_libraries(gles-unittests -landroid) target_link_libraries(gles-unittests -landroid)
endif() endif()
endif() endif(BUILD_TESTS)
if(BUILD_TESTS AND BUILD_YARN)
file(GLOB YARN_TEST_LIST
${YARN_DIR}/*_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/third_party/googletest/googletest/src/gtest-all.cc
)
set(YARN_TEST_INCLUDE_DIR
${CMAKE_CURRENT_SOURCE_DIR}/third_party/googletest/googletest/include/
${CMAKE_CURRENT_SOURCE_DIR}/third_party/googletest/googlemock/include/
${CMAKE_CURRENT_SOURCE_DIR}/third_party/googletest/googletest/
${CMAKE_CURRENT_SOURCE_DIR}/src
)
add_executable(yarn-unittests ${YARN_TEST_LIST})
set_target_properties(yarn-unittests PROPERTIES
INCLUDE_DIRECTORIES "${YARN_TEST_INCLUDE_DIR}"
FOLDER "Tests"
COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS}"
COMPILE_DEFINITIONS "STANDALONE"
)
target_link_libraries(yarn-unittests Yarn ${OS_LIBS})
endif(BUILD_TESTS AND BUILD_YARN)
if(BUILD_TESTS) if(BUILD_TESTS)
set(MATH_UNITTESTS_LIST set(MATH_UNITTESTS_LIST
...@@ -2189,4 +2249,4 @@ if(BUILD_TESTS AND BUILD_VULKAN) ...@@ -2189,4 +2249,4 @@ if(BUILD_TESTS AND BUILD_VULKAN)
) )
target_link_libraries(vk-unittests ${OS_LIBS} SPIRV-Tools) target_link_libraries(vk-unittests ${OS_LIBS} SPIRV-Tools)
endif() endif(BUILD_TESTS AND BUILD_VULKAN)
// Copyright 2019 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "Yarn_test.hpp"
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
// Copyright 2019 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "gmock/gmock.h"
#include "gtest/gtest.h"
class WithoutBoundScheduler : public testing::Test {};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment