Skip to content

Commit ad30ca6

Browse files
committed
Create a simple makefile and allow regressions to use it.
1 parent b2d4020 commit ad30ca6

File tree

3 files changed

+73
-9
lines changed

3 files changed

+73
-9
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,11 @@ cppfront/x64/Debug/microsoft/STL/std.compat.ixx.ifc.dt.module.json.command
4646
cppfront/x64/Debug/microsoft/STL/std.ixx.ifc.dt.d.json
4747
cppfront/x64/Debug/microsoft/STL/std.ixx.ifc.dt.module.json
4848
cppfront/x64/Debug/microsoft/STL/std.ixx.ifc.dt.module.json.command
49+
50+
# Crashes and hangs
51+
crashes/
52+
hangs/
53+
54+
# Generated files
55+
cppfront.exe
56+

Makefile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright 2022-2025 Herb Sutter
2+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
#
4+
# Part of the Cppfront Project, under the Apache License v2.0 with LLVM Exceptions.
5+
# See https://github.com/hsutter/cppfront/blob/main/LICENSE for license information.
6+
#
7+
# This Makefile is strictly optional and is just a convenience for building cppfront.
8+
# You can also build cppfront by running the cppfront.cpp source file through your
9+
# C++ compiler in the normal manner.
10+
11+
all: cppfront.exe source/reflect.h include/cpp2regex.h
12+
13+
CXX ?= g++
14+
CPPFRONT ?= ./cppfront.exe
15+
CFLAGS ?=
16+
17+
CFLAGS += -Wall -Werror -Wextra -Wpedantic
18+
19+
ifeq (${DEBUG},1)
20+
CFLAGS += -g
21+
endif
22+
ifeq (${RELEASE},1)
23+
CFLAGS += -O3
24+
endif
25+
ifeq (${PROFILE},1)
26+
CFLAGS += -pg
27+
endif
28+
ifeq (${SANITIZE},1)
29+
CFLAGS += -fsanitize=address -fsanitize=undefined
30+
endif
31+
ifeq (${COVERAGE},1)
32+
CFLAGS += --coverage
33+
endif
34+
35+
cppfront.exe: source/cppfront.cpp source/common.h source/cpp2regex.h include/cpp2regex.h source/cpp2util.h include/cpp2util.h source/io.h source/lex.h source/parse.h source/reflect.h source/sema.h source/to_cpp1.h
36+
${CXX} -std=c++20 -o cppfront.exe -Iinclude ${CFLAGS} source/cppfront.cpp
37+
38+
include/cpp2regex.h: include/cpp2regex.h2
39+
${CPPFRONT} include/cpp2regex.h2 -o include/cpp2regex.h
40+
41+
source/reflect.h: source/reflect.h2
42+
${CPPFRONT} source/reflect.h2 -o source/reflect.h
43+
44+
clean:
45+
rm -f cppfront.exe

regression-tests/run-tests.sh

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
################
44
usage() {
5-
echo "Usage: $0 -c <compiler> [-l <run label>] [-t <tests to run>]"
5+
echo "Usage: $0 -c <compiler> [-l <run label>] [-t <tests to run>] [-e <executable>]"
66
echo " -c <compiler> The compiler to use for the test"
77
echo " -s <cxx_std> The C++ standard to compile with (e.g. 'c++20', 'c++2b', 'c++latest' depending on the compiler)"
88
echo " -d <stdlib> Clang-only: the C++ Standard Library to link with ('libstdc++', 'libc++', or 'default' for platform default)"
99
echo " -l <run label> The label to use in output patch file name"
1010
echo " -t <tests to run> Runs only the provided, comma-separated tests (filenames including .cpp2)"
1111
echo " If the argument is not used all tests are run"
12+
echo " -e <executable> Use the provided cppfront executable for the test"
13+
echo " If the argument is not used run-tests will build cppfront"
1214
exit 1
1315
}
1416

@@ -89,7 +91,7 @@ check_file () {
8991
fi
9092
}
9193

92-
optstring="c:s:d:l:t:"
94+
optstring="c:s:d:l:t:e:"
9395
while getopts ${optstring} arg; do
9496
case "${arg}" in
9597
c)
@@ -104,6 +106,9 @@ while getopts ${optstring} arg; do
104106
l)
105107
label="${OPTARG}"
106108
;;
109+
e)
110+
executable="${OPTARG}"
111+
;;
107112
t)
108113
# Replace commas with spaces
109114
chosen_tests=${OPTARG//,/ }
@@ -177,7 +182,9 @@ else
177182
"$compiler_version" == *"g++-13"*
178183
]]; then
179184
exec_out_dir="$expected_results_dir/gcc-13"
180-
elif [[ "$compiler_version" == *"g++-14"* ]]; then
185+
elif [[ "$compiler_version" == *"g++-14"* ||
186+
"$compiler_version" == *"g++ (Ubuntu 14"*
187+
]]; then
181188
exec_out_dir="$expected_results_dir/gcc-14"
182189
else
183190
printf "Unhandled compiler version:\n$compiler_version\n\n"
@@ -250,12 +257,16 @@ else
250257
fi
251258

252259
################
253-
cppfront_cmd="cppfront.exe"
254-
echo "Building cppfront"
255-
$compiler_cmd"$cppfront_cmd" ../source/cppfront.cpp
256-
if [[ $? -ne 0 ]]; then
257-
echo "Compilation failed"
258-
exit 2
260+
if [ -z "$executable" ]; then
261+
cppfront_cmd="cppfront.exe"
262+
echo "Building cppfront"
263+
$compiler_cmd"$cppfront_cmd" ../source/cppfront.cpp
264+
if [[ $? -ne 0 ]]; then
265+
echo "Compilation failed"
266+
exit 2
267+
fi
268+
else
269+
cppfront_cmd="$executable"
259270
fi
260271

261272
################

0 commit comments

Comments
 (0)