From f1d1454e81fd0dd93970c1d0f7c02b739941f568 Mon Sep 17 00:00:00 2001 From: bird Date: Mon, 30 Nov 2009 00:30:43 +0000 Subject: [PATCH] 0.1.5: Backported r2356, r2357, r2358, r2359 and r2360: Objective-C++ support. git-svn-id: https://www.virtualbox.org/svn/kbuild-mirror/branches/kBuild-0.1.5@2368 1093d150-e988-4e3a-8fd4-90e8b09e91e5 --- kBuild/footer.kmk | 5 ++++ kBuild/header.kmk | 16 +++++++---- kBuild/tools/GCC4MACHO.kmk | 70 +++++++++++++++++++++++++++++++++++++++------- kBuild/tools/GXX4MACHO.kmk | 70 +++++++++++++++++++++++++++++++++++++++------- kBuild/units/qt4.kmk | 1 + 5 files changed, 136 insertions(+), 26 deletions(-) diff --git a/kBuild/footer.kmk b/kBuild/footer.kmk index dfd599c9..44b96cb5 100644 --- a/kBuild/footer.kmk +++ b/kBuild/footer.kmk @@ -2168,6 +2168,11 @@ local type := OBJC $(kb-src-one 2) endef +define def_src_handler_objcxx +local type := OBJCXX + $(kb-src-one 2) +endef + define def_src_handler_asm local type := AS $(kb-src-one 2) diff --git a/kBuild/header.kmk b/kBuild/header.kmk index 671ee568..93483fc6 100644 --- a/kBuild/header.kmk +++ b/kBuild/header.kmk @@ -808,6 +808,8 @@ KBUILD_SRC_HANDLERS := \ .cc:def_src_handler_cxx \ .CC:def_src_handler_cxx \ .m:def_src_handler_objc \ + .M:def_src_handler_objcxx \ + .mm:def_src_handler_objcxx \ .asm:def_src_handler_asm \ .ASM:def_src_handler_asm \ .s:def_src_handler_asm \ @@ -819,20 +821,20 @@ KBUILD_SRC_HANDLERS := \ ## PROPS_TOOLS # This is a subset of PROPS_SINGLE. -PROPS_TOOLS := TOOL CTOOL CXXTOOL OBJCTOOL ASTOOL RCTOOL ARTOOL LDTOOL FETCHTOOL UNPACKTOOL PATCHTOOL +PROPS_TOOLS := TOOL CTOOL CXXTOOL OBJCTOOL OBJCXXTOOL ASTOOL RCTOOL ARTOOL LDTOOL FETCHTOOL UNPACKTOOL PATCHTOOL ## PROPS_SINGLE # The list of non-accumulative target properties. # A Config.kmk file can add it's own properties to this list and kBuild # will do the necessary inheritance for templates, sdks, tools and targets. PROPS_SINGLE := $(PROPS_TOOLS) TEMPLATE INST NOINST BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU FETCHDIR \ - OBJSUFF COBJSUFF CXXOBJSUFF OBJCOBJSUFF ASOBJSUFF RCOBJSUFF SYSSUFF BINSUFF EXESUFF DLLSUFF LIBSUFF ARLIBSUFF \ + OBJSUFF COBJSUFF CXXOBJSUFF OBJCOBJSUFF OBJCXXOBJSUFF ASOBJSUFF RCOBJSUFF SYSSUFF BINSUFF EXESUFF DLLSUFF LIBSUFF ARLIBSUFF \ MODE UID GID ## PROPS_SINGLE_LNK # Subset of PROPS_SINGLE which applies to all linkable targets. -PROPS_SINGLE_LNK := TOOL TEMPLATE CTOOL CXXTOOL OBJCTOOL ASTOOL RCTOOL \ +PROPS_SINGLE_LNK := TOOL TEMPLATE CTOOL CXXTOOL OBJCTOOL OBJCXXTOOL ASTOOL RCTOOL \ INST NOINST BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU \ - OBJSUFF COBJSUFF CXXOBJSUFF OBJCOBJSUFF ASOBJSUFF RCOBJSUFF \ + OBJSUFF COBJSUFF CXXOBJSUFF OBJCOBJSUFF OBJCXXOBJSUFF ASOBJSUFF RCOBJSUFF \ MODE UID GID ## PROPS_DEFERRED @@ -851,6 +853,7 @@ PROPS_ACCUMULATE_R := \ CFLAGS CDEFS \ CXXFLAGS CXXDEFS \ OBJCFLAGS OBJCDEFS \ + OBJCXXFLAGS OBJCXXDEFS \ ASFLAGS ASDEFS \ RCFLAGS RCDEFS \ LDFLAGS \ @@ -863,6 +866,7 @@ PROPS_ACCUMULATE_R_LNK := \ CFLAGS CDEFS \ CXXFLAGS CXXDEFS \ OBJCFLAGS OBJCDEFS \ + OBJCXXFLAGS OBJCXXDEFS \ ASFLAGS ASDEFS \ RCFLAGS RCDEFS \ IDFLAGS IFDLAGS ISFLAGS @@ -874,14 +878,14 @@ PROPS_ACCUMULATE_R_LNK := \ # will do the necessary inheritance from templates to targets. PROPS_ACCUMULATE_L := \ SDKS USES SOURCES SRC_HANDLERS INTERMEDIATES \ - INCS CINCS CXXINCS OBJCINCS ASINCS RCINCS \ + INCS CINCS CXXINCS OBJCINCS OBJCXXINCS ASINCS RCINCS \ LIBS LIBPATH \ DIRS BLDDIRS CLEAN ## PROPS_ACCUMULATE_L_LNK # Subset of PROPS_ACCUMULATE_L which applies to all linkable targets. PROPS_ACCUMULATE_L_LNK := \ SDKS USES SOURCES SRC_HANDLERS INTERMEDIATES \ - INCS CINCS CXXINCS OBJCINCS ASINCS RCINCS \ + INCS CINCS CXXINCS OBJCINCS OBJCXXINCS ASINCS RCINCS \ BLDDIRS CLEAN ## PROPS_ALL diff --git a/kBuild/tools/GCC4MACHO.kmk b/kBuild/tools/GCC4MACHO.kmk index 50bab8d7..e3819d53 100644 --- a/kBuild/tools/GCC4MACHO.kmk +++ b/kBuild/tools/GCC4MACHO.kmk @@ -34,11 +34,12 @@ TOOL_GCC4MACHO := GCC v4 targeting Darwin (Mac OS X) Mach-o. # Tool Specific Properties -TOOL_GCC4MACHO_CC ?= gcc$(HOSTSUFF_EXE) -TOOL_GCC4MACHO_CXX ?= g++$(HOSTSUFF_EXE) -TOOL_GCC4MACHO_OBJC?= gcc$(HOSTSUFF_EXE) -TOOL_GCC4MACHO_AS ?= gcc$(HOSTSUFF_EXE) -TOOL_GCC4MACHO_LD ?= gcc$(HOSTSUFF_EXE) +TOOL_GCC4MACHO_CC ?= gcc$(HOSTSUFF_EXE) +TOOL_GCC4MACHO_CXX ?= g++$(HOSTSUFF_EXE) +TOOL_GCC4MACHO_OBJC ?= gcc$(HOSTSUFF_EXE) +TOOL_GCC4MACHO_OBJCXX ?= gcc$(HOSTSUFF_EXE) +TOOL_GCC4MACHO_AS ?= gcc$(HOSTSUFF_EXE) +TOOL_GCC4MACHO_LD ?= gcc$(HOSTSUFF_EXE) TOOL_GCC4MACHO_LD_SYSMOD ?= gcc$(HOSTSUFF_EXE) ifndef TOOL_GCC4MACHO_LDFLAGS.$(KBUILD_TARGET) TOOL_GCC4MACHO_LDFLAGS.dll ?= -dynamiclib @@ -49,9 +50,10 @@ TOOL_GCC4MACHO_LDFLAGS.sysmod ?= -r #TOOL_GCC4MACHO_LD_SONAME = -Wl,-dylib_install_name $(firstword $($(1)_SONAME.$(KBUILD_TARGET).$(KBUILD_TYPE)) $($(1)_SONAME.$(KBUILD_TARGET)) $($(1)_SONAME.$(KBUILD_TYPE)) $($(1)_SONAME) $(notdir $(2))) ifdef SLKRUNS -TOOL_GCC4MACHO_CC += -fmessage-length=0 -TOOL_GCC4MACHO_CXX += -fmessage-length=0 -TOOL_GCC4MACHO_OBJC+= -fmessage-length=0 +TOOL_GCC4MACHO_CC += -fmessage-length=0 +TOOL_GCC4MACHO_CXX += -fmessage-length=0 +TOOL_GCC4MACHO_OBJC += -fmessage-length=0 +TOOL_GCC4MACHO_OBJCXX += -fmessage-length=0 endif # General Properties used by kBuild @@ -64,7 +66,6 @@ TOOL_GCC4MACHO_CINCS ?= TOOL_GCC4MACHO_CDEFS ?= TOOL_GCC4MACHO_CXXOBJSUFF ?= .o -TOOL_GCC4MACHO_CXXOBJSUFF ?= .o TOOL_GCC4MACHO_CXXFLAGS ?= TOOL_GCC4MACHO_CXXFLAGS.debug ?= -g TOOL_GCC4MACHO_CXXFLAGS.profile ?= -g -O2 #-pg @@ -73,7 +74,6 @@ TOOL_GCC4MACHO_CXXINCS ?= TOOL_GCC4MACHO_CXXDEFS ?= TOOL_GCC4MACHO_OBJCOBJSUFF ?= .o -TOOL_GCC4MACHO_OBJCOBJSUFF ?= .o TOOL_GCC4MACHO_OBJCFLAGS ?= TOOL_GCC4MACHO_OBJCFLAGS.debug ?= -g TOOL_GCC4MACHO_OBJCFLAGS.profile?= -O2 #-g -pg @@ -81,6 +81,14 @@ TOOL_GCC4MACHO_OBJCFLAGS.release?= -O2 TOOL_GCC4MACHO_OBJCINCS ?= TOOL_GCC4MACHO_OBJCDEFS ?= +TOOL_GCC4MACHO_OBJCXXOBJSUFF ?= .o +TOOL_GCC4MACHO_OBJCXXFLAGS ?= +TOOL_GCC4MACHO_OBJCXXFLAGS.debug ?= -g +TOOL_GCC4MACHO_OBJCXXFLAGS.profile ?= -O2 #-g -pg +TOOL_GCC4MACHO_OBJCXXFLAGS.release ?= -O2 +TOOL_GCC4MACHO_OBJCXXINCS ?= +TOOL_GCC4MACHO_OBJCXXDEFS ?= + TOOL_GCC4MACHO_ASFLAGS ?= -x assembler-with-cpp TOOL_GCC4MACHO_ASFLAGS.debug ?= -g TOOL_GCC4MACHO_ASFLAGS.profile ?= -g @@ -222,6 +230,48 @@ endef endif # !KBUILD_USE_KOBJCACHE +## Compile Objective-C++ source. +# @param $(target) Normalized main target name. +# @param $(source) Source filename (relative). +# @param $(obj) Object file name. This shall be (re)created by the compilation. +# @param $(dep) Dependcy file. This shall be (re)created by the compilation. +# @param $(flags) Flags. +# @param $(defs) Definitions. No -D or something. +# @param $(incs) Includes. No -I or something. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# @param $(outbase) Output basename (full). Use this for list files and such. +# @param $(objsuff) Object suffix. +TOOL_GCC4MACHO_COMPILE_OBJCXX_DEPEND = +TOOL_GCC4MACHO_COMPILE_OBJCXX_DEPORD = +ifdef KBUILD_USE_KOBJCACHE +TOOL_GCC4MACHO_COMPILE_OBJCXX_USES_KOBJCACHE = 1 +TOOL_GCC4MACHO_COMPILE_OBJCXX_OUTPUT = $(outbase).mii +define TOOL_GCC4MACHO_COMPILE_OBJCXX_CMDS + $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\ + --kObjCache-cpp $(outbase).mii\ + $(TOOL_GCC4MACHO_OBJCXX) -E -o -\ + $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ + -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ + $(abspath $(source))\ + --kObjCache-cc $(obj)\ + $(TOOL_GCC4MACHO_OBJCXX) -c\ + $(flags) -fpreprocessed -x objective-c++\ + -o $(obj)\ + - +endef +else # !KBUILD_USE_KOBJCACHE +TOOL_GCC4MACHO_COMPILE_OBJCXX_OUTPUT = +define TOOL_GCC4MACHO_COMPILE_OBJCXX_CMDS + $(QUIET)$(TOOL_GCC4MACHO_OBJCXX) -c\ + $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ + -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ + -o $(obj)\ + $(abspath $(source)) +endef +endif # !KBUILD_USE_KOBJCACHE + + ## Compile Assembly source. # @param $(target) Normalized main target name. # @param $(source) Source filename (relative). diff --git a/kBuild/tools/GXX4MACHO.kmk b/kBuild/tools/GXX4MACHO.kmk index 43a104cd..1697b2f2 100644 --- a/kBuild/tools/GXX4MACHO.kmk +++ b/kBuild/tools/GXX4MACHO.kmk @@ -34,11 +34,12 @@ TOOL_GXX4MACHO := GCC v4 targeting Darwin (Mac OS X) Mach-o, for building C++ code. # Tool Specific Properties -TOOL_GXX4MACHO_CC ?= gcc$(HOSTSUFF_EXE) -TOOL_GXX4MACHO_CXX ?= g++$(HOSTSUFF_EXE) -TOOL_GXX4MACHO_OBJC?= gcc$(HOSTSUFF_EXE) -TOOL_GXX4MACHO_AS ?= gcc$(HOSTSUFF_EXE) -TOOL_GXX4MACHO_LD ?= g++$(HOSTSUFF_EXE) +TOOL_GXX4MACHO_CC ?= gcc$(HOSTSUFF_EXE) +TOOL_GXX4MACHO_CXX ?= g++$(HOSTSUFF_EXE) +TOOL_GXX4MACHO_OBJC ?= gcc$(HOSTSUFF_EXE) +TOOL_GXX4MACHO_OBJCXX ?= gcc$(HOSTSUFF_EXE) +TOOL_GXX4MACHO_AS ?= gcc$(HOSTSUFF_EXE) +TOOL_GXX4MACHO_LD ?= g++$(HOSTSUFF_EXE) TOOL_GXX4MACHO_LD_SYSMOD ?= g++$(HOSTSUFF_EXE) ifndef TOOL_GXX4MACHO_LDFLAGS.$(KBUILD_TARGET) TOOL_GXX4MACHO_LDFLAGS.dll ?= -dynamiclib @@ -49,9 +50,10 @@ TOOL_GXX4MACHO_LDFLAGS.sysmod ?= -r #TOOL_GXX4MACHO_LD_SONAME = -Wl,-dylib_install_name $(firstword $($(1)_SONAME.$(KBUILD_TARGET).$(KBUILD_TYPE)) $($(1)_SONAME.$(KBUILD_TARGET)) $($(1)_SONAME.$(KBUILD_TYPE)) $($(1)_SONAME) $(notdir $(2))) ifdef SLKRUNS -TOOL_GXX4MACHO_CC += -fmessage-length=0 -TOOL_GXX4MACHO_CXX += -fmessage-length=0 -TOOL_GXX4MACHO_OBJC+= -fmessage-length=0 +TOOL_GXX4MACHO_CC += -fmessage-length=0 +TOOL_GXX4MACHO_CXX += -fmessage-length=0 +TOOL_GXX4MACHO_OBJC += -fmessage-length=0 +TOOL_GXX4MACHO_OBJCXX += -fmessage-length=0 endif # General Properties used by kBuild @@ -64,7 +66,6 @@ TOOL_GXX4MACHO_CINCS ?= TOOL_GXX4MACHO_CDEFS ?= TOOL_GXX4MACHO_CXXOBJSUFF ?= .o -TOOL_GXX4MACHO_CXXOBJSUFF ?= .o TOOL_GXX4MACHO_CXXFLAGS ?= TOOL_GXX4MACHO_CXXFLAGS.debug ?= -g TOOL_GXX4MACHO_CXXFLAGS.profile ?= -O2 #-g -pg @@ -73,7 +74,6 @@ TOOL_GXX4MACHO_CXXINCS ?= TOOL_GXX4MACHO_CXXDEFS ?= TOOL_GXX4MACHO_OBJCOBJSUFF ?= .o -TOOL_GXX4MACHO_OBJCOBJSUFF ?= .o TOOL_GXX4MACHO_OBJCFLAGS ?= TOOL_GXX4MACHO_OBJCFLAGS.debug ?= -g TOOL_GXX4MACHO_OBJCFLAGS.profile?= -O2 #-g -pg @@ -81,6 +81,14 @@ TOOL_GXX4MACHO_OBJCFLAGS.release?= -O2 TOOL_GXX4MACHO_OBJCINCS ?= TOOL_GXX4MACHO_OBJCDEFS ?= +TOOL_GXX4MACHO_OBJCXXOBJSUFF ?= .o +TOOL_GXX4MACHO_OBJCXXFLAGS ?= +TOOL_GXX4MACHO_OBJCXXFLAGS.debug ?= -g +TOOL_GXX4MACHO_OBJCXXFLAGS.profile ?= -O2 #-g -pg +TOOL_GXX4MACHO_OBJCXXFLAGS.release ?= -O2 +TOOL_GXX4MACHO_OBJCXXINCS ?= +TOOL_GXX4MACHO_OBJCXXDEFS ?= + TOOL_GXX4MACHO_ASFLAGS ?= -x assembler-with-cpp TOOL_GXX4MACHO_ASFLAGS.debug ?= -g TOOL_GXX4MACHO_ASFLAGS.profile ?= -g @@ -222,6 +230,48 @@ endef endif # !KUSE_OBJCACHE +## Compile Objective-C++ source. +# @param $(target) Normalized main target name. +# @param $(source) Source filename (relative). +# @param $(obj) Object file name. This shall be (re)created by the compilation. +# @param $(dep) Dependcy file. This shall be (re)created by the compilation. +# @param $(flags) Flags. +# @param $(defs) Definitions. No -D or something. +# @param $(incs) Includes. No -I or something. +# @param $(dirdep) Directory creation dependency. +# @param $(deps) Other dependencies. +# @param $(outbase) Output basename (full). Use this for list files and such. +# @param $(objsuff) Object suffix. +TOOL_GXX4MACHO_COMPILE_OBJCXX_DEPEND = +TOOL_GXX4MACHO_COMPILE_OBJCXX_DEPORD = +ifdef KBUILD_USE_KOBJCACHE +TOOL_GXX4MACHO_COMPILE_OBJCXX_USES_KOBJCACHE = 1 +TOOL_GXX4MACHO_COMPILE_OBJCXX_OUTPUT = $(outbase).mii +define TOOL_GXX4MACHO_COMPILE_OBJCXX_CMDS + $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\ + --kObjCache-cpp $(outbase).mii\ + $(TOOL_GXX4MACHO_OBJCXX) -E -o -\ + $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ + -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ + $(abspath $(source))\ + --kObjCache-cc $(obj)\ + $(TOOL_GXX4MACHO_OBJCXX) -c\ + $(flags) -fpreprocessed -x objective-c++ \ + -o $(obj)\ + - +endef +else # !KBUILD_USE_KOBJCACHE +TOOL_GXX4MACHO_COMPILE_OBJCXX_OUTPUT = +define TOOL_GXX4MACHO_COMPILE_OBJCXX_CMDS + $(QUIET)$(TOOL_GXX4MACHO_OBJCXX) -c\ + $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\ + -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\ + -o $(obj)\ + $(abspath $(source)) +endef +endif # !KUSE_OBJCACHE + + ## Compile Assembly source. # @param $(target) Normalized main target name. # @param $(source) Source filename (relative). diff --git a/kBuild/units/qt4.kmk b/kBuild/units/qt4.kmk index cd34dda4..f29a72b4 100644 --- a/kBuild/units/qt4.kmk +++ b/kBuild/units/qt4.kmk @@ -956,6 +956,7 @@ local qt_infix := $(firstword \ ifeq ($(bld_trg),darwin) # Adding -F to CXXFLAGS is necessary to make #include stuff work... $(eval $(target)_CXXFLAGS += -F$(PATH_SDK_QT4_LIB) ) + $(eval $(target)_OBJCXXFLAGS += -F$(PATH_SDK_QT4_LIB) ) $(eval $(target)_LDFLAGS += -F$(PATH_SDK_QT4_LIB) $(foreach module,$(qt_modules), -framework $(qt_prefix)Qt$(module)$(qt_infix)) ) $(eval $(target)_INCS += $(foreach module,$(qt_modules), $(PATH_SDK_QT4_LIB)/$(qt_prefix)Qt$(module)$(qt_infix).framework/Versions/4/Headers) ) else -- 2.11.4.GIT