@@ -702,10 +702,15 @@ unix_build_build_script_cmd: (compiler_cmd: std::string, info: cpp2b_source_buil
702702build_build_script: (info: cpp2b_source_build_info) -> build_binary_result = {
703703 compiler :== cpp2b::compiler();
704704 bin_outpath := fs::absolute(".cache/cpp2/bin") / fs::path(info.src).replace_extension(shared_library_extension());
705+ bin_cache_file_path := fs::path(bin_outpath.generic_string() + ".cpp2bcache")
705706 log_path := fs::absolute(".cache/cpp2/log/compile") / fs::path(info.src).replace_extension(".log");
706707 ensure_dir(log_path.parent_path());
707708 ensure_dir(bin_outpath.parent_path());
708709
710+ if fs::exists(bin_outpath) && fs::exists(bin_cache_file_path) {
711+ bin_cache_file: std::fstream = (bin_cache_file_path, std::ios::binary);
712+ }
713+
709714 d := fs::absolute(modules_dir());
710715 cmd_str: std::string = "";
711716 if compiler == cpp2b::compiler_type::msvc { cmd_str = cl_build_build_script_cmd(info, bin_outpath); }
@@ -855,21 +860,21 @@ do_build: (targets: std::vector<std::string>) -> (stuff: full_build_info, exit_c
855860 file_hashes.insert(std::make_pair(p, hash));
856861 }
857862
858- data_file : std::fstream = (".cache/cpp2/.data ", std::ios::binary | std::ios::in);
863+ hash_data_file : std::fstream = (".cache/cpp2/.hash ", std::ios::binary | std::ios::in);
859864
860- while data_file {
865+ while hash_data_file {
861866 path_length: u16 = 0;
862- data_file >> path_length;
863- if !data_file { break; }
867+ hash_data_file >> path_length;
868+ if !hash_data_file { break; }
864869
865870 p: std::string = "";
866871 p.resize(path_length);
867- data_file .read(p.data(), path_length);
868- if !data_file { break; }
872+ hash_data_file .read(p.data(), path_length);
873+ if !hash_data_file { break; }
869874
870875 path_hash: u64 = 0;
871- data_file .read(reinterpret_cast<*char>(path_hash&), 8);
872- if !data_file { break; }
876+ hash_data_file .read(reinterpret_cast<*char>(path_hash&), 8);
877+ if !hash_data_file { break; }
873878
874879 prev_file_hashes[fs::path(p)] = path_hash;
875880 }
@@ -889,16 +894,16 @@ do_build: (targets: std::vector<std::string>) -> (stuff: full_build_info, exit_c
889894 }
890895 }
891896
892- data_file .close();
893- data_file .open(".cache/cpp2/.data", std::ios::binary | std::ios::out | std::ios::trunc);
897+ hash_data_file .close();
898+ hash_data_file .open(".cache/cpp2/.data", std::ios::binary | std::ios::out | std::ios::trunc);
894899
895900 for file_hashes do(inout entry) {
896901 p := entry.first.generic_string();
897902 hash := entry.second;
898903
899- data_file << unsafe_cast<u16>(p.size());
900- data_file .write(p.data(), p.size());
901- data_file .write(reinterpret_cast<*char>(hash&), 8);
904+ hash_data_file << unsafe_cast<u16>(p.size());
905+ hash_data_file .write(p.data(), p.size());
906+ hash_data_file .write(reinterpret_cast<*char>(hash&), 8);
902907 }
903908
904909 for transpile_futures do(inout fut) {
@@ -939,7 +944,6 @@ do_build: (targets: std::vector<std::string>) -> (stuff: full_build_info, exit_c
939944 std::pair("std.compat", true),
940945 );
941946
942-
943947 for cpp1_module_source_files do(src_file: fs::path) {
944948 result := cpp2b_parse_cpp1_module_statements(std::ifstream(src_file));
945949
0 commit comments