From c0fd5197e098c69d751008eaff6706464113284f Mon Sep 17 00:00:00 2001 From: Venelin Date: Tue, 24 Dec 2024 17:34:52 +0200 Subject: [PATCH] -q option --- src/cppipe.cpp | 26 ++++++++++++++++++++++---- todo.txt | 1 - 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/cppipe.cpp b/src/cppipe.cpp index 99e659f..26a2e3a 100644 --- a/src/cppipe.cpp +++ b/src/cppipe.cpp @@ -61,12 +61,16 @@ const char DEBUG_PREFIX[] = "__DBG"; // Context fs::path HOME; -bool debug = false; fs::path src_file; SrcType src_type; fs::path cache_dir; 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[]) @@ -119,7 +123,8 @@ int parse_args_until_src(int argc, char* argv[]) "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" "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" "CPPIPEPATH - ':'-separated list of directories to prepend to the FILE search path\n"; exit(0); @@ -128,12 +133,15 @@ int parse_args_until_src(int argc, char* argv[]) { debug = true; } + else if( arg == "-q" ) + { + quick = true; + } else // Then treat it as the src_arg { src_arg = i; break; } - } if( !src_arg ) @@ -284,6 +292,16 @@ optional preprocess_and_compare() 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 new_preprocessed = preprocess_and_compare(); // Only compile if the source is newer then the bin @@ -316,7 +334,7 @@ void compile_src_file() 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) diff --git a/todo.txt b/todo.txt index 23046e3..6d5997c 100644 --- a/todo.txt +++ b/todo.txt @@ -1,4 +1,3 @@ --q only check timestamps man tips (sigaction SIGCHILD, SIG_IGN, SIG_DFL) - redirected processes block if their output is not read