From 6ac564c64fff5e4a46e17efca2df302ca8265464 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Mon, 19 Dec 2022 00:36:04 -0700 Subject: [PATCH] build: remove unused subprocess.h dependency --- .gitmodules | 3 -- 3rdparty/subprocess.h | 1 - CMakeLists.txt | 3 +- tests/test_qbsp.cc | 115 ------------------------------------------ tests/test_qbsp_q2.cc | 1 - 5 files changed, 1 insertion(+), 122 deletions(-) delete mode 160000 3rdparty/subprocess.h diff --git a/.gitmodules b/.gitmodules index 5e4a2754..ec5d67c7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,9 +7,6 @@ [submodule "3rdparty/nanobench"] path = 3rdparty/nanobench url = https://github.com/martinus/nanobench -[submodule "3rdparty/subprocess.h"] - path = 3rdparty/subprocess.h - url = https://github.com/sheredom/subprocess.h [submodule "3rdparty/pareto"] path = 3rdparty/pareto url = https://github.com/alandefreitas/pareto.git diff --git a/3rdparty/subprocess.h b/3rdparty/subprocess.h deleted file mode 160000 index a6789987..00000000 --- a/3rdparty/subprocess.h +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a67899873722edddc22e66e41f6ae8a05a3a3a88 diff --git a/CMakeLists.txt b/CMakeLists.txt index d92c6cd2..2fec588f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,8 +21,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "M endif() include_directories( - "${CMAKE_SOURCE_DIR}/include" - "${CMAKE_SOURCE_DIR}/3rdparty/subprocess.h") + "${CMAKE_SOURCE_DIR}/include") find_package (Threads) diff --git a/tests/test_qbsp.cc b/tests/test_qbsp.cc index a475e034..7df01aa1 100644 --- a/tests/test_qbsp.cc +++ b/tests/test_qbsp.cc @@ -13,7 +13,6 @@ #include #include -#include #include #include @@ -72,120 +71,6 @@ mapentity_t &LoadMapPath(const std::filesystem::path &name) #include -#if 0 -std::tuple> LoadTestmapRef(const std::filesystem::path &name) -{ - const char *destdir = test_quake2_maps_dir; - if (strlen(destdir) == 0) { - return {}; - } - - auto testmap_path = std::filesystem::path(testmaps_dir) / name; - auto map_in_game_path = fs::path(destdir) / name.filename(); - fs::copy(testmap_path, map_in_game_path, fs::copy_options::overwrite_existing); - - std::string map_string = map_in_game_path.generic_string(); - - const char *command_line[] = {R"(C:\Users\Eric\Documents\q2tools-220\x64\Debug\4bsp.exe)", - map_string.c_str(), - NULL}; - - struct subprocess_s subprocess; - int result = subprocess_create(command_line, 0, &subprocess); - if (0 != result) { - throw std::runtime_error("error launching process"); - } - - // let the process write - FILE* p_stdout = subprocess_stdout(&subprocess); - char buf[32]; - void *res; - do { - res = fgets(buf, 32, p_stdout); - } while (res != nullptr); - - int retcode; - if (0 != subprocess_join(&subprocess, &retcode)) { - throw std::runtime_error("error joining"); - } - - // re-open the .bsp and return it - fs::path bsp_path = map_in_game_path; - bsp_path.replace_extension("bsp"); - - bspdata_t bspdata; - LoadBSPFile(bsp_path, &bspdata); - - bspdata.version->game->init_filesystem(bsp_path, qbsp_options); - - ConvertBSPFormat(&bspdata, &bspver_generic); - - // write to .json for inspection - serialize_bsp(bspdata, std::get(bspdata.bsp), fs::path(bsp_path).replace_extension(".bsp.json")); - - std::optional prtfile; - if (const auto prtpath = fs::path(bsp_path).replace_extension(".prt"); fs::exists(prtpath)) { - prtfile = {LoadPrtFile(prtpath, bspdata.loadversion)}; - } - - return std::make_tuple(std::move(std::get(bspdata.bsp)), - std::move(bspdata.bspx.entries), - std::move(prtfile)); -} - -std::tuple> LoadTestmapRefQ1(const std::filesystem::path &name) -{ - auto testmap_path = std::filesystem::path(testmaps_dir) / name; - std::string testmap_path_string = testmap_path.generic_string(); - - const char *command_line[] = {R"(C:\Users\Eric\Downloads\ericw-tools-v0.18.1-win64\bin\qbsp.exe)", - testmap_path_string.c_str(), - NULL}; - - struct subprocess_s subprocess; - int result = subprocess_create(command_line, 0, &subprocess); - if (0 != result) { - throw std::runtime_error("error launching process"); - } - - // let the process write - FILE* p_stdout = subprocess_stdout(&subprocess); - char buf[32]; - void *res; - do { - res = fgets(buf, 32, p_stdout); - } while (res != nullptr); - - int retcode; - if (0 != subprocess_join(&subprocess, &retcode)) { - throw std::runtime_error("error joining"); - } - - // re-open the .bsp and return it - fs::path bsp_path = testmap_path; - bsp_path.replace_extension("bsp"); - - bspdata_t bspdata; - LoadBSPFile(bsp_path, &bspdata); - - bspdata.version->game->init_filesystem(bsp_path, qbsp_options); - - ConvertBSPFormat(&bspdata, &bspver_generic); - - // write to .json for inspection - serialize_bsp(bspdata, std::get(bspdata.bsp), fs::path(bsp_path).replace_extension(".bsp.json")); - - std::optional prtfile; - if (const auto prtpath = fs::path(bsp_path).replace_extension(".prt"); fs::exists(prtpath)) { - prtfile = {LoadPrtFile(prtpath, bspdata.loadversion)}; - } - - return std::make_tuple(std::move(std::get(bspdata.bsp)), - std::move(bspdata.bspx.entries), - std::move(prtfile)); -} -#endif - std::tuple> LoadTestmap(const std::filesystem::path &name, std::vector extra_args) { auto map_path = std::filesystem::path(testmaps_dir) / name; diff --git a/tests/test_qbsp_q2.cc b/tests/test_qbsp_q2.cc index 0a7080f5..bc565985 100644 --- a/tests/test_qbsp_q2.cc +++ b/tests/test_qbsp_q2.cc @@ -2,7 +2,6 @@ #include #include -#include #include #include