servo: Merge #2232 - Some minor configure and Makefile cleanup (from metajack:configure-cleanup); r=jdm
authorJack Moffitt <jack@metajack.im>
Tue, 29 Apr 2014 15:07:40 -0400
changeset 383281 170332740d3b08b81b6c356fb2f32560223211ec
parent 383280 edfb0804b8ac38c987f372f4ec856ba4aff2b79b
child 383282 654cc7e528462e2124a08f3cec822b74fd3fc66d
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm
servo: Merge #2232 - Some minor configure and Makefile cleanup (from metajack:configure-cleanup); r=jdm Move CFG_TARGET_TRIPLES to CFG_TARGET, since only one target is supported anyway. Create config.{mk,tmp,status} files in build directory instead of the source directory. r? @larsbergstrom Source-Repo: https://github.com/servo/servo Source-Revision: a1838f858ffc7758513756c5b59431bc442a0619
servo/.gitignore
servo/Makefile.backup
servo/Makefile.in
servo/configure
--- a/servo/.gitignore
+++ b/servo/.gitignore
@@ -7,23 +7,20 @@
 *.dll
 *.dummy
 *.pkl
 *.pyc
 *.swp
 *.swo
 .DS_Store
 servo-test
-Makefile
 Servo.app
+.config.mk.last
 build*
 objdir
-config.mk
-config.stamp
-config.tmp
 parser.out
 src/components/script/dom/bindings/codegen/*.rs
 src/components/script/dom/bindings/codegen/_cache/
 src/components/script/dom/bindings/codegen/test/*.rs
 src/components/script/dom/bindings/codegen/RegisterBindings.cpp
 src/components/script/dom/bindings/codegen/PrototypeList.h
 src/components/script/dom/bindings/codegen/UnionTypes.h
 src/components/script/dom/bindings/codegen/UnionConversions.h
--- a/servo/Makefile.backup
+++ b/servo/Makefile.backup
@@ -2,16 +2,17 @@
 # Because Rust takes a very long time to build and changes infrequently,
 # the bots want to reuse it between builds. They can do so by running
 # `make backup-rust` and `make restore-rust`.
 #
 # backup-rust is run before the build directory is cleaned. if it fails, that's ok.
 #
 # restore-rust is run after configure and before invoking make. if it fails, we must abort.
 
-include config.mk
+-include .config.mk.last
 
-.PHONY: backup-rust restore-rust
+.PHONY: backup-rust
 backup-rust:
-	-mv $(CFG_BUILD_DIR)src/compiler/rust ../$(CFG_TARGET_TRIPLES)
+	@if [ ! -z "$(CFG_BUILD_DIR)" ]; then echo "Backing up Rust"; mv $(CFG_BUILD_DIR)src/compiler/rust ../$(CFG_TARGET); else echo "Skipping Rust backup"; fi
 
+.PHONY: restore-rust
 restore-rust:
-	if [ -d ../$(CFG_TARGET_TRIPLES) ]; then rm -rf $(CFG_BUILD_DIR)src/compiler/rust; mv ../$(CFG_TARGET_TRIPLES) $(CFG_BUILD_DIR)src/compiler/rust; fi
+	@if [ ! -z "$(CFG_BUILD_DIR)" -a -d ../$(CFG_TARGET) ]; then echo "Restoring Rust from backup"; rm -rf $(CFG_BUILD_DIR)src/compiler/rust; mv ../$(CFG_TARGET) $(CFG_BUILD_DIR)src/compiler/rust; else echo "Skipping Rust restore"; fi
--- a/servo/Makefile.in
+++ b/servo/Makefile.in
@@ -22,17 +22,17 @@ B := $(CFG_BUILD_DIR)
 # Delete the built-in rules.
 .SUFFIXES:
 %:: %,v
 %:: RCS/%,v
 %:: RCS/%
 %:: s.%
 %:: SCCS/s.%
 
-MKFILE_DEPS := config.stamp $(call rwildcard,$(S)mk/,*)
+MKFILE_DEPS := $(CFG_BUILD_HOME)config.stamp $(call rwildcard,$(S)mk/,*)
 
 CFG_GCCISH_CFLAGS += -DRUST_DEBUG
 CFG_RUSTC_FLAGS += -D unused-imports
 
 ifdef CFG_DISABLE_OPTIMIZE
   $(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))
   CFG_RUSTC_FLAGS +=
 else
@@ -70,22 +70,22 @@ ifndef CFG_DISABLE_MANAGE_SUBMODULES
 NEED_GIT_RECONFIG=$(shell cd "$(S)" && "$(CFG_GIT)" submodule status | grep -c '^\(+\|-\)')
 else
 NEED_GIT_RECONFIG=0
 endif
 
 ifeq ($(NEED_GIT_RECONFIG),0)
 else
 # If the submodules have changed then always execute config.mk
-.PHONY: $(S)config.stamp
+.PHONY: $(CFG_BUILD_HOME)config.stamp
 endif
 
-$(S)Makefile $(S)config.mk: $(S)config.stamp
+$(CFG_BUILD_HOME)Makefile $(CFG_BUILD_HOME)config.mk: $(CFG_BUILD_HOME)config.stamp
 
-$(S)config.stamp : $(S)configure $(S)Makefile.in
+$(CFG_BUILD_HOME)config.stamp : $(S)configure $(S)Makefile.in
 	@$(call E, cfg: reconfiguring)
 	$(Q)$(S)configure $(CFG_CONFIGURE_ARGS)
 
 # Build the compiler
 ifneq ($(CFG_LOCAL_RUSTC),1)
 $(CFG_RUSTC): $(B)src/compiler/rust/rust-auto-clean-stamp
 	@$(call E, building rustc)
 	$(Q)CFG_RUSTC_FLAGS= CFG_ENABLE_DEBUG= RUSTFLAGS="$(CFG_RUSTC_SELF_FLAGS)" $(MAKE) -C "$(CFG_BUILD_DIR)src/compiler/rust"
@@ -159,17 +159,17 @@ define DEF_SUBMODULE_DEPS
 ROUGH_DEPS_$(1)=$$(call rwildcard,$$(S)src/$$(PATH_$(1)),*h *c *cpp *rs *rc)
 DONE_DEPS_$(1)=$$(foreach dep,$$(DEPS_$(1)),$$(DONE_$$(dep)))
 # the main target for a submodule
 endef
 
 # Define how to make submodule targets
 define DEF_SUBMODULE_RULES
 
-ENV_RLDFLAGS_$(1) = -L $$(CFG_BUILD_HOME)workspace/lib/$$(CFG_TARGET_TRIPLES)
+ENV_RLDFLAGS_$(1) = -L $$(CFG_BUILD_HOME)workspace/lib/$$(CFG_TARGET)
 ENV_RLDFLAGS_$(1) += $$(foreach dep,$$(DEPS_$(1)),-L $$(B)src/$$(PATH_$$(dep)) -L $$(B)src/$$(PATH_$$(dep))/.libs -L $$(B)src/$$(PATH_$$(dep))/src/.libs)
 
 # variables that depend on dependency definitions from sub.mk!
 ENV_CFLAGS_$(1) = CFLAGS="$$(CFLAGS_$(1))"
 ENV_RFLAGS_$(1) = RUSTFLAGS="$$(strip $$(CFG_RUSTC_FLAGS)) $$(ENV_RLDFLAGS_$(1))"
 
 # Native builds do not depend on the rust compiler, so we can build them in parallel with rustc
 RUSTC_DEP_$(1)=
@@ -364,18 +364,18 @@ package: servo
 	cp $(S)Info.plist Servo.app/Contents/
 	cp servo Servo.app/Contents/MacOS/
 	cp $(B)src/platform/macos/rust-cocoa/lib*.dylib Servo.app/Contents/MacOS/src/platform/macos/rust-cocoa/
 	cp $(B)src/support/azure/rust-azure/lib*.dylib Servo.app/Contents/MacOS/src/support/azure/rust-azure/
 
 else ifeq ($(CFG_OSTYPE),linux-androideabi)
 package: servo
 	mkdir -p sofile
-	find . ! \( \( -type d -path './sofile' -o -path './$(CFG_TARGET_TRIPLES)/src/compiler/rust' \) -prune \) -name '*.so' -type f | xargs -I {} cp -f {} $(CFG_BUILD_HOME)sofile/
-	find $(CFG_RUST_HOME)/lib/rustlib/$(CFG_TARGET_TRIPLES)/lib/ -name '*.so' -type f -size +1c | xargs -I {} cp -f {} $(CFG_BUILD_HOME)sofile/
+	find . ! \( \( -type d -path './sofile' -o -path './$(CFG_TARGET)/src/compiler/rust' \) -prune \) -name '*.so' -type f | xargs -I {} cp -f {} $(CFG_BUILD_HOME)sofile/
+	find $(CFG_RUST_HOME)/lib/rustlib/$(CFG_TARGET)/lib/ -name '*.so' -type f -size +1c | xargs -I {} cp -f {} $(CFG_BUILD_HOME)sofile/
 	cd $(S)src/platform/android/servo-android-glue && make with-libs
 	cd $(CFG_BUILD_HOME)
 	cp $(S)src/platform/android/servo-android-glue/bin/ServoAndroid-debug.apk $(CFG_BUILD_HOME)
 
 else
 
 bindings: $(AUTOGEN_SRC_script)
 
--- a/servo/configure
+++ b/servo/configure
@@ -68,17 +68,17 @@ putvar() {
     eval T=\$$1
     eval TLEN=\${#$1}
     if [ $TLEN -gt 35 ]
     then
         printf "configure: %-20s := %.35s ...\n" $1 "$T"
     else
         printf "configure: %-20s := %s %s\n" $1 "$T" "$2"
     fi
-    printf "%-20s ?= %s\n" $1 "$T" >>${CFG_SRC_DIR}config.tmp
+    printf "%-20s ?= %s\n" $1 "$T" >>${CFG_BUILD_HOME}config.tmp
 }
 
 probe() {
     local V=$1
     shift
     local P
     local T
     for P
@@ -187,20 +187,20 @@ split_triple() {
     local ARCH=$2
     local VENDOR=$3
     local OS=$4
 
     eval $ARCH=$(echo "$TRIPLE" | cut -d'-' -f1)
     eval $VENDOR=$(echo "$TRIPLE" | cut -d'-' -f2)
     eval $OS=$(echo "$TRIPLE" | cut -d'-' -f3)
 
-        if [ $(echo "$TRIPLE" | cut -d'-' -f3) = "androideabi" ]
-        then
-            eval $OS="android"
-        fi
+    if [ $(echo "$TRIPLE" | cut -d'-' -f3) = "androideabi" ]
+    then
+        eval $OS="android"
+    fi
 }
 
 os_type() {
     # The goal here is to come up with the same triple as LLVM would,
     # at least for the subset of platforms we're willing to target.
 
     local OP=$1
     local OSTYPE=$(echo "$2" | tr '[:upper:]' '[:lower:]')
@@ -295,17 +295,17 @@ then
     then
         CPUTYPE=x86_64
     fi
 fi
 
 os_type CFG_BUILD_OSTYPE ${OSTYPE}
 cpu_type CFG_BUILD_CPUTYPE ${CPUTYPE}
 
-DEFAULT_TARGET_TRIPLE="${CFG_BUILD_CPUTYPE}-${CFG_BUILD_OSTYPE}"
+DEFAULT_TARGET="${CFG_BUILD_CPUTYPE}-${CFG_BUILD_OSTYPE}"
 
 CFG_SRC_DIR="$(cd $(dirname $0) && pwd)/"
 CFG_BUILD_HOME="$(pwd)/"
 CFG_SELF=${CFG_SRC_DIR}$(basename $0)
 CFG_CONFIGURE_ARGS="$@"
 CFG_PATH=$PATH
 
 if [ -n "$CFG_DISABLE_MANAGE_SUBMODULES" ]
@@ -324,43 +324,43 @@ then
     shift
     echo ""
     echo "Usage: $CFG_SELF [options]"
     echo ""
     echo "Options:"
     echo ""
 else
     msg "recreating config.tmp"
-    echo '' >${CFG_SRC_DIR}config.tmp
+    echo '' >${CFG_BUILD_HOME}config.tmp
 
     step_msg "processing $CFG_SELF args"
 fi
 
 opt optimize 1 "build optimized rust code"
 opt optimize-cxx 1 "build optimized C++ code"
 opt manage-submodules 1 "let the build manage the git submodules"
 opt fast-make 0 "use .gitmodules as timestamp for submodule deps"
 opt debug 0 "build with debugging code and symbols"
 opt debug-skia 0 "build Skia and Azure for debugging (significant performance hit)"
 valopt local-rust-root "" "set prefix for local rust binary"
-valopt target-triples "${DEFAULT_TARGET_TRIPLE}" "target triple to be compiled"
+valopt target "${DEFAULT_TARGET}" "target to be compiled"
 valopt android-cross-path "/opt/ndk_standalone" "Android NDK cross compiler path"
 valopt android-ndk-path "/opt/android-ndk" "Android NDK path"
 valopt android-sdk-path "/opt/android-sdk" "Android SDK path"
 valopt android-font-path "/system/fonts" "Android Font path"
 valopt android-resource-path "/sdcard/servo" "Android Resource path"
 
 if [ $HELP -eq 1 ]
 then
     echo ""
     exit 0
 fi
 
 # Split target triple
-split_triple "${CFG_TARGET_TRIPLES}" TARGET_CPUTYPE TARGET_VENDOR TARGET_OSTYPE
+split_triple "${CFG_TARGET}" TARGET_CPUTYPE TARGET_VENDOR TARGET_OSTYPE
 
 # Set target os and cpu type
 os_type CFG_OSTYPE ${TARGET_OSTYPE}
 cpu_type CFG_CPUTYPE ${TARGET_CPUTYPE}
 
 # probe before updating PATH so we don't get ndk-toolchain stuff
 probe_need CFG_GIT         git
 probe_need CFG_PYTHON2     python2 python2.7 python
@@ -394,17 +394,17 @@ case ${TARGET_OSTYPE} in
         probe CFG_AR               ar
         probe CFG_RANLIB	   ranlib
         CFG_RUSTC_FLAGS=""
         ;;
 esac
 
 probe CFG_CLANG            clang++
 
-CFG_BUILD_DIR="${CFG_BUILD_HOME}${CFG_TARGET_TRIPLES}/"
+CFG_BUILD_DIR="${CFG_BUILD_HOME}${CFG_TARGET}/"
 make_dir "${CFG_BUILD_DIR}"
 
 if [ ! -z "$CFG_LOCAL_RUST_ROOT" ]
 then
     if [ -f ${CFG_LOCAL_RUST_ROOT}/bin/rustc ]
     then
         LRV=`${CFG_LOCAL_RUST_ROOT}/bin/rustc --version`
         step_msg "using rustc at: ${CFG_LOCAL_RUST_ROOT} with version: $LRV"
@@ -412,18 +412,18 @@ then
         CFG_RUST_HOME=${CFG_LOCAL_RUST_ROOT}
         CFG_LOCAL_RUSTC=1
     else
         err "No rustc found at ${CFG_LOCAL_RUST_ROOT}/bin/rustc"
     fi
 else
     step_msg "using in-tree rust compiler"
     # The Rust compiler we're going to build
-    CFG_RUSTC="${CFG_BUILD_DIR}src/compiler/rust/${DEFAULT_TARGET_TRIPLE}/stage2/bin/rustc"
-    CFG_RUST_HOME="${CFG_BUILD_DIR}src/compiler/rust/${DEFAULT_TARGET_TRIPLE}/stage2"
+    CFG_RUSTC="${CFG_BUILD_DIR}src/compiler/rust/${DEFAULT_TARGET}/stage2/bin/rustc"
+    CFG_RUST_HOME="${CFG_BUILD_DIR}src/compiler/rust/${DEFAULT_TARGET}/stage2"
 fi
 
 if [ -z "$CFG_ENABLE_CLANG" -a -z "$CFG_CC" ]
 then
     err "either clang or gcc is required"
 fi
 
 # Configure submodules
@@ -539,17 +539,17 @@ CFG_SUBMODULES="\
     platform/android/fontconfig \
     platform/linux/rust-fontconfig \
     platform/linux/rust-freetype \
     ${CFG_SUBMODULES}"
 fi
 
 step_msg "writing configuration"
 
-putvar CFG_TARGET_TRIPLES
+putvar CFG_TARGET
 putvar CFG_CPUTYPE
 putvar CFG_OSTYPE
 putvar CFG_SRC_DIR
 putvar CFG_BUILD_HOME
 putvar CFG_BUILD_DIR
 putvar CFG_CONFIGURE_ARGS
 putvar CFG_SUBMODULES
 putvar CFG_DISABLE_MANAGE_SUBMODULES
@@ -559,20 +559,20 @@ putvar CFG_RUST_HOME
 putvar CFG_PATH
 putvar CFG_LOCAL_RUSTC
 putvar CFG_LOCAL_RUST_ROOT
 putvar CFG_ENABLE_DEBUG
 putvar CFG_ENABLE_DEBUG_SKIA
 
 msg
 copy_if_changed ${CFG_SRC_DIR}Makefile.in ${CFG_BUILD_HOME}Makefile
-move_if_changed ${CFG_SRC_DIR}config.tmp ${CFG_SRC_DIR}config.mk
-copy_if_changed ${CFG_SRC_DIR}config.mk ${CFG_BUILD_HOME}config.mk
-rm -f ${CFG_SRC_DIR}config.tmp
-touch ${CFG_SRC_DIR}config.stamp
+move_if_changed ${CFG_BUILD_HOME}config.tmp ${CFG_BUILD_HOME}config.mk
+copy_if_changed ${CFG_BUILD_HOME}config.mk ${CFG_SRC_DIR}/.config.mk.last
+rm -f ${CFG_BUILD_HOME}config.tmp
+touch ${CFG_BUILD_HOME}config.stamp
 
 export CFG_CONFIG_MK="${CFG_BUILD_HOME}config.mk"
 
 step_msg "making build directories"
 
 cd "${CFG_BUILD_DIR}"
 
 for i in ${CFG_SUBMODULES}
@@ -715,15 +715,14 @@ do
         *)
             ;;
     esac
 
     if [ -n "$ENABLE_DEBUG" ]; then
         CONFIGURE_ARGS="${CONFIGURE_ARGS} --enable-debug"
     fi
 
-    if [ -f ${CONFIGURE_SCRIPT} ]
-    then
+    if [ -f ${CONFIGURE_SCRIPT} ]; then
 	(sh ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}) || exit $?
     fi
 done
 
 step_msg "complete"