From 671ac8030d3af107e6ee362772d8a3771b98e34f Mon Sep 17 00:00:00 2001
From: Marco Matthies <71844+marcom@users.noreply.github.com>
Date: Mon, 17 Jun 2024 16:53:24 +0200
Subject: [PATCH] Only call precompile during package precompilation

---
 src/Persefone.jl | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/Persefone.jl b/src/Persefone.jl
index 12e1faf..615fd88 100644
--- a/src/Persefone.jl
+++ b/src/Persefone.jl
@@ -149,8 +149,12 @@ include("nature/species/wyvern.jl")
 
 include("core/simulation.jl") #this must be last
 
-# precompile important functions - TODO use PrecompileTools.jl
-precompile(initialise, (String,Int))
-precompile(stepsimulation!, (SimulationModel,))
-
+function _precompile()
+    precompile(initialise, (String,Int))
+    precompile(stepsimulation!, (SimulationModel,))
+end
+if ccall(:jl_generating_output, Cint, ()) == 1
+    # only run this during precompilation
+    _precompile()
+end
 end
-- 
GitLab