Debian Codegraph @

test/blackbox-tests/test-cases/foreign-stubs/cxx-flags.t/run.t

raw
1 Default: use_standard_c_and_cxx_flags = false
2 =============================================
3
4 $ make_dune_project 2.8
5
6 > The flags that Dune should use for compilation
7 $ GCC_CF="-x c++"
8 $ Clang_CF="-x c++"
9 $ Msvc_CF="/TP"
10
11 > And linking
12 $ GCC_LF_OPT=" -ldopt -lstdc++ -ldopt -shared-libgcc"
13 $ Clang_LF_OPT=" -ldopt -lc++"
14 $ Msvc_LF_OPT=""
15 $ GCC_LF_LIB=" -cclib -lstdc++ -cclib -shared-libgcc"
16 $ Clang_LF_LIB=" -cclib -lc++"
17 $ Msvc_LF_LIB=""
18
19 > Check that compiler detection is done
20 $ dune build .dune/cc_vendor/cc_vendor
21
22 $ cat _build/default/.dune/cc_vendor/cc_vendor |
23 > grep -ce "clang\|gcc\|msvc"
24 1
25
26 > No specific flags added for compilation...
27 $ dune rules baz.o | tr -s '\n' ' ' |
28 > grep -ce "$GCC_CF\|$Clang_CF|$Msvc_CF"
29 0
30 [1]
31
32 $ dune rules bazexe.o | tr -s '\n' ' ' |
33 > grep -ce "$GCC_CF\|$Clang_CF\|$Msvc_CF"
34 0
35 [1]
36
37 > ...nor linking
38 $ dune rules libquad_stubs.a | tr -s '\n' ' ' |
39 > grep -ce "quad_stubs baz.o)"
40 1
41
42 $ dune rules main.exe | tr -s '\n' ' ' |
43 > grep -ce "Main.cmx)"
44 1
45
46 With use_standard_c_and_cxx_flags = false
47 =========================================
48
49 $ cat >dune-project <<EOF
50 > (lang dune 2.8)
51 > (use_standard_c_and_cxx_flags false)
52 > EOF
53
54 > No specific flags added for compilation...
55 $ dune rules baz.o | tr -s '\n' ' ' |
56 > grep -ce "$GCC_CF\|$Clang_CF|$Msvc_CF"
57 0
58 [1]
59
60 $ dune rules bazexe.o | tr -s '\n' ' ' |
61 > grep -ce "$GCC_CF\|$Clang_CF\|$Msvc_CF"
62 0
63 [1]
64
65 > ...nor linking
66 $ dune rules libquad_stubs.a | tr -s '\n' ' ' |
67 > grep -ce "quad_stubs baz.o)"
68 1
69
70 $ dune rules main.exe | tr -s '\n' ' ' |
71 > grep -ce "Main.cmx)"
72 1
73
74 With use_standard_c_and_cxx_flags = true
75 ========================================
76
77 $ cat >dune-project <<EOF
78 > (lang dune 2.8)
79 > (use_standard_c_and_cxx_flags true)
80 > EOF
81
82 > Check that compiler detection is done
83 $ dune build .dune/cc_vendor/cc_vendor
84
85 $ cat _build/default/.dune/cc_vendor/cc_vendor |
86 > grep -ce "clang\|gcc\|msvc"
87 1
88
89 > Specific flags added for compilation...
90 $ dune rules baz.o | tr -s '\n' ' ' |
91 > grep -ce "$GCC_CF\|$Clang_CF\|$Msvc_CF"
92 1
93
94 $ dune rules bazexe.o | tr -s '\n' ' ' |
95 > grep -ce "$GCC_CF\|$Clang_CF\|$Msvc_CF"
96 1
97
98 > ..and link
99 $ dune rules libquad_stubs.a | tr -s '\n' ' ' |
100 > grep -ce "quad_stubs baz.o$GCC_LF_OPT)\|quad_stubs baz.o$Clang_LF_OPT)\|quad_stubs baz.o$Msvc_LF_OPT)"
101 1
102
103 $ dune rules main.exe | tr -s '\n' ' ' |
104 > grep -ce "Main.cmx$GCC_LF_LIB)\|Main.cmx$Clang_LF_LIB)\|Main.cmx$Msvc_LF_LIB)"
105 1
106
107 $ dune clean
108
109 $ dune exec ./main.exe
110 2046
111 4096
112 Hello World Baz!
113 Hello World Bazexe!
114
115 $ [ -f _build/default/.dune/cc_vendor/cc_vendor ]
116
117 (this also works with sandbox=symlink, #6415)
118
119 $ dune exec --sandbox symlink ./main.exe
120 2046
121 4096
122 Hello World Baz!
123 Hello World Bazexe!
124
125 cc_vendor is not computed if not required
126 =====================================
127 $ dune clean
128
129 $ dune exec ./sub/main_no_stubs.exe
130 OK
131
132 $ [ -f _build/default/.dune/cc_vendor/cc_vendor ]
133 [1]
134
135
136 one can extend link flags in env
137 ================================
138
139 $ OTHER=" --other-flag --yet-some-other-flag)"
140
141 $ dune rules sub/main.exe --profile some-profile | tr -s '\n' ' ' |
142 > grep -ce "Main.cmx$GCC_LF_LIB$OTHER\|Main.cmx$Clang_LF_LIB$OTHER\|Main.cmx$Msvc_LF_LIB$OTHER"
143 1
144