Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(516)

Side by Side Diff: native_client_sdk/src/build_tools/make_rules.py

Issue 10855162: add linux support for examples and libs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import os 6 import os
7 7
8 8
9 # 9 #
10 # Default macros for various platforms. 10 # Default macros for various platforms.
(...skipping 24 matching lines...) Expand all
35 PNACL_CC?=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-clang -c 35 PNACL_CC?=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-clang -c
36 PNACL_CXX?=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-clang++ -c -std=gnu++ 98 36 PNACL_CXX?=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-clang++ -c -std=gnu++ 98
37 PNACL_LINK?=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-clang++ 37 PNACL_LINK?=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-clang++
38 PNACL_LIB?=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-ar r 38 PNACL_LIB?=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-ar r
39 PNACL_DUMP?=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/objdump 39 PNACL_DUMP?=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/objdump
40 PNACL_CCFLAGS?=-MMD -pthread $(NACL_WARNINGS) -idirafter $(NACL_SDK_ROOT)/includ e 40 PNACL_CCFLAGS?=-MMD -pthread $(NACL_WARNINGS) -idirafter $(NACL_SDK_ROOT)/includ e
41 PNACL_LDFLAGS?=-pthread 41 PNACL_LDFLAGS?=-pthread
42 TRANSLATE:=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-translate 42 TRANSLATE:=$(TC_PATH)/$(OSNAME)_x86_pnacl/newlib/bin/pnacl-translate
43 """ 43 """
44 44
45 LINUX_DEFAULTS = """
46 LINUX_CC?=gcc -c
47 LINUX_CXX?=g++ -c -std=gnu++98
48 LINUX_LINK?=g++ -shared -Wl,-as-needed
49 LINUX_LIB?=ar r
50 LINUX_CCFLAGS=-I$(NACL_SDK_ROOT)/include -I$(NACL_SDK_ROOT)/include/linux
51 """
52
45 WIN_DEFAULTS = """ 53 WIN_DEFAULTS = """
46 WIN_CC?=cl.exe /nologo 54 WIN_CC?=cl.exe /nologo
47 WIN_CXX?=cl.exe /nologo 55 WIN_CXX?=cl.exe /nologo
48 WIN_LINK?=link.exe /nologo 56 WIN_LINK?=link.exe /nologo
49 WIN_LIB?=lib.exe /nologo 57 WIN_LIB?=lib.exe /nologo
50 WIN_CCFLAGS=/I$(NACL_SDK_ROOT)/include /I$(NACL_SDK_ROOT)/include/win -D WIN32 - D _WIN32 58 WIN_CCFLAGS=/I$(NACL_SDK_ROOT)/include /I$(NACL_SDK_ROOT)/include/win -D WIN32 - D _WIN32
51 """ 59 """
52 60
53 # 61 #
54 # Compile rules for various platforms. 62 # Compile rules for various platforms.
55 # 63 #
56 CC_RULE = '<tc>/<config>/<name>_<ARCH>.o : %.<ext> $(THIS_MAKE) | <tc>/<config>'
57 NACL_CC_RULES = { 64 NACL_CC_RULES = {
58 'Debug': '<TAB>$(<CC>) -o $@ $< -g -O0 <MACH> -DTCNAME=<tc> $(<TC>_CCFLAGS) $( <PROJ>_<EXT>FLAGS) <DEFLIST> <INCLIST>', 65 'Debug': '<TAB>$(<CC>) -o $@ $< -g -O0 <MACH> -DTCNAME=<tc> $(<TC>_CCFLAGS) $( <PROJ>_<EXT>FLAGS) <DEFLIST> <INCLIST>',
59 'Release': '<TAB>$(<CC>) -o $@ $< -O2 <MACH> -DTCNAME=<tc> $(<TC>_CCFLAGS) $(< PROJ>_<EXT>FLAGS) <DEFLIST> <INCLIST>', 66 'Release': '<TAB>$(<CC>) -o $@ $< -O2 <MACH> -DTCNAME=<tc> $(<TC>_CCFLAGS) $(< PROJ>_<EXT>FLAGS) <DEFLIST> <INCLIST>',
60 } 67 }
61 68
62 SO_CC_RULES = { 69 SO_CC_RULES = {
63 'Debug': '<TAB>$(<CC>) -o $@ $< -g -O0 <MACH> -fPIC -DTCNAME=<tc> $(<TC>_CCFLA GS) $(<PROJ>_<EXT>FLAGS) <DEFLIST> <INCLIST>', 70 'Debug': '<TAB>$(<CC>) -o $@ $< -g -O0 <MACH> -fPIC -DTCNAME=<tcname> $(<TC>_C CFLAGS) $(<PROJ>_<EXT>FLAGS) <DEFLIST> <INCLIST>',
64 'Release': '<TAB>$(<CC>) -o $@ $< -02 <MACH> -fPIC -DTCNAME=<tc> $(<TC>_CCFLAG S) $(<PROJ>_<EXT>FLAGS) <DEFLIST> <INCLIST>' 71 'Release': '<TAB>$(<CC>) -o $@ $< -O2 <MACH> -fPIC -DTCNAME=<tcname> $(<TC>_CC FLAGS) $(<PROJ>_<EXT>FLAGS) <DEFLIST> <INCLIST>'
65 } 72 }
66 73
67 WIN_CC_RULES = { 74 WIN_CC_RULES = {
68 'Debug': '<TAB>$(<CC>) /Od /Fo$@ /MTd /Zi /c $< -DTCNAME=host $(WIN_CCFLAGS) < DEFLIST> <INCLIST>', 75 'Debug': '<TAB>$(<CC>) /Od /Fo$@ /MTd /Zi /c $< -DTCNAME=<tcname> $(WIN_CCFLAG S) <DEFLIST> <INCLIST>',
69 'Release': '<TAB>$(<CC>) /O2 /Fo$@ /MT /c $< -DTCNAME=host $(WIN_CCFLAGS) <DEF LIST> <INCLIST>' 76 'Release': '<TAB>$(<CC>) /O2 /Fo$@ /MT /c $< -DTCNAME=<tcname> $(WIN_CCFLAGS) <DEFLIST> <INCLIST>'
70 } 77 }
71 78
72 # 79 #
73 # Link rules for various platforms. 80 # Link rules for various platforms.
74 # 81 #
75 NEXE_LINK_RULES = { 82 NEXE_LINK_RULES = {
76 'Debug': '<TAB>$(<LINK>) -o $@ $^ -g <MACH> $(<TC>_LDFLAGS) $(<PROJ>_LDFLAGS) -L$(NACL_SDK_ROOT)/lib/$(OSNAME)_<ARCH>_<tc>/<config> <LIBLIST>', 83 'Debug': '<TAB>$(<LINK>) -o $@ $^ -g <MACH> $(<TC>_LDFLAGS) $(<PROJ>_LDFLAGS) -L$(NACL_SDK_ROOT)/lib/$(OSNAME)_<ARCH>_<tc>/<config> <LIBLIST>',
77 'Release': '<TAB>$(<LINK>) -o $@ $^ <MACH> $(<TC>_LDFLAGS) $(<PROJ>_LDFLAGS) - L$(NACL_SDK_ROOT)/lib/$(OSNAME)_<ARCH>_<tc>/<config> <LIBLIST>' 84 'Release': '<TAB>$(<LINK>) -o $@ $^ <MACH> $(<TC>_LDFLAGS) $(<PROJ>_LDFLAGS) - L$(NACL_SDK_ROOT)/lib/$(OSNAME)_<ARCH>_<tc>/<config> <LIBLIST>'
78 } 85 }
79 86
80 SO_LINK_RULES = { 87 SO_LINK_RULES = {
81 'Debug': '<TAB>$(<LINK>) -o $@ $^ -g <MACH> -shared $(<PROJ>_LDFLAGS) -L$(NACL _SDK_ROOT)/lib/$(OSNAME)_<ARCH>_<tc>/<config> <LIBLIST>', 88 'Debug': '<TAB>$(<LINK>) -o $@ $^ -g <MACH> -shared $(<PROJ>_LDFLAGS) -L$(NACL _SDK_ROOT)/lib/$(OSNAME)_<ARCH>_<tcname>/<config> <LIBLIST>',
82 'Release': '<TAB>$(<LINK>) -o $@ $^ <MACH> -shared $(<PROJ>_LDFLAGS) -L$(NACL_ SDK_ROOT)/lib/$(OSNAME)_<ARCH>_<tc>/<config> <LIBLIST>', 89 'Release': '<TAB>$(<LINK>) -o $@ $^ <MACH> -shared $(<PROJ>_LDFLAGS) -L$(NACL_ SDK_ROOT)/lib/$(OSNAME)_<ARCH>_<tcname>/<config> <LIBLIST>',
83 } 90 }
84 91
85 PEXE_TRANSLATE_RULE = """ 92 PEXE_TRANSLATE_RULE = """
86 <tc>/<config>/<proj>_x86_32.nexe : <tc>/<config>/<proj>.pexe 93 <tc>/<config>/<proj>_x86_32.nexe : <tc>/<config>/<proj>.pexe
87 <TAB>$(TRANSLATE) -arch x86-32 $< -o $@ 94 <TAB>$(TRANSLATE) -arch x86-32 $< -o $@
88 95
89 <tc>/<config>/<proj>_x86_64.nexe : <tc>/<config>/<proj>.pexe 96 <tc>/<config>/<proj>_x86_64.nexe : <tc>/<config>/<proj>.pexe
90 <TAB>$(TRANSLATE) -arch x86-64 $< -o $@ 97 <TAB>$(TRANSLATE) -arch x86-64 $< -o $@
91 98
92 <tc>/<config>/<proj>_arm.nexe : <tc>/<config>/<proj>.pexe 99 <tc>/<config>/<proj>_arm.nexe : <tc>/<config>/<proj>.pexe
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 WIN_TOOL = { 159 WIN_TOOL = {
153 'DEFINE': '-D%s', 160 'DEFINE': '-D%s',
154 'INCLUDE': '/I%s', 161 'INCLUDE': '/I%s',
155 'LIBRARY': '%s.lib', 162 'LIBRARY': '%s.lib',
156 'MAIN': '<tc>/<config>/<proj>.dll', 163 'MAIN': '<tc>/<config>/<proj>.dll',
157 'NMFMAIN': '<tc>/<config>/<proj>.dll', 164 'NMFMAIN': '<tc>/<config>/<proj>.dll',
158 'SO': None, 165 'SO': None,
159 'LIB': '$(NACL_SDK_ROOT)/lib/win_<ARCH>_host/<config>/<proj>.lib', 166 'LIB': '$(NACL_SDK_ROOT)/lib/win_<ARCH>_host/<config>/<proj>.lib',
160 } 167 }
161 168
169 LINUX_TOOL = {
170 'DEFINE': '-D%s',
171 'INCLUDE': '-I%s',
172 'LIBRARY': '-l%s',
173 'MAIN': '<tc>/<config>/lib<proj>_<ARCH>.so',
174 'NMFMAIN': '<tc>/<config>/lib<proj>_<ARCH>.so',
175 'SO': '<tc>/<config>/lib<proj>_<ARCH>.so',
176 'LIB': '$(NACL_SDK_ROOT)/lib/linux_<ARCH>_host/<config>/lib<proj>.a',
177 }
178
162 NACL_TOOL = { 179 NACL_TOOL = {
163 'DEFINE': '-D%s', 180 'DEFINE': '-D%s',
164 'INCLUDE': '-I%s', 181 'INCLUDE': '-I%s',
165 'LIBRARY': '-l%s', 182 'LIBRARY': '-l%s',
166 'MAIN': '<tc>/<config>/<proj>_<ARCH>.nexe', 183 'MAIN': '<tc>/<config>/<proj>_<ARCH>.nexe',
167 'NMFMAIN': '<tc>/<config>/<proj>_<ARCH>.nexe', 184 'NMFMAIN': '<tc>/<config>/<proj>_<ARCH>.nexe',
168 'SO': '<tc>/<config>/<proj>_<ARCH>.so', 185 'SO': '<tc>/<config>/<proj>_<ARCH>.so',
169 'LIB': '$(NACL_SDK_ROOT)/lib/$(OSNAME)_<ARCH>_<tc>/<config>/lib<proj>.a', 186 'LIB': '$(NACL_SDK_ROOT)/lib/$(OSNAME)_<ARCH>_<tc>/<config>/lib<proj>.a',
170 } 187 }
171 188
172 PNACL_TOOL = { 189 PNACL_TOOL = {
173 'DEFINE': '-D%s', 190 'DEFINE': '-D%s',
174 'INCLUDE': '-I%s', 191 'INCLUDE': '-I%s',
175 'LIBRARY': '-l%s', 192 'LIBRARY': '-l%s',
176 'MAIN': '<tc>/<config>/<proj>.pexe', 193 'MAIN': '<tc>/<config>/<proj>.pexe',
177 'NMFMAIN': 194 'NMFMAIN':
178 '<tc>/<config>/<proj>_x86_32.nexe ' 195 '<tc>/<config>/<proj>_x86_32.nexe '
179 '<tc>/<config>/<proj>_x86_64.nexe ' 196 '<tc>/<config>/<proj>_x86_64.nexe '
180 '<tc>/<config>/<proj>_arm.nexe', 197 '<tc>/<config>/<proj>_arm.nexe',
181 'SO': None, 198 'SO': None,
182 'LIB': '$(NACL_SDK_ROOT)/lib/$(OSNAME)_<ARCH>_<tc>/<config>/lib<proj>.a', 199 'LIB': '$(NACL_SDK_ROOT)/lib/$(OSNAME)_<ARCH>_<tc>/<config>/lib<proj>.a',
183 } 200 }
184 201
185 202
186 # 203 #
187 # Various Architectures 204 # Various Architectures
188 # 205 #
206 LINUX_32 = {
207 '<arch>': '32',
208 '<ARCH>': 'x86_32',
209 '<MACH>': '-m32',
210 }
211 LINUX_64 = {
212 '<arch>': '64',
213 '<ARCH>': 'x86_64',
214 '<MACH>': '-m64',
215 }
189 NACL_X86_32 = { 216 NACL_X86_32 = {
190 '<arch>': '32', 217 '<arch>': '32',
191 '<ARCH>': 'x86_32', 218 '<ARCH>': 'x86_32',
192 '<MACH>': '-m32', 219 '<MACH>': '-m32',
193 } 220 }
194 NACL_X86_64 = { 221 NACL_X86_64 = {
195 '<arch>': '64', 222 '<arch>': '64',
196 '<ARCH>': 'x86_64', 223 '<ARCH>': 'x86_64',
197 '<MACH>': '-m64', 224 '<MACH>': '-m64',
198 } 225 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 'win' : { 272 'win' : {
246 'ARCHES': [WIN_32], 273 'ARCHES': [WIN_32],
247 'DEFS': WIN_DEFAULTS, 274 'DEFS': WIN_DEFAULTS,
248 'CC': WIN_CC_RULES, 275 'CC': WIN_CC_RULES,
249 'CXX': WIN_CC_RULES, 276 'CXX': WIN_CC_RULES,
250 'NMF' : NMF_EMPTY, 277 'NMF' : NMF_EMPTY,
251 'MAIN': WIN_LINK_RULES, 278 'MAIN': WIN_LINK_RULES,
252 'LIB': WIN_LIB_RULES, 279 'LIB': WIN_LIB_RULES,
253 'SO': None, 280 'SO': None,
254 'TOOL': WIN_TOOL 281 'TOOL': WIN_TOOL
282 },
283 'linux' : {
284 'ARCHES': [LINUX_32, LINUX_64],
285 'DEFS': LINUX_DEFAULTS,
286 'CC': SO_CC_RULES,
287 'CXX': SO_CC_RULES,
288 'NMF' : NMF_EMPTY,
289 'MAIN': SO_LINK_RULES,
290 'LIB': POSIX_LIB_RULES,
291 'SO': None,
292 'TOOL': LINUX_TOOL
255 } 293 }
256 } 294 }
257 295
258 class MakeRules(object): 296 class MakeRules(object):
259 """MakeRules generates Tool, Config, and Arch dependend makefile settings. 297 """MakeRules generates Tool, Config, and Arch dependend makefile settings.
260 298
261 The MakeRules object generates strings used in the makefile based on the 299 The MakeRules object generates strings used in the makefile based on the
262 current object settings such as toolchain, configuration, architecture... 300 current object settings such as toolchain, configuration, architecture...
263 It stores settings such as includes, defines, and lists, and converts them 301 It stores settings such as includes, defines, and lists, and converts them
264 to the appropriate format whenever the toolchain changes. 302 to the appropriate format whenever the toolchain changes.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 self.SetDefines(defs) 397 self.SetDefines(defs)
360 self.SetIncludes(incs) 398 self.SetIncludes(incs)
361 self.SetLibraries(libs) 399 self.SetLibraries(libs)
362 400
363 def SetSource(self, src): 401 def SetSource(self, src):
364 self.source = source 402 self.source = source
365 self.vars['<src>'] = src 403 self.vars['<src>'] = src
366 404
367 def SetToolchain(self, tc): 405 def SetToolchain(self, tc):
368 TC = tc.upper() 406 TC = tc.upper()
407 if tc in ('linux', 'win'):
408 tcname = 'host'
409 else:
410 tcname = tc
369 self.vars['<CC>'] = '%s_CC' % TC 411 self.vars['<CC>'] = '%s_CC' % TC
370 self.vars['<CXX>'] = '%s_CXX' % TC 412 self.vars['<CXX>'] = '%s_CXX' % TC
371 self.vars['<DUMP>'] = '%s_DUMP' % TC 413 self.vars['<DUMP>'] = '%s_DUMP' % TC
372 self.vars['<LIB>'] = '%s_LIB' % TC 414 self.vars['<LIB>'] = '%s_LIB' % TC
373 self.vars['<LINK>'] = '%s_LINK' % TC 415 self.vars['<LINK>'] = '%s_LINK' % TC
374 self.vars['<tc>'] = tc 416 self.vars['<tc>'] = tc
417 self.vars['<tcname>'] = tcname
375 self.vars['<TC>'] = TC 418 self.vars['<TC>'] = TC
376 self.SetDefines(self.defines) 419 self.SetDefines(self.defines)
377 self.SetIncludes(self.includes) 420 self.SetIncludes(self.includes)
378 self.SetLibraries(self.libraries) 421 self.SetLibraries(self.libraries)
379 422
380 def SetVars(self, **kwargs): 423 def SetVars(self, **kwargs):
381 # Add other passed in replacements 424 # Add other passed in replacements
382 for key in kwargs: 425 for key in kwargs:
383 self.vars['<%s>' % key] = kwargs[key] 426 self.vars['<%s>' % key] = kwargs[key]
384 self.var_set = kwargs 427 self.var_set = kwargs
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 } 479 }
437 for dll in dlls: 480 for dll in dlls:
438 replace['<proj>'] = dll 481 replace['<proj>'] = dll
439 nmf_targets.append(Replace(dll_target, replace)) 482 nmf_targets.append(Replace(dll_target, replace))
440 replace['<proj>'] = main 483 replace['<proj>'] = main
441 nmf_targets.append(Replace(target, replace)) 484 nmf_targets.append(Replace(target, replace))
442 485
443 replace['<NMF_TARGETS>'] = ' '.join(nmf_targets) 486 replace['<NMF_TARGETS>'] = ' '.join(nmf_targets)
444 rules = Replace(BUILD_RULES[tc]['NMF'], replace) 487 rules = Replace(BUILD_RULES[tc]['NMF'], replace)
445 return '\nALL_TARGETS+=%s/%s/%s.nmf' % (tc, cfg, main) + rules + '\n' 488 return '\nALL_TARGETS+=%s/%s/%s.nmf' % (tc, cfg, main) + rules + '\n'
OLDNEW
« no previous file with comments | « native_client_sdk/src/build_tools/generate_make.py ('k') | native_client_sdk/src/examples/file_histogram/example.dsc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698