Working
This commit is contained in:
parent
7cdb08746e
commit
465d0daa9c
Binary file not shown.
@ -70,7 +70,7 @@ static uint64_t fnv1a_64(const void* data, size_t len) {
|
|||||||
// Reset to decimal format
|
// Reset to decimal format
|
||||||
cpp << std::dec;
|
cpp << std::dec;
|
||||||
cpp << "static const size_t filedata_len = " << filedata.size() << ";\n";
|
cpp << "static const size_t filedata_len = " << filedata.size() << ";\n";
|
||||||
cpp << "static const char* file_hash = \"" << hash << "\";\n";
|
cpp << "static uint64_t file_hash = " << hash << "U;\n";
|
||||||
cpp << R"cpp(
|
cpp << R"cpp(
|
||||||
bool recreate_file(std::string destination_folder) {
|
bool recreate_file(std::string destination_folder) {
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
@ -88,13 +88,11 @@ bool recreate_file(std::string destination_folder) {
|
|||||||
std::ofstream out(outpath, std::ios::binary);
|
std::ofstream out(outpath, std::ios::binary);
|
||||||
out.write(reinterpret_cast<const char*>(filedata), filedata_len);
|
out.write(reinterpret_cast<const char*>(filedata), filedata_len);
|
||||||
}
|
}
|
||||||
std::cout << "[dehydrate] " << outpath << ": ";
|
|
||||||
if (!fs::exists(outpath)) {
|
if (!fs::exists(outpath)) {
|
||||||
std::cout << "created\n";
|
std::cout << "[dehydrate] " << outpath.filename() << ": created\n";
|
||||||
} else if (needs_write) {
|
} else if (needs_write) {
|
||||||
std::cout << "updated (hash changed)\n";
|
std::cout << "[dehydrate] " << outpath.filename() << ": updated (hash changed)\n";
|
||||||
} else {
|
|
||||||
std::cout << "unchanged (hash match)\n";
|
|
||||||
}
|
}
|
||||||
return needs_write;
|
return needs_write;
|
||||||
}
|
}
|
||||||
@ -202,7 +200,7 @@ static uint64_t fnv1a_64(const void* data, size_t len) {
|
|||||||
// Reset to decimal format
|
// Reset to decimal format
|
||||||
cpp << std::dec;
|
cpp << std::dec;
|
||||||
cpp << "static const size_t len_" << var << " = " << filedata.size() << ";\n";
|
cpp << "static const size_t len_" << var << " = " << filedata.size() << ";\n";
|
||||||
cpp << "static uint64_t hash_" << var << " = \"" << hash << "\";\n";
|
cpp << "static uint64_t hash_" << var << " = " << hash << "U;\n";
|
||||||
cpp << "static const char* rel_" << var << " = \"" << rel << "\";\n";
|
cpp << "static const char* rel_" << var << " = \"" << rel << "\";\n";
|
||||||
}
|
}
|
||||||
// Write recreate_tree using heredoc style
|
// Write recreate_tree using heredoc style
|
||||||
@ -229,13 +227,11 @@ bool recreate_tree(std::string destination_folder) {
|
|||||||
std::ofstream out(outpath, std::ios::binary);
|
std::ofstream out(outpath, std::ios::binary);
|
||||||
out.write(reinterpret_cast<const char*>()cpp" << "data_" << var << R"cpp(), )cpp" << "len_" << var << R"cpp();
|
out.write(reinterpret_cast<const char*>()cpp" << "data_" << var << R"cpp(), )cpp" << "len_" << var << R"cpp();
|
||||||
}
|
}
|
||||||
std::cout << "[dehydrate] " << outpath << ": ";
|
|
||||||
if (!fs::exists(outpath)) {
|
if (!fs::exists(outpath)) {
|
||||||
std::cout << "created\n";
|
std::cout << "[dehydrate] " << outpath.filename() << ": created\n";
|
||||||
} else if (needs_write) {
|
} else if (needs_write) {
|
||||||
std::cout << "updated (hash changed)\n";
|
std::cout << "[dehydrate] " << outpath.filename() << ": updated (hash changed)\n";
|
||||||
} else {
|
|
||||||
std::cout << "unchanged (hash match)\n";
|
|
||||||
}
|
}
|
||||||
any_written = any_written || needs_write;
|
any_written = any_written || needs_write;
|
||||||
}
|
}
|
||||||
|
6
test.sh
6
test.sh
@ -28,13 +28,19 @@ EOF
|
|||||||
|
|
||||||
g++ -std=c++17 -I $TEST_DIR -o $TEST_DIR/testexe $TEST_DIR/main.cpp $TEST_DIR/_src.cpp
|
g++ -std=c++17 -I $TEST_DIR -o $TEST_DIR/testexe $TEST_DIR/main.cpp $TEST_DIR/_src.cpp
|
||||||
|
|
||||||
|
echo "----------------------------------------"
|
||||||
|
echo "Should generate all files from src/"
|
||||||
$TEST_DIR/testexe
|
$TEST_DIR/testexe
|
||||||
|
|
||||||
# second time should be no changes (hash should match)
|
# second time should be no changes (hash should match)
|
||||||
|
echo "----------------------------------------"
|
||||||
|
echo "Should be no changes - rerun on same output"
|
||||||
$TEST_DIR/testexe
|
$TEST_DIR/testexe
|
||||||
|
|
||||||
|
|
||||||
# third time just two files changed
|
# third time just two files changed
|
||||||
|
echo "----------------------------------------"
|
||||||
|
echo "Should be two changes: generator.cpp and hash.cpp"
|
||||||
rm $TEST_DIR/temp/generator.cpp
|
rm $TEST_DIR/temp/generator.cpp
|
||||||
echo "whee!" >> $TEST_DIR/temp/hash.cpp
|
echo "whee!" >> $TEST_DIR/temp/hash.cpp
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user