about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-05-11 14:07:42 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-05-19 10:52:57 -0700
commitfcf7ecd1d709c3a4ecc652349763710914271fb0 (patch)
treee84f9a6d0945b8a0866de2dd4ef4117937c8d3b6
parentb56d47cc80a7df471c0e2f96fa62a3e3983972ec (diff)
downloadrust-fcf7ecd1d709c3a4ecc652349763710914271fb0.tar.gz
rust-fcf7ecd1d709c3a4ecc652349763710914271fb0.zip
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.
-rw-r--r--mk/platform.mk19
-rw-r--r--mk/rt.mk6
2 files changed, 20 insertions, 5 deletions
diff --git a/mk/platform.mk b/mk/platform.mk
index 8e7e61c92a4..53fb8138916 100644
--- a/mk/platform.mk
+++ b/mk/platform.mk
@@ -133,6 +133,21 @@ endef
 $(foreach target,$(CFG_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)
   CCACHE_CPP2=1
@@ -163,7 +178,7 @@ define CFG_MAKE_TOOLCHAIN
   CFG_COMPILE_C_$(1) = $$(CC_$(1)) \
         $$(CFG_GCCISH_CFLAGS) \
         $$(CFG_GCCISH_CFLAGS_$(1)) \
-        -c -o $$(1) $$(2)
+        -c $$(call CFG_CC_OUTPUT_$(1),$$(1)) $$(2)
   CFG_LINK_C_$(1) = $$(CC_$(1)) \
         $$(CFG_GCCISH_LINK_FLAGS) -o $$(1) \
         $$(CFG_GCCISH_LINK_FLAGS_$(1)) \
@@ -174,7 +189,7 @@ define CFG_MAKE_TOOLCHAIN
         $$(CFG_GCCISH_CXXFLAGS) \
         $$(CFG_GCCISH_CFLAGS_$(1)) \
         $$(CFG_GCCISH_CXXFLAGS_$(1)) \
-        -c -o $$(1) $$(2)
+        -c $$(call CFG_CC_OUTPUT_$(1),$$(1)) $$(2)
   CFG_LINK_CXX_$(1) = $$(CXX_$(1)) \
         $$(CFG_GCCISH_LINK_FLAGS) -o $$(1) \
         $$(CFG_GCCISH_LINK_FLAGS_$(1)) \
diff --git a/mk/rt.mk b/mk/rt.mk
index c913fe385d6..3d3e4c8866c 100644
--- a/mk/rt.mk
+++ b/mk/rt.mk
@@ -81,8 +81,8 @@ $$(RT_OUTPUT_DIR_$(1))/%.o: $(S)src/rt/%.c $$(MKFILE_DEPS)
 	@mkdir -p $$(@D)
 	@$$(call E, compile: $$@)
 	$$(Q)$$(call CFG_COMPILE_C_$(1), $$@, \
-		-I $$(S)src/rt/hoedown/src \
-		-I $$(S)src/rt \
+		$$(call CFG_CC_INCLUDE_$(1),$$(S)src/rt/hoedown/src) \
+		$$(call CFG_CC_INCLUDE_$(1),$$(S)src/rt) \
                  $$(RUNTIME_CFLAGS_$(1))) $$<
 
 $$(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))
 $$(RT_OUTPUT_DIR_$(1))/$$(NATIVE_$(2)_$(1)): $$(OBJS_$(2)_$(1))
 	@$$(call E, link: $$@)
-	$$(Q)$$(AR_$(1)) rcs $$@ $$^
+	$$(Q)$$(call CFG_CREATE_ARCHIVE_$(1),$$@) $$^
 
 endef