Skip to content
Draft
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
4 changes: 2 additions & 2 deletions .github/workflows/CI-unixish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ jobs:
sudo apt-get install valgrind
- name: Install missing software on ubuntu (clang++)
if: matrix.os == 'ubuntu-24.04' && matrix.compiler == 'clang++'
if: contains(matrix.os, 'ubuntu') && matrix.compiler == 'clang++'
run: |
sudo apt-get update
sudo apt-get install libc++-18-dev
sudo apt-get install libc++-dev
# coreutils contains "nproc"
- name: Install missing software on macos
Expand Down
66 changes: 0 additions & 66 deletions .github/workflows/CI-windows.yml

This file was deleted.

44 changes: 0 additions & 44 deletions .github/workflows/clang-tidy.yml

This file was deleted.

62 changes: 0 additions & 62 deletions .github/workflows/format.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test: testrunner simplecpp
python3 -m pytest integration_test.py -vv

selfcheck: simplecpp
./selfcheck.sh
CXX=$(CXX) ./selfcheck.sh

simplecpp: main.o simplecpp.o
$(CXX) $(LDFLAGS) main.o simplecpp.o -o simplecpp
Expand Down
5 changes: 5 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ int main(int argc, char **argv)
}
case 'I': { // include path
const char * const value = arg[2] ? (argv[i] + 2) : argv[++i];
std::ifstream f(value);
if (!f.is_open()) {
std::cout << "error: include path '" << value << "' does not exist" << std::endl;
std::exit(1);
}
dui.includePaths.push_back(value);
found = true;
break;
Expand Down
109 changes: 107 additions & 2 deletions selfcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,113 @@ output=$(./simplecpp simplecpp.cpp -e -f 2>&1)
ec=$?
errors=$(echo "$output" | grep -v 'Header not found: <')
if [ $ec -ne 0 ]; then
# only fail if got errors which do not refer to missing system includes
# only fail if we got errors which do not refer to missing system includes
if [ ! -z "$errors" ]; then
exit $ec
fi
fi
fi

if [ -z "$CXX" ]; then
exit 0
fi

cxx_type=$($CXX --version | head -1 | cut -d' ' -f1)
if [ "$cxx_type" = "Ubuntu" ]; then
cxx_type=$($CXX --version | head -1 | cut -d' ' -f2)
fi
# TODO: how to get built-in include paths from compiler?
if [ "$cxx_type" = "g++" ]; then
gcc_ver=$($CXX -dumpversion)
defs=
defs="$defs -D__GNUC__"
defs="$defs -D__STDC__"
defs="$defs -D__STDC_HOSTED__"
defs="$defs -D__CHAR_BIT__=8"
defs="$defs -D__x86_64__"
defs="$defs -D__has_builtin(x)=(1)"
defs="$defs -D__has_cpp_attribute(x)=(1)"
defs="$defs -D__has_attribute(x)=(1)"
# some required include paths might differ per distro
inc=
inc="$inc -I/usr/include"
inc="$inc -I/usr/include/linux"
inc="$inc -I/usr/include/c++/$gcc_ver"
if [ -d "/usr/include/c++/$gcc_ver/x86_64-pc-linux-gnu" ]; then
inc="$inc -I/usr/include/c++/$gcc_ver/x86_64-pc-linux-gnu"
fi
if [ -d "/usr/lib/gcc/x86_64-pc-linux-gnu/$gcc_ver/include" ]; then
inc="$inc -I/usr/lib/gcc/x86_64-pc-linux-gnu/$gcc_ver/include"
fi
if [ -d "/usr/lib/gcc/x86_64-linux-gnu/$gcc_ver/include" ]; then
inc="$inc -I/usr/lib/gcc/x86_64-linux-gnu/$gcc_ver/include"
fi
if [ -d "/usr/include/x86_64-linux-gnu" ]; then
inc="$inc -I/usr/include/x86_64-linux-gnu"
inc="$inc -I/usr/include/x86_64-linux-gnu/c++/$gcc_ver"
fi
./simplecpp simplecpp.cpp -e -f -std=gnu++11 $defs $inc
ec=$?
if [ $ec -ne 0 ]; then
exit $ec
fi
elif [ "$cxx_type" = "clang" ]; then
clang_ver=$($CXX -dumpversion)
clang_ver=${clang_ver%%.*}
defs=
defs="$defs -D__BYTE_ORDER__"
defs="$defs -D__linux__"
defs="$defs -D__x86_64__"
defs="$defs -D__SIZEOF_SIZE_T__=8"
defs="$defs -D__has_feature(x)=(1)"
defs="$defs -D__has_extension(x)=(1)"
defs="$defs -D__has_attribute(x)=(0)"
defs="$defs -D__has_cpp_attribute(x)=(0)"
defs="$defs -D__has_include_next(x)=(0)"
defs="$defs -D__has_builtin(x)=(1)"
# some required include paths might differ per distro
inc=
if [ -d "/usr/include/c++/v1" ]; then
inc="$inc -I/usr/include/c++/v1"
fi
if [ -d "/usr/lib/llvm-$clang_ver/include/c++/v1" ]; then
inc="$inc -I/usr/lib/llvm-$clang_ver/include/c++/v1"
fi
inc="$inc -I/usr/include"
inc="$inc -I/usr/lib/clang/$clang_ver/include"
if [ -d "/usr/include/x86_64-linux-gnu" ]; then
inc="$inc -I/usr/include/x86_64-linux-gnu"
fi
./simplecpp simplecpp.cpp -e -f -std=gnu++11 $defs $inc
ec=$?
if [ $ec -ne 0 ]; then
exit $ec
fi
elif [ "$cxx_type" = "Apple" ]; then
xcode_path="/Applications/Xcode_16.4.app"
if [ ! -d "$xcode_path" ]; then
xcode_path="/Applications/Xcode_15.2.app"
fi
sdk_path="$xcode_path/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
defs=
defs="$defs -D__BYTE_ORDER__"
defs="$defs -D__APPLE__"
defs="$defs -D__GNUC__=15"
defs="$defs -D__x86_64__"
defs="$defs -D__has_feature(x)=(1)"
defs="$defs -D__has_extension(x)=(1)"
defs="$defs -D__has_attribute(x)=(0)"
defs="$defs -D__has_cpp_attribute(x)=(0)"
defs="$defs -D__has_include_next(x)=(0)"
inc=
inc="$inc -I$sdk_path/usr/include/c++/v1"
inc="$inc -I$sdk_path/usr/include"
inc="$inc -I$sdk_path/usr/include/i386"
./simplecpp simplecpp.cpp -e -f -std=gnu++11 $defs $inc
ec=$?
if [ $ec -ne 0 ]; then
exit $ec
fi
else
echo "unknown compiler '$cxx_type'"
exit 1
fi
Loading