diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..9765bd2 --- /dev/null +++ b/.clangd @@ -0,0 +1,9 @@ +InlayHints: + Designators: No + Enabled: Yes + ParameterNames: No + DeducedTypes: No + +CompileFlags: + Add: [-std=c++17, -Wall, -Wextra, -Wpedantic, -Werror] + Compiler: clang++ \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ba2eaef..26de2b1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,20 +2,56 @@ name: ci on: push: - branches: [ "main" ] + branches: [ "main", "add-ci-test" ] pull_request: - branches: [ "main" ] + branches: [ "main", "add-ci-test" ] jobs: build: - runs-on: ${{ matrix.os }} + name: ${{matrix.platform.name}} + runs-on: ${{matrix.platform.os}} strategy: + fail-fast: false + matrix: - os: [ubuntu-latest, windows-latest] + platform: + # - { name: Windows VS2019, ls: dir, os: windows-2019, disp: type, sample: pgn_samples, testpgn: pgn_samples\\first.pgn, testuci: pgn_samples\\first, analyzedpgn: .\\pgn_samples\\first.analyzed.pgn, bin: .\\apgn.exe } + # - { name: Windows VS2022, ls: dir, os: windows-2022, disp: type, sample: pgn_samples, testpgn: pgn_samples\\first.pgn, testuci: pgn_samples\\first, analyzedpgn: .\\pgn_samples\\first.analyzed.pgn, bin: .\\apgn.exe } + # - { name: Windows-Clang, ls: dir, os: windows-latest, disp: type, sample: pgn_samples, testpgn: pgn_samples\\first.pgn, testuci: pgn_samples\\first, analyzedpgn: .\\pgn_samples\\first.analyzed.pgn, bin: .\\apgn.exe, flags: CC=clang CXX=clang++ } + - { name: Windows-GCC, ls: dir, os: windows-latest, disp: type, sample: pgn_samples, testpgn: pgn_samples\\first.pgn, testuci: pgn_samples\\first, analyzedpgn: .\\pgn_samples\\first.analyzed.pgn, bin: .\\apgn.exe, flags: CC=gcc CXX=g++ } + - { name: Linux-GCC, ls: ls, os: ubuntu-latest, disp: cat, sample: ./pgn_samples, testpgn: ./pgn_samples/first.pgn, testuci: ./pgn_samples/first, analyzedpgn: ./pgn_samples/first.analyzed.pgn, bin: ./apgn } + - { name: Linux-Clang, ls: ls, os: ubuntu-latest, disp: cat, sample: ./pgn_samples, testpgn: ./pgn_samples/first.pgn, testuci: ./pgn_samples/first, analyzedpgn: ./pgn_samples/first.analyzed.pgn, bin: ./apgn, flags: CC=clang CXX=clang++ } + # - { name: MacOS-XCode, ls: ls, os: macos-latest, disp: cat, sample: ./pgn_samples, testpgn: ./pgn_samples/first.pgn, testuci: ./pgn_samples/first, analyzedpgn: ./pgn_samples/first.analyzed.pgn, bin: ./apgn } steps: - uses: actions/checkout@v3 - - name: compile and build - run: make -j4 \ No newline at end of file + - run: echo "this is a test" > test.log + + - name: build for -> ${{matrix.platform.os}} + run: make ${{matrix.platform.flags}} -j4 + + - name: ready executable for execution + run: chmod a+rx ${{matrix.platform.bin}} + + - name: ready first.pgn for reading + run: chmod a+r ${{matrix.platform.testpgn}} + + - name: run test + run: ${{matrix.platform.bin}} -depth 5 ${{matrix.platform.testpgn}} + + - name: show files in current directory + run: ${{matrix.platform.ls}} + + - name: show files in sample pgn folder + run: ${{matrix.platform.ls}} ${{matrix.platform.sample}} + + - name: display pgn test subject + run: ${{matrix.platform.disp}} ${{matrix.platform.testpgn}} + + - name: display uci test subject + run: ${{matrix.platform.disp}} ${{matrix.platform.testuci}} + + - name: display results + run: ${{matrix.platform.disp}} ${{matrix.platform.analyzedpgn}} \ No newline at end of file diff --git a/Makefile b/Makefile index d907879..7f30c25 100644 --- a/Makefile +++ b/Makefile @@ -21,14 +21,14 @@ all: mv dependencies/uci-analyser/analyse bin/analyse ifeq ($(OS), Linux) - chmod +x bin/engines/stockfish + chmod a+rx bin/engines/stockfish else - chmod +x bin/engines/stockfish.exe + chmod a+rx bin/engines/stockfish.exe endif - ${CXX} ${CXX_FLAGS} main.cpp -o ${EXECUTABLE} + $(CXX) $(CXX_FLAGS) main.cpp -o $(EXECUTABLE) test: - ./${EXECUTABLE} ./pgn_samples/first.pgn W + ./$(EXECUTABLE) ./pgn_samples/first.pgn W test_clean: ifeq ($(OS), Linux) @@ -39,7 +39,7 @@ endif install: ifeq ($(OS), Linux) - @ln -s $(dir $(abspath $(lastword $(MAKEFILE_LIST))))${EXECUTABLE} ${INSTALLPATH} + @ln -s $(dir $(abspath $(lastword $(MAKEFILE_LIST))))$(EXECUTABLE) $(INSTALLPATH) else @echo "make install is not supported for windows" # SETX /M PATH "%PATH%;$(dir $(abspath $(lastword $(MAKEFILE_LIST))))" @@ -47,7 +47,7 @@ endif uninstall: ifeq ($(OS), Linux) - @rm ${INSTALLPATH}/${EXECUTABLE} + @rm $(INSTALLPATH)/$(EXECUTABLE) else @echo "make uninstall is not supported for windows" endif @@ -58,4 +58,4 @@ clean: @echo "removing uci-analyse object files" @$(MAKE) -C dependencies/uci-analyser clean @echo "removing analyse-pgn binaries files" - @rm ./bin/analyse${EXTENSION} ./bin/pgn-extract${EXTENSION} ./${EXECUTABLE} \ No newline at end of file + @rm ./bin/analyse$(EXTENSION) ./bin/pgn-extract$(EXTENSION) ./$(EXECUTABLE) \ No newline at end of file diff --git a/convert.hpp b/convert.hpp index 51d32a3..5057837 100755 --- a/convert.hpp +++ b/convert.hpp @@ -194,7 +194,7 @@ namespace apgn_convert wait(NULL); } #else - std::string analyse_executable_path = apgnFileSys::getExecpath()+"/bin/analyse"; + std::string analyse_executable_path = apgnFileSys::getExecpath()+"\\bin\\analyse"; std::string result_pgn; switch (apgn_COLOR) @@ -212,6 +212,11 @@ namespace apgn_convert throw std::runtime_error("something happend - error in convert.hpp"); break; } + + std::cout << "\n\n--------------------------- Results Output Debug : Start --------------------------- \n"; + std::cout << result_pgn << "\n"; + std::cout << "\n--------------------------- Results Output Debug : End --------------------------- \n"; + #endif // check if file exist diff --git a/dependencies/uci-analyser/Makefile b/dependencies/uci-analyser/Makefile index 6baf296..b5b4296 100755 --- a/dependencies/uci-analyser/Makefile +++ b/dependencies/uci-analyser/Makefile @@ -22,7 +22,7 @@ OS := $(shell uname) -CC=g++ +CXX=g++ ifeq ($(OS), Linux) # LINUX @@ -46,10 +46,10 @@ OBJS=analyse.o evaluation.o engine.o utils.o interpret.o TARGET=analyse .cpp.o: - $(CC) $(CFLAGS) $< -o $@ + $(CXX) $(CFLAGS) $< -o $@ $(TARGET) : $(OBJS) - $(CC) -o $@ $(OBJS) + $(CXX) -o $@ $(OBJS) clean: rm -f $(OBJS) $(TARGET) diff --git a/dependencies/uci-analyser/interpret.cpp b/dependencies/uci-analyser/interpret.cpp index f90b230..80ea6c2 100755 --- a/dependencies/uci-analyser/interpret.cpp +++ b/dependencies/uci-analyser/interpret.cpp @@ -1,5 +1,7 @@ +#include #include #include +#include #include "interpret.hpp" using namespace std; @@ -88,8 +90,14 @@ namespace interpret ofstream outfile; outfile.open(saveFile+".stats.txt",ios_base::out | ios_base::app); - outfile<<"==============================================================\n"; - outfile< cmdArguments) { + std::cout << "\nCommand : " << cmdline_in << ' '; + for (auto &e: cmdArguments) { + std::cout << e << ' '; + } + std::cout << '\n'; + PROCESS_INFORMATION processInfo; STARTUPINFOA startupInfo; SECURITY_ATTRIBUTES saAttr; @@ -24,7 +30,7 @@ namespace apgn std::string cmdline; // replace -> char cmdline[256]; std::string outbuf; // replace -> char outbuf[32768]; DWORD bytes_read; - char tBuf[257]; + char tBuf[257] = {}; DWORD exitcode; @@ -32,6 +38,10 @@ namespace apgn cmdline = std::string(cmdline_in); // replaced -> strcpy_s(cmdline, sizeof(cmdline), cmdline_in); + std::cout << "\n\n--------------------------- \"cmdline\" Debug : Start --------------------------- \n"; + std::cout << cmdline << "\n"; + std::cout << "\n--------------------------- \"cmdline\" Debug : End --------------------------- \n"; + memset(&saAttr, 0, sizeof(saAttr)); saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr.bInheritHandle = TRUE; @@ -53,7 +63,7 @@ namespace apgn memset(&startupInfo, 0, sizeof(startupInfo)); startupInfo.cb = sizeof(startupInfo); - // startupInfo.hStdError = stdoutWriteHandle; // not needed for my specific use case + startupInfo.hStdError = stdoutWriteHandle; // not needed for my specific use case startupInfo.hStdOutput = stdoutWriteHandle; startupInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE); startupInfo.dwFlags |= STARTF_USESTDHANDLES; @@ -89,17 +99,27 @@ namespace apgn if (!ReadFile(stdoutReadHandle, tBuf, 256, &bytes_read, NULL)) { // printf("ReadFile: %u\n", GetLastError()); // comment out, not needed for my specific use case + std::cerr << "ReadFile() - Error : " << GetLastError() << " (cannot open file)\n"; break; } + if (bytes_read > 0) { tBuf[bytes_read] = '\0'; outbuf += std::string(tBuf); // replaced -> strcat_s(outbuf, sizeof(outbuf), tBuf); } + std::string dotsLoad('.',loadingDot); std::cout<<"analysing moves("<