@@ -700,10 +700,15 @@ unix_build_build_script_cmd: (compiler_cmd: std::string, info: cpp2b_source_buil
700
700
build_build_script: (info: cpp2b_source_build_info) -> build_binary_result = {
701
701
compiler :== cpp2b::compiler();
702
702
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")
703
704
log_path := fs::absolute(".cache/cpp2/log/compile") / fs::path(info.src).replace_extension(".log");
704
705
ensure_dir(log_path.parent_path());
705
706
ensure_dir(bin_outpath.parent_path());
706
707
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
+
707
712
d := fs::absolute(modules_dir());
708
713
cmd_str: std::string = "";
709
714
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
853
858
file_hashes.insert(std::make_pair(p, hash));
854
859
}
855
860
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);
857
862
858
- while data_file {
863
+ while hash_data_file {
859
864
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; }
862
867
863
868
p: std::string = "";
864
869
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; }
867
872
868
873
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; }
871
876
872
877
prev_file_hashes[fs::path(p)] = path_hash;
873
878
}
@@ -887,16 +892,16 @@ do_build: (targets: std::vector<std::string>) -> (stuff: full_build_info, exit_c
887
892
}
888
893
}
889
894
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);
892
897
893
898
for file_hashes do(inout entry) {
894
899
p := entry.first.generic_string();
895
900
hash := entry.second;
896
901
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);
900
905
}
901
906
902
907
for transpile_futures do(inout fut) {
@@ -937,7 +942,6 @@ do_build: (targets: std::vector<std::string>) -> (stuff: full_build_info, exit_c
937
942
std::pair("std.compat", true),
938
943
);
939
944
940
-
941
945
for cpp1_module_source_files do(src_file: fs::path) {
942
946
result := cpp2b_parse_cpp1_module_statements(std::ifstream(src_file));
943
947
0 commit comments