From e5d2d97425e75d8ac143865358e5a829b6a73b12 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sun, 22 Jan 2023 23:06:28 +0800 Subject: [PATCH] build: update cmake compile structure --- src/CMakeLists.txt | 64 +++-------------- src/graph/svg/CMakeLists.txt | 1 - src/klotski/CMakeLists.txt | 67 ++++++++++++++++++ src/{ => klotski}/all_cases/CMakeLists.txt | 3 +- src/{ => klotski}/all_cases/all_cases.cc | 0 src/{ => klotski}/all_cases/all_cases.h | 0 src/{ => klotski}/all_cases/basic_ranges.cc | 0 src/{ => klotski}/all_cases/basic_ranges.h | 0 src/{ => klotski}/analyse/CMakeLists.txt | 0 src/{ => klotski}/analyse/analyse.cc | 0 src/{ => klotski}/analyse/analyse.h | 0 src/{ => klotski}/analyse/backtrack.cc | 0 src/{ => klotski}/analyse/backtrack_legacy.cc | 0 src/{ => klotski}/common_code/CMakeLists.txt | 0 src/{ => klotski}/common_code/common_code.cc | 0 src/{ => klotski}/common_code/common_code.h | 0 src/{ => klotski}/common_code/convert.cc | 0 src/{ => klotski}/common_code/serialize.cc | 0 src/{ => klotski}/core/CMakeLists.txt | 0 src/{ => klotski}/core/core.cc | 0 src/{ => klotski}/core/core.h | 0 src/{ => klotski}/fast_cal/CMakeLists.txt | 0 src/{ => klotski}/fast_cal/cal_core.cc | 0 src/{ => klotski}/fast_cal/fast_cal.cc | 0 src/{ => klotski}/fast_cal/fast_cal.h | 0 src/{ => klotski}/graph/CMakeLists.txt | 0 src/{ => klotski}/graph/case.cc | 0 src/{ => klotski}/graph/graph.cc | 0 src/{ => klotski}/graph/graph.h | 0 src/{ => klotski}/graph/svg/svg.cc | 0 src/{ => klotski}/graph/svg/svg.h | 0 src/klotski/klotski_ffi.cc | 2 + src/{ => klotski}/raw_code/CMakeLists.txt | 0 src/{ => klotski}/raw_code/convert.cc | 0 src/{ => klotski}/raw_code/raw_code.cc | 0 src/{ => klotski}/raw_code/raw_code.h | 0 src/{ => klotski}/short_code/CMakeLists.txt | 0 src/{ => klotski}/short_code/convert.cc | 0 .../short_code/offset/all_cases_offset.h | 0 .../short_code/offset/basic_ranges_offset.h | 0 .../short_code/offset/range_prefix_offset.h | 0 src/{ => klotski}/short_code/serialize.cc | 0 .../short_code/serialize_chars.h | 0 src/{ => klotski}/short_code/short_code.cc | 0 src/{ => klotski}/short_code/short_code.h | 0 src/{ => klotski}/utils/CMakeLists.txt | 0 src/{ => klotski}/utils/common.cc | 0 src/{ => klotski}/utils/common.h | 0 src/main.cc | 69 +++++++++++++------ 49 files changed, 127 insertions(+), 79 deletions(-) delete mode 100644 src/graph/svg/CMakeLists.txt create mode 100644 src/klotski/CMakeLists.txt rename src/{ => klotski}/all_cases/CMakeLists.txt (71%) rename src/{ => klotski}/all_cases/all_cases.cc (100%) rename src/{ => klotski}/all_cases/all_cases.h (100%) rename src/{ => klotski}/all_cases/basic_ranges.cc (100%) rename src/{ => klotski}/all_cases/basic_ranges.h (100%) rename src/{ => klotski}/analyse/CMakeLists.txt (100%) rename src/{ => klotski}/analyse/analyse.cc (100%) rename src/{ => klotski}/analyse/analyse.h (100%) rename src/{ => klotski}/analyse/backtrack.cc (100%) rename src/{ => klotski}/analyse/backtrack_legacy.cc (100%) rename src/{ => klotski}/common_code/CMakeLists.txt (100%) rename src/{ => klotski}/common_code/common_code.cc (100%) rename src/{ => klotski}/common_code/common_code.h (100%) rename src/{ => klotski}/common_code/convert.cc (100%) rename src/{ => klotski}/common_code/serialize.cc (100%) rename src/{ => klotski}/core/CMakeLists.txt (100%) rename src/{ => klotski}/core/core.cc (100%) rename src/{ => klotski}/core/core.h (100%) rename src/{ => klotski}/fast_cal/CMakeLists.txt (100%) rename src/{ => klotski}/fast_cal/cal_core.cc (100%) rename src/{ => klotski}/fast_cal/fast_cal.cc (100%) rename src/{ => klotski}/fast_cal/fast_cal.h (100%) rename src/{ => klotski}/graph/CMakeLists.txt (100%) rename src/{ => klotski}/graph/case.cc (100%) rename src/{ => klotski}/graph/graph.cc (100%) rename src/{ => klotski}/graph/graph.h (100%) rename src/{ => klotski}/graph/svg/svg.cc (100%) rename src/{ => klotski}/graph/svg/svg.h (100%) create mode 100644 src/klotski/klotski_ffi.cc rename src/{ => klotski}/raw_code/CMakeLists.txt (100%) rename src/{ => klotski}/raw_code/convert.cc (100%) rename src/{ => klotski}/raw_code/raw_code.cc (100%) rename src/{ => klotski}/raw_code/raw_code.h (100%) rename src/{ => klotski}/short_code/CMakeLists.txt (100%) rename src/{ => klotski}/short_code/convert.cc (100%) rename src/{ => klotski}/short_code/offset/all_cases_offset.h (100%) rename src/{ => klotski}/short_code/offset/basic_ranges_offset.h (100%) rename src/{ => klotski}/short_code/offset/range_prefix_offset.h (100%) rename src/{ => klotski}/short_code/serialize.cc (100%) rename src/{ => klotski}/short_code/serialize_chars.h (100%) rename src/{ => klotski}/short_code/short_code.cc (100%) rename src/{ => klotski}/short_code/short_code.h (100%) rename src/{ => klotski}/utils/CMakeLists.txt (100%) rename src/{ => klotski}/utils/common.cc (100%) rename src/{ => klotski}/utils/common.h (100%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 712a08e..ceb559c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,60 +1,14 @@ cmake_minimum_required(VERSION 3.0) -################################################ +include_directories(klotski) +include_directories(klotski/utils) +include_directories(klotski/all_cases) -include_directories(utils) -include_directories(all_cases) +include_directories(klotski/raw_code) +include_directories(klotski/short_code) +include_directories(klotski/common_code) -include_directories(raw_code) -include_directories(short_code) -include_directories(common_code) +add_subdirectory(klotski) -include_directories(core) -include_directories(analyse) -include_directories(fast_cal) - -include_directories(graph) - -include_directories(benchmark) - -################################################ - -add_subdirectory(utils) -add_subdirectory(all_cases) - -add_subdirectory(raw_code) -add_subdirectory(short_code) -add_subdirectory(common_code) - -add_subdirectory(core) -add_subdirectory(analyse) -add_subdirectory(fast_cal) - -add_subdirectory(graph) - -add_subdirectory(benchmark) - -################################################ - -add_executable(klotski main.cc) - -################################################ - -target_link_libraries(klotski utils) -target_link_libraries(klotski all_cases) - -target_link_libraries(klotski raw_code) -target_link_libraries(klotski short_code) -target_link_libraries(klotski common_code) - -target_link_libraries(klotski core) -target_link_libraries(klotski analyse) -target_link_libraries(klotski fast_cal) - -target_link_libraries(klotski graph) - -target_link_libraries(klotski benchmark) - -target_link_libraries(klotski pthread) - -################################################ +add_executable(klotski_bin main.cc) +target_link_libraries(klotski_bin klotski) diff --git a/src/graph/svg/CMakeLists.txt b/src/graph/svg/CMakeLists.txt deleted file mode 100644 index 6ca873c..0000000 --- a/src/graph/svg/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_library(svg svg.cc) diff --git a/src/klotski/CMakeLists.txt b/src/klotski/CMakeLists.txt new file mode 100644 index 0000000..3006900 --- /dev/null +++ b/src/klotski/CMakeLists.txt @@ -0,0 +1,67 @@ +cmake_minimum_required(VERSION 3.0) + +################################################ + +include_directories(utils) +include_directories(all_cases) + +include_directories(raw_code) +include_directories(short_code) +include_directories(common_code) + +#include_directories(core) +#include_directories(analyse) +#include_directories(fast_cal) +# +#include_directories(graph) +# +#include_directories(benchmark) + +################################################ + +add_subdirectory(utils) +add_subdirectory(all_cases) + +add_subdirectory(raw_code) +add_subdirectory(short_code) +add_subdirectory(common_code) + +#add_subdirectory(core) +#add_subdirectory(analyse) +#add_subdirectory(fast_cal) +# +#add_subdirectory(graph) +# +#add_subdirectory(benchmark) + +################################################ + +add_library(klotski klotski_ffi.cc) + +target_link_libraries(klotski utils) +target_link_libraries(klotski all_cases) + +target_link_libraries(klotski raw_code) +target_link_libraries(klotski short_code) +target_link_libraries(klotski common_code) + +################################################ + +#target_link_libraries(klotski utils) +#target_link_libraries(klotski all_cases) + +#target_link_libraries(klotski raw_code) +#target_link_libraries(klotski short_code) +#target_link_libraries(klotski common_code) +# +#target_link_libraries(klotski core) +#target_link_libraries(klotski analyse) +#target_link_libraries(klotski fast_cal) +# +#target_link_libraries(klotski graph) +# +#target_link_libraries(klotski benchmark) +# +#target_link_libraries(klotski pthread) + +################################################ diff --git a/src/all_cases/CMakeLists.txt b/src/klotski/all_cases/CMakeLists.txt similarity index 71% rename from src/all_cases/CMakeLists.txt rename to src/klotski/all_cases/CMakeLists.txt index b41a565..29a672f 100644 --- a/src/all_cases/CMakeLists.txt +++ b/src/klotski/all_cases/CMakeLists.txt @@ -1,3 +1,4 @@ -add_library(all_cases all_cases.cc basic_ranges.cc) +cmake_minimum_required(VERSION 3.0) +add_library(all_cases all_cases.cc basic_ranges.cc) target_link_libraries(all_cases utils) diff --git a/src/all_cases/all_cases.cc b/src/klotski/all_cases/all_cases.cc similarity index 100% rename from src/all_cases/all_cases.cc rename to src/klotski/all_cases/all_cases.cc diff --git a/src/all_cases/all_cases.h b/src/klotski/all_cases/all_cases.h similarity index 100% rename from src/all_cases/all_cases.h rename to src/klotski/all_cases/all_cases.h diff --git a/src/all_cases/basic_ranges.cc b/src/klotski/all_cases/basic_ranges.cc similarity index 100% rename from src/all_cases/basic_ranges.cc rename to src/klotski/all_cases/basic_ranges.cc diff --git a/src/all_cases/basic_ranges.h b/src/klotski/all_cases/basic_ranges.h similarity index 100% rename from src/all_cases/basic_ranges.h rename to src/klotski/all_cases/basic_ranges.h diff --git a/src/analyse/CMakeLists.txt b/src/klotski/analyse/CMakeLists.txt similarity index 100% rename from src/analyse/CMakeLists.txt rename to src/klotski/analyse/CMakeLists.txt diff --git a/src/analyse/analyse.cc b/src/klotski/analyse/analyse.cc similarity index 100% rename from src/analyse/analyse.cc rename to src/klotski/analyse/analyse.cc diff --git a/src/analyse/analyse.h b/src/klotski/analyse/analyse.h similarity index 100% rename from src/analyse/analyse.h rename to src/klotski/analyse/analyse.h diff --git a/src/analyse/backtrack.cc b/src/klotski/analyse/backtrack.cc similarity index 100% rename from src/analyse/backtrack.cc rename to src/klotski/analyse/backtrack.cc diff --git a/src/analyse/backtrack_legacy.cc b/src/klotski/analyse/backtrack_legacy.cc similarity index 100% rename from src/analyse/backtrack_legacy.cc rename to src/klotski/analyse/backtrack_legacy.cc diff --git a/src/common_code/CMakeLists.txt b/src/klotski/common_code/CMakeLists.txt similarity index 100% rename from src/common_code/CMakeLists.txt rename to src/klotski/common_code/CMakeLists.txt diff --git a/src/common_code/common_code.cc b/src/klotski/common_code/common_code.cc similarity index 100% rename from src/common_code/common_code.cc rename to src/klotski/common_code/common_code.cc diff --git a/src/common_code/common_code.h b/src/klotski/common_code/common_code.h similarity index 100% rename from src/common_code/common_code.h rename to src/klotski/common_code/common_code.h diff --git a/src/common_code/convert.cc b/src/klotski/common_code/convert.cc similarity index 100% rename from src/common_code/convert.cc rename to src/klotski/common_code/convert.cc diff --git a/src/common_code/serialize.cc b/src/klotski/common_code/serialize.cc similarity index 100% rename from src/common_code/serialize.cc rename to src/klotski/common_code/serialize.cc diff --git a/src/core/CMakeLists.txt b/src/klotski/core/CMakeLists.txt similarity index 100% rename from src/core/CMakeLists.txt rename to src/klotski/core/CMakeLists.txt diff --git a/src/core/core.cc b/src/klotski/core/core.cc similarity index 100% rename from src/core/core.cc rename to src/klotski/core/core.cc diff --git a/src/core/core.h b/src/klotski/core/core.h similarity index 100% rename from src/core/core.h rename to src/klotski/core/core.h diff --git a/src/fast_cal/CMakeLists.txt b/src/klotski/fast_cal/CMakeLists.txt similarity index 100% rename from src/fast_cal/CMakeLists.txt rename to src/klotski/fast_cal/CMakeLists.txt diff --git a/src/fast_cal/cal_core.cc b/src/klotski/fast_cal/cal_core.cc similarity index 100% rename from src/fast_cal/cal_core.cc rename to src/klotski/fast_cal/cal_core.cc diff --git a/src/fast_cal/fast_cal.cc b/src/klotski/fast_cal/fast_cal.cc similarity index 100% rename from src/fast_cal/fast_cal.cc rename to src/klotski/fast_cal/fast_cal.cc diff --git a/src/fast_cal/fast_cal.h b/src/klotski/fast_cal/fast_cal.h similarity index 100% rename from src/fast_cal/fast_cal.h rename to src/klotski/fast_cal/fast_cal.h diff --git a/src/graph/CMakeLists.txt b/src/klotski/graph/CMakeLists.txt similarity index 100% rename from src/graph/CMakeLists.txt rename to src/klotski/graph/CMakeLists.txt diff --git a/src/graph/case.cc b/src/klotski/graph/case.cc similarity index 100% rename from src/graph/case.cc rename to src/klotski/graph/case.cc diff --git a/src/graph/graph.cc b/src/klotski/graph/graph.cc similarity index 100% rename from src/graph/graph.cc rename to src/klotski/graph/graph.cc diff --git a/src/graph/graph.h b/src/klotski/graph/graph.h similarity index 100% rename from src/graph/graph.h rename to src/klotski/graph/graph.h diff --git a/src/graph/svg/svg.cc b/src/klotski/graph/svg/svg.cc similarity index 100% rename from src/graph/svg/svg.cc rename to src/klotski/graph/svg/svg.cc diff --git a/src/graph/svg/svg.h b/src/klotski/graph/svg/svg.h similarity index 100% rename from src/graph/svg/svg.h rename to src/klotski/graph/svg/svg.h diff --git a/src/klotski/klotski_ffi.cc b/src/klotski/klotski_ffi.cc new file mode 100644 index 0000000..7f51ced --- /dev/null +++ b/src/klotski/klotski_ffi.cc @@ -0,0 +1,2 @@ +#include + diff --git a/src/raw_code/CMakeLists.txt b/src/klotski/raw_code/CMakeLists.txt similarity index 100% rename from src/raw_code/CMakeLists.txt rename to src/klotski/raw_code/CMakeLists.txt diff --git a/src/raw_code/convert.cc b/src/klotski/raw_code/convert.cc similarity index 100% rename from src/raw_code/convert.cc rename to src/klotski/raw_code/convert.cc diff --git a/src/raw_code/raw_code.cc b/src/klotski/raw_code/raw_code.cc similarity index 100% rename from src/raw_code/raw_code.cc rename to src/klotski/raw_code/raw_code.cc diff --git a/src/raw_code/raw_code.h b/src/klotski/raw_code/raw_code.h similarity index 100% rename from src/raw_code/raw_code.h rename to src/klotski/raw_code/raw_code.h diff --git a/src/short_code/CMakeLists.txt b/src/klotski/short_code/CMakeLists.txt similarity index 100% rename from src/short_code/CMakeLists.txt rename to src/klotski/short_code/CMakeLists.txt diff --git a/src/short_code/convert.cc b/src/klotski/short_code/convert.cc similarity index 100% rename from src/short_code/convert.cc rename to src/klotski/short_code/convert.cc diff --git a/src/short_code/offset/all_cases_offset.h b/src/klotski/short_code/offset/all_cases_offset.h similarity index 100% rename from src/short_code/offset/all_cases_offset.h rename to src/klotski/short_code/offset/all_cases_offset.h diff --git a/src/short_code/offset/basic_ranges_offset.h b/src/klotski/short_code/offset/basic_ranges_offset.h similarity index 100% rename from src/short_code/offset/basic_ranges_offset.h rename to src/klotski/short_code/offset/basic_ranges_offset.h diff --git a/src/short_code/offset/range_prefix_offset.h b/src/klotski/short_code/offset/range_prefix_offset.h similarity index 100% rename from src/short_code/offset/range_prefix_offset.h rename to src/klotski/short_code/offset/range_prefix_offset.h diff --git a/src/short_code/serialize.cc b/src/klotski/short_code/serialize.cc similarity index 100% rename from src/short_code/serialize.cc rename to src/klotski/short_code/serialize.cc diff --git a/src/short_code/serialize_chars.h b/src/klotski/short_code/serialize_chars.h similarity index 100% rename from src/short_code/serialize_chars.h rename to src/klotski/short_code/serialize_chars.h diff --git a/src/short_code/short_code.cc b/src/klotski/short_code/short_code.cc similarity index 100% rename from src/short_code/short_code.cc rename to src/klotski/short_code/short_code.cc diff --git a/src/short_code/short_code.h b/src/klotski/short_code/short_code.h similarity index 100% rename from src/short_code/short_code.h rename to src/klotski/short_code/short_code.h diff --git a/src/utils/CMakeLists.txt b/src/klotski/utils/CMakeLists.txt similarity index 100% rename from src/utils/CMakeLists.txt rename to src/klotski/utils/CMakeLists.txt diff --git a/src/utils/common.cc b/src/klotski/utils/common.cc similarity index 100% rename from src/utils/common.cc rename to src/klotski/utils/common.cc diff --git a/src/utils/common.h b/src/klotski/utils/common.h similarity index 100% rename from src/utils/common.h rename to src/klotski/utils/common.h diff --git a/src/main.cc b/src/main.cc index 5290ba6..1cc45d5 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,16 +1,18 @@ #include -#include "core.h" +//#include "core.h" + #include "all_cases.h" -#include "basic_ranges.h" -#include "common_code.h" -#include "short_code.h" + #include "raw_code.h" -#include "fast_cal.h" -#include "analyse.h" +#include "short_code.h" +#include "common_code.h" + +//#include "fast_cal.h" +//#include "analyse.h" #include "common.h" -#include "graph.h" +//#include "graph.h" -#include "benchmark.h" +//#include "benchmark.h" #include #include @@ -20,19 +22,42 @@ //int main(int argc, char *argv[]) { int main() { + std::cout << "start test" << std::endl; + +// std::cout << (uint32_t)Common::check_range(1, Common::range_reverse(0xA9BF0C00)) << std::endl; + +// AllCases::build(); +// for (const auto &a : AllCases::fetch()) { +// std::cout << a.size() << std::endl; +// } + + std::cout << RawCode::from_common_code("1a9bf0c") << std::endl; + std::cout << RawCode::create(0x0603EDF5CAFFF5E2) << std::endl; + + std::cout << CommonCode::create(0x1A9BF0C00) << std::endl; + std::cout << CommonCode::from_string("1a9bf0c") << std::endl; + std::cout << CommonCode::from_short_code(4091296) << std::endl; + std::cout << CommonCode::from_raw_code(0x0603EDF5CAFFF5E2) << std::endl; + + std::cout << ShortCode::create(4091296) << std::endl; + std::cout << ShortCode::from_string("4WVE1") << std::endl; + std::cout << ShortCode::from_common_code(0x1A9BF0C00) << std::endl; + + std::cout << "end test" << std::endl; + // BasicRanges::build(); // Benchmark::basic_ranges(std::cout); // std::cout << std::endl; - Benchmark::all_cases(std::cout); +// Benchmark::all_cases(std::cout); - std::cout << std::endl; - Benchmark::basic_ranges(std::cout); +// std::cout << std::endl; +// Benchmark::basic_ranges(std::cout); return 0; - BasicRanges::build(); +// BasicRanges::build(); // AllCases::build(); @@ -73,9 +98,9 @@ int main() { // } - auto start_time = clock(); +// auto start_time = clock(); - auto a = Analyse(RawCode::from_common_code("1a9bf0c")); +// auto a = Analyse(RawCode::from_common_code("1a9bf0c")); // auto a = Analyse(RawCode::from_common_code("4fea134")); // auto a = Analyse(RawCode::from_common_code("A5D3AF")); @@ -84,23 +109,23 @@ int main() { // auto ret = a.build_until([](uint64_t code) { // return ((code >> (3 * 0xD)) & 0b111) == B_2x2; // }); - auto ret = a.build_resolve(); +// auto ret = a.build_resolve(); // for (const auto &r : ret) { // std::cout << r << std::endl; // } // std::cout << ret.size() << std::endl; - std::cerr << (clock() - start_time) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl; +// std::cerr << (clock() - start_time) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl; - start_time = clock(); - auto svg_ret = a.backtrack(ret); - std::cerr << (clock() - start_time) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl; +// start_time = clock(); +// auto svg_ret = a.backtrack(ret); +// std::cerr << (clock() - start_time) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl; - auto g = Graph(); - auto svg_data = g.svg_demo(svg_ret); +// auto g = Graph(); +// auto svg_data = g.svg_demo(svg_ret); // std::cout << svg_data << std::endl; @@ -141,7 +166,7 @@ int main() { // std::cerr << (clock() - start_time) / CLOCKS_PER_SEC << "s" << std::endl; // std::cerr << (clock() - start_time) * 1000 / CLOCKS_PER_SEC << "ms" << std::endl; - std::cerr << (clock() - start_time) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl; +// std::cerr << (clock() - start_time) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl; // std::cout << "complete benchmark" << std::endl;