Nobuaki Sukegawa | 27378fa | 2015-10-29 00:41:39 +0900 | [diff] [blame] | 1 | # |
| 2 | # Licensed to the Apache Software Foundation (ASF) under one |
| 3 | # or more contributor license agreements. See the NOTICE file |
| 4 | # distributed with this work for additional information |
| 5 | # regarding copyright ownership. The ASF licenses this file |
| 6 | # to you under the Apache License, Version 2.0 (the |
| 7 | # "License"); you may not use this file except in compliance |
| 8 | # with the License. You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, |
| 13 | # software distributed under the License is distributed on an |
| 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | # KIND, either express or implied. See the License for the |
| 16 | # specific language governing permissions and limitations |
| 17 | # under the License. |
| 18 | # |
| 19 | |
| 20 | set(hs_test_gen |
| 21 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/ConstantsDemo_Consts.hs |
| 22 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/ConstantsDemo_Types.hs |
| 23 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/DebugProtoTest_Consts.hs |
| 24 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/DebugProtoTest_Types.hs |
| 25 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/EmptyService_Client.hs |
| 26 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/EmptyService.hs |
| 27 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/EmptyService_Iface.hs |
| 28 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/Include_Consts.hs |
| 29 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/Include_Types.hs |
| 30 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/Inherited_Client.hs |
| 31 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/Inherited.hs |
| 32 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/Inherited_Iface.hs |
| 33 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/ReverseOrderService_Client.hs |
| 34 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/ReverseOrderService.hs |
| 35 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/ReverseOrderService_Iface.hs |
| 36 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/SecondService_Client.hs |
| 37 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/SecondService.hs |
| 38 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/SecondService_Iface.hs |
| 39 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/ServiceForExceptionWithAMap_Client.hs |
| 40 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/ServiceForExceptionWithAMap.hs |
| 41 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/ServiceForExceptionWithAMap_Iface.hs |
| 42 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/Srv_Client.hs |
| 43 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/Srv.hs |
| 44 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/Srv_Iface.hs |
| 45 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/ThriftTest_Client.hs |
| 46 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/ThriftTest_Consts.hs |
| 47 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/ThriftTest.hs |
| 48 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/ThriftTest_Iface.hs |
| 49 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/ThriftTest_Types.hs |
| 50 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/Yowza_Client.hs |
| 51 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/Yowza.hs |
| 52 | ${CMAKE_CURRENT_BINARY_DIR}/gen-hs/Yowza_Iface.hs |
| 53 | ) |
| 54 | |
| 55 | set(hs_crosstest_apps |
| 56 | ${CMAKE_CURRENT_BINARY_DIR}/TestServer |
| 57 | ${CMAKE_CURRENT_BINARY_DIR}/TestClient |
| 58 | ) |
| 59 | set(hs_crosstest_args |
| 60 | -igen-hs |
| 61 | -odir=${CMAKE_CURRENT_BINARY_DIR} |
| 62 | -hidir=${CMAKE_CURRENT_BINARY_DIR} |
| 63 | ) |
Nobuaki Sukegawa | e8c71d8 | 2015-11-23 19:51:37 +0900 | [diff] [blame^] | 64 | |
| 65 | if (CMAKE_BUILD_TYPE STREQUAL "Debug") |
| 66 | set(hs_optimize -O0) |
| 67 | else() |
| 68 | set(hs_optimize -O1) |
| 69 | endif() |
| 70 | |
Nobuaki Sukegawa | 27378fa | 2015-10-29 00:41:39 +0900 | [diff] [blame] | 71 | add_custom_command( |
| 72 | OUTPUT ${hs_crosstest_apps} |
Nobuaki Sukegawa | e8c71d8 | 2015-11-23 19:51:37 +0900 | [diff] [blame^] | 73 | COMMAND ${GHC} ${hs_optimize} ${hs_crosstest_args} ${CMAKE_CURRENT_SOURCE_DIR}/TestServer.hs -o TestServer |
| 74 | COMMAND ${GHC} ${hs_optimize} ${hs_crosstest_args} ${CMAKE_CURRENT_SOURCE_DIR}/TestClient.hs -o TestClient |
Nobuaki Sukegawa | 27378fa | 2015-10-29 00:41:39 +0900 | [diff] [blame] | 75 | DEPENDS ${hs_test_gen} haskell_library TestServer.hs TestClient.hs |
| 76 | ) |
| 77 | add_custom_target(haskell_crosstest ALL |
| 78 | COMMENT "Building Haskell cross test executables" |
| 79 | DEPENDS ${hs_crosstest_apps} |
| 80 | ) |
| 81 | |
| 82 | set(hs_test_sources |
| 83 | ConstantsDemo_Main.hs |
| 84 | DebugProtoTest_Main.hs |
| 85 | Include_Main.hs |
| 86 | ThriftTest_Main.hs |
| 87 | ) |
| 88 | set(hs_test_args |
| 89 | -Wall |
| 90 | -XScopedTypeVariables |
| 91 | -i${PROJECT_SOURCE_DIR}/lib/hs/src |
| 92 | -i${CMAKE_CURRENT_BINARY_DIR}/gen-hs |
| 93 | ) |
| 94 | add_custom_target(haskell_tests ALL DEPENDS ${hs_test_gen}) |
| 95 | foreach(SRC ${hs_test_sources}) |
| 96 | get_filename_component(BASE ${SRC} NAME_WE) |
| 97 | add_test(NAME HaskellTests-${BASE} |
| 98 | COMMAND ${RUN_HASKELL} ${hs_test_args} ${SRC} |
| 99 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
| 100 | endforeach() |
| 101 | |
| 102 | set(hs_test_gen_sources |
| 103 | ${PROJECT_SOURCE_DIR}/test/ConstantsDemo.thrift |
| 104 | ${PROJECT_SOURCE_DIR}/test/DebugProtoTest.thrift |
| 105 | ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift |
| 106 | ${PROJECT_SOURCE_DIR}/test/Include.thrift |
| 107 | ) |
| 108 | add_custom_command(OUTPUT ${hs_test_gen} |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 109 | COMMAND ${THRIFT_COMPILER} --gen hs ${PROJECT_SOURCE_DIR}/test/ConstantsDemo.thrift |
| 110 | COMMAND ${THRIFT_COMPILER} --gen hs ${PROJECT_SOURCE_DIR}/test/DebugProtoTest.thrift |
| 111 | COMMAND ${THRIFT_COMPILER} --gen hs ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift |
| 112 | COMMAND ${THRIFT_COMPILER} --gen hs ${PROJECT_SOURCE_DIR}/test/Include.thrift |
| 113 | DEPENDS ${hs_test_gen_sources} |
Nobuaki Sukegawa | 27378fa | 2015-10-29 00:41:39 +0900 | [diff] [blame] | 114 | ) |