|
14 | 14 | } |
15 | 15 | }, |
16 | 16 | "extract_dir": "dist", |
| 17 | + "installer": { |
| 18 | + "script": [ |
| 19 | + "ensure \"$dir\\lib\\pkgconfig\" | Out-Null", |
| 20 | + "$content = \"prefix=$dir`nexec_prefix=$dir`nlibdir=$dir\\lib`nincludedir=$dir\\include`npkgdatadir=$dir\\share\\rime-data`npluginsdir=$dir\\lib\\rime-plugins`n`nName: Rime`nDescription: Rime Input Method Engine`nVersion: $version`nCflags: -I`${includedir}`nLibs: -L`${libdir} -lrime\"", |
| 21 | + "$content = $content -replace \"\\\\\", \"/\"", |
| 22 | + "Set-Content -Path \"$dir\\lib\\pkgconfig\\rime.pc\" -Value \"$content\"", |
| 23 | + "function Add-PathToEnvVar {", |
| 24 | + " param(", |
| 25 | + " [string[]]$Path,", |
| 26 | + " [string]$TargetEnvVar,", |
| 27 | + " [switch]$Global,", |
| 28 | + " [switch]$Force", |
| 29 | + " )", |
| 30 | + " $inPath, $strippedPath = Split-PathLikeEnvVar $Path (Get-EnvVar -Name $TargetEnvVar -Global:$Global) -Verbose", |
| 31 | + " if ([string]::IsNullOrEmpty($strippedPath)) {", |
| 32 | + " $val = (@($Path) -join ';')", |
| 33 | + " } else {", |
| 34 | + " $val = ((@($Path) + $strippedPath) -join ';')", |
| 35 | + " }", |
| 36 | + " if (!$inPath -or $Force) {", |
| 37 | + " Set-EnvVar -Name $TargetEnvVar -Value $val -Global:$Global", |
| 38 | + " }", |
| 39 | + " Set-Content env:\\$TargetEnvVar $val", |
| 40 | + "}", |
| 41 | + "Add-PathToEnvVar -Path \"$dir\\lib\\pkgconfig\" -TargetEnvVar \"PKG_CONFIG_PATH\" -Global:$global -Force", |
| 42 | + "Add-PathToEnvVar -Path \"$dir\" -TargetEnvVar \"CMAKE_PREFIX_PATH\" -Global:$global -Force" |
| 43 | + ] |
| 44 | + }, |
| 45 | + "pre_uninstall": [ |
| 46 | + "function Remove-PathFromEnvVar {", |
| 47 | + " param(", |
| 48 | + " [string[]]$Path,", |
| 49 | + " [string]$TargetEnvVar,", |
| 50 | + " [switch]$Global,", |
| 51 | + " [switch]$PassThru", |
| 52 | + " )", |
| 53 | + " $inPath, $strippedPath = Split-PathLikeEnvVar $Path (Get-EnvVar -Name $TargetEnvVar -Global:$Global)", |
| 54 | + " if ($inPath) {", |
| 55 | + " Set-EnvVar -Name $TargetEnvVar -Value $strippedPath -Global:$Global", |
| 56 | + " }", |
| 57 | + " $inSessionPath, $inSessionStrippedPath = Split-PathLikeEnvVar $Path $(Get-Content env:\\$TargetEnvVar -ErrorAction SilentlyContinue)", |
| 58 | + " if ($inSessionPath) {", |
| 59 | + " Set-Content env:\\$TargetEnvVar $inSessionStrippedPath", |
| 60 | + " }", |
| 61 | + " if ($PassThru) {", |
| 62 | + " return $inPath", |
| 63 | + " }", |
| 64 | + "}", |
| 65 | + "Remove-PathFromEnvVar -Path \"$dir\\lib\\pkgconfig\" -TargetEnvVar \"PKG_CONFIG_PATH\" -Global:$global", |
| 66 | + "Remove-PathFromEnvVar -Path \"$dir\" -TargetEnvVar \"CMAKE_PREFIX_PATH\" -Global:$global" |
| 67 | + ], |
17 | 68 | "bin": [ |
18 | 69 | "bin\\rime_deployer.exe", |
19 | 70 | "bin\\rime_dict_manager.exe", |
20 | 71 | "bin\\rime_patch.exe" |
21 | 72 | ], |
| 73 | + "env_add_path": "lib", |
22 | 74 | "env_set": { |
23 | 75 | "LIBRIME_INCLUDE_DIR": "$dir\\include", |
24 | 76 | "LIBRIME_LIB_DIR": "$dir\\lib", |
|
0 commit comments