diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml index ff7c3f65..b0523507 100644 --- a/.github/workflows/CI-unixish.yml +++ b/.github/workflows/CI-unixish.yml @@ -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 }} @@ -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: | diff --git a/Makefile b/Makefile index 4a6ae6b7..525669eb 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/main.cpp b/main.cpp index a6d14386..747f041b 100644 --- a/main.cpp +++ b/main.cpp @@ -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; diff --git a/selfcheck.sh b/selfcheck.sh index a43ef8c5..5cf7beb1 100755 --- a/selfcheck.sh +++ b/selfcheck.sh @@ -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 \ No newline at end of file +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