aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-03-28 15:33:38 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-03-28 15:33:38 -0400
commit583d11401294c962f5ad3296221c2de7823fb7d6 (patch)
tree7c12fe682dc2e7e1375ac6a06c1b3ce277fdb2bf /src
parentca76fb335ae7b3f820beeeed5667950e7489711e (diff)
Add platform check for /proc/self/exe
Diffstat (limited to 'src')
-rw-r--r--src/tomo.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/tomo.c b/src/tomo.c
index 21ebed2f..9233244c 100644
--- a/src/tomo.c
+++ b/src/tomo.c
@@ -31,7 +31,10 @@
#define run_cmd(...) ({ const char *_cmd = String(__VA_ARGS__); if (verbose) print("\033[34;1m", _cmd, "\033[m"); popen(_cmd, "w"); })
#define array_text(arr) Text$join(Text(" "), arr)
+#ifdef __linux__
+// Only on Linux is /proc/self/exe available
static struct stat compiler_stat;
+#endif
static const char *paths_str(Array_t paths) {
Text_t result = EMPTY_TEXT;
@@ -88,6 +91,7 @@ typedef struct {
#endif
int main(int argc, char *argv[])
{
+#ifdef __linux__
// Get the file modification time of the compiler, so we
// can recompile files after changing the compiler:
char compiler_path[PATH_MAX];
@@ -97,6 +101,7 @@ int main(int argc, char *argv[])
compiler_path[count] = '\0';
if (stat(compiler_path, &compiler_stat) != 0)
err(1, "Could not find age of compiler");
+#endif
USE_COLOR = getenv("COLOR") ? strcmp(getenv("COLOR"), "1") == 0 : isatty(STDOUT_FILENO);
if (getenv("NO_COLOR") && getenv("NO_COLOR")[0] != '\0')
@@ -595,9 +600,11 @@ bool is_stale(Path_t path, Path_t relative_to)
if (stat(Path$as_c_string(path), &target_stat) != 0)
return true;
+#ifdef __linux__
// Any file older than the compiler is stale:
if (target_stat.st_mtime < compiler_stat.st_mtime)
return true;
+#endif
struct stat relative_to_stat;
if (stat(Path$as_c_string(relative_to), &relative_to_stat) != 0)