-
Notifications
You must be signed in to change notification settings - Fork 6
Add Shell Execution Extensions to Context #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
9966f2d
cafc710
99399d0
23d2fc1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| namespace BuildScripts; | ||
|
|
||
| public static class FrostingContextExtensions | ||
| { | ||
| private static readonly ProcessSettings _processSettings; | ||
|
|
||
| static FrostingContextExtensions() => _processSettings = new ProcessSettings(); | ||
|
|
||
| public static void SetShellWorkingDir(this FrostingContext context, string path) | ||
| { | ||
| _processSettings.WorkingDirectory = path; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feel free to use the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 99399d0 |
||
| } | ||
|
|
||
| public static int ShellExecute(this FrostingContext context, string command, string environmentVariables = "") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pass env variables in a separate function
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 23d2fc1 From our previous discussion, the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Additionally, I was not able to find any decent way of doing space character escapes in the command. The problem comes in situations where you want to set an environment variable such as context.SetShellEnvironmentVariables("CFLAGS", $"-w -arch arm64 -I{dependencyDir}/include");The space escapes would need to be set for the path in the Open to suggestions on this if still needed
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are supposed to set it to either: or |
||
| { | ||
| string shellCommandPath = context switch | ||
| { | ||
| _ when context.IsRunningOnWindows() => @"C:\msys64\usr\bin\bash.exe", | ||
| _ when context.IsRunningOnLinux() => "sh", | ||
| _ when context.IsRunningOnMacOs() => "zsh", | ||
| _ => throw new PlatformNotSupportedException("Unsupported Platform") | ||
| }; | ||
|
|
||
| _processSettings.Arguments = $"-c \"{environmentVariables} {command}\""; | ||
| return context.StartProcess(shellCommandPath, _processSettings); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just do:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 99399d0