@@ -700,10 +700,15 @@ unix_build_build_script_cmd: (compiler_cmd: std::string, info: cpp2b_source_buil
700700build_build_script: (info: cpp2b_source_build_info) -> build_binary_result = {
701701 compiler :== cpp2b::compiler();
702702 bin_outpath := fs::absolute(".cache/cpp2/bin") / fs::path(info.src).replace_extension(shared_library_extension());
703+ bin_cache_file_path := fs::path(bin_outpath.generic_string() + ".cpp2bcache")
703704 log_path := fs::absolute(".cache/cpp2/log/compile") / fs::path(info.src).replace_extension(".log");
704705 ensure_dir(log_path.parent_path());
705706 ensure_dir(bin_outpath.parent_path());
706707
708+ if fs::exists(bin_outpath) && fs::exists(bin_cache_file_path) {
709+ bin_cache_file: std::fstream = (bin_cache_file_path, std::ios::binary);
710+ }
711+
707712 d := fs::absolute(modules_dir());
708713 cmd_str: std::string = "";
709714 if compiler == cpp2b::compiler_type::msvc { cmd_str = cl_build_build_script_cmd(info, bin_outpath); }
@@ -853,21 +858,21 @@ do_build: (targets: std::vector<std::string>) -> (stuff: full_build_info, exit_c
853858 file_hashes.insert(std::make_pair(p, hash));
854859 }
855860
856- data_file : std::fstream = (".cache/cpp2/.data ", std::ios::binary | std::ios::in);
861+ hash_data_file : std::fstream = (".cache/cpp2/.hash ", std::ios::binary | std::ios::in);
857862
858- while data_file {
863+ while hash_data_file {
859864 path_length: u16 = 0;
860- data_file >> path_length;
861- if !data_file { break; }
865+ hash_data_file >> path_length;
866+ if !hash_data_file { break; }
862867
863868 p: std::string = "";
864869 p.resize(path_length);
865- data_file .read(p.data(), path_length);
866- if !data_file { break; }
870+ hash_data_file .read(p.data(), path_length);
871+ if !hash_data_file { break; }
867872
868873 path_hash: u64 = 0;
869- data_file .read(reinterpret_cast<*char>(path_hash&), 8);
870- if !data_file { break; }
874+ hash_data_file .read(reinterpret_cast<*char>(path_hash&), 8);
875+ if !hash_data_file { break; }
871876
872877 prev_file_hashes[fs::path(p)] = path_hash;
873878 }
@@ -887,16 +892,16 @@ do_build: (targets: std::vector<std::string>) -> (stuff: full_build_info, exit_c
887892 }
888893 }
889894
890- data_file .close();
891- data_file .open(".cache/cpp2/.data", std::ios::binary | std::ios::out | std::ios::trunc);
895+ hash_data_file .close();
896+ hash_data_file .open(".cache/cpp2/.data", std::ios::binary | std::ios::out | std::ios::trunc);
892897
893898 for file_hashes do(inout entry) {
894899 p := entry.first.generic_string();
895900 hash := entry.second;
896901
897- data_file << unsafe_cast<u16>(p.size());
898- data_file .write(p.data(), p.size());
899- data_file .write(reinterpret_cast<*char>(hash&), 8);
902+ hash_data_file << unsafe_cast<u16>(p.size());
903+ hash_data_file .write(p.data(), p.size());
904+ hash_data_file .write(reinterpret_cast<*char>(hash&), 8);
900905 }
901906
902907 for transpile_futures do(inout fut) {
@@ -937,7 +942,6 @@ do_build: (targets: std::vector<std::string>) -> (stuff: full_build_info, exit_c
937942 std::pair("std.compat", true),
938943 );
939944
940-
941945 for cpp1_module_source_files do(src_file: fs::path) {
942946 result := cpp2b_parse_cpp1_module_statements(std::ifstream(src_file));
943947
0 commit comments