1 # Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 # file at the top-level directory of this distribution and at
3 # http://rust-lang.org/COPYRIGHT.
5 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 # option. This file may not be copied, modified, or distributed
9 # except according to those terms.
11 BG
= $(CFG_BUILD_DIR
)/grammar
/
13 B
= $(CFG_BUILD_DIR
)/$(CFG_BUILD
)/stage2
/
14 L
= $(B
)lib
/rustlib
/$(CFG_BUILD
)/lib
15 LD
= $(CFG_BUILD
)/stage2
/lib
/rustlib
/$(CFG_BUILD
)/lib
/
16 RUSTC
= $(STAGE2_T_
$(CFG_BUILD
)_H_
$(CFG_BUILD
))
17 ifeq ($(CFG_OSTYPE
),apple-darwin
)
23 # Run the reference lexer against libsyntax and compare the tokens and spans.
24 # If "// ignore-lexer-test" is present in the file, it will be ignored.
26 # $(1) is the file to test.
28 grep
"// ignore-lexer-test" $(1) ; \
29 if
[ $$?
-eq
1 ]; then \
30 CLASSPATH
=$(B
)grammar
$(CFG_GRUN
) RustLexer tokens
-tokens
< $(1) \
31 |
$(B
)grammar
/verify
$(1) ; \
38 $(BG
)RustLexer.class
: $(BG
) $(SG
)RustLexer.g4
39 $(Q
)$(CFG_ANTLR4
) -o
$(BG
) $(SG
)RustLexer.g4
40 $(Q
)$(CFG_JAVAC
) -d
$(BG
) $(BG
)RustLexer.java
42 check-build-lexer-verifier
: $(BG
)verify
45 VERIFY_DEPS
:= rustc-stage2-H-
$(CFG_BUILD
) $(LD
)stamp.rustc
50 $(BG
)verify
: $(BG
) $(SG
)verify.rs
$(VERIFY_DEPS
)
51 $(Q
)$(RUSTC
) --out-dir
$(BG
) -L
$(L
) $(SG
)verify.rs
56 check-lexer
: $(BG
) $(BG
)RustLexer.class check-build-lexer-verifier
57 $(info Verifying libsyntax against the reference lexer ...
)
58 $(Q
)$(SG
)check.sh
$(S
) "$(BG)" \
59 "$(CFG_GRUN)" "$(BG)verify" "$(BG)RustLexer.tokens"
61 $(info cfg
: lexer tooling not available
, skipping lexer
test...
)
66 $(info cfg
: lexer tooling not available
, skipping lexer
test...
)
71 $(info cfg
: lexer tooling not available
, skipping lexer
test...
)
76 $(BG
)lex.yy.c
: $(SG
)lexer.l
$(BG
)
78 $(Q
)$(CFG_FLEX
) -o
$@
$<
80 $(BG
)lexer-lalr.o
: $(BG
)lex.yy.c
$(BG
)parser-lalr.tab.h
82 $(Q
)$(CFG_CC
) -include $(BG
)parser-lalr.tab.h
-c
-o
$@
$<
84 $(BG
)parser-lalr.tab.c
$(BG
)parser-lalr.tab.h
: $(SG
)parser-lalr.y
86 $(Q
)$(CFG_BISON
) $< --output
=$(BG
)parser-lalr.tab.c
--defines
=$(BG
)parser-lalr.tab.h \
87 --name-prefix
=rs
--warnings
=error
=all
89 $(BG
)parser-lalr.o
: $(BG
)parser-lalr.tab.c
91 $(Q
)$(CFG_CC
) -c
-o
$@
$<
93 $(BG
)parser-lalr-main.o
: $(SG
)parser-lalr-main.c
95 $(Q
)$(CFG_CC
) -std
=c99
-c
-o
$@
$<
97 $(BG
)parser-lalr
: $(BG
)parser-lalr.o
$(BG
)parser-lalr-main.o
$(BG
)lexer-lalr.o
99 $(Q
)$(CFG_CC
) -o
$@
$^
$(FLEX_LDFLAGS
)
104 check-grammar
: $(BG
) $(BG
)parser-lalr
105 $(info Verifying grammar ...
)
106 $(SG
)testparser.py
-p
$(BG
)parser-lalr
-s
$(S
)src
109 $(info cfg
: bison not available
, skipping parser
test...
)
114 $(info cfg
: flex not available
, skipping parser
test...
)