aboutsummaryrefslogtreecommitdiff
path: root/tests/cc/modules/testscript
blob: 8f6fd965416d1d26d120d419de4b34844e0a8aaa (plain)
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
# file      : tests/cc/modules/testscript
# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
# license   : MIT; see accompanying LICENSE file

crosstest = false
test.arguments = config.cxx="$recall($cxx.path)"

.include ../../common.test

+cat <<EOI >+build/bootstrap.build
using test
EOI

+cat <<EOI >=build/root.build
cxx.std = experimental
cxx.features.modules = true

using cxx

hxx{*}: extension = hxx
mxx{*}: extension = mxx
cxx{*}: extension = cxx

exe{*}: test = true
EOI

# Determine if we have module support.
#
+$* noop <<EOI | set modules
print $cxx.features.modules
EOI

: enabled
:
if $modules
{

# Common source files that are symlinked (@@ TODO: ln builtin) in the
# test directories if used.
#
+cat <<EOI >=test.mxx
#if __cpp_modules >= 201704
export
#endif
module foo.test;

export int f (int);
EOI

+cat <<EOI >=test.cxx
module foo.test;
int f (int i) {return i - 1;}
EOI

+cat <<EOI >=driver.cxx
import foo.test;
int main (int argc, char*[]) {return f (argc);}
EOI

: bmi-combined
:
: Test combined interface/implementation unit specified as bmi{}.
:
if ($cxx.id != "gcc")
cp ../test.mxx ./ && cat >+test.mxx <<EOI #;
  int f (int i) {return i - 1;}
  EOI
cp ../driver.cxx ./ #;
$* test clean <<EOI
  exe{test}: cxx{driver} bmi{test}
  bmi{test}: mxx{test}
  EOI
end

: mxx-combined
:
: Test combined interface/implementation unit specified as mxx{}.
:
if ($cxx.id != "gcc")
cp ../test.mxx ./ && cat >+test.mxx <<EOI #;
  int f (int i) {return i - 1;}
  EOI
cp ../driver.cxx ./ #;
$* test clean <<EOI
  exe{test}: cxx{driver} mxx{test}
  EOI
end

: bmi-separate
:
: Test separate interface/implementation unit specified as bmi{}.
:
cp ../test.mxx ../test.cxx ../driver.cxx ./;
$* test clean <<EOI
  exe{test}: cxx{driver} {bmi cxx}{test}
  bmi{test}: mxx{test}
  EOI

: mxx-separate
:
: Test separate interface/implementation unit specified as mxx{}.
:
cp ../test.mxx ../test.cxx ../driver.cxx ./;
$* test clean <<EOI
  exe{test}: cxx{driver} {mxx cxx}{test}
  EOI
}