Skip to content

Commit

Permalink
Add Meta.engine_version (#11320)
Browse files Browse the repository at this point in the history
Numerous times I wasn't sure when running the IDE if I'm running the bundled engine or a development build. Usually this depends on if I launch the standalone IDE or use a development build of project-manager.

Still it's not always obvious, and making sure that your IDE is running the right engine version is very often the first step when debugging issues with e.g. engine changes not showing up properly.

Thus I thought it may be worth to add this method (currently hidden to users in component browser by marking as `PRIVATE`, one has to type it in manually):
![image](https://github.com/user-attachments/assets/13af3df4-49ff-49bb-9b19-601258a8ca02)

I think it should be a helpful tool for debugging.
  • Loading branch information
radeusgd authored Oct 15, 2024
1 parent 2285b7d commit 21bd05f
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
6 changes: 6 additions & 0 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Meta.enso
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
@@ -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());
}
}
5 changes: 5 additions & 0 deletions test/Base_Tests/src/Semantic/Meta_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 21bd05f

Please sign in to comment.