Use a common function getPGDir between winbuild/BuildAll.ps1 and installer/buildInsta...
authorHiroshi Inoue <h-inoue@dream.email.ne.jp>
Thu, 1 Sep 2016 03:26:18 +0000 (12:26 +0900)
committerHiroshi Inoue <h-inoue@dream.email.ne.jp>
Thu, 1 Sep 2016 03:26:18 +0000 (12:26 +0900)
installer/buildInstallers.ps1
winbuild/BuildAll.ps1
winbuild/configuration.ps1

index 170ce7e22579816d4778a11cf047f58504a8bf98..6ffa0293459d80fa610f513676723d797529a5ec 100644 (file)
@@ -34,11 +34,10 @@ Param(
 [string]$BuildConfigPath
 )
 
-function findRuntime($runtime_version)
+function findRuntime($runtime_version, $pgmvc)
 {
    # where's the dll? 
    $rt_dllname="msvcr${runtime_version}0.dll"
-   $pgmvc = $archinfo.runtime_folder
    if ("$pgmvc" -ne "") {
        $dllspecified = "${pgmvc}\${rt_dllname}"
        if (Test-Path -Path $dllspecified) {
@@ -120,43 +119,7 @@ function buildInstaller($CPUTYPE)
 {
    $VERSION = $configInfo.Configuration.version
 
-   $archinfo = $configInfo.Configuration.$CPUTYPE
-
-   $LIBPQVER=$archinfo.libpq.version
-   if ($LIBPQVER -eq "") {
-       $LIBPQVER=$LIBPQ_VERSION
-   }
-
-   if ($CPUTYPE -eq "x64")
-   {
-       $LIBPQBINDIR=$archinfo.libpq.bin
-       if ($LIBPQBINDIR -eq "default") {
-           if ($env:PROCESSOR_ARCHITECTURE -ne "x86") {
-               $pgmfs = "$env:ProgramFiles"
-               $LIBPQBINDIR = "$pgmfs\PostgreSQL\$LIBPQVER\bin"
-           }
-           elseif ("${env:ProgramW6432}" -ne "") {
-               $pgmfs = "$env:ProgramW6432"
-               $LIBPQBINDIR = "$pgmfs\PostgreSQL\$LIBPQVER\bin"
-           }
-       }
-   }
-   elseif ($CPUTYPE -eq "x86")
-   {
-       $LIBPQBINDIR=$archinfo.libpq.bin
-       if ($env:PROCESSOR_ARCHITECTURE -eq "x86") {
-           $pgmfs = "$env:ProgramFiles"
-       } else {
-           $pgmfs = "${env:ProgramFiles(x86)}"
-       }
-       if ($LIBPQBINDIR -eq "default") {
-           $LIBPQBINDIR = "$pgmfs\PostgreSQL\$LIBPQVER\bin"
-       }
-   }
-   else
-   {
-       throw "Unknown CPU type $CPUTYPE";
-   }
+   $LIBPQBINDIR=getPGDir $configInfo $CPUTYPE "bin"
    # msvc runtime psqlodbc links
    $PODBCMSVCDLL = ""
    $PODBCMSVPDLL = ""
@@ -165,6 +128,7 @@ function buildInstaller($CPUTYPE)
    # msvc runtime libpq links
    $LIBPQMSVCDLL = ""
    $LIBPQMSVCSYS = ""
+   $pgmvc = $configInfo.Configuration.$CPUTYPE.runtime_folder
    if (-not $ExcludeRuntime) {
        $toolset = $configInfo.Configuration.BuildResult.PlatformToolset
        if ($toolset -match "^v(\d+)0") {
@@ -174,7 +138,7 @@ function buildInstaller($CPUTYPE)
        }
        # where's the msvc runtime dll psqlodbc links?
        if ([int] $runtime_version0 -lt 14) { 
-           $dlls=findRuntime($runtime_version0)
+           $dlls=findRuntime $runtime_version0 $pgmvc
            $PODBCMSVCDLL=$dlls[0]
            $PODBCMSVPDLL=$PODBCMSVCDLL.Replace("msvcr", "msvcp")
            $PODBCMSVCSYS=$dlls[1]
@@ -189,7 +153,7 @@ function buildInstaller($CPUTYPE)
                $runtime_version1=$msvclist[0]
            }
            if ($runtime_version1 -ne $runtime_version0) {
-               $dlls=findRuntime($runtime_version1)
+               $dlls=findRuntime $runtime_version1 $pgmvc
                $LIBPQMSVCDLL=$dlls[0]
                $LIBPQMSVCSYS=$dlls[1]
                Write-Host "LIBPQ requires msvcr${runtime_version1}0.dll"
index 3df9b28d8bad0cbe04029097088239665f52496c..f21cd4d09dba307fd865fef34542892ba9339567 100755 (executable)
@@ -66,42 +66,16 @@ Param(
 [switch]$AlongWithInstallers
 )
 
-function buildPlatform($platinfo, $Platform)
+function buildPlatform($configInfo, $Platform)
 {
-   $LIBPQVER=$platinfo.libpq.version
-   if ($LIBPQVER -eq "") {
-       $LIBPQVER = $LIBPQ_VERSION
-   }
-   $PG_INC=$platinfo.libpq.include
-   $PG_LIB=$platinfo.libpq.lib
-   $BUILD_MACROS=$platinfo.build_macros
-   if ($Platform -eq "x64") {
-       if ($env:PROCESSOR_ARCHITECTURE -eq "x86") {
-           $pgmfs = "$env:ProgramW6432"
-       } else {
-           $pgmfs = "$env:ProgramFiles"
-       }
+   if ($Platform -ieq "x64") {
+       $platinfo=$configInfo.Configuration.x64
    } else {
-       if ($env:PROCESSOR_ARCHITECTURE -eq "x86") {
-           $pgmfs = "$env:ProgramFiles"
-       } else {
-           $pgmfs = "${env:ProgramFiles(x86)}"
-       }
-   }
-   if ($PG_INC -eq "default") {
-       if ($pgmfs -eq "") {
-           PG_INC=""
-       } else {
-           $PG_INC = "$pgmfs\PostgreSQL\$LIBPQVER\include"
-       }
-   }
-   if ($PG_LIB -eq "default") {
-       if ($pgmfs -eq "") {
-           PG_LIB=""
-       } else {
-           $PG_LIB = "$pgmfs\PostgreSQL\$LIBPQVER\lib"
-       }
+       $platinfo=$configInfo.Configuration.x86
    }
+   $BUILD_MACROS=$platinfo.build_macros
+   $PG_INC=getPGDir $configInfo $Platform "include"
+   $PG_LIB=getPGDir $configInfo $Platform "lib"
 
    Write-Host "USE LIBPQ  : ($PG_INC $PG_LIB)"
 
@@ -263,7 +237,7 @@ try {
 #  build 32bit dlls
 #
    if ($Platform -ieq "Win32" -or $Platform -ieq "both") {
-       buildPlatform $configInfo.Configuration.x86 "Win32"
+       buildPlatform $configInfo "Win32"
        if ($LastExitCode -ne 0) {
            $recordResult = $false
        }
@@ -272,7 +246,7 @@ try {
 #  build 64bit dlls
 #
    if ($Platform -ieq "x64" -or $Platform -ieq "both") {
-       buildPlatform $configInfo.Configuration.x64 "x64"
+       buildPlatform $configInfo "x64"
        if ($LastExitCode -ne 0) {
            $recordResult = $false
        }
index e68c91626e502eb9189d2922973f76cff6c44e64..afb333f77215b584855e3392fe4a259f3ef1ec65 100755 (executable)
@@ -77,8 +77,50 @@ function global:unifyNodes($node1, $node2)
     }
 }
 
+function global:getPGDir($configInfo, $Platform, $kind)
+{
+   if ($Platform -ieq "x64") {
+       $platinfo=$configInfo.Configuration.x64
+   } else {
+       $platinfo=$configInfo.Configuration.x86
+   }
+   $LIBPQVER=$platinfo.libpq.version
+   if ($LIBPQVER -eq "") {
+       $LIBPQVER = $LIBPQ_VERSION
+   }
+   if ($kind -eq "include") {
+       $result=$platinfo.libpq.include
+   } elseif ($kind -eq "lib") {
+       $result=$platinfo.libpq.lib
+   } else {
+       $result=$platinfo.libpq.bin
+   }
+   if ($result -ne "default") {
+       return $result
+   }
+   if ($Platform -ieq "x64") {
+       if ($env:PROCESSOR_ARCHITECTURE -eq "x86") {
+           $pgmfs = "$env:ProgramW6432"
+       } else {
+           $pgmfs = "$env:ProgramFiles"
+       }
+   } else {
+       if ($env:PROCESSOR_ARCHITECTURE -eq "x86") {
+           $pgmfs = "$env:ProgramFiles"
+       } else {
+           $pgmfs = "${env:ProgramFiles(x86)}"
+       }
+   }
+   if ("$pgmfs" -eq "") {
+       $result = $null
+   } else {
+       $result = "$pgmfs\PostgreSQL\$LIBPQVER\$kind"
+   }
+   return $result
+}
+
 Write-Debug "configPath=$configPath"
-$global:LIBPQ_VERSION="9.3"
+$global:LIBPQ_VERSION="9.5"
 $scriptPath = [System.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Definition)
 $global:configurationTemplatePath = "$scriptPath\configuration_template.xml"
 $global:configurationXmlPath = $configPath