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..881446ef38c3 --- /dev/null +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/CurrentEngineVersionNode.java @@ -0,0 +1,45 @@ +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; +import org.enso.version.BuildVersion; + +@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() { + return getCurrentVersion(); + } + + @CompilerDirectives.TruffleBoundary + private Text getCurrentVersion() { + 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(" (at "); + sb.append(BuildVersion.latestCommitDate()); + sb.append(")\non ref "); + sb.append(BuildVersion.ref()); + if (BuildVersion.isDirty()) { + sb.append("\n(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