Warning, /frameworks/syntax-highlighting/autotests/input/craftenv.ps1 is written in an unsupported language. File is not indexed.

0001 <#
0002    Copied from Craft for testing syntax highlighting
0003 #>
0004 
0005 @" multi
0006    line
0007    string
0008 "@
0009 
0010 $foo = "Test `u{2013} String`nwith `"escapes`""
0011 
0012 #    this file sets some environment variables that are needed
0013 #    for finding programs and libraries etc.
0014 #    by Hannah von Reth <vonreth@kde.org>
0015 #    you should copy kdesettings.ini to ..\etc\kdesettings.ini
0016 #    and adapt it to your needs (see that file for more info)
0017 
0018 #    this file should contain all path settings - and provide thus an environment
0019 #    to build and run kde programs
0020 #    based on kdeenv.bat
0021 
0022 cls
0023 
0024 
0025 $env:CraftRoot=[System.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Definition)
0026 
0027 $CRAFT_ARGUMENTS = $args
0028 
0029 &{
0030 [version]$minPythonVersion = 3.6
0031 
0032 function findPython([string] $name)
0033 {
0034     $py = (Get-Command $name -ErrorAction SilentlyContinue)
0035     if ($py -and ($py | Get-Member Version) -and $py.Version -ge $minPythonVersion) {
0036         $env:CRAFT_PYTHON=$py.Source
0037     }
0038 }
0039 
0040 findPython("python3")
0041 findPython("python")
0042 
0043 function readINI([string] $fileName)
0044 {
0045    $ini = @{}
0046 
0047   switch -regex -file $fileName {
0048     "^\[(.+)\]$" {
0049       $section = $matches[1].Trim()
0050       $ini[$section] = @{}
0051     }
0052     "^\s*([^#].+?)\s*=\s*(.*)" {
0053       $name,$value = $matches[1..2]
0054       $ini[$section][$name] = $value.Trim()
0055     }
0056   }
0057   $ini
0058 }
0059 
0060 
0061 
0062 if(test-path -path $env:CraftRoot\..\etc\kdesettings.ini)
0063 {
0064     $settings = readINI $env:CraftRoot\..\etc\kdesettings.ini
0065 }
0066 else
0067 {
0068     Write-Error("$env:CraftRoot\..\etc\kdesettings.ini Does not exist")
0069     break
0070 }
0071 if( $CRAFT_ARGUMENTS[0] -eq "--get")
0072 {
0073     Write-Host($settings[$CRAFT_ARGUMENTS[1]][$CRAFT_ARGUMENTS[2]])
0074     break
0075 }
0076 
0077 
0078 function prependPATH([string] $path)
0079 {
0080     $env:PATH="$path{0}$env:PATH" -f [IO.Path]::PathSeparator
0081 }
0082 
0083 
0084 if( -Not $env:CRAFT_PYTHON)
0085 {
0086     prependPATH $settings["Paths"]["Python"]
0087     $env:CRAFT_PYTHON=[IO.PATH]::COMBINE($settings["Paths"]["Python"], "python")
0088 }
0089 
0090 (& $env:CRAFT_PYTHON ([IO.PATH]::COMBINE("$env:CraftRoot", "bin", "CraftSetupHelper.py")) "--setup") |
0091 foreach {
0092   if ($_ -match "=") {
0093     $v = $_.split("=")
0094     set-item -force -path "ENV:\$($v[0])"  -value "$($v[1])"
0095     #Write-Host("$v[0]=$v[1]")
0096   }
0097 }
0098 
0099 cd "$env:KDEROOT"
0100 }
0101 
0102 
0103 function Global:craft() {
0104     return & $env:CRAFT_PYTHON ([IO.PATH]::COMBINE("$env:CraftRoot", "bin", "craft.py")) $args
0105 }
0106 
0107 
0108 if($args.Length -ne 0)
0109 {
0110     invoke-expression -command "$args"
0111 }