Grpc.mak.template 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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.
  29. <%!
  30. import re
  31. %>\
  32. <%namespace file="packages.include" import="get_openssl,get_zlib"/>\
  33. <%def name="to_windows_path(path)">${path.replace('/','\\')}</%def>\
  34. <%
  35. disallowed_dependencies = set(['end2end_certs'])
  36. build_from_project_file = set(['gpr',
  37. 'grpc',
  38. 'grpc_unsecure',
  39. 'gpr_test_util',
  40. 'grpc_test_util',
  41. 'grpc_test_util_unsecure',
  42. ])
  43. buildable_targets = [ target for target in targets + libs
  44. if not disallowed_dependencies.intersection(target.get('deps', [])) and
  45. target.build in ['all', 'test', 'private', 'tool', 'benchmark'] and
  46. target.language in ['c', 'c++'] and
  47. all([src.endswith('.c') for src in target.src]) and
  48. 'windows' in target.get('platforms', ['windows']) ]
  49. c_test_targets = [ target for target in buildable_targets if target.build == 'test' and not target.language == 'c++' ]
  50. cxx_test_targets = [ target for target in buildable_targets if target.build == 'test' and target.language == 'c++' ]
  51. %>\
  52. # NMake file to build secondary gRPC targets on Windows.
  53. # Use grpc.sln to solution to build the gRPC libraries.
  54. OUT_DIR=test_bin
  55. CC=cl.exe /nologo
  56. LINK=link.exe /nologo
  57. LIBTOOL=lib.exe /nologo /nodefaultlib
  58. REPO_ROOT=..
  59. OPENSSL_INCLUDES = .\packages\${get_openssl()}\build\native\include
  60. ZLIB_INCLUDES = .\packages\${get_zlib()}\build\native\include
  61. INCLUDES=/I$(REPO_ROOT) /I$(REPO_ROOT)\include /I$(OPENSSL_INCLUDES) /I$(ZLIB_INCLUDES)
  62. DEFINES=/D WIN32 /D _LIB /D _USE_32BIT_TIME_T /D _UNICODE /D UNICODE /D _CRT_SECURE_NO_WARNINGS
  63. CFLAGS=/c $(INCLUDES) /Z7 /W3 /WX- /sdl $(DEFINES) /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /TC /analyze-
  64. LFLAGS=/DEBUG /INCREMENTAL /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86
  65. 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
  66. WINSOCK_LIBS=ws2_32.lib
  67. GENERAL_LIBS=advapi32.lib comdlg32.lib gdi32.lib kernel32.lib odbc32.lib odbccp32.lib ole32.lib oleaut32.lib shell32.lib user32.lib uuid.lib winspool.lib
  68. ZLIB_LIBS=.\packages\${get_zlib()}\build\native\lib\v120\Win32\Debug\static\cdecl\zlib.lib
  69. LIBS=$(OPENSSL_LIBS) $(ZLIB_LIBS) $(GENERAL_LIBS) $(WINSOCK_LIBS)
  70. all: buildtests
  71. $(OUT_DIR):
  72. mkdir $(OUT_DIR)
  73. build_libs: \
  74. % for target in buildable_targets:
  75. % if target.build == 'private' or target.build == 'all':
  76. % if target.name in build_from_project_file:
  77. build_${target.name} \
  78. % else:
  79. Debug\${target.name}.lib \
  80. % endif
  81. % endif
  82. % endfor
  83. buildtests: buildtests_c buildtests_cxx
  84. buildtests_c: \
  85. % for target in c_test_targets:
  86. ${target.name}.exe \
  87. % endfor
  88. echo All tests built.
  89. buildtests_cxx: \
  90. % for target in cxx_test_targets:
  91. ${target.name}.exe \
  92. % endfor
  93. echo All tests built.
  94. % for target in buildable_targets:
  95. %if target.name in build_from_project_file:
  96. build_${target.name}:
  97. msbuild grpc.sln /t:${target.name} /p:Configuration=Debug /p:Linkage-grpc_dependencies_zlib=static
  98. %else:
  99. %if target.build == 'private':
  100. Debug\${target.name}.lib: \
  101. %else:
  102. ${target.name}.exe: build_libs \
  103. %endif
  104. $(OUT_DIR)
  105. echo Building ${target.name}
  106. $(CC) $(CFLAGS) /Fo:$(OUT_DIR)\ \
  107. %for source in target.src:
  108. $(REPO_ROOT)\${to_windows_path(source)} \
  109. %endfor
  110. %if not target.src:
  111. $(REPO_ROOT)\${to_windows_path('vsprojects/dummy.c')} \
  112. %endif
  113. %if target.build == 'private':
  114. $(LIBTOOL) /OUT:"Debug\${target.name}.lib" \
  115. %else:
  116. $(LINK) $(LFLAGS) /OUT:"$(OUT_DIR)\${target.name}.exe" \
  117. %for dep in target.get('deps', []):
  118. Debug\${dep}.lib \
  119. %endfor
  120. $(LIBS) \
  121. %endif
  122. %for source in target.src:
  123. $(OUT_DIR)\${re.search('([^/]+)\.c$', source).group(1)}.obj \
  124. %endfor
  125. %if target.build != 'private':
  126. ${target.name}: ${target.name}.exe
  127. echo Running ${target.name}
  128. $(OUT_DIR)\${target.name}.exe
  129. %endif
  130. %endif
  131. % endfor