blob: 95a28d0f98f05aa0fcf6c812118c34636d500eee [file] [log] [blame]
Craig Tillerd7f33352015-02-20 15:18:45 -08001# Copyright 2015, Google Inc.
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met:
7#
8# * Redistributions of source code must retain the above copyright
9# notice, this list of conditions and the following disclaimer.
10# * Redistributions in binary form must reproduce the above
11# copyright notice, this list of conditions and the following disclaimer
12# in the documentation and/or other materials provided with the
13# distribution.
14# * Neither the name of Google Inc. nor the names of its
15# contributors may be used to endorse or promote products derived from
16# this software without specific prior written permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Jan Tattermusch451a2272015-02-12 18:34:50 -080029<%!
30 import re
31%>\
Jan Tattermusch789e7ae2015-04-16 21:03:30 -070032<%namespace file="packages.include" import="get_openssl,get_zlib"/>\
Jan Tattermusch451a2272015-02-12 18:34:50 -080033<%def name="to_windows_path(path)">${path.replace('/','\\')}</%def>\
34<%
35 allowed_dependencies = set(['gpr', 'grpc', 'gpr_test_util', 'grpc_test_util'])
Craig Tillerfef0c2d2015-04-08 15:58:59 -070036 buildable_targets = [ target for target in targets
37 if set(target.deps).issubset(allowed_dependencies) and
Jan Tattermusch789e7ae2015-04-16 21:03:30 -070038 all([src.endswith('.c') for src in target.src]) and
39 'windows' in target.platforms ]
Craig Tillerf5a7c8b2015-04-08 09:48:54 -070040 c_test_targets = [ target for target in buildable_targets if target.build == 'test' and not target.language == 'c++' ]
41 cxx_test_targets = [ target for target in buildable_targets if target.build == 'test' and target.language == 'c++' ]
Jan Tattermusch451a2272015-02-12 18:34:50 -080042%>\
Jan Tattermuschd5b076a2015-02-12 19:16:42 -080043# NMake file to build secondary gRPC targets on Windows.
44# Use grpc.sln to solution to build the gRPC libraries.
Jan Tattermusch451a2272015-02-12 18:34:50 -080045
46OUT_DIR=test_bin
47
Jan Tattermuscha2ad5582015-02-12 19:44:35 -080048CC=cl.exe
49LINK=link.exe
Jan Tattermusch64d10c12015-02-13 09:39:54 -080050
Jan Tattermusch8ff00a32015-04-20 18:43:06 -070051REPO_ROOT=..
Jan Tattermusch789e7ae2015-04-16 21:03:30 -070052OPENSSL_INCLUDES = .\packages\${get_openssl()}\build\native\include\v120\Win32\Debug\static
53ZLIB_INCLUDES = .\packages\${get_zlib()}\build\native\include
Jan Tattermusch8ff00a32015-04-20 18:43:06 -070054INCLUDES=/I$(REPO_ROOT) /I$(REPO_ROOT)\include /I$(OPENSSL_INCLUDES) /I$(ZLIB_INCLUDES)
Jan Tattermusch64d10c12015-02-13 09:39:54 -080055DEFINES=/D WIN32 /D _LIB /D _USE_32BIT_TIME_T /D _UNICODE /D UNICODE /D _CRT_SECURE_NO_WARNINGS
56CFLAGS=/c $(INCLUDES) /nologo /Z7 /W3 /WX- /sdl $(DEFINES) /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /TC /analyze-
Jan Tattermuscha2ad5582015-02-12 19:44:35 -080057LFLAGS=/DEBUG /INCREMENTAL /NOLOGO /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86
Jan Tattermusch64d10c12015-02-13 09:39:54 -080058
Jan Tattermusch789e7ae2015-04-16 21:03:30 -070059OPENSSL_LIBS=.\packages\${get_openssl()}\build\native\lib\v120\Win32\Debug\static\ssleay32.lib .\packages\${get_openssl()}\build\native\lib\v120\Win32\Debug\static\libeay32.lib
Jan Tattermusch64d10c12015-02-13 09:39:54 -080060WINSOCK_LIBS=ws2_32.lib
Jan Tattermusch789e7ae2015-04-16 21:03:30 -070061ZLIB_LIBS=.\packages\${get_zlib()}\build\native\lib\v120\Win32\Debug\static\cdecl\zlib.lib
Jan Tattermusch64d10c12015-02-13 09:39:54 -080062LIBS=$(OPENSSL_LIBS) $(WINSOCK_LIBS) $(ZLIB_LIBS)
Jan Tattermuscha2ad5582015-02-12 19:44:35 -080063
Jan Tattermusch87d621b2015-04-20 10:00:38 -070064build_gpr_test_util:
65 msbuild grpc.sln /t:gpr_test_util /p:Configuration=Debug
Jan Tattermusch451a2272015-02-12 18:34:50 -080066
Jan Tattermusch87d621b2015-04-20 10:00:38 -070067build_grpc_test_util:
68 msbuild grpc.sln /t:grpc_test_util /p:Configuration=Debug
Jan Tattermusch451a2272015-02-12 18:34:50 -080069
70$(OUT_DIR):
71 mkdir $(OUT_DIR)
72
Craig Tillerf5a7c8b2015-04-08 09:48:54 -070073buildtests: buildtests_c buildtests_cxx
74
75buildtests_c: \
76% for target in c_test_targets:
Jan Tattermusch451a2272015-02-12 18:34:50 -080077${target.name}.exe \
78% endfor
79
80 echo All tests built.
81
Craig Tillerf5a7c8b2015-04-08 09:48:54 -070082buildtests_cxx: \
83% for target in cxx_test_targets:
84${target.name}.exe \
Jan Tattermusch451a2272015-02-12 18:34:50 -080085% endfor
86
Craig Tillerf5a7c8b2015-04-08 09:48:54 -070087 echo All tests built.
Jan Tattermusch13126662015-02-12 18:52:07 -080088
Jan Tattermuscheca65472015-02-12 19:29:26 -080089% for target in buildable_targets:
Jan Tattermusch87d621b2015-04-20 10:00:38 -070090${target.name}.exe: build_grpc_test_util $(OUT_DIR)
Jan Tattermusch451a2272015-02-12 18:34:50 -080091 echo Building ${target.name}
Jan Tattermuscha2ad5582015-02-12 19:44:35 -080092 $(CC) $(CFLAGS) /Fo:$(OUT_DIR)\ \
Jan Tattermusch451a2272015-02-12 18:34:50 -080093%for source in target.src:
Jan Tattermusch8ff00a32015-04-20 18:43:06 -070094$(REPO_ROOT)\${to_windows_path(source)} \
Jan Tattermusch451a2272015-02-12 18:34:50 -080095%endfor
96
Jan Tattermuscha2ad5582015-02-12 19:44:35 -080097 $(LINK) $(LFLAGS) /OUT:"$(OUT_DIR)\${target.name}.exe" \
Jan Tattermusch451a2272015-02-12 18:34:50 -080098%for dep in target.deps:
99Debug\${dep}.lib \
100%endfor
Jan Tattermuscha2ad5582015-02-12 19:44:35 -0800101$(LIBS) \
Jan Tattermusch451a2272015-02-12 18:34:50 -0800102%for source in target.src:
103$(OUT_DIR)\${re.search('([^/]+)\.c$', source).group(1)}.obj \
104%endfor
105
Jan Tattermusch451a2272015-02-12 18:34:50 -0800106${target.name}: ${target.name}.exe
107 echo Running ${target.name}
108 $(OUT_DIR)\${target.name}.exe
109
Craig Tillerd7f33352015-02-20 15:18:45 -0800110% endfor