mk: Add build system support for cl.exe
We have a number of support C/C++ files in Rust that we link into the standard library and other various locations, and these all need to be built with cl.exe instead of gcc.exe when targeting MSVC. This commit adds helper macros for this functionality to use different sets of programs/flags/invocations on MSVC than on GNU-like platforms.
This commit is contained in:
parent
b56d47cc80
commit
fcf7ecd1d7
|
@ -133,6 +133,21 @@ endef
|
||||||
$(foreach target,$(CFG_TARGET), \
|
$(foreach target,$(CFG_TARGET), \
|
||||||
$(eval $(call FILTER_FLAGS,$(target))))
|
$(eval $(call FILTER_FLAGS,$(target))))
|
||||||
|
|
||||||
|
# Configure various macros to pass gcc or cl.exe style arguments
|
||||||
|
define CC_MACROS
|
||||||
|
CFG_CC_INCLUDE_$(1)=-I $$(1)
|
||||||
|
ifeq ($$(findstring msvc,$(1)),msvc)
|
||||||
|
CFG_CC_OUTPUT_$(1)=-Fo:$$(1)
|
||||||
|
CFG_CREATE_ARCHIVE_$(1)=$$(AR_$(1)) -OUT:$$(1)
|
||||||
|
else
|
||||||
|
CFG_CC_OUTPUT_$(1)=-o $$(1)
|
||||||
|
CFG_CREATE_ARCHIVE_$(1)=$$(AR_$(1)) crus $$(1)
|
||||||
|
endif
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(foreach target,$(CFG_TARGET), \
|
||||||
|
$(eval $(call CC_MACROS,$(target))))
|
||||||
|
|
||||||
|
|
||||||
ifeq ($(CFG_CCACHE_CPP2),1)
|
ifeq ($(CFG_CCACHE_CPP2),1)
|
||||||
CCACHE_CPP2=1
|
CCACHE_CPP2=1
|
||||||
|
@ -163,7 +178,7 @@ define CFG_MAKE_TOOLCHAIN
|
||||||
CFG_COMPILE_C_$(1) = $$(CC_$(1)) \
|
CFG_COMPILE_C_$(1) = $$(CC_$(1)) \
|
||||||
$$(CFG_GCCISH_CFLAGS) \
|
$$(CFG_GCCISH_CFLAGS) \
|
||||||
$$(CFG_GCCISH_CFLAGS_$(1)) \
|
$$(CFG_GCCISH_CFLAGS_$(1)) \
|
||||||
-c -o $$(1) $$(2)
|
-c $$(call CFG_CC_OUTPUT_$(1),$$(1)) $$(2)
|
||||||
CFG_LINK_C_$(1) = $$(CC_$(1)) \
|
CFG_LINK_C_$(1) = $$(CC_$(1)) \
|
||||||
$$(CFG_GCCISH_LINK_FLAGS) -o $$(1) \
|
$$(CFG_GCCISH_LINK_FLAGS) -o $$(1) \
|
||||||
$$(CFG_GCCISH_LINK_FLAGS_$(1)) \
|
$$(CFG_GCCISH_LINK_FLAGS_$(1)) \
|
||||||
|
@ -174,7 +189,7 @@ define CFG_MAKE_TOOLCHAIN
|
||||||
$$(CFG_GCCISH_CXXFLAGS) \
|
$$(CFG_GCCISH_CXXFLAGS) \
|
||||||
$$(CFG_GCCISH_CFLAGS_$(1)) \
|
$$(CFG_GCCISH_CFLAGS_$(1)) \
|
||||||
$$(CFG_GCCISH_CXXFLAGS_$(1)) \
|
$$(CFG_GCCISH_CXXFLAGS_$(1)) \
|
||||||
-c -o $$(1) $$(2)
|
-c $$(call CFG_CC_OUTPUT_$(1),$$(1)) $$(2)
|
||||||
CFG_LINK_CXX_$(1) = $$(CXX_$(1)) \
|
CFG_LINK_CXX_$(1) = $$(CXX_$(1)) \
|
||||||
$$(CFG_GCCISH_LINK_FLAGS) -o $$(1) \
|
$$(CFG_GCCISH_LINK_FLAGS) -o $$(1) \
|
||||||
$$(CFG_GCCISH_LINK_FLAGS_$(1)) \
|
$$(CFG_GCCISH_LINK_FLAGS_$(1)) \
|
||||||
|
|
6
mk/rt.mk
6
mk/rt.mk
|
@ -81,8 +81,8 @@ $$(RT_OUTPUT_DIR_$(1))/%.o: $(S)src/rt/%.c $$(MKFILE_DEPS)
|
||||||
@mkdir -p $$(@D)
|
@mkdir -p $$(@D)
|
||||||
@$$(call E, compile: $$@)
|
@$$(call E, compile: $$@)
|
||||||
$$(Q)$$(call CFG_COMPILE_C_$(1), $$@, \
|
$$(Q)$$(call CFG_COMPILE_C_$(1), $$@, \
|
||||||
-I $$(S)src/rt/hoedown/src \
|
$$(call CFG_CC_INCLUDE_$(1),$$(S)src/rt/hoedown/src) \
|
||||||
-I $$(S)src/rt \
|
$$(call CFG_CC_INCLUDE_$(1),$$(S)src/rt) \
|
||||||
$$(RUNTIME_CFLAGS_$(1))) $$<
|
$$(RUNTIME_CFLAGS_$(1))) $$<
|
||||||
|
|
||||||
$$(RT_OUTPUT_DIR_$(1))/%.o: $(S)src/rt/%.S $$(MKFILE_DEPS) \
|
$$(RT_OUTPUT_DIR_$(1))/%.o: $(S)src/rt/%.S $$(MKFILE_DEPS) \
|
||||||
|
@ -109,7 +109,7 @@ OBJS_$(2)_$(1) := $$(OBJS_$(2)_$(1):.S=.o)
|
||||||
NATIVE_$(2)_$(1) := $$(call CFG_STATIC_LIB_NAME_$(1),$(2))
|
NATIVE_$(2)_$(1) := $$(call CFG_STATIC_LIB_NAME_$(1),$(2))
|
||||||
$$(RT_OUTPUT_DIR_$(1))/$$(NATIVE_$(2)_$(1)): $$(OBJS_$(2)_$(1))
|
$$(RT_OUTPUT_DIR_$(1))/$$(NATIVE_$(2)_$(1)): $$(OBJS_$(2)_$(1))
|
||||||
@$$(call E, link: $$@)
|
@$$(call E, link: $$@)
|
||||||
$$(Q)$$(AR_$(1)) rcs $$@ $$^
|
$$(Q)$$(call CFG_CREATE_ARCHIVE_$(1),$$@) $$^
|
||||||
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue