Skip to content

Comptime Improvements#2417

Open
Rune-Magic wants to merge 23 commits intobeefytech:masterfrom
Rune-Magic:cfi
Open

Comptime Improvements#2417
Rune-Magic wants to merge 23 commits intobeefytech:masterfrom
Rune-Magic:cfi

Conversation

@Rune-Magic
Copy link
Copy Markdown
Contributor

@Rune-Magic Rune-Magic commented Mar 25, 2026

adds:

  • Console.Write[Line] to comptime
  • Environment.[G|S]etVariable to comptime
  • make Compiler.Options.* eval to their enum type instead of to int32
  • add Console.RunShellCommand

@Rune-Magic Rune-Magic mentioned this pull request Mar 25, 2026
3 tasks
@Rune-Magic
Copy link
Copy Markdown
Contributor Author

Rune-Magic commented Mar 26, 2026

btw something like Console.RunShellCommand is neccersary because currently the only way to replicate its functionality is: (which doesn't run at comptime)

// I tried for an hour and was not able to get anything working :(

not sure if this is the best exposure of such a feature though

@bfiete
Copy link
Copy Markdown
Collaborator

bfiete commented Mar 27, 2026

And what about what I had mentioned earlier - write out a script/batch file and then run it in prebuild?

@bfiete
Copy link
Copy Markdown
Collaborator

bfiete commented Mar 27, 2026

RunShellCommand is not a feature I am prepared to add at the moment, as I had previously mentioned. It goes into a deeper feature or controlling the build process via code, which I had said I was not ready to do.

@Rune-Magic
Copy link
Copy Markdown
Contributor Author

Rune-Magic commented Mar 29, 2026

I mean you can already do this at comptime: (UseShellExecute doesn't work though)

let startInfo = scope ProcessStartInfo();
startInfo.SetFileNameAndArguments("<command>");
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.CreateNoWindow = true;

let proc = scope SpawnedProcess();
if (proc.Start(startInfo) case .Err)
    return;

let output = scope FileStream();
let sr = scope StreamReader(output);
proc.AttachStandardOutput(output);

while (!proc.HasExited)
{
	let str = sr.ReadToEnd(.. scope .());
	Console.Write(str);
}

it's just a more convinenient way of doing that

@bfiete
Copy link
Copy Markdown
Collaborator

bfiete commented Mar 29, 2026

It's not the "executing things" that I object to, it's the "interacting with the build system via comptime" that I object to.

@Rune-Magic
Copy link
Copy Markdown
Contributor Author

Rune-Magic commented Mar 29, 2026

but RunShellCommand just runs a shell command, it doesn't run an ide command or a script manager command

@bfiete
Copy link
Copy Markdown
Collaborator

bfiete commented Mar 29, 2026

https://github.com/beefytech/Beef/pull/2417/changes#diff-b6a56ea0c901990ffc877cad40196069f530a9aa0c1418c94a40cce1e98b87f7R800
let inst = app.DoRun("", StringView(cmd), app.mWorkspace.mDir, .None, null, null, .ShellCommand);

DoRun is the part of the "build system". This is "interacting with the build system via coptime". Why does everything with you have to be so argumentative?

@Rune-Magic
Copy link
Copy Markdown
Contributor Author

I thought it only starts a process and streams it's stdout to the output window, but I can change the implementation if you like

@bfiete
Copy link
Copy Markdown
Collaborator

bfiete commented Mar 29, 2026

I don't think you're hearing me, here. This feature is not happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants