From ea19c283cf110f3ff96340d352a895c604a04e4d Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 6 Sep 2023 10:47:01 +0200 Subject: [PATCH] tools: moved `dmake` to its own folder --- .gitignore | 1 - Makefile | 8 ++++---- cppcheck.sln | 2 +- tools/CMakeLists.txt | 33 +-------------------------------- tools/dmake/CMakeLists.txt | 32 ++++++++++++++++++++++++++++++++ tools/{ => dmake}/dmake.cpp | 8 ++++---- tools/{ => dmake}/dmake.vcxproj | 0 tools/readme.md | 2 +- 8 files changed, 43 insertions(+), 43 deletions(-) create mode 100644 tools/dmake/CMakeLists.txt rename tools/{ => dmake}/dmake.cpp (98%) rename tools/{ => dmake}/dmake.vcxproj (100%) diff --git a/.gitignore b/.gitignore index af691695934..1f13761eb78 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,6 @@ tags /testrunner /testrunner.exe tools/daca2*.html -tools/dmake tools/errmsg tools/extracttests diff --git a/Makefile b/Makefile index 6cbb850ad46..0babe33327b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# This file is generated by tools/dmake, do not edit. +# This file is generated by dmake, do not edit. ifndef VERBOSE VERBOSE= @@ -361,7 +361,7 @@ check: all checkcfg: cppcheck validateCFG ./test/cfg/runtests.sh -dmake: tools/dmake.o cli/filelister.o $(libcppdir)/pathmatch.o $(libcppdir)/path.o $(libcppdir)/utils.o externals/simplecpp/simplecpp.o +dmake: tools/dmake/dmake.o cli/filelister.o $(libcppdir)/pathmatch.o $(libcppdir)/path.o $(libcppdir)/utils.o externals/simplecpp/simplecpp.o $(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) run-dmake: dmake @@ -896,6 +896,6 @@ externals/simplecpp/simplecpp.o: externals/simplecpp/simplecpp.cpp externals/sim externals/tinyxml2/tinyxml2.o: externals/tinyxml2/tinyxml2.cpp externals/tinyxml2/tinyxml2.h $(CXX) $(CPPFLAGS) $(CXXFLAGS) -w -c -o $@ externals/tinyxml2/tinyxml2.cpp -tools/dmake.o: tools/dmake.cpp cli/filelister.h lib/config.h lib/pathmatch.h lib/utils.h - $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ tools/dmake.cpp +tools/dmake/dmake.o: tools/dmake/dmake.cpp cli/filelister.h lib/config.h lib/pathmatch.h lib/utils.h + $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ tools/dmake/dmake.cpp diff --git a/cppcheck.sln b/cppcheck.sln index 31272442c75..8ea1af26aa8 100644 --- a/cppcheck.sln +++ b/cppcheck.sln @@ -15,7 +15,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testrunner", "test\testrunn EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cppcheck", "lib\cppcheck.vcxproj", "{C183DB5B-AD6C-423D-80CA-1F9549555A1A}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dmake", "tools\dmake.vcxproj", "{19EC86CD-0004-4917-B852-E6BD110B6E6F}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dmake", "tools\dmake\dmake.vcxproj", "{19EC86CD-0004-4917-B852-E6BD110B6E6F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 4f9ea9d7007..34c059a8bff 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,32 +1 @@ -# TODO: when using ccache and matchcompiler this will accessed before the file was generated and thus the build fails -set(srcs_lib pathmatch.cpp path.cpp) -foreach(file ${srcs_lib}) - if (NOT USE_MATCHCOMPILER_OPT STREQUAL "Off") - set(src "${CMAKE_BINARY_DIR}/lib/build/mc_${file}") - set_source_files_properties(${src} PROPERTIES GENERATED TRUE) - else() - set(src "${CMAKE_SOURCE_DIR}/lib/${file}") - endif() - set(srcs_tools ${srcs_tools} ${src}) -endforeach() - -add_executable(dmake EXCLUDE_FROM_ALL - dmake.cpp - ${CMAKE_SOURCE_DIR}/cli/filelister.cpp - ${srcs_tools} - ${CMAKE_SOURCE_DIR}/lib/utils.cpp - $ -) -target_include_directories(dmake PRIVATE ${CMAKE_SOURCE_DIR}/cli ${CMAKE_SOURCE_DIR}/lib) -target_externals_include_directories(dmake PRIVATE ${CMAKE_SOURCE_DIR}/externals/simplecpp) -if (WIN32 AND NOT BORLAND) - if(NOT MINGW) - target_link_libraries(dmake Shlwapi.lib) - else() - target_link_libraries(dmake shlwapi) - endif() -endif() - -add_custom_target(run-dmake $ - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - DEPENDS dmake) +add_subdirectory(dmake) \ No newline at end of file diff --git a/tools/dmake/CMakeLists.txt b/tools/dmake/CMakeLists.txt new file mode 100644 index 00000000000..4f9ea9d7007 --- /dev/null +++ b/tools/dmake/CMakeLists.txt @@ -0,0 +1,32 @@ +# TODO: when using ccache and matchcompiler this will accessed before the file was generated and thus the build fails +set(srcs_lib pathmatch.cpp path.cpp) +foreach(file ${srcs_lib}) + if (NOT USE_MATCHCOMPILER_OPT STREQUAL "Off") + set(src "${CMAKE_BINARY_DIR}/lib/build/mc_${file}") + set_source_files_properties(${src} PROPERTIES GENERATED TRUE) + else() + set(src "${CMAKE_SOURCE_DIR}/lib/${file}") + endif() + set(srcs_tools ${srcs_tools} ${src}) +endforeach() + +add_executable(dmake EXCLUDE_FROM_ALL + dmake.cpp + ${CMAKE_SOURCE_DIR}/cli/filelister.cpp + ${srcs_tools} + ${CMAKE_SOURCE_DIR}/lib/utils.cpp + $ +) +target_include_directories(dmake PRIVATE ${CMAKE_SOURCE_DIR}/cli ${CMAKE_SOURCE_DIR}/lib) +target_externals_include_directories(dmake PRIVATE ${CMAKE_SOURCE_DIR}/externals/simplecpp) +if (WIN32 AND NOT BORLAND) + if(NOT MINGW) + target_link_libraries(dmake Shlwapi.lib) + else() + target_link_libraries(dmake shlwapi) + endif() +endif() + +add_custom_target(run-dmake $ + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + DEPENDS dmake) diff --git a/tools/dmake.cpp b/tools/dmake/dmake.cpp similarity index 98% rename from tools/dmake.cpp rename to tools/dmake/dmake.cpp index eee4b458ba3..3844a380aa9 100644 --- a/tools/dmake.cpp +++ b/tools/dmake/dmake.cpp @@ -82,7 +82,7 @@ static void getDeps(const std::string &filename, std::vector &depfi getDeps("lib" + filename.substr(filename.find('/')), depfiles); else if (startsWith(filename, "test/")) getDeps("cli" + filename.substr(filename.find('/')), depfiles); - else if (startsWith(filename, "tools/")) + else if (startsWith(filename, "tools")) getDeps("cli" + filename.substr(filename.find('/')), depfiles); else if (startsWith(filename, "lib/")) { for (const std::string & external : externalfolders) @@ -306,7 +306,7 @@ int main(int argc, char **argv) } std::vector toolsfiles; - err = getCppFiles(toolsfiles, "tools/", false); + err = getCppFiles(toolsfiles, "tools/dmake/", false); if (!err.empty()) { std::cerr << err << std::endl; return EXIT_FAILURE; @@ -442,7 +442,7 @@ int main(int argc, char **argv) return EXIT_FAILURE; } - fout << "# This file is generated by tools/dmake, do not edit.\n\n"; + fout << "# This file is generated by dmake, do not edit.\n\n"; fout << "ifndef VERBOSE\n" << " VERBOSE=\n" @@ -671,7 +671,7 @@ int main(int argc, char **argv) fout << "\t./testrunner -q\n\n"; fout << "checkcfg:\tcppcheck validateCFG\n"; fout << "\t./test/cfg/runtests.sh\n\n"; - fout << "dmake:\ttools/dmake.o cli/filelister.o $(libcppdir)/pathmatch.o $(libcppdir)/path.o $(libcppdir)/utils.o externals/simplecpp/simplecpp.o\n"; + fout << "dmake:\ttools/dmake/dmake.o cli/filelister.o $(libcppdir)/pathmatch.o $(libcppdir)/path.o $(libcppdir)/utils.o externals/simplecpp/simplecpp.o\n"; fout << "\t$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)\n\n"; fout << "run-dmake: dmake\n"; fout << "\t./dmake" << (release ? " --release" : "") << "\n\n"; // Make CI in release builds happy diff --git a/tools/dmake.vcxproj b/tools/dmake/dmake.vcxproj similarity index 100% rename from tools/dmake.vcxproj rename to tools/dmake/dmake.vcxproj diff --git a/tools/readme.md b/tools/readme.md index 8a160f552a1..436f3322b1d 100644 --- a/tools/readme.md +++ b/tools/readme.md @@ -49,7 +49,7 @@ void f2() { ``` From this we can see that the usage of `Token::Match()` in `f1()` has been optimized, whereas the one in `f2()` couldn't be optimized (the string wasn't inline on the `Token::Match()` call). **The developer doesn't need to use this tool during development but should be aware of these optimizations**. *Building with this optimization, cppcheck can get a boost of 2x of speed-up.* -### * tools/dmake.cpp +### * tools/dmake/dmake.cpp Automatically generates the main `Makefile` for Cppcheck (**the main `Makefile` should not be modified manually**). To build and run the `dmake` tool execute: ```shell