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

Side by Side Diff: native_client_sdk/src/doc/devguide/tutorial/tutorial-part2.rst

Issue 241753002: NaClSDK: Fix LINK+STRIP make rules to only apply to Release or PNaCl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update comment Created 6 years, 8 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 .. _tutorial2: 1 .. _tutorial2:
2 2
3 ###################################### 3 ######################################
4 C++ Tutorial: Getting Started (Part 2) 4 C++ Tutorial: Getting Started (Part 2)
5 ###################################### 5 ######################################
6 6
7 .. contents:: 7 .. contents::
8 :local: 8 :local:
9 :backlinks: none 9 :backlinks: none
10 :depth: 2 10 :depth: 2
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 TARGET = part2 62 TARGET = part2
63 LIBS = ppapi_cpp ppapi 63 LIBS = ppapi_cpp ppapi
64 64
65 CFLAGS = -Wall 65 CFLAGS = -Wall
66 SOURCES = hello_tutorial.cc 66 SOURCES = hello_tutorial.cc
67 67
68 # Build rules generated by macros from common.mk: 68 # Build rules generated by macros from common.mk:
69 69
70 $(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS)))) 70 $(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS))))
71 71
72 ifeq ($(CONFIG),Release) 72 # The PNaCl workflow uses both an unstripped and finalized/stripped binary.
73 # On NaCl, only produce a stripped binary for Release configs (not Debug).
74 ifneq (,$(or $(findstring pnacl,$(TOOLCHAIN)),$(findstring Release,$(CONFIG) )))
73 $(eval $(call LINK_RULE,$(TARGET)_unstripped,$(SOURCES),$(LIBS),$(DEPS))) 75 $(eval $(call LINK_RULE,$(TARGET)_unstripped,$(SOURCES),$(LIBS),$(DEPS)))
74 $(eval $(call STRIP_RULE,$(TARGET),$(TARGET)_unstripped)) 76 $(eval $(call STRIP_RULE,$(TARGET),$(TARGET)_unstripped))
75 else 77 else
76 $(eval $(call LINK_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS))) 78 $(eval $(call LINK_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS)))
77 endif 79 endif
78 80
79 $(eval $(call NMF_RULE,$(TARGET),)) 81 $(eval $(call NMF_RULE,$(TARGET),))
80 82
81 Choosing valid toolchains, and including common.mk 83 Choosing valid toolchains, and including common.mk
82 -------------------------------------------------- 84 --------------------------------------------------
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 Build macros 177 Build macros
176 ------------ 178 ------------
177 179
178 For many projects, the following build macros do not need to be changed; they 180 For many projects, the following build macros do not need to be changed; they
179 will use the variables we've defined above. 181 will use the variables we've defined above.
180 182
181 .. naclcode:: 183 .. naclcode::
182 184
183 $(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS)))) 185 $(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS))))
184 186
185 ifeq ($(CONFIG),Release) 187 ifneq (,$(or $(findstring pnacl,$(TOOLCHAIN)),$(findstring Release,$(CONFIG) )))
186 $(eval $(call LINK_RULE,$(TARGET)_unstripped,$(SOURCES),$(LIBS),$(DEPS))) 188 $(eval $(call LINK_RULE,$(TARGET)_unstripped,$(SOURCES),$(LIBS),$(DEPS)))
187 $(eval $(call STRIP_RULE,$(TARGET),$(TARGET)_unstripped)) 189 $(eval $(call STRIP_RULE,$(TARGET),$(TARGET)_unstripped))
188 else 190 else
189 $(eval $(call LINK_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS))) 191 $(eval $(call LINK_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS)))
190 endif 192 endif
191 193
192 $(eval $(call NMF_RULE,$(TARGET),)) 194 $(eval $(call NMF_RULE,$(TARGET),))
193 195
194 The first line defines rules to compile each source in ``SOURCES``, using the 196 The first line defines rules to compile each source in ``SOURCES``, using the
195 flags in ``CFLAGS``: 197 flags in ``CFLAGS``:
196 198
197 .. naclcode:: 199 .. naclcode::
198 200
199 $(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS)))) 201 $(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS))))
200 202
201 The next six lines define rules to link the object files into one or more 203 The next six lines define rules to link the object files into one or more
202 executables. When ``TOOLCHAIN`` is ``pnacl``, there is only one executable 204 executables. When ``TOOLCHAIN`` is ``pnacl``, there is only one executable
203 generated: in the example above, ``part2.pexe``. When using a NaCl toolchain, 205 generated: in the example above, ``part2.pexe``. When using a NaCl toolchain,
204 there will be three executables generated, one for each architecture: in the 206 there will be three executables generated, one for each architecture: in the
205 example above, ``part2_arm.nexe``, ``part2_x86_32.nexe`` and 207 example above, ``part2_arm.nexe``, ``part2_x86_32.nexe`` and
206 ``part2_x86_64.nexe``. 208 ``part2_x86_64.nexe``.
207 209
208 When ``CONFIG`` is ``Release``, each executable is also stripped to remove 210 When ``CONFIG`` is ``Release``, each executable is also stripped to remove
209 debug information and reduce the file size: 211 debug information and reduce the file size. Otherwise, when the ``TOOLCHAIN``
212 is ``pnacl``, the workflow involves creating an unstripped binary for debugging
213 and then finalizing it and stripping it for publishing.
210 214
211 .. naclcode:: 215 .. naclcode::
212 216
213 ifeq ($(CONFIG),Release) 217 ifneq (,$(or $(findstring pnacl,$(TOOLCHAIN)),$(findstring Release,$(CONFIG) )))
214 $(eval $(call LINK_RULE,$(TARGET)_unstripped,$(SOURCES),$(LIBS),$(DEPS))) 218 $(eval $(call LINK_RULE,$(TARGET)_unstripped,$(SOURCES),$(LIBS),$(DEPS)))
215 $(eval $(call STRIP_RULE,$(TARGET),$(TARGET)_unstripped)) 219 $(eval $(call STRIP_RULE,$(TARGET),$(TARGET)_unstripped))
216 else 220 else
217 $(eval $(call LINK_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS))) 221 $(eval $(call LINK_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS)))
218 endif 222 endif
219 223
220 Finally, the NMF rule generates a NaCl manifest file (``.nmf``) that references 224 Finally, the NMF rule generates a NaCl manifest file (``.nmf``) that references
221 each executable generated in the previous step: 225 each executable generated in the previous step:
222 226
223 .. naclcode:: 227 .. naclcode::
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 // postMessage sends a message to it. 491 // postMessage sends a message to it.
488 common.naclModule.postMessage('hello'); 492 common.naclModule.postMessage('hello');
489 } 493 }
490 494
491 // This function is called by common.js when a message is received from the 495 // This function is called by common.js when a message is received from the
492 // NaCl module. 496 // NaCl module.
493 function handleMessage(message) { 497 function handleMessage(message) {
494 var logEl = document.getElementById('log'); 498 var logEl = document.getElementById('log');
495 logEl.textContent += message.data; 499 logEl.textContent += message.data;
496 } 500 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698