-
Notifications
You must be signed in to change notification settings - Fork 411
/
run.t
138 lines (104 loc) · 3.08 KB
/
run.t
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
Default: use_standard_c_and_cxx_flags = false
=============================================
$ cat >dune-project <<EOF
> (lang dune 2.8)
> EOF
> The flags that Dune should use for compilation
$ GCC_CF="-x c++"
$ Clang_CF="-x c++"
$ Msvc_CF="/TP"
> And linking
$ GCC_LF_OPT=" -ldopt -lstdc++ -ldopt -shared-libgcc"
$ Clang_LF_OPT=" -ldopt -lc++"
$ Msvc_LF_OPT=""
$ GCC_LF_LIB=" -cclib -lstdc++ -cclib -shared-libgcc"
$ Clang_LF_LIB=" -cclib -lc++"
$ Msvc_LF_LIB=""
> Check that compiler detection is done
$ dune build .dune/ccomp/ccomp
$ cat _build/default/.dune/ccomp/ccomp |
> grep -ce "clang\|gcc\|msvc"
1
> No specific flags added for compilation...
$ dune rules baz.o | tr -s '\n' ' ' |
> grep -ce "$GCC_CF\|$Clang_CF|$Msvc_CF"
0
[1]
$ dune rules bazexe.o | tr -s '\n' ' ' |
> grep -ce "$GCC_CF\|$Clang_CF\|$Msvc_CF"
0
[1]
> ...nor linking
$ dune rules libquad_stubs.a | tr -s '\n' ' ' |
> grep -ce "quad_stubs baz.o)"
1
$ dune rules main.exe | tr -s '\n' ' ' |
> grep -ce "Main.cmx)"
1
With use_standard_c_and_cxx_flags = false
=========================================
$ cat >dune-project <<EOF
> (lang dune 2.8)
> (use_standard_c_and_cxx_flags false)
> EOF
> No specific flags added for compilation...
$ dune rules baz.o | tr -s '\n' ' ' |
> grep -ce "$GCC_CF\|$Clang_CF|$Msvc_CF"
0
[1]
$ dune rules bazexe.o | tr -s '\n' ' ' |
> grep -ce "$GCC_CF\|$Clang_CF\|$Msvc_CF"
0
[1]
> ...nor linking
$ dune rules libquad_stubs.a | tr -s '\n' ' ' |
> grep -ce "quad_stubs baz.o)"
1
$ dune rules main.exe | tr -s '\n' ' ' |
> grep -ce "Main.cmx)"
1
With use_standard_c_and_cxx_flags = true
========================================
$ cat >dune-project <<EOF
> (lang dune 2.8)
> (use_standard_c_and_cxx_flags true)
> EOF
> Check that compiler detection is done
$ dune build .dune/ccomp/ccomp
$ cat _build/default/.dune/ccomp/ccomp |
> grep -ce "clang\|gcc\|msvc"
1
> Specific flags added for compilation...
$ dune rules baz.o | tr -s '\n' ' ' |
> grep -ce "$GCC_CF\|$Clang_CF\|$Msvc_CF"
1
$ dune rules bazexe.o | tr -s '\n' ' ' |
> grep -ce "$GCC_CF\|$Clang_CF\|$Msvc_CF"
1
> ..and link
$ dune rules libquad_stubs.a | tr -s '\n' ' ' |
> grep -ce "quad_stubs baz.o$GCC_LF_OPT)\|quad_stubs baz.o$Clang_LF_OPT)\|quad_stubs baz.o$Msvc_LF_OPT)"
1
$ dune rules main.exe | tr -s '\n' ' ' |
> grep -ce "Main.cmx$GCC_LF_LIB)\|Main.cmx$Clang_LF_LIB)\|Main.cmx$Msvc_LF_LIB)"
1
$ dune clean
$ dune exec ./main.exe
2046
4096
Hello World Baz!
Hello World Bazexe!
$ [ -f _build/default/.dune/ccomp/ccomp ]
ccomp is not computed if not required
=====================================
$ dune clean
$ dune exec ./sub/main_no_stubs.exe
OK
$ [ -f _build/default/.dune/ccomp/ccomp ]
[1]
one can extend link flags in env
================================
$ OTHER=" --other-flag --yet-some-other-flag)"
$ dune rules sub/main.exe --profile some-profile | tr -s '\n' ' ' |
> grep -ce "Main.cmx$GCC_LF_LIB$OTHER\|Main.cmx$Clang_LF_LIB$OTHER\|Main.cmx$Msvc_LF_LIB$OTHER"
1