Skip to content

selfcheck.sh: also run with system includes made available #438

New issue

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

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

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
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
14 changes: 10 additions & 4 deletions .github/workflows/CI-unixish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ jobs:

strategy:
matrix:
compiler: [clang++, g++]
os: [ubuntu-22.04, ubuntu-24.04, macos-13, macos-14, macos-15]
compiler: [clang++]
include:
- os: ubuntu-22.04
compiler: g++
- os: ubuntu-24.04
compiler: g++
fail-fast: false

runs-on: ${{ matrix.os }}
Expand All @@ -26,15 +31,16 @@ 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
if: contains(matrix.os, 'macos')
run: |
brew install python3
brew install coreutils

- name: Install missing Python packages
run: |
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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
48 changes: 46 additions & 2 deletions selfcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,52 @@ 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
if [ "$cxx_type" = "g++" ]; then
gcc_ver=$($CXX -dumpversion)
./simplecpp simplecpp.cpp -e -f -std=gnu++11 -D__GNUC__ -D__STDC__ -D__STDC_HOSTED__ -D__CHAR_BIT__=8 -I"/usr/include" -I"/usr/include/linux" -I"/usr/include/c++/$gcc_ver" -I"/usr/include/x86_64-linux-gnu/c++/$gcc_ver"
ec=$?
if [ $ec -ne 0 ]; then
exit $ec
fi
elif [ "$cxx_type" = "clang" ]; then
clang_ver=$($CXX -dumpversion)
clang_ver=${clang_ver%%.*}
find /usr/include -name stubs-32.h
cxx_inc="/usr/include/c++/v1"
if [ ! -d "$cxx_inc" ]; then
cxx_inc="/usr/lib/llvm-$clang_ver/include/c++/v1"
fi
./simplecpp simplecpp.cpp -e -f -std=gnu++11 -D__BYTE_ORDER__ -D__linux__ -I"$cxx_inc" -I"/usr/include" -I"/usr/include/x86_64-linux-gnu"
ec=$?
if [ $ec -ne 0 ]; then
exit $ec
fi
elif [ "$cxx_type" = "Apple" ]; then
find /Applications -name endian.h
xcode_path="/Applications/Xcode_16.4.app"
if [ ! -d "$xcode_path" ]; then
xcode_path="/Applications/Xcode_15.2.app"
fi
./simplecpp simplecpp.cpp -e -f -std=gnu++11 -D__BYTE_ORDER__ -D__APPLE__ -I"$xcode_path/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include" -I"$xcode_path/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1"
ec=$?
if [ $ec -ne 0 ]; then
exit $ec
fi
else
echo "unknown compiler '$cxx_type'"
exit 1
fi
Loading