go.etcd.io/etcd@v3.3.27+incompatible/build.ps1 (about) 1 $ORG_PATH="github.com/coreos" 2 $REPO_PATH="$ORG_PATH/etcd" 3 $PWD = $((Get-Item -Path ".\" -Verbose).FullName) 4 $FSROOT = $((Get-Location).Drive.Name+":") 5 $FSYS = $((Get-WMIObject win32_logicaldisk -filter "DeviceID = '$FSROOT'").filesystem) 6 7 if ($FSYS.StartsWith("FAT","CurrentCultureIgnoreCase")) { 8 echo "Error: Cannot build etcd using the $FSYS filesystem (use NTFS instead)" 9 exit 1 10 } 11 12 # Set $Env:GO_LDFLAGS="-s" for building without symbols. 13 $GO_LDFLAGS="$Env:GO_LDFLAGS -X $REPO_PATH/cmd/vendor/$REPO_PATH/version.GitSHA=$GIT_SHA" 14 15 # rebuild symlinks 16 git ls-files -s cmd | select-string -pattern 120000 | ForEach { 17 $l = $_.ToString() 18 $lnkname = $l.Split(' ')[1] 19 $target = "$(git log -p HEAD -- $lnkname | select -last 2 | select -first 1)" 20 $target = $target.SubString(1,$target.Length-1).Replace("/","\") 21 $lnkname = $lnkname.Replace("/","\") 22 23 $terms = $lnkname.Split("\") 24 $dirname = $terms[0..($terms.length-2)] -join "\" 25 $lnkname = "$PWD\$lnkname" 26 $targetAbs = "$((Get-Item -Path "$dirname\$target").FullName)" 27 $targetAbs = $targetAbs.Replace("/", "\") 28 29 if (test-path -pathtype container "$targetAbs") { 30 if (Test-Path "$lnkname") { 31 if ((Get-Item "$lnkname") -is [System.IO.DirectoryInfo]) { 32 # rd so deleting junction doesn't take files with it 33 cmd /c rd "$lnkname" 34 } 35 } 36 if (Test-Path "$lnkname") { 37 if (!((Get-Item "$lnkname") -is [System.IO.DirectoryInfo])) { 38 cmd /c del /A /F "$lnkname" 39 } 40 } 41 cmd /c mklink /J "$lnkname" "$targetAbs" ">NUL" 42 } else { 43 # Remove file with symlink data (first run) 44 if (Test-Path "$lnkname") { 45 cmd /c del /A /F "$lnkname" 46 } 47 cmd /c mklink /H "$lnkname" "$targetAbs" ">NUL" 48 } 49 } 50 51 if (-not $env:GOPATH) { 52 $orgpath="$PWD\gopath\src\" + $ORG_PATH.Replace("/", "\") 53 if (Test-Path "$orgpath\etcd") { 54 if ((Get-Item "$orgpath\etcd") -is [System.IO.DirectoryInfo]) { 55 # rd so deleting junction doesn't take files with it 56 cmd /c rd "$orgpath\etcd" 57 } 58 } 59 if (Test-Path "$orgpath") { 60 if ((Get-Item "$orgpath") -is [System.IO.DirectoryInfo]) { 61 # rd so deleting junction doesn't take files with it 62 cmd /c rd "$orgpath" 63 } 64 } 65 if (Test-Path "$orgpath") { 66 if (!((Get-Item "$orgpath") -is [System.IO.DirectoryInfo])) { 67 # Remove file with symlink data (first run) 68 cmd /c del /A /F "$orgpath" 69 } 70 } 71 cmd /c mkdir "$orgpath" 72 cmd /c mklink /J "$orgpath\etcd" "$PWD" ">NUL" 73 $env:GOPATH = "$PWD\gopath" 74 } 75 76 # Static compilation is useful when etcd is run in a container 77 $env:CGO_ENABLED = 0 78 $env:GO15VENDOREXPERIMENT = 1 79 $GIT_SHA="$(git rev-parse --short HEAD)" 80 go build -a -installsuffix cgo -ldflags $GO_LDFLAGS -o bin\etcd.exe "$REPO_PATH\cmd\etcd" 81 go build -a -installsuffix cgo -ldflags $GO_LDFLAGS -o bin\etcdctl.exe "$REPO_PATH\cmd\etcdctl"