diff --git a/.clang-tidy b/.clang-tidy index 19508860132..62047bd3966 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -70,7 +70,7 @@ Checks: > -readability-suspicious-call-argument, -readability-uppercase-literal-suffix WarningsAsErrors: '*' -HeaderFilterRegex: '(cli|gui|lib|oss-fuzz|test|triage)\/[a-z_]+\.h' +HeaderFilterRegex: '(cli|gui|frontend|lib|oss-fuzz|test|triage)\/[a-z_]+\.h' ExcludeHeaderFilterRegex: 'ui_.*.h' CheckOptions: - key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml index 62adc9a62c5..964948b4fb9 100644 --- a/.github/workflows/CI-unixish.yml +++ b/.github/workflows/CI-unixish.yml @@ -523,7 +523,7 @@ jobs: ./cppcheck $selfcheck_options externals || ec=1 # self check lib/cli mkdir b1 - ./cppcheck $selfcheck_options $cppcheck_options --cppcheck-build-dir=b1 --addon=naming.json cli || ec=1 + ./cppcheck $selfcheck_options $cppcheck_options --cppcheck-build-dir=b1 --addon=naming.json cli frontend || ec=1 ./cppcheck $selfcheck_options $cppcheck_options --cppcheck-build-dir=b1 --addon=naming.json --enable=internal lib || ec=1 # check gui with qt settings mkdir b2 diff --git a/.github/workflows/asan.yml b/.github/workflows/asan.yml index 3e8fc4053f1..44b490cbf94 100644 --- a/.github/workflows/asan.yml +++ b/.github/workflows/asan.yml @@ -145,7 +145,7 @@ jobs: cppcheck_options="-D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2" ec=0 ./cmake.output/bin/cppcheck $selfcheck_options externals || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json cli || ec=1 + ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json cli frontend || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json --enable=internal lib || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -DQT_VERSION=0x060000 -DQ_MOC_OUTPUT_REVISION=69 -DQT_CHARTS_LIB -DQT_MOC_HAS_STRINGDATA --library=qt --addon=naming.json -Icmake.output/gui -Igui gui/*.cpp cmake.output/gui/*.cpp || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -Icli test/*.cpp tools/dmake/*.cpp || ec=1 diff --git a/.github/workflows/tsan.yml b/.github/workflows/tsan.yml index 2f6b1ef38e0..3fa13777bd8 100644 --- a/.github/workflows/tsan.yml +++ b/.github/workflows/tsan.yml @@ -148,7 +148,7 @@ jobs: cppcheck_options="-D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2" ec=0 ./cmake.output/bin/cppcheck $selfcheck_options externals || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json cli || ec=1 + ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json cli frontend || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json --enable=internal lib || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -DQT_VERSION=0x060000 -DQ_MOC_OUTPUT_REVISION=69 -DQT_CHARTS_LIB -DQT_MOC_HAS_STRINGDATA --library=qt --addon=naming.json -Icmake.output/gui -Igui gui/*.cpp cmake.output/gui/*.cpp || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -Icli test/*.cpp tools/dmake/*.cpp || ec=1 diff --git a/.github/workflows/ubsan.yml b/.github/workflows/ubsan.yml index 5720cbf35d5..349be66c201 100644 --- a/.github/workflows/ubsan.yml +++ b/.github/workflows/ubsan.yml @@ -142,7 +142,7 @@ jobs: cppcheck_options="-D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2" ec=0 ./cmake.output/bin/cppcheck $selfcheck_options externals || ec=1 - ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json cli || ec=1 + ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json cli frontend || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json --enable=internal lib || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -DQT_VERSION=0x060000 -DQ_MOC_OUTPUT_REVISION=69 -DQT_CHARTS_LIB -DQT_MOC_HAS_STRINGDATA --library=qt --addon=naming.json -Icmake.output/gui -Igui gui/*.cpp cmake.output/gui/*.cpp || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -Icli test/*.cpp tools/dmake/*.cpp || ec=1 diff --git a/CMakeLists.txt b/CMakeLists.txt index a47d5fc6257..a99ce95e6ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,6 +101,7 @@ if(USE_BUNDLED_TINYXML2) endif() add_subdirectory(externals/simplecpp) add_subdirectory(lib) # CppCheck Library +add_subdirectory(frontend) add_subdirectory(cli) # Client application add_subdirectory(test) # Tests add_subdirectory(gui) # Graphical application diff --git a/Makefile b/Makefile index 2a72e243844..4d7b43b7b29 100644 --- a/Makefile +++ b/Makefile @@ -162,8 +162,12 @@ ifndef INCLUDE_FOR_LIB INCLUDE_FOR_LIB=-Ilib -isystem externals -isystem externals/picojson -isystem externals/simplecpp -isystem externals/tinyxml2 endif +ifndef INCLUDE_FOR_FE + INCLUDE_FOR_FE=-Ilib +endif + ifndef INCLUDE_FOR_CLI - INCLUDE_FOR_CLI=-Ilib -isystem externals/picojson -isystem externals/simplecpp -isystem externals/tinyxml2 + INCLUDE_FOR_CLI=-Ilib -Ifrontend -isystem externals/picojson -isystem externals/simplecpp -isystem externals/tinyxml2 endif ifndef INCLUDE_FOR_TEST @@ -252,6 +256,8 @@ LIBOBJ = $(libcppdir)/valueflow.o \ EXTOBJ = externals/simplecpp/simplecpp.o \ externals/tinyxml2/tinyxml2.o +FEOBJ = frontend/frontend.o + CLIOBJ = cli/cmdlineparser.o \ cli/cppcheckexecutor.o \ cli/executor.o \ @@ -344,12 +350,12 @@ TESTOBJ = test/fixture.o \ ###### Targets -cppcheck: $(EXTOBJ) $(LIBOBJ) $(CLIOBJ) +cppcheck: $(EXTOBJ) $(LIBOBJ) $(FEOBJ) $(CLIOBJ) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^ $(LIBS) $(LDFLAGS) $(RDYNAMIC) all: cppcheck testrunner -testrunner: $(EXTOBJ) $(TESTOBJ) $(LIBOBJ) cli/cmdlineparser.o cli/cppcheckexecutor.o cli/executor.o cli/filelister.o cli/processexecutor.o cli/sehwrapper.o cli/signalhandler.o cli/singleexecutor.o cli/stacktrace.o cli/threadexecutor.o +testrunner: $(EXTOBJ) $(TESTOBJ) $(LIBOBJ) $(FEOBJ) cli/cmdlineparser.o cli/cppcheckexecutor.o cli/executor.o cli/filelister.o cli/processexecutor.o cli/sehwrapper.o cli/signalhandler.o cli/singleexecutor.o cli/stacktrace.o cli/threadexecutor.o $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^ $(LIBS) $(LDFLAGS) $(RDYNAMIC) test: all @@ -653,6 +659,9 @@ $(libcppdir)/vf_settokenvalue.o: lib/vf_settokenvalue.cpp lib/addoninfo.h lib/as $(libcppdir)/vfvalue.o: lib/vfvalue.cpp lib/config.h lib/errortypes.h lib/mathlib.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vfvalue.cpp +frontend/frontend.o: frontend/frontend.cpp frontend/frontend.h + $(CXX) ${INCLUDE_FOR_FE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ frontend/frontend.cpp + cli/cmdlineparser.o: cli/cmdlineparser.cpp cli/cmdlinelogger.h cli/cmdlineparser.h cli/filelister.h externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/importproject.h lib/library.h lib/mathlib.h lib/path.h lib/pathmatch.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/utils.h lib/xml.h $(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/cmdlineparser.cpp diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt index dc13dba1403..8ea47196350 100644 --- a/cli/CMakeLists.txt +++ b/cli/CMakeLists.txt @@ -6,7 +6,7 @@ if (BUILD_CLI) list(REMOVE_ITEM srcs ${mainfile}) add_library(cli_objs OBJECT ${hdrs} ${srcs}) - target_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/lib/) + target_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/lib/ ${PROJECT_SOURCE_DIR}/frontend/) if(USE_BUNDLED_TINYXML2) target_externals_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/) else() @@ -26,7 +26,7 @@ if (BUILD_CLI) set_source_files_properties(processexecutor.cpp PROPERTIES COMPILE_FLAGS -Wno-reserved-identifier) endif() - list(APPEND cppcheck_SOURCES ${hdrs} ${mainfile} $) + list(APPEND cppcheck_SOURCES ${hdrs} ${mainfile} $ $) if (NOT BUILD_CORE_DLL) list(APPEND cppcheck_SOURCES $) list(APPEND cppcheck_SOURCES $) diff --git a/cli/cli.vcxproj b/cli/cli.vcxproj index 3178f4319d2..5d4ee25b0e3 100644 --- a/cli/cli.vcxproj +++ b/cli/cli.vcxproj @@ -85,7 +85,7 @@ - ..\lib;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories) + ..\lib;..\frontend;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories) true ProgramDatabase Disabled @@ -114,7 +114,7 @@ - ..\lib;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories) + ..\lib;..\frontend;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories) true ProgramDatabase Disabled @@ -143,7 +143,7 @@ - ..\lib;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories) + ..\lib;..\frontend;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories) false MaxSpeed CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions) @@ -181,7 +181,7 @@ - ..\lib;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories) + ..\lib;..\frontend;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories) false MaxSpeed CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;NDEBUG;WIN32;HAVE_RULES;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions) @@ -231,6 +231,7 @@ + @@ -254,6 +255,7 @@ + diff --git a/cli/cli.vcxproj.filters b/cli/cli.vcxproj.filters index 2320255e6b5..5d3bd1c86cc 100644 --- a/cli/cli.vcxproj.filters +++ b/cli/cli.vcxproj.filters @@ -23,9 +23,6 @@ Header Files - - Header Files - Header Files @@ -44,6 +41,12 @@ Header Files + + Header Files + + + Header Files + @@ -55,9 +58,6 @@ Source Files - - Source Files - Source Files @@ -79,6 +79,12 @@ Source Files + + Source Files + + + Source Files + diff --git a/frontend/CMakeLists.txt b/frontend/CMakeLists.txt new file mode 100644 index 00000000000..e5e64bfe85b --- /dev/null +++ b/frontend/CMakeLists.txt @@ -0,0 +1,5 @@ +file(GLOB hdrs "*.h") +file(GLOB srcs "*.cpp") + +add_library(frontend_objs OBJECT ${hdrs} ${srcs}) +target_include_directories(frontend_objs PRIVATE ${PROJECT_SOURCE_DIR}/lib) \ No newline at end of file diff --git a/frontend/frontend.cpp b/frontend/frontend.cpp new file mode 100644 index 00000000000..133ab8ac8fe --- /dev/null +++ b/frontend/frontend.cpp @@ -0,0 +1,22 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2025 Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "frontend.h" + +namespace frontend +{} diff --git a/frontend/frontend.h b/frontend/frontend.h new file mode 100644 index 00000000000..50a20264af1 --- /dev/null +++ b/frontend/frontend.h @@ -0,0 +1,25 @@ +/* -*- C++ -*- + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2025 Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef FRONTEND_H +#define FRONTEND_H + +namespace frontend +{} + +#endif // FRONTEND_H diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index 21375fbd784..fdf154b270a 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -20,7 +20,7 @@ CheckOptions: list(APPEND cppcheck-gui-deps ${hdrs} ${uis_hdrs} ${resources} ${qms}) add_custom_target(gui-build-deps SOURCES ${cppcheck-gui-deps}) - list(APPEND cppcheck-gui_SOURCES ${srcs}) + list(APPEND cppcheck-gui_SOURCES ${srcs} $) if (NOT BUILD_CORE_DLL) list(APPEND cppcheck-gui_SOURCES $ $) if(USE_BUNDLED_TINYXML2) @@ -34,7 +34,7 @@ CheckOptions: add_executable(cppcheck-gui ${cppcheck-gui-deps} ${cppcheck-gui_SOURCES}) set_target_properties(cppcheck-gui PROPERTIES AUTOMOC ON) set_target_properties(cppcheck-gui PROPERTIES WIN32_EXECUTABLE ON) - target_include_directories(cppcheck-gui PRIVATE ${PROJECT_SOURCE_DIR}/lib/) + target_include_directories(cppcheck-gui PRIVATE ${PROJECT_SOURCE_DIR}/lib/ ${PROJECT_SOURCE_DIR}/frontend/) if(USE_BUNDLED_TINYXML2) target_externals_include_directories(cppcheck-gui PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/) else() diff --git a/lib/cppcheck.vcxproj.filters b/lib/cppcheck.vcxproj.filters index a4c000fd9a6..958ba595f7d 100644 --- a/lib/cppcheck.vcxproj.filters +++ b/lib/cppcheck.vcxproj.filters @@ -9,6 +9,9 @@ {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx + + {00a07a33-9811-481c-91aa-46bfba1cda93} + @@ -212,88 +215,13 @@ Source Files - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - Source Files - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - Source Files - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - + Source Files @@ -541,98 +469,24 @@ Header Files - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - Header Files - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - Header Files - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - Header Files - + + Resource Files + - + + Resource Files + \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3b516f38965..0155cd15e80 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,7 +4,7 @@ if (BUILD_TESTS) file(GLOB hdrs "*.h") file(GLOB srcs "*.cpp") - list(APPEND testrunner_SOURCES ${hdrs} ${srcs} $) + list(APPEND testrunner_SOURCES ${hdrs} ${srcs} $ $) if (NOT BUILD_CORE_DLL) list(APPEND testrunner_SOURCES $ $) if(USE_BUNDLED_TINYXML2) @@ -13,7 +13,7 @@ if (BUILD_TESTS) endif() add_executable(testrunner ${testrunner_SOURCES}) - target_include_directories(testrunner PRIVATE ${PROJECT_SOURCE_DIR}/lib/ ${PROJECT_SOURCE_DIR}/cli/) + target_include_directories(testrunner PRIVATE ${PROJECT_SOURCE_DIR}/lib/ ${PROJECT_SOURCE_DIR}/cli/ ${PROJECT_SOURCE_DIR}/frontend/) if(USE_BUNDLED_TINYXML2) target_externals_include_directories(testrunner PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2) else() diff --git a/test/testrunner.vcxproj b/test/testrunner.vcxproj index 2f44ad4395f..176f9737ad9 100755 --- a/test/testrunner.vcxproj +++ b/test/testrunner.vcxproj @@ -34,6 +34,7 @@ + Create Create @@ -125,6 +126,7 @@ + @@ -198,7 +200,7 @@ - ..\cli;..\lib;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories) + ..\cli;..\frontend;..\lib;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories) true ProgramDatabase Disabled @@ -227,7 +229,7 @@ - ..\cli;..\lib;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories) + ..\cli;..\frontend;..\lib;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories) true ProgramDatabase Disabled @@ -256,7 +258,7 @@ - ..\cli;..\lib;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories) + ..\cli;..\frontend;..\lib;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories) false MaxSpeed CPPCHECKLIB_IMPORT;SIMPLECPP_IMPORT;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions) @@ -296,7 +298,7 @@ - ..\cli;..\lib;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories) + ..\cli;..\frontend;..\lib;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories) false MaxSpeed CPPCHECKLIB_IMPORT;SIMPLECPP_IMPORT;NDEBUG;WIN32;HAVE_RULES;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions) diff --git a/test/testrunner.vcxproj.filters b/test/testrunner.vcxproj.filters index 81ab11f1f3c..6aa63768b24 100644 --- a/test/testrunner.vcxproj.filters +++ b/test/testrunner.vcxproj.filters @@ -136,9 +136,6 @@ Source Files - - Source Files - Source Files @@ -220,9 +217,6 @@ Source Files - - Source Files - Source Files @@ -268,6 +262,18 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + @@ -291,9 +297,6 @@ Header Files - - Header Files - Header Files @@ -315,5 +318,11 @@ Header Files + + Header Files + + + Header Files + \ No newline at end of file diff --git a/tools/dmake/dmake.cpp b/tools/dmake/dmake.cpp index f85f65ae0d4..1dc58916b48 100644 --- a/tools/dmake/dmake.cpp +++ b/tools/dmake/dmake.cpp @@ -89,6 +89,8 @@ static void getDeps(std::string filename, std::vector &depfiles) * Files are searched according to the following priority: * [test, tools] -> cli -> lib -> externals */ + if (startsWith(filename, "frontend/")) + getDeps("lib" + filename.substr(filename.find('/')), depfiles); if (startsWith(filename, "cli/")) getDeps("lib" + filename.substr(filename.find('/')), depfiles); else if (startsWith(filename, "test/")) @@ -432,6 +434,13 @@ int main(int argc, char **argv) return EXIT_FAILURE; } + std::vector frontendfiles; + err = getCppFiles(frontendfiles, "frontend/", false); + if (!err.empty()) { + std::cerr << err << std::endl; + return EXIT_FAILURE; + } + std::vector clifiles; err = getCppFiles(clifiles, "cli/", false); if (!err.empty()) { @@ -453,7 +462,7 @@ int main(int argc, char **argv) return EXIT_FAILURE; } - if (libfiles.empty() && clifiles.empty() && testfiles.empty()) { + if (libfiles.empty() && frontendfiles.empty() && clifiles.empty() && testfiles.empty()) { std::cerr << "No files found. Are you in the correct directory?" << std::endl; return EXIT_FAILURE; } @@ -481,6 +490,13 @@ int main(int argc, char **argv) libfiles_h.emplace("vf_analyze.h"); libfiles_h.emplace("xml.h"); + std::vector frontendfiles_h; + for (const std::string &frontendfile : frontendfiles) { + std::string fname(frontendfile.substr(9)); + fname.erase(fname.find(".cpp")); + frontendfiles_h.emplace_back(fname + ".h"); + } + std::vector clifiles_h; for (const std::string &clifile : clifiles) { std::string fname(clifile.substr(4)); @@ -504,10 +520,18 @@ int main(int argc, char **argv) const std::string c = clifile.substr(4); outstr += make_vcxproj_cl_entry(c, c == "executor.cpp" ? Precompile : Compile); } + for (const std::string &frontendfile: frontendfiles) { + const std::string c = "..\\frontend\\" + frontendfile.substr(9); + outstr += make_vcxproj_cl_entry(c, Compile); + } }, [&](std::string &outstr){ for (const std::string &clifile_h: clifiles_h) { outstr += make_vcxproj_cl_entry(clifile_h, Include); } + for (const std::string &frontendfile_h: frontendfiles_h) { + const std::string h = "..\\frontend\\" + frontendfile_h; + outstr += make_vcxproj_cl_entry(h, Include); + } }); write_vcxproj("lib/cppcheck.vcxproj", [&](std::string &outstr){ @@ -535,6 +559,11 @@ int main(int argc, char **argv) outstr += make_vcxproj_cl_entry(c, Compile); } + for (const std::string &frontendfile: frontendfiles) { + const std::string c = "..\\frontend\\" + frontendfile.substr(9); + outstr += make_vcxproj_cl_entry(c, Compile); + } + for (const std::string &testfile: testfiles) { const std::string t = testfile.substr(5); outstr += make_vcxproj_cl_entry(t, t == "fixture.cpp" ? Precompile : Compile); @@ -545,6 +574,11 @@ int main(int argc, char **argv) outstr += make_vcxproj_cl_entry(c, Include); } + for (const std::string &frontendfile_h: frontendfiles_h) { + const std::string h = "..\\frontend\\" + frontendfile_h; + outstr += make_vcxproj_cl_entry(h, Include); + } + for (const std::string &testfile_h: testfiles_h) { outstr += make_vcxproj_cl_entry(testfile_h, Include); } @@ -718,7 +752,8 @@ int main(int argc, char **argv) makeConditionalVariable(fout, "PREFIX", "/usr"); makeConditionalVariable(fout, "INCLUDE_FOR_LIB", "-Ilib -isystem externals -isystem externals/picojson -isystem externals/simplecpp -isystem externals/tinyxml2"); - makeConditionalVariable(fout, "INCLUDE_FOR_CLI", "-Ilib -isystem externals/picojson -isystem externals/simplecpp -isystem externals/tinyxml2"); + makeConditionalVariable(fout, "INCLUDE_FOR_FE", "-Ilib"); + makeConditionalVariable(fout, "INCLUDE_FOR_CLI", "-Ilib -Ifrontend -isystem externals/picojson -isystem externals/simplecpp -isystem externals/tinyxml2"); makeConditionalVariable(fout, "INCLUDE_FOR_TEST", "-Ilib -Icli -isystem externals/simplecpp -isystem externals/tinyxml2"); fout << "BIN=$(DESTDIR)$(PREFIX)/bin\n\n"; @@ -730,12 +765,13 @@ int main(int argc, char **argv) fout << "\n###### Object Files\n\n"; fout << "LIBOBJ = " << objfiles(libfiles_prio) << "\n\n"; fout << "EXTOBJ = " << objfiles(extfiles) << "\n\n"; + fout << "FEOBJ = " << objfiles(frontendfiles) << "\n\n"; fout << "CLIOBJ = " << objfiles(clifiles) << "\n\n"; fout << "TESTOBJ = " << objfiles(testfiles) << "\n\n"; fout << ".PHONY: run-dmake tags\n\n"; fout << "\n###### Targets\n\n"; - fout << "cppcheck: $(EXTOBJ) $(LIBOBJ) $(CLIOBJ)\n"; + fout << "cppcheck: $(EXTOBJ) $(LIBOBJ) $(FEOBJ) $(CLIOBJ)\n"; fout << "\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^ $(LIBS) $(LDFLAGS) $(RDYNAMIC)\n\n"; fout << "all:\tcppcheck testrunner\n\n"; std::string testrunner_clifiles_o; @@ -746,7 +782,7 @@ int main(int argc, char **argv) const std::string o = clifile.substr(0, clifile.length()-3) + 'o'; testrunner_clifiles_o += o; } - fout << "testrunner: $(EXTOBJ) $(TESTOBJ) $(LIBOBJ)" << testrunner_clifiles_o << "\n"; + fout << "testrunner: $(EXTOBJ) $(TESTOBJ) $(LIBOBJ) $(FEOBJ)" << testrunner_clifiles_o << "\n"; fout << "\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^ $(LIBS) $(LDFLAGS) $(RDYNAMIC)\n\n"; fout << "test:\tall\n"; fout << "\t./testrunner\n\n"; @@ -835,6 +871,7 @@ int main(int argc, char **argv) fout << "\n###### Build\n\n"; compilefiles(fout, libfiles_prio, "${INCLUDE_FOR_LIB}"); + compilefiles(fout, frontendfiles, "${INCLUDE_FOR_FE}"); compilefiles(fout, clifiles, "${INCLUDE_FOR_CLI}"); compilefiles(fout, testfiles, "${INCLUDE_FOR_TEST}"); compilefiles(fout, extfiles, "");