Craig Tiller | d7f3335 | 2015-02-20 15:18:45 -0800 | [diff] [blame] | 1 | # 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 Tattermusch | 451a227 | 2015-02-12 18:34:50 -0800 | [diff] [blame] | 29 | <%! |
| 30 | import re |
| 31 | %>\ |
Jan Tattermusch | 789e7ae | 2015-04-16 21:03:30 -0700 | [diff] [blame] | 32 | <%namespace file="packages.include" import="get_openssl,get_zlib"/>\ |
Jan Tattermusch | 451a227 | 2015-02-12 18:34:50 -0800 | [diff] [blame] | 33 | <%def name="to_windows_path(path)">${path.replace('/','\\')}</%def>\ |
| 34 | <% |
| 35 | allowed_dependencies = set(['gpr', 'grpc', 'gpr_test_util', 'grpc_test_util']) |
Craig Tiller | fef0c2d | 2015-04-08 15:58:59 -0700 | [diff] [blame] | 36 | buildable_targets = [ target for target in targets |
| 37 | if set(target.deps).issubset(allowed_dependencies) and |
Jan Tattermusch | 789e7ae | 2015-04-16 21:03:30 -0700 | [diff] [blame] | 38 | all([src.endswith('.c') for src in target.src]) and |
| 39 | 'windows' in target.platforms ] |
Craig Tiller | f5a7c8b | 2015-04-08 09:48:54 -0700 | [diff] [blame] | 40 | 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 Tattermusch | 451a227 | 2015-02-12 18:34:50 -0800 | [diff] [blame] | 42 | %>\ |
Jan Tattermusch | d5b076a | 2015-02-12 19:16:42 -0800 | [diff] [blame] | 43 | # NMake file to build secondary gRPC targets on Windows. |
| 44 | # Use grpc.sln to solution to build the gRPC libraries. |
Jan Tattermusch | 451a227 | 2015-02-12 18:34:50 -0800 | [diff] [blame] | 45 | |
| 46 | OUT_DIR=test_bin |
| 47 | |
Jan Tattermusch | a2ad558 | 2015-02-12 19:44:35 -0800 | [diff] [blame] | 48 | CC=cl.exe |
| 49 | LINK=link.exe |
Jan Tattermusch | 64d10c1 | 2015-02-13 09:39:54 -0800 | [diff] [blame] | 50 | |
Jan Tattermusch | 8ff00a3 | 2015-04-20 18:43:06 -0700 | [diff] [blame] | 51 | REPO_ROOT=.. |
Jan Tattermusch | 789e7ae | 2015-04-16 21:03:30 -0700 | [diff] [blame] | 52 | OPENSSL_INCLUDES = .\packages\${get_openssl()}\build\native\include\v120\Win32\Debug\static |
| 53 | ZLIB_INCLUDES = .\packages\${get_zlib()}\build\native\include |
Jan Tattermusch | 8ff00a3 | 2015-04-20 18:43:06 -0700 | [diff] [blame] | 54 | INCLUDES=/I$(REPO_ROOT) /I$(REPO_ROOT)\include /I$(OPENSSL_INCLUDES) /I$(ZLIB_INCLUDES) |
Jan Tattermusch | 64d10c1 | 2015-02-13 09:39:54 -0800 | [diff] [blame] | 55 | DEFINES=/D WIN32 /D _LIB /D _USE_32BIT_TIME_T /D _UNICODE /D UNICODE /D _CRT_SECURE_NO_WARNINGS |
| 56 | CFLAGS=/c $(INCLUDES) /nologo /Z7 /W3 /WX- /sdl $(DEFINES) /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /TC /analyze- |
Jan Tattermusch | a2ad558 | 2015-02-12 19:44:35 -0800 | [diff] [blame] | 57 | LFLAGS=/DEBUG /INCREMENTAL /NOLOGO /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 |
Jan Tattermusch | 64d10c1 | 2015-02-13 09:39:54 -0800 | [diff] [blame] | 58 | |
Jan Tattermusch | 789e7ae | 2015-04-16 21:03:30 -0700 | [diff] [blame] | 59 | OPENSSL_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 Tattermusch | 64d10c1 | 2015-02-13 09:39:54 -0800 | [diff] [blame] | 60 | WINSOCK_LIBS=ws2_32.lib |
Jan Tattermusch | 789e7ae | 2015-04-16 21:03:30 -0700 | [diff] [blame] | 61 | ZLIB_LIBS=.\packages\${get_zlib()}\build\native\lib\v120\Win32\Debug\static\cdecl\zlib.lib |
Jan Tattermusch | 64d10c1 | 2015-02-13 09:39:54 -0800 | [diff] [blame] | 62 | LIBS=$(OPENSSL_LIBS) $(WINSOCK_LIBS) $(ZLIB_LIBS) |
Jan Tattermusch | a2ad558 | 2015-02-12 19:44:35 -0800 | [diff] [blame] | 63 | |
Jan Tattermusch | 87d621b | 2015-04-20 10:00:38 -0700 | [diff] [blame^] | 64 | build_gpr_test_util: |
| 65 | msbuild grpc.sln /t:gpr_test_util /p:Configuration=Debug |
Jan Tattermusch | 451a227 | 2015-02-12 18:34:50 -0800 | [diff] [blame] | 66 | |
Jan Tattermusch | 87d621b | 2015-04-20 10:00:38 -0700 | [diff] [blame^] | 67 | build_grpc_test_util: |
| 68 | msbuild grpc.sln /t:grpc_test_util /p:Configuration=Debug |
Jan Tattermusch | 451a227 | 2015-02-12 18:34:50 -0800 | [diff] [blame] | 69 | |
| 70 | $(OUT_DIR): |
| 71 | mkdir $(OUT_DIR) |
| 72 | |
Craig Tiller | f5a7c8b | 2015-04-08 09:48:54 -0700 | [diff] [blame] | 73 | buildtests: buildtests_c buildtests_cxx |
| 74 | |
| 75 | buildtests_c: \ |
| 76 | % for target in c_test_targets: |
Jan Tattermusch | 451a227 | 2015-02-12 18:34:50 -0800 | [diff] [blame] | 77 | ${target.name}.exe \ |
| 78 | % endfor |
| 79 | |
| 80 | echo All tests built. |
| 81 | |
Craig Tiller | f5a7c8b | 2015-04-08 09:48:54 -0700 | [diff] [blame] | 82 | buildtests_cxx: \ |
| 83 | % for target in cxx_test_targets: |
| 84 | ${target.name}.exe \ |
Jan Tattermusch | 451a227 | 2015-02-12 18:34:50 -0800 | [diff] [blame] | 85 | % endfor |
| 86 | |
Craig Tiller | f5a7c8b | 2015-04-08 09:48:54 -0700 | [diff] [blame] | 87 | echo All tests built. |
Jan Tattermusch | 1312666 | 2015-02-12 18:52:07 -0800 | [diff] [blame] | 88 | |
Jan Tattermusch | eca6547 | 2015-02-12 19:29:26 -0800 | [diff] [blame] | 89 | % for target in buildable_targets: |
Jan Tattermusch | 87d621b | 2015-04-20 10:00:38 -0700 | [diff] [blame^] | 90 | ${target.name}.exe: build_grpc_test_util $(OUT_DIR) |
Jan Tattermusch | 451a227 | 2015-02-12 18:34:50 -0800 | [diff] [blame] | 91 | echo Building ${target.name} |
Jan Tattermusch | a2ad558 | 2015-02-12 19:44:35 -0800 | [diff] [blame] | 92 | $(CC) $(CFLAGS) /Fo:$(OUT_DIR)\ \ |
Jan Tattermusch | 451a227 | 2015-02-12 18:34:50 -0800 | [diff] [blame] | 93 | %for source in target.src: |
Jan Tattermusch | 8ff00a3 | 2015-04-20 18:43:06 -0700 | [diff] [blame] | 94 | $(REPO_ROOT)\${to_windows_path(source)} \ |
Jan Tattermusch | 451a227 | 2015-02-12 18:34:50 -0800 | [diff] [blame] | 95 | %endfor |
| 96 | |
Jan Tattermusch | a2ad558 | 2015-02-12 19:44:35 -0800 | [diff] [blame] | 97 | $(LINK) $(LFLAGS) /OUT:"$(OUT_DIR)\${target.name}.exe" \ |
Jan Tattermusch | 451a227 | 2015-02-12 18:34:50 -0800 | [diff] [blame] | 98 | %for dep in target.deps: |
| 99 | Debug\${dep}.lib \ |
| 100 | %endfor |
Jan Tattermusch | a2ad558 | 2015-02-12 19:44:35 -0800 | [diff] [blame] | 101 | $(LIBS) \ |
Jan Tattermusch | 451a227 | 2015-02-12 18:34:50 -0800 | [diff] [blame] | 102 | %for source in target.src: |
| 103 | $(OUT_DIR)\${re.search('([^/]+)\.c$', source).group(1)}.obj \ |
| 104 | %endfor |
| 105 | |
Jan Tattermusch | 451a227 | 2015-02-12 18:34:50 -0800 | [diff] [blame] | 106 | ${target.name}: ${target.name}.exe |
| 107 | echo Running ${target.name} |
| 108 | $(OUT_DIR)\${target.name}.exe |
| 109 | |
Craig Tiller | d7f3335 | 2015-02-20 15:18:45 -0800 | [diff] [blame] | 110 | % endfor |