-q option

This commit is contained in:
vrd
2025-06-06 18:00:38 +03:00
parent 0d330bd3da
commit c0fd5197e0
2 changed files with 22 additions and 5 deletions
+22 -4
View File
@@ -61,12 +61,16 @@ const char DEBUG_PREFIX[] = "__DBG";
// Context // Context
fs::path HOME; fs::path HOME;
bool debug = false;
fs::path src_file; fs::path src_file;
SrcType src_type; SrcType src_type;
fs::path cache_dir; fs::path cache_dir;
fs::path bin; // cache bins to avoid recompiles fs::path bin; // cache bins to avoid recompiles
// Options
bool debug = false;
// just compare timestamps of the source and bin, dont preprocess
bool quick = false;
} }
int main(int argc, char* argv[]) int main(int argc, char* argv[])
@@ -119,7 +123,8 @@ int parse_args_until_src(int argc, char* argv[])
"Pass the ARGUMENTS to the compiled binary\n" "Pass the ARGUMENTS to the compiled binary\n"
"The binaries are cached and recompiled only if the source or it's headers have changed\n\n" "The binaries are cached and recompiled only if the source or it's headers have changed\n\n"
"Options:\n" "Options:\n"
"-g debug the binary, asserts are also enabled\n\n" "-g debug the binary, asserts are also enabled\n"
"-q quicker, just compare source and binary time stamps, if included files were updated a recompile WON'T occur!\n\n"
"Environment variables:\n" "Environment variables:\n"
"CPPIPEPATH - ':'-separated list of directories to prepend to the FILE search path\n"; "CPPIPEPATH - ':'-separated list of directories to prepend to the FILE search path\n";
exit(0); exit(0);
@@ -128,12 +133,15 @@ int parse_args_until_src(int argc, char* argv[])
{ {
debug = true; debug = true;
} }
else if( arg == "-q" )
{
quick = true;
}
else // Then treat it as the src_arg else // Then treat it as the src_arg
{ {
src_arg = i; src_arg = i;
break; break;
} }
} }
if( !src_arg ) if( !src_arg )
@@ -284,6 +292,16 @@ optional<fs::path> preprocess_and_compare()
void compile_src_file() void compile_src_file()
{ {
if(quick)
{
error_code ec;
if(fs::last_write_time(src_file) < fs::last_write_time(bin, ec))
{
// Binary is newer then source, dont recompile
return;
}
}
optional<fs::path> new_preprocessed = preprocess_and_compare(); optional<fs::path> new_preprocessed = preprocess_and_compare();
// Only compile if the source is newer then the bin // Only compile if the source is newer then the bin
@@ -316,7 +334,7 @@ void compile_src_file()
void print_usage() void print_usage()
{ {
cout << "Usage: cppipe [-g] FILE [ARGUMENTS]...\n"; cout << "Usage: cppipe [OPTION]... FILE [ARGUMENTS]...\n";
} }
SrcType find_src_type(const string_view p) SrcType find_src_type(const string_view p)
-1
View File
@@ -1,4 +1,3 @@
-q only check timestamps
man man
tips (sigaction SIGCHILD, SIG_IGN, SIG_DFL) tips (sigaction SIGCHILD, SIG_IGN, SIG_DFL)
- redirected processes block if their output is not read - redirected processes block if their output is not read