From acf338139004ffcf879b17112626182977e5bb53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sj=C3=B6lund?= Date: Thu, 20 Aug 2026 09:57:32 +0200 Subject: [PATCH] Fix BuildSysPro's external "C" include directory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Its IncludeDirectory annotations name modelica://BuildSysPro/Resources/C-Sources, which the library does not have — the IBPSA C sources are in IBPSA/Resources/C-Sources, and in a stale copy under Resources/IBPSA/C-Sources in 3.5.0 and older. omc therefore emitted no -I for them and every model reaching one failed to compile. Add both directories with setCFlags, plus the -include flags a few of those sources need: they call str*/malloc/ModelicaError without including the header, and only compile for the C target because the surrounding translation unit happens to have it. With --nobuildmodel, translating and building share one simulate() call and only the record's messages says either failed. Tell them apart by the translation clocks, so a wasm-jit build failure — the JIT compile, or building the model's Include C sources — is reported as Compile rather than as SimCode or Simulate. Assisted-by: Claude Opus 5 --- configs/conf.json | 4 +++- testmodel.py | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/configs/conf.json b/configs/conf.json index e038012..315cea0 100644 --- a/configs/conf.json +++ b/configs/conf.json @@ -210,7 +210,9 @@ "libraryVersionNameForTests":"" }, { - "library":"BuildSysPro" + "library":"BuildSysPro", + "_comment":"IncludeDirectory says modelica://BuildSysPro/Resources/C-Sources, which does not exist; the IBPSA C sources are in IBPSA/Resources/C-Sources (Resources/IBPSA/C-Sources in 3.5.0 and older). Some of them call str*/malloc/ModelicaError without including the header", + "extraCustomCommands":["setCFlags(getCFlags() + \" -include string.h -include stdlib.h -include ModelicaUtilities.h \\\"-I$libraryLocation/IBPSA/Resources/C-Sources\\\" \\\"-I$libraryLocation/Resources/IBPSA/C-Sources\\\"\")"] }, { "library":"BusinessSimulation" diff --git a/testmodel.py b/testmodel.py index da5e1c7..00e59a6 100755 --- a/testmodel.py +++ b/testmodel.py @@ -508,10 +508,13 @@ def simulateCmd(resimulate): execTimeTranslateModel=monotonic()-start simres = None +buildFailed = False if useSimulate: simres = res or {} - # A failed translate/build is only reported in the messages of the record - res = not (simres.get("messages") or "").startswith("Failed to build model") + # A failed translate/build is only reported in the messages of the record; the + # translation clocks below say which of the two it was + buildFailed = (simres.get("messages") or "").startswith("Failed to build model") + res = True err = omc.sendExpression("OpenModelica.Scripting.getErrorString()") total = omc.sendExpression("OpenModelica.Scripting.Internal.Time.timerTock(OpenModelica.Scripting.Internal.Time.RT_CLOCK_SIMULATE_TOTAL)")-total_before buildmodel = omc.sendExpression("OpenModelica.Scripting.Internal.Time.timerTock(OpenModelica.Scripting.Internal.Time.RT_CLOCK_BUILD_MODEL)") @@ -573,6 +576,10 @@ def simulateCmd(resimulate): # a resimulate leaves it in the simulation time execstat["build"] = simres["timeCompile"] if useSimulate else 0.0 execstat["phase"] = 5 + if buildFailed: + with open(errFile, 'a+') as fp: + fp.write(simres.get("messages") or "") + writeResultAndExit(0, False, omc, omc_new) else: if isWin: res = checkOutputTimeout("\"%s\\share\\omc\\scripts\\Compile.bat\" %s gcc %s parallel dynamic 24 0" % (conf["omhome"], conf["fileName"], msysEnvironment), conf["ulimitOmc"], conf)