pp.mk 1.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
# Copyright 2012 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.

11 12 13 14
# Create a way to reformat just some files
ifdef PPFILES
  PP_INPUTS_FILTERED := $(wildcard $(PPFILES))
else
15 16
  PP_INPUTS = $(wildcard $(addprefix $(S)src/libstd/,*.rs */*.rs)) \
              $(wildcard $(addprefix $(S)src/libextra/,*.rs */*.rs)) \
G
Graydon Hoare 已提交
17
              $(wildcard $(addprefix $(S)src/rustc/,*.rs */*.rs */*/*.rs)) \
18
              $(wildcard $(S)src/test/*/*.rs    \
19
                         $(S)src/test/*/*/*.rs) \
20
              $(wildcard $(S)src/rustpkg/*.rs) \
21 22
              $(wildcard $(S)src/rusti/*.rs) \
              $(wildcard $(S)src/rust/*.rs)
23

24
  PP_INPUTS_FILTERED = $(shell echo $(PP_INPUTS) | xargs grep -L \
25
                       "no-reformat\|xfail-pretty\|xfail-test")
26
endif
27

28
reformat: $(SREQ1$(CFG_BUILD_TRIPLE))
G
Graydon Hoare 已提交
29
	@$(call E, reformat [stage1]: $@)
30
	for i in $(PP_INPUTS_FILTERED);  \
31
    do $(call CFG_RUN_TARG_$(CFG_BUILD_TRIPLE),1,$(CFG_BUILD_TRIPLE)/stage1/rustc$(X_$(CFG_BUILD_TRIPLE))) \
32
       --pretty normal $$i >$$i.tmp; \
33 34 35 36 37 38 39
    if [ $$? -ne 0 ]; \
        then echo failed to print $$i; rm $$i.tmp; \
        else if cmp --silent $$i.tmp $$i; \
            then echo no changes to $$i; rm $$i.tmp; \
            else echo reformated $$i; mv $$i.tmp $$i; \
        fi; \
    fi; \
G
Graydon Hoare 已提交
40
    done