@@ -702,10 +702,15 @@ unix_build_build_script_cmd: (compiler_cmd: std::string, info: cpp2b_source_buil
702
702
build_build_script: (info: cpp2b_source_build_info) -> build_binary_result = {
703
703
compiler :== cpp2b::compiler();
704
704
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")
705
706
log_path := fs::absolute(".cache/cpp2/log/compile") / fs::path(info.src).replace_extension(".log");
706
707
ensure_dir(log_path.parent_path());
707
708
ensure_dir(bin_outpath.parent_path());
708
709
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
+
709
714
d := fs::absolute(modules_dir());
710
715
cmd_str: std::string = "";
711
716
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
855
860
file_hashes.insert(std::make_pair(p, hash));
856
861
}
857
862
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);
859
864
860
- while data_file {
865
+ while hash_data_file {
861
866
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; }
864
869
865
870
p: std::string = "";
866
871
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; }
869
874
870
875
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; }
873
878
874
879
prev_file_hashes[fs::path(p)] = path_hash;
875
880
}
@@ -889,16 +894,16 @@ do_build: (targets: std::vector<std::string>) -> (stuff: full_build_info, exit_c
889
894
}
890
895
}
891
896
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);
894
899
895
900
for file_hashes do(inout entry) {
896
901
p := entry.first.generic_string();
897
902
hash := entry.second;
898
903
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);
902
907
}
903
908
904
909
for transpile_futures do(inout fut) {
@@ -939,7 +944,6 @@ do_build: (targets: std::vector<std::string>) -> (stuff: full_build_info, exit_c
939
944
std::pair("std.compat", true),
940
945
);
941
946
942
-
943
947
for cpp1_module_source_files do(src_file: fs::path) {
944
948
result := cpp2b_parse_cpp1_module_statements(std::ifstream(src_file));
945
949
0 commit comments