-
-
Notifications
You must be signed in to change notification settings - Fork 480
[Improv]: Add environment variables for use by wrappers #2969
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
Changes from 2 commits
d595dbc
8db11ac
87ee893
5d1a6fe
e78e680
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 | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -45,6 +45,7 @@ import { | |||||||||||||||||||||||||||||||
GameInfo, | ||||||||||||||||||||||||||||||||
Runner, | ||||||||||||||||||||||||||||||||
EnviromentVariable, | ||||||||||||||||||||||||||||||||
WrapperEnv, | ||||||||||||||||||||||||||||||||
WrapperVariable, | ||||||||||||||||||||||||||||||||
ExecResult, | ||||||||||||||||||||||||||||||||
GameSettings, | ||||||||||||||||||||||||||||||||
|
@@ -275,6 +276,7 @@ async function prepareWineLaunch( | |||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||
* Maps general settings to environment variables | ||||||||||||||||||||||||||||||||
* @param gameSettings The GameSettings to get the environment variables for | ||||||||||||||||||||||||||||||||
* @param wrapperEnv The wrapper info to be added into the environment variables | ||||||||||||||||||||||||||||||||
* @returns A big string of environment variables, structured key=value | ||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||
function setupEnvVars(gameSettings: GameSettings) { | ||||||||||||||||||||||||||||||||
|
@@ -305,6 +307,34 @@ function setupEnvVars(gameSettings: GameSettings) { | |||||||||||||||||||||||||||||||
return ret | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||
* Maps launcher info to environment variables for consumption by wrappers | ||||||||||||||||||||||||||||||||
* @param wrapperEnv The info to be added into the environment variables | ||||||||||||||||||||||||||||||||
* @returns Environment variables | ||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||
function setupWrapperEnvVars(wrapperEnv: WrapperEnv) { | ||||||||||||||||||||||||||||||||
const ret: Record<string, string> = {} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
ret.HEROIC_APP_NAME = wrapperEnv.appName | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
switch (wrapperEnv.appRunner) { | ||||||||||||||||||||||||||||||||
case 'gog': | ||||||||||||||||||||||||||||||||
ret.HEROIC_APP_SOURCE = 'gog' | ||||||||||||||||||||||||||||||||
break | ||||||||||||||||||||||||||||||||
case 'legendary': | ||||||||||||||||||||||||||||||||
ret.HEROIC_APP_SOURCE = 'epic' | ||||||||||||||||||||||||||||||||
break | ||||||||||||||||||||||||||||||||
case 'nile': | ||||||||||||||||||||||||||||||||
ret.HEROIC_APP_SOURCE = 'amazon' | ||||||||||||||||||||||||||||||||
break | ||||||||||||||||||||||||||||||||
case 'sideload': | ||||||||||||||||||||||||||||||||
ret.HEROIC_APP_SOURCE = 'sideload' | ||||||||||||||||||||||||||||||||
break | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
Comment on lines
+320
to
+333
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. Why not ?
Suggested change
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. I was thinking there could be a case in the future where it may help to distinguish the runner and the source, like if you could choose two different runners for the same store or if one runner supported multiple stores. Not sure if that's a valid/realistic concern given Heroic's design goals. I added a |
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
return ret | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||
* Maps Wine-related settings to environment variables | ||||||||||||||||||||||||||||||||
* @param gameSettings The GameSettings to get the environment variables for | ||||||||||||||||||||||||||||||||
|
@@ -982,6 +1012,7 @@ export { | |||||||||||||||||||||||||||||||
launchCleanup, | ||||||||||||||||||||||||||||||||
prepareWineLaunch, | ||||||||||||||||||||||||||||||||
setupEnvVars, | ||||||||||||||||||||||||||||||||
setupWrapperEnvVars, | ||||||||||||||||||||||||||||||||
setupWineEnvVars, | ||||||||||||||||||||||||||||||||
setupWrappers, | ||||||||||||||||||||||||||||||||
runWineCommand, | ||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -62,6 +62,7 @@ import { | |||||||||||||||||||||||||
prepareWineLaunch, | ||||||||||||||||||||||||||
runWineCommand as runWineCommandUtil, | ||||||||||||||||||||||||||
setupEnvVars, | ||||||||||||||||||||||||||
setupWrapperEnvVars, | ||||||||||||||||||||||||||
setupWrappers | ||||||||||||||||||||||||||
} from '../../launcher' | ||||||||||||||||||||||||||
import { | ||||||||||||||||||||||||||
|
@@ -464,9 +465,13 @@ export async function launch( | |||||||||||||||||||||||||
? ['--override-exe', gameSettings.targetExe] | ||||||||||||||||||||||||||
: [] | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
let commandEnv = isWindows | ||||||||||||||||||||||||||
? process.env | ||||||||||||||||||||||||||
: { ...process.env, ...setupEnvVars(gameSettings) } | ||||||||||||||||||||||||||
let commandEnv = { | ||||||||||||||||||||||||||
...process.env, | ||||||||||||||||||||||||||
...setupWrapperEnvVars({ appName, appRunner: 'gog' }) | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
if (!isWindows) { | ||||||||||||||||||||||||||
commandEnv = { ...commandEnv, ...setupEnvVars(gameSettings) } | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
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.
Suggested change
This feels a little cleaner 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. Good call. Updated in 5d1a6fe. |
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
const wrappers = setupWrappers( | ||||||||||||||||||||||||||
gameSettings, | ||||||||||||||||||||||||||
|
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.
Seems like this was moved to its own function
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.
Ah, I originally tried adding the functionality here, but realized it worked better separate and forgot to reset the documentation. Fixed in 87ee893.