mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 15:22:15 +00:00
Improve drawergen to only recompile the object file if its timestamp does not match
This commit is contained in:
parent
015151d0f4
commit
f4d5fb4c25
8 changed files with 65 additions and 1 deletions
|
@ -21,6 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
#include "timestamp.h"
|
||||||
#include "fixedfunction/drawspancodegen.h"
|
#include "fixedfunction/drawspancodegen.h"
|
||||||
#include "fixedfunction/drawwallcodegen.h"
|
#include "fixedfunction/drawwallcodegen.h"
|
||||||
#include "fixedfunction/drawcolumncodegen.h"
|
#include "fixedfunction/drawcolumncodegen.h"
|
||||||
|
@ -618,6 +619,18 @@ std::string LLVMProgram::DumpModule()
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
std::string &AllTimestamps()
|
||||||
|
{
|
||||||
|
static std::string timestamps;
|
||||||
|
return timestamps;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddSourceFileTimestamp(const char *timestamp)
|
||||||
|
{
|
||||||
|
if (!AllTimestamps().empty()) AllTimestamps().push_back(' ');
|
||||||
|
AllTimestamps() += timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
|
@ -626,6 +639,25 @@ int main(int argc, char **argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string timestamp_filename = argv[1] + std::string(".timestamp");
|
||||||
|
|
||||||
|
FILE *file = fopen(timestamp_filename.c_str(), "rb");
|
||||||
|
if (file != nullptr)
|
||||||
|
{
|
||||||
|
char buffer[4096];
|
||||||
|
int bytes_read = fread(buffer, 1, 4096, file);
|
||||||
|
fclose(file);
|
||||||
|
std::string last_timestamp;
|
||||||
|
if (bytes_read > 0)
|
||||||
|
last_timestamp = std::string(buffer, bytes_read);
|
||||||
|
|
||||||
|
if (AllTimestamps() == last_timestamp)
|
||||||
|
{
|
||||||
|
std::cout << "Not recompiling drawers because the object file is already up to date." << std::endl;
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
llvm::install_fatal_error_handler([](void *user_data, const std::string& reason, bool gen_crash_diag)
|
llvm::install_fatal_error_handler([](void *user_data, const std::string& reason, bool gen_crash_diag)
|
||||||
{
|
{
|
||||||
std::cerr << "LLVM fatal error: " << reason;
|
std::cerr << "LLVM fatal error: " << reason;
|
||||||
|
@ -640,7 +672,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
LLVMDrawers drawersSSE2(cpuName, "_SSE2");
|
LLVMDrawers drawersSSE2(cpuName, "_SSE2");
|
||||||
|
|
||||||
FILE *file = fopen(argv[1], "wb");
|
file = fopen(argv[1], "wb");
|
||||||
if (file == nullptr)
|
if (file == nullptr)
|
||||||
{
|
{
|
||||||
std::cerr << "Unable to open " << argv[1] << " for writing." << std::endl;
|
std::cerr << "Unable to open " << argv[1] << " for writing." << std::endl;
|
||||||
|
@ -656,6 +688,20 @@ int main(int argc, char **argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
file = fopen(timestamp_filename.c_str(), "wb");
|
||||||
|
if (file == nullptr)
|
||||||
|
{
|
||||||
|
std::cerr << "Could not create timestamp file" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
result = fwrite(AllTimestamps().data(), AllTimestamps().length(), 1, file);
|
||||||
|
fclose(file);
|
||||||
|
if (result != 1)
|
||||||
|
{
|
||||||
|
std::cerr << "Could not write timestamp file" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
//LLVMDrawers drawersSSE4("core2");
|
//LLVMDrawers drawersSSE4("core2");
|
||||||
//LLVMDrawers drawersAVX("sandybridge");
|
//LLVMDrawers drawersAVX("sandybridge");
|
||||||
//LLVMDrawers drawersAVX2("haswell");
|
//LLVMDrawers drawersAVX2("haswell");
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
#include "timestamp.h"
|
||||||
#include "fixedfunction/drawcolumncodegen.h"
|
#include "fixedfunction/drawcolumncodegen.h"
|
||||||
#include "ssa/ssa_function.h"
|
#include "ssa/ssa_function.h"
|
||||||
#include "ssa/ssa_scope.h"
|
#include "ssa/ssa_scope.h"
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
#include "timestamp.h"
|
||||||
#include "fixedfunction/drawercodegen.h"
|
#include "fixedfunction/drawercodegen.h"
|
||||||
#include "ssa/ssa_function.h"
|
#include "ssa/ssa_function.h"
|
||||||
#include "ssa/ssa_scope.h"
|
#include "ssa/ssa_scope.h"
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
#include "timestamp.h"
|
||||||
#include "fixedfunction/drawskycodegen.h"
|
#include "fixedfunction/drawskycodegen.h"
|
||||||
#include "ssa/ssa_function.h"
|
#include "ssa/ssa_function.h"
|
||||||
#include "ssa/ssa_scope.h"
|
#include "ssa/ssa_scope.h"
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
#include "timestamp.h"
|
||||||
#include "fixedfunction/drawspancodegen.h"
|
#include "fixedfunction/drawspancodegen.h"
|
||||||
#include "ssa/ssa_function.h"
|
#include "ssa/ssa_function.h"
|
||||||
#include "ssa/ssa_scope.h"
|
#include "ssa/ssa_scope.h"
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
#include "timestamp.h"
|
||||||
#include "fixedfunction/drawtrianglecodegen.h"
|
#include "fixedfunction/drawtrianglecodegen.h"
|
||||||
#include "ssa/ssa_function.h"
|
#include "ssa/ssa_function.h"
|
||||||
#include "ssa/ssa_scope.h"
|
#include "ssa/ssa_scope.h"
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
#include "timestamp.h"
|
||||||
#include "fixedfunction/drawwallcodegen.h"
|
#include "fixedfunction/drawwallcodegen.h"
|
||||||
#include "ssa/ssa_function.h"
|
#include "ssa/ssa_function.h"
|
||||||
#include "ssa/ssa_scope.h"
|
#include "ssa/ssa_scope.h"
|
||||||
|
|
12
tools/drawergen/timestamp.h
Normal file
12
tools/drawergen/timestamp.h
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
void AddSourceFileTimestamp(const char *timestamp);
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
struct TimestampSourceFile
|
||||||
|
{
|
||||||
|
TimestampSourceFile() { AddSourceFileTimestamp(__TIME__); }
|
||||||
|
} timestamp;
|
||||||
|
}
|
Loading…
Reference in a new issue