Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Create a simple makefile and allow regressions to use it. #1380

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,11 @@ cppfront/x64/Debug/microsoft/STL/std.compat.ixx.ifc.dt.module.json.command
cppfront/x64/Debug/microsoft/STL/std.ixx.ifc.dt.d.json
cppfront/x64/Debug/microsoft/STL/std.ixx.ifc.dt.module.json
cppfront/x64/Debug/microsoft/STL/std.ixx.ifc.dt.module.json.command

# Crashes and hangs
crashes/
hangs/

# Generated files
cppfront.exe

45 changes: 45 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2022-2025 Herb Sutter
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
# Part of the Cppfront Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://github.com/hsutter/cppfront/blob/main/LICENSE for license information.
#
# This Makefile is strictly optional and is just a convenience for building cppfront.
# You can also build cppfront by running the cppfront.cpp source file through your
# C++ compiler in the normal manner.

all: cppfront.exe source/reflect.h include/cpp2regex.h

CXX ?= g++
CPPFRONT ?= ./cppfront.exe
CFLAGS ?=

CFLAGS += -Wall -Werror -Wextra -Wpedantic

ifeq (${DEBUG},1)
CFLAGS += -g
endif
ifeq (${RELEASE},1)
CFLAGS += -O3
endif
ifeq (${PROFILE},1)
CFLAGS += -pg
endif
ifeq (${SANITIZE},1)
CFLAGS += -fsanitize=address -fsanitize=undefined
endif
ifeq (${COVERAGE},1)
CFLAGS += --coverage
endif

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
${CXX} -std=c++20 -o cppfront.exe -Iinclude ${CFLAGS} source/cppfront.cpp

include/cpp2regex.h: include/cpp2regex.h2
${CPPFRONT} include/cpp2regex.h2 -o include/cpp2regex.h

source/reflect.h: source/reflect.h2
${CPPFRONT} source/reflect.h2 -o source/reflect.h

clean:
rm -f cppfront.exe
29 changes: 20 additions & 9 deletions regression-tests/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

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

Expand Down Expand Up @@ -89,7 +91,7 @@ check_file () {
fi
}

optstring="c:s:d:l:t:"
optstring="c:s:d:l:t:e:"
while getopts ${optstring} arg; do
case "${arg}" in
c)
Expand All @@ -104,6 +106,9 @@ while getopts ${optstring} arg; do
l)
label="${OPTARG}"
;;
e)
executable="${OPTARG}"
;;
t)
# Replace commas with spaces
chosen_tests=${OPTARG//,/ }
Expand Down Expand Up @@ -177,7 +182,9 @@ else
"$compiler_version" == *"g++-13"*
]]; then
exec_out_dir="$expected_results_dir/gcc-13"
elif [[ "$compiler_version" == *"g++-14"* ]]; then
elif [[ "$compiler_version" == *"g++-14"* ||
"$compiler_version" == *"g++ (Ubuntu 14"*
]]; then
exec_out_dir="$expected_results_dir/gcc-14"
else
printf "Unhandled compiler version:\n$compiler_version\n\n"
Expand Down Expand Up @@ -250,12 +257,16 @@ else
fi

################
cppfront_cmd="cppfront.exe"
echo "Building cppfront"
$compiler_cmd"$cppfront_cmd" ../source/cppfront.cpp
if [[ $? -ne 0 ]]; then
echo "Compilation failed"
exit 2
if [ -z "$executable" ]; then
cppfront_cmd="cppfront.exe"
echo "Building cppfront"
$compiler_cmd"$cppfront_cmd" ../source/cppfront.cpp
if [[ $? -ne 0 ]]; then
echo "Compilation failed"
exit 2
fi
else
cppfront_cmd="$executable"
fi

################
Expand Down