-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compile client with default read and write access
This makes it more convenient to start the client without asking for permissions to the Steam's common folder. Read-write access is only applied for supported games. The permission prompt will only appear if the game is not located where it is expected to be. This only works for Windows since on Linux all games are located in the users home directory.
- Loading branch information
Showing
3 changed files
with
60 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,22 +4,40 @@ | |
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
import { join } from 'https://deno.land/[email protected]/path/mod.ts'; | ||
import { Command } from 'https://deno.land/x/[email protected]/command/mod.ts'; | ||
import { colors } from 'https://deno.land/x/[email protected]/ansi/colors.ts'; | ||
|
||
const devHostname = 'autorender.portal2.local'; | ||
|
||
const supportedTargets: Record<string, { target: string; binaryName: string }> = { | ||
type SupportedTarget = { | ||
target: string; | ||
binaryName: string; | ||
steamappsDir?: string; | ||
}; | ||
|
||
const supportedTargets: Record<string, SupportedTarget> = { | ||
linux: { | ||
target: 'x86_64-unknown-linux-gnu', | ||
binaryName: 'autorenderclient', | ||
}, | ||
windows: { | ||
target: 'x86_64-pc-windows-msvc', | ||
binaryName: 'autorenderclient.exe', | ||
steamappsDir: 'C:\\\\Program Files (x86)\\\\Steam\\\\steamapps', | ||
}, | ||
}; | ||
|
||
export const supportedGames: Record<string, { sourcemod: boolean }> = { | ||
'Portal 2': { sourcemod: false }, | ||
'Aperture Tag': { sourcemod: false }, | ||
'Thinking with Time Machine': { sourcemod: false }, | ||
'Portal Stories Mel': { sourcemod: false }, | ||
// 'Portal 2 Community Edition': { sourcemod: false }, | ||
'Portal Reloaded': { sourcemod: false }, | ||
'Portal 2 Speedrun Mod': { sourcemod: true }, | ||
}; | ||
|
||
const getCompilationOptions = (os: string) => { | ||
const target = supportedTargets[os]; | ||
if (!target) { | ||
|
@@ -41,24 +59,28 @@ const main = async () => { | |
const systems = all ? ['linux', 'windows'] : [os ?? Deno.build.os]; | ||
|
||
for (const os of systems) { | ||
const { target, binaryName } = getCompilationOptions(os); | ||
const { target, binaryName, steamappsDir } = getCompilationOptions(os); | ||
const developerFlags = release ? '' : `--unsafely-ignore-certificate-errors=${devHostname}`; | ||
|
||
const command = new Deno.Command('deno', { | ||
env: { | ||
COMPILATION_TARGET: target, | ||
COMPILATION_BINARY_NAME: binaryName, | ||
COMPILATION_DEVELOPER_FLAGS: developerFlags, | ||
}, | ||
args: [ | ||
'task', | ||
'--cwd', | ||
'src/client', | ||
'compile', | ||
], | ||
}); | ||
const env = { | ||
COMPILATION_TARGET: target, | ||
COMPILATION_BINARY_NAME: binaryName, | ||
COMPILATION_DEVELOPER_FLAGS: developerFlags, | ||
COMPILATION_READ_WRITE_GAME_PATHS: steamappsDir | ||
? ',' + Object.entries(supportedGames) | ||
.map(([gameName, { sourcemod }]) => join(steamappsDir, sourcemod ? 'sourcemods' : 'common', gameName!)) | ||
.join(',') | ||
: '', | ||
}; | ||
|
||
const args = [ | ||
'task', | ||
'--cwd', | ||
'src/client', | ||
'compile', | ||
]; | ||
|
||
await command | ||
await new Deno.Command('deno', { env, args }) | ||
.spawn() | ||
.output(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters