From 4c5d4c5ae9857dd0db17963bfa48d452accff63f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Wa=C5=9Bko?= Date: Mon, 14 Oct 2024 17:13:07 +0200 Subject: [PATCH 1/3] Add `Meta.engine_version` --- .../lib/Standard/Base/0.0.0-dev/src/Meta.enso | 6 +++ .../meta/CurrentEngineVersionNode.java | 40 +++++++++++++++++++ test/Base_Tests/src/Semantic/Meta_Spec.enso | 5 +++ 3 files changed, 51 insertions(+) create mode 100644 engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/CurrentEngineVersionNode.java diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Meta.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Meta.enso index 49d4095ef40c..230da42d53e2 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Meta.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Meta.enso @@ -688,3 +688,9 @@ type Instrumentor - fqn: fully qualified name. find_type_by_qualified_name : Text -> Any find_type_by_qualified_name fqn = @Builtin_Method "Meta.find_type_by_qualified_name" + +## PRIVATE + ADVANCED + Returns the version of the currently running Enso engine. +engine_version : Text +engine_version = @Builtin_Method "Meta.engine_version" diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/CurrentEngineVersionNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/CurrentEngineVersionNode.java new file mode 100644 index 000000000000..c96e66f1281a --- /dev/null +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/CurrentEngineVersionNode.java @@ -0,0 +1,40 @@ +package org.enso.interpreter.node.expression.builtin.meta; + +import com.oracle.truffle.api.nodes.Node; +import org.enso.interpreter.dsl.BuiltinMethod; +import org.enso.interpreter.runtime.data.text.Text; +import org.enso.version.BuildVersion; +import scala.collection.mutable.StringBuilder; + +@BuiltinMethod( + type = "Meta", + name = "engine_version", + description = "Returns the version of the currently running Enso engine.", + autoRegister = false) +public class CurrentEngineVersionNode extends Node { + + public Text execute() { + StringBuilder sb = new StringBuilder(); + sb.append("Enso Engine Version: "); + sb.append(BuildVersion.ensoVersion()); + sb.append("\nDefault Edition: "); + sb.append(BuildVersion.currentEdition()); + + sb.append("\nCompiled with GraalVM "); + sb.append(BuildVersion.graalVersion()); + sb.append(", Scalac "); + sb.append(BuildVersion.scalacVersion()); + + sb.append("\nBased on commit "); + sb.append(BuildVersion.commit()); + sb.append(" on ref "); + sb.append(BuildVersion.ref()); + sb.append(" at "); + sb.append(BuildVersion.latestCommitDate()); + if (BuildVersion.isDirty()) { + sb.append(" (with uncommitted changes)"); + } + + return Text.create(sb.toString()); + } +} diff --git a/test/Base_Tests/src/Semantic/Meta_Spec.enso b/test/Base_Tests/src/Semantic/Meta_Spec.enso index 9714a3882d9e..42d75e555327 100644 --- a/test/Base_Tests/src/Semantic/Meta_Spec.enso +++ b/test/Base_Tests/src/Semantic/Meta_Spec.enso @@ -476,6 +476,11 @@ add_specs suite_builder = typ = Meta.Type.find fqn typ . should_equal meta_type + suite_builder.group "Engine Metadata" group_builder-> + group_builder.specify "should return engine version" <| + version = Meta.engine_version + version.should_contain "Enso Engine Version:" + main filter=Nothing = suite = Test.build suite_builder-> add_specs suite_builder From 01e3afff06d78ecb268ac791d8e06d75e91b2919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Wa=C5=9Bko?= Date: Mon, 14 Oct 2024 17:22:00 +0200 Subject: [PATCH 2/3] reorder, change import --- .../builtin/meta/CurrentEngineVersionNode.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/CurrentEngineVersionNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/CurrentEngineVersionNode.java index c96e66f1281a..fa1897e081a6 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/CurrentEngineVersionNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/CurrentEngineVersionNode.java @@ -4,7 +4,6 @@ import org.enso.interpreter.dsl.BuiltinMethod; import org.enso.interpreter.runtime.data.text.Text; import org.enso.version.BuildVersion; -import scala.collection.mutable.StringBuilder; @BuiltinMethod( type = "Meta", @@ -27,12 +26,12 @@ public Text execute() { sb.append("\nBased on commit "); sb.append(BuildVersion.commit()); - sb.append(" on ref "); - sb.append(BuildVersion.ref()); - sb.append(" at "); + sb.append(" (at "); sb.append(BuildVersion.latestCommitDate()); + sb.append(")\non ref "); + sb.append(BuildVersion.ref()); if (BuildVersion.isDirty()) { - sb.append(" (with uncommitted changes)"); + sb.append("\n(with uncommitted changes)"); } return Text.create(sb.toString()); From cbf12d8df04356482c8b3374162ffe1bed839bcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Wa=C5=9Bko?= Date: Tue, 15 Oct 2024 11:36:54 +0200 Subject: [PATCH 3/3] truffle boundary --- .../expression/builtin/meta/CurrentEngineVersionNode.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/CurrentEngineVersionNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/CurrentEngineVersionNode.java index fa1897e081a6..881446ef38c3 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/CurrentEngineVersionNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/CurrentEngineVersionNode.java @@ -1,5 +1,6 @@ package org.enso.interpreter.node.expression.builtin.meta; +import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.nodes.Node; import org.enso.interpreter.dsl.BuiltinMethod; import org.enso.interpreter.runtime.data.text.Text; @@ -13,6 +14,11 @@ public class CurrentEngineVersionNode extends Node { public Text execute() { + return getCurrentVersion(); + } + + @CompilerDirectives.TruffleBoundary + private Text getCurrentVersion() { StringBuilder sb = new StringBuilder(); sb.append("Enso Engine Version: "); sb.append(BuildVersion.ensoVersion());