-
Notifications
You must be signed in to change notification settings - Fork 0
/
scons_tests.py
90 lines (79 loc) · 1.97 KB
/
scons_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
## Windstille - A Sci-Fi Action-Adventure Game
## Copyright (C) 2000,2005 Ingo Ruhnke <grumbel@gmx.de>
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
# YACC
yacc_test_text = """
%{
#include <stdio.h>
/* MSVC++ needs this before it can swallow Bison output */
#ifdef _MSC_VER
# define __STDC__
#endif
%}
%token MSG
%start ROOT
%%
ROOT:
MSG { printf("HELLO"); }
;
%%
"""
def CheckYacc(context):
context.Message("Checking for Yacc ('%s')... " % context.env.get('YACC'))
is_ok = context.TryCompile(yacc_test_text,".y")
context.Result(is_ok)
return is_ok
# LEX
lex_test_text = """
%{
#include <stdio.h>
%}
DIGIT [0-9]
ID [a-z][a-z0-9]*
%%
{DIGIT}+ {
printf("A digit: %s\\n",yytext);
}
[ \\t\\n]+ /* ignore */
. {
printf("Unrecognized guff");
}
%%
main(){
yylex();
}
"""
def CheckLex(context):
context.Message("Checking for Lex ('%s')... " % context.env.get('LEX'))
is_ok = context.TryCompile(lex_test_text,".l")
context.Result(is_ok)
return is_ok
def Check32bit(context):
check32bit_test_source_file = """
#include <stdio.h>
int main()
{
printf("%dbit", sizeof(void*)*8);
return 0;
}
"""
context.Message('Checking for bits... ')
(suc, output) = context.TryRun(check32bit_test_source_file, '.cpp')
if suc:
context.Result(output)
else:
context.Result("test error")
return output
# EOF #