make/common/NativeCompilation.gmk
changeset 29173 ad065cf432e9
parent 28909 58d622f06630
child 29304 81a723f8d33c
equal deleted inserted replaced
29172:bc8ec27d5e6f 29173:ad065cf432e9
    80   # param 3 = the bin dir that stores all .o (.obj) and .d files.
    80   # param 3 = the bin dir that stores all .o (.obj) and .d files.
    81   # param 4 = the c flags to the compiler
    81   # param 4 = the c flags to the compiler
    82   # param 5 = the c compiler
    82   # param 5 = the c compiler
    83   # param 6 = the c++ flags to the compiler
    83   # param 6 = the c++ flags to the compiler
    84   # param 7 = the c++ compiler
    84   # param 7 = the c++ compiler
    85   # param 8 = the objc compiler
    85   # param 8 = the flags to the assembler
    86   # param 9 = the flags to the assembler
       
    87 
    86 
    88   ifneq (,$$(filter %.c,$2))
    87   ifneq (,$$(filter %.c,$2))
    89     # Compile as a C file
    88     # Compile as a C file
    90     $1_$2_FLAGS=$(CFLAGS_CCACHE) $4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$(<F)"' -c
    89     $1_$2_FLAGS=$(CFLAGS_CCACHE) $4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$(<F)"' -c
    91     $1_$2_COMP=$5
    90     $1_$2_COMP=$5
    92     $1_$2_DEP_FLAG:=$(C_FLAG_DEPS)
    91     $1_$2_DEP_FLAG:=$(C_FLAG_DEPS)
    93   else ifneq (,$$(filter %.m,$2))
    92   else ifneq (,$$(filter %.m,$2))
    94     # Compile as a objective-c file
    93     # Compile as an Objective-C file
    95     $1_$2_FLAGS=-x objective-c $(CFLAGS_CCACHE) $4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$(<F)"' -c
    94     $1_$2_FLAGS=-x objective-c $(CFLAGS_CCACHE) $4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$(<F)"' -c
    96     $1_$2_COMP=$8
    95     $1_$2_COMP=$5
    97     $1_$2_DEP_FLAG:=$(C_FLAG_DEPS)
    96     $1_$2_DEP_FLAG:=$(C_FLAG_DEPS)
    98   else ifneq (,$$(filter %.s,$2))
    97   else ifneq (,$$(filter %.s,$2))
    99     # Compile as assembler file
    98     # Compile as assembler file
   100     $1_$2_FLAGS=$9 -DTHIS_FILE='"$$(<F)"'
    99     $1_$2_FLAGS=$8 -DTHIS_FILE='"$$(<F)"'
   101     $1_$2_COMP=$(AS)
   100     $1_$2_COMP=$(AS)
   102     $1_$2_DEP_FLAG:=
   101     $1_$2_DEP_FLAG:=
   103   else ifneq (,$$(filter %.cpp,$2)$$(filter %.mm,$2))
   102   else ifneq (,$$(filter %.cpp,$2)$$(filter %.mm,$2))
   104     # Compile as a C++ file
   103     # Compile as a C++ or Objective-C++ file
   105     $1_$2_FLAGS=$(CFLAGS_CCACHE) $6 $$($1_$(notdir $2)_CXXFLAGS) -DTHIS_FILE='"$$(<F)"' -c
   104     $1_$2_FLAGS=$(CFLAGS_CCACHE) $6 $$($1_$(notdir $2)_CXXFLAGS) -DTHIS_FILE='"$$(<F)"' -c
   106     $1_$2_COMP=$7
   105     $1_$2_COMP=$7
   107     $1_$2_DEP_FLAG:=$(CXX_FLAG_DEPS)
   106     $1_$2_DEP_FLAG:=$(CXX_FLAG_DEPS)
   108   else
   107   else
   109     $$(error Internal error in NativeCompilation.gmk: no compiler for file $2)
   108     $$(error Internal error in NativeCompilation.gmk: no compiler for file $2)
   322     $1_CC:=$(CC)
   321     $1_CC:=$(CC)
   323   endif
   322   endif
   324   ifeq ($$($1_CXX),)
   323   ifeq ($$($1_CXX),)
   325     $1_CXX:=$(CXX)
   324     $1_CXX:=$(CXX)
   326   endif
   325   endif
   327   ifeq ($$($1_OBJC),)
       
   328     $1_OBJC:=$(OBJC)
       
   329   endif
       
   330 
   326 
   331   # Make sure the dirs exist.
   327   # Make sure the dirs exist.
   332   $$(call MakeDir,$$($1_OBJECT_DIR) $$($1_OUTPUT_DIR))
   328   $$(call MakeDir,$$($1_OBJECT_DIR) $$($1_OUTPUT_DIR))
   333   $$(foreach d,$$($1_SRC), $$(if $$(wildcard $$d),,$$(error SRC specified to SetupNativeCompilation $1 contains missing directory $$d)))
   329   $$(foreach d,$$($1_SRC), $$(if $$(wildcard $$d),,$$(error SRC specified to SetupNativeCompilation $1 contains missing directory $$d)))
   334 
   330 
   452   # Track variable changes for all variables that affect the compilation command
   448   # Track variable changes for all variables that affect the compilation command
   453   # lines for all object files in this setup. This includes at least all the
   449   # lines for all object files in this setup. This includes at least all the
   454   # variables used in the call to add_native_source below.
   450   # variables used in the call to add_native_source below.
   455   $1_COMPILE_VARDEPS := $$($1_CFLAGS) $$($1_EXTRA_CFLAGS) $(SYSROOT_CFLAGS) \
   451   $1_COMPILE_VARDEPS := $$($1_CFLAGS) $$($1_EXTRA_CFLAGS) $(SYSROOT_CFLAGS) \
   456       $$($1_CXXFLAGS) $$($1_EXTRA_CXXFLAGS) \
   452       $$($1_CXXFLAGS) $$($1_EXTRA_CXXFLAGS) \
   457       $$($1_CC) $$($1_CXX) $$($1_OBJC) $$($1_ASFLAGS) \
   453       $$($1_CC) $$($1_CXX) $$($1_ASFLAGS) \
   458       $$(foreach s, $$($1_SRCS), \
   454       $$(foreach s, $$($1_SRCS), \
   459           $$($1_$$(notdir $$s)_CFLAGS) $$($1_$$(notdir $$s)_CXXFLAGS))
   455           $$($1_$$(notdir $$s)_CFLAGS) $$($1_$$(notdir $$s)_CXXFLAGS))
   460   $1_COMPILE_VARDEPS_FILE := $$(call DependOnVariable, $1_COMPILE_VARDEPS, \
   456   $1_COMPILE_VARDEPS_FILE := $$(call DependOnVariable, $1_COMPILE_VARDEPS, \
   461       $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).comp.vardeps)
   457       $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).comp.vardeps)
   462 
   458 
   464   $$(foreach p,$$($1_SRCS), \
   460   $$(foreach p,$$($1_SRCS), \
   465       $$(eval $$(call add_native_source,$1,$$p,$$($1_OBJECT_DIR), \
   461       $$(eval $$(call add_native_source,$1,$$p,$$($1_OBJECT_DIR), \
   466           $$($1_CFLAGS) $$($1_EXTRA_CFLAGS) $(SYSROOT_CFLAGS), \
   462           $$($1_CFLAGS) $$($1_EXTRA_CFLAGS) $(SYSROOT_CFLAGS), \
   467           $$($1_CC), \
   463           $$($1_CC), \
   468           $$($1_CXXFLAGS) $$($1_EXTRA_CXXFLAGS) $(SYSROOT_CFLAGS), \
   464           $$($1_CXXFLAGS) $$($1_EXTRA_CXXFLAGS) $(SYSROOT_CFLAGS), \
   469           $$($1_CXX),$$($1_OBJC),$$($1_ASFLAGS))))
   465           $$($1_CXX), $$($1_ASFLAGS))))
   470 
   466 
   471   # Setup rule for printing progress info when compiling source files.
   467   # Setup rule for printing progress info when compiling source files.
   472   # This is a rough heuristic and may not always print accurate information.
   468   # This is a rough heuristic and may not always print accurate information.
   473   $$($1_BUILD_INFO): $$($1_SRCS) $$($1_COMPILE_VARDEPS_FILE)
   469   $$($1_BUILD_INFO): $$($1_SRCS) $$($1_COMPILE_VARDEPS_FILE)
   474         ifeq ($$(wildcard $$($1_TARGET)),)
   470         ifeq ($$(wildcard $$($1_TARGET)),)