55 $(ECHO) "Getting symbols from nm"; \ |
55 $(ECHO) "Getting symbols from nm"; \ |
56 $(NM) -m $$($1_TARGET) | $(GREP) "__TEXT" | \ |
56 $(NM) -m $$($1_TARGET) | $(GREP) "__TEXT" | \ |
57 $(EGREP) -v "non-external|private extern|__TEXT,__eh_frame" | \ |
57 $(EGREP) -v "non-external|private extern|__TEXT,__eh_frame" | \ |
58 $(SED) -e 's/.* //' > $$(@D)/$$(basename $$(@F)).symbols; \ |
58 $(SED) -e 's/.* //' > $$(@D)/$$(basename $$(@F)).symbols; \ |
59 fi |
59 fi |
|
60 endef |
|
61 |
|
62 ################################################################################ |
|
63 # Creates a recipe that creates a compile_commands.json fragment. Remove any |
|
64 # occurences of FIXPATH programs from the command to show the actual invocation. |
|
65 # |
|
66 # Param 1: Name of file to create |
|
67 # Param 2: Working directory |
|
68 # Param 3: Source file |
|
69 # Param 4: Compile command |
|
70 # Param 5: Object name |
|
71 ################################################################################ |
|
72 define WriteCompileCommandsFragment |
|
73 $(call LogInfo, Creating compile commands fragment for $(notdir $3)) |
|
74 $(call MakeDir, $(dir $1)) |
|
75 $(call WriteFile,{ \ |
|
76 "directory": "$(strip $2)"$(COMMA) \ |
|
77 "file": "$(strip $3)"$(COMMA) \ |
|
78 "command": "$(strip $(subst $(DQUOTE),\$(DQUOTE),$(subst \,\\,\ |
|
79 $(subst $(FIXPATH),,$4))))"$(COMMA) \ |
|
80 "output": "$(strip $5)" \ |
|
81 }$(COMMA), \ |
|
82 $1) |
60 endef |
83 endef |
61 |
84 |
62 ################################################################################ |
85 ################################################################################ |
63 # Define a native toolchain configuration that can be used by |
86 # Define a native toolchain configuration that can be used by |
64 # SetupNativeCompilation calls |
87 # SetupNativeCompilation calls |
201 |
224 |
202 # The target file to be generated. |
225 # The target file to be generated. |
203 $1_OBJ := $$($$($1_BASE)_OBJECT_DIR)/$$(call replace_with_obj_extension, \ |
226 $1_OBJ := $$($$($1_BASE)_OBJECT_DIR)/$$(call replace_with_obj_extension, \ |
204 $$($1_FILENAME)) |
227 $$($1_FILENAME)) |
205 |
228 |
|
229 # Generate the corresponding compile_commands.json fragment. |
|
230 $1_OBJ_JSON = $$(MAKESUPPORT_OUTPUTDIR)/compile-commands/$$(subst /,_,$$(subst \ |
|
231 $$(OUTPUTDIR)/,,$$($1_OBJ))).json |
|
232 $$($1_BASE)_ALL_OBJS_JSON += $$($1_OBJ_JSON) |
|
233 |
206 # Only continue if this object file hasn't been processed already. This lets |
234 # Only continue if this object file hasn't been processed already. This lets |
207 # the first found source file override any other with the same name. |
235 # the first found source file override any other with the same name. |
208 ifeq ($$(findstring $$($1_OBJ), $$($$($1_BASE)_OBJS_SO_FAR)), ) |
236 ifeq ($$(findstring $$($1_OBJ), $$($$($1_BASE)_OBJS_SO_FAR)), ) |
209 $$($1_BASE)_OBJS_SO_FAR += $$($1_OBJ) |
237 $$($1_BASE)_OBJS_SO_FAR += $$($1_OBJ) |
210 # This is the definite source file to use for $1_FILENAME. |
238 # This is the definite source file to use for $1_FILENAME. |
295 ifneq ($$(strip $$($1_CFLAGS) $$($1_CXXFLAGS) $$($1_OPTIMIZATION)), ) |
323 ifneq ($$(strip $$($1_CFLAGS) $$($1_CXXFLAGS) $$($1_OPTIMIZATION)), ) |
296 $1_VARDEPS := $$($1_CFLAGS) $$($1_CXXFLAGS) $$($1_OPTIMIZATION) |
324 $1_VARDEPS := $$($1_CFLAGS) $$($1_CXXFLAGS) $$($1_OPTIMIZATION) |
297 $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, $$($1_OBJ).vardeps) |
325 $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, $$($1_OBJ).vardeps) |
298 endif |
326 endif |
299 |
327 |
300 $$($1_OBJ): $$($1_SRC_FILE) $$($$($1_BASE)_COMPILE_VARDEPS_FILE) \ |
328 $1_OBJ_DEPS := $$($1_SRC_FILE) $$($$($1_BASE)_COMPILE_VARDEPS_FILE) \ |
301 $$($$($1_BASE)_EXTRA_DEPS) $$($1_VARDEPS_FILE) | $$($$($1_BASE)_BUILD_INFO) |
329 $$($$($1_BASE)_EXTRA_DEPS) $$($1_VARDEPS_FILE) |
|
330 $1_COMPILE_OPTIONS := $$($1_FLAGS) $(CC_OUT_OPTION)$$($1_OBJ) $$($1_SRC_FILE) |
|
331 |
|
332 $$($1_OBJ_JSON): $$($1_OBJ_DEPS) |
|
333 $$(call WriteCompileCommandsFragment, $$@, $$(PWD), $$($1_SRC_FILE), \ |
|
334 $$($1_COMPILER) $$($1_COMPILE_OPTIONS), $$($1_OBJ)) |
|
335 |
|
336 $$($1_OBJ): $$($1_OBJ_DEPS) | $$($$($1_BASE)_BUILD_INFO) |
302 $$(call LogInfo, Compiling $$($1_FILENAME) (for $$($$($1_BASE)_BASENAME))) |
337 $$(call LogInfo, Compiling $$($1_FILENAME) (for $$($$($1_BASE)_BASENAME))) |
303 $$(call MakeDir, $$(@D)) |
338 $$(call MakeDir, $$(@D)) |
304 ifneq ($(TOOLCHAIN_TYPE), microsoft) |
339 ifneq ($(TOOLCHAIN_TYPE), microsoft) |
305 ifeq ($(TOOLCHAIN_TYPE)$$(filter %.s, $$($1_FILENAME)), solstudio) |
340 ifeq ($(TOOLCHAIN_TYPE)$$(filter %.s, $$($1_FILENAME)), solstudio) |
306 # The Solaris studio compiler doesn't output the full path to the |
341 # The Solaris studio compiler doesn't output the full path to the |
307 # object file in the generated deps files. Fixing it with sed. If |
342 # object file in the generated deps files. Fixing it with sed. If |
308 # compiling assembly, don't try this. |
343 # compiling assembly, don't try this. |
309 $$(call ExecuteWithLog, $$@, \ |
344 $$(call ExecuteWithLog, $$@, \ |
310 $$($1_COMPILER) $$($1_FLAGS) $$($1_DEP_FLAG) $$($1_DEP).tmp \ |
345 $$($1_COMPILER) $$($1_DEP_FLAG) $$($1_DEP).tmp $$($1_COMPILE_OPTIONS)) |
311 $(CC_OUT_OPTION)$$($1_OBJ) $$($1_SRC_FILE)) |
|
312 $(SED) 's|^$$(@F):|$$@:|' $$($1_DEP).tmp > $$($1_DEP) |
346 $(SED) 's|^$$(@F):|$$@:|' $$($1_DEP).tmp > $$($1_DEP) |
313 else |
347 else |
314 $$(call ExecuteWithLog, $$@, \ |
348 $$(call ExecuteWithLog, $$@, \ |
315 $$($1_COMPILER) $$($1_FLAGS) $$($1_DEP_FLAG) $$($1_DEP) \ |
349 $$($1_COMPILER) $$($1_DEP_FLAG) $$($1_DEP) $$($1_COMPILE_OPTIONS)) |
316 $(CC_OUT_OPTION)$$($1_OBJ) $$($1_SRC_FILE)) |
|
317 endif |
350 endif |
318 # Create a dependency target file from the dependency file. |
351 # Create a dependency target file from the dependency file. |
319 # Solution suggested by http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/ |
352 # Solution suggested by http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/ |
320 ifneq ($$($1_DEP), ) |
353 ifneq ($$($1_DEP), ) |
321 $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_DEP) > $$($1_DEP_TARGETS) |
354 $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_DEP) > $$($1_DEP_TARGETS) |
327 # |
360 # |
328 # Keep as much as possible on one execution line for best performance |
361 # Keep as much as possible on one execution line for best performance |
329 # on Windows. No need to save exit code from compilation since |
362 # on Windows. No need to save exit code from compilation since |
330 # pipefail is always active on Windows. |
363 # pipefail is always active on Windows. |
331 $$(call ExecuteWithLog, $$@, \ |
364 $$(call ExecuteWithLog, $$@, \ |
332 $$($1_COMPILER) $$($1_FLAGS) -showIncludes \ |
365 $$($1_COMPILER) -showIncludes $$($1_COMPILE_OPTIONS)) \ |
333 $(CC_OUT_OPTION)$$($1_OBJ) $$($1_SRC_FILE)) \ |
|
334 | $(TR) -d '\r' | $(GREP) -v -e "^Note: including file:" \ |
366 | $(TR) -d '\r' | $(GREP) -v -e "^Note: including file:" \ |
335 -e "^$$($1_FILENAME)$$$$" || test "$$$$?" = "1" ; \ |
367 -e "^$$($1_FILENAME)$$$$" || test "$$$$?" = "1" ; \ |
336 $(ECHO) $$@: \\ > $$($1_DEP) ; \ |
368 $(ECHO) $$@: \\ > $$($1_DEP) ; \ |
337 $(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_OBJ).log \ |
369 $(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_OBJ).log \ |
338 | $(SORT) -u >> $$($1_DEP) ; \ |
370 | $(SORT) -u >> $$($1_DEP) ; \ |
692 $1_PCH_DEP_TARGETS := $$($1_PCH_FILE).d.targets |
724 $1_PCH_DEP_TARGETS := $$($1_PCH_FILE).d.targets |
693 |
725 |
694 -include $$($1_PCH_DEP) |
726 -include $$($1_PCH_DEP) |
695 -include $$($1_PCH_DEP_TARGETS) |
727 -include $$($1_PCH_DEP_TARGETS) |
696 |
728 |
|
729 $1_PCH_COMMAND := $$($1_CC) $$($1_CFLAGS) $$($1_EXTRA_CFLAGS) $$($1_SYSROOT_CFLAGS) \ |
|
730 $$($1_OPT_CFLAGS) -x c++-header -c $(C_FLAG_DEPS) $$($1_PCH_DEP) |
|
731 |
697 $$($1_PCH_FILE): $$($1_PRECOMPILED_HEADER) $$($1_COMPILE_VARDEPS_FILE) |
732 $$($1_PCH_FILE): $$($1_PRECOMPILED_HEADER) $$($1_COMPILE_VARDEPS_FILE) |
698 $$(call LogInfo, Generating precompiled header) |
733 $$(call LogInfo, Generating precompiled header) |
699 $$(call MakeDir, $$(@D)) |
734 $$(call MakeDir, $$(@D)) |
700 $$(call ExecuteWithLog, $$@, \ |
735 $$(call ExecuteWithLog, $$@, $$($1_PCH_COMMAND) $$< -o $$@) |
701 $$($1_CC) $$($1_CFLAGS) $$($1_EXTRA_CFLAGS) $$($1_SYSROOT_CFLAGS) \ |
|
702 $$($1_OPT_CFLAGS) \ |
|
703 -x c++-header -c $(C_FLAG_DEPS) $$($1_PCH_DEP) $$< -o $$@) |
|
704 $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_PCH_DEP) > $$($1_PCH_DEP_TARGETS) |
736 $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_PCH_DEP) > $$($1_PCH_DEP_TARGETS) |
705 |
737 |
706 $$($1_ALL_OBJS): $$($1_PCH_FILE) |
738 $$($1_ALL_OBJS): $$($1_PCH_FILE) |
707 |
739 |
|
740 # Generate the corresponding compile_commands.json fragment. |
|
741 $1_PCH_FILE_JSON := $$(MAKESUPPORT_OUTPUTDIR)/compile-commands/$$(subst /,_,$$(subst \ |
|
742 $$(OUTPUTDIR)/,,$$($1_PCH_FILE))).json |
|
743 $1_ALL_OBJS_JSON += $$($1_PCH_FILE_JSON) |
|
744 |
|
745 $$($1_PCH_FILE_JSON): $$($1_PRECOMPILED_HEADER) $$($1_COMPILE_VARDEPS_FILE) |
|
746 $$(call WriteCompileCommandsFragment, $$@, $$(PWD), $$<, \ |
|
747 $$($1_PCH_COMMAND) $$< -o $$($1_PCH_FILE), $$($1_PCH_FILE)) |
708 endif |
748 endif |
709 endif |
749 endif |
710 endif |
750 endif |
711 |
751 |
712 # Now call SetupCompileNativeFile for each source file we are going to compile. |
752 # Now call SetupCompileNativeFile for each source file we are going to compile. |