Skip to content

Commit

Permalink
Use candle's -arch option to select build platform
Browse files Browse the repository at this point in the history
According to docs, using Package/@platform "is discouraged". The -arch
option also provides the default bitness for components, making the
Component/@win64 attribute unnecessary in single-architecture packages.
  • Loading branch information
chrullrich committed Oct 6, 2024
1 parent 2df3461 commit e71947d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 60 deletions.
4 changes: 2 additions & 2 deletions installer/buildInstallers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function buildInstaller([string]$CPUTYPE)
Write-Host ".`nBuilding psqlODBC/$SUBLOC merge module..."
$BINBASE = GetObjbase ".."
$INSTBASE = GetObjbase ".\$CPUTYPE" "installer\$CPUTYPE"
candle -nologo $libpqRelArgs "-dPlatform=$CPUTYPE" "-dVERSION=$VERSION" "-dSUBLOC=$SUBLOC" "-dLIBPQBINDIR=$LIBPQBINDIR" "-dLIBPQMSVCDLL=$LIBPQMSVCDLL" "-dLIBPQMSVCSYS=$LIBPQMSVCSYS" "-dPODBCMSVCDLL=$PODBCMSVCDLL" "-dPODBCMSVPDLL=$PODBCMSVPDLL" "-dPODBCMSVCSYS=$PODBCMSVCSYS" "-dPODBCMSVPSYS=$PODBCMSVPSYS" "-dNoPDB=$NoPDB" "-dBINBASE=$BINBASE" -o $INSTBASE\psqlodbcm.wixobj psqlodbcm_cpu.wxs
candle -nologo -arch $CPUTYPE $libpqRelArgs "-dVERSION=$VERSION" "-dSUBLOC=$SUBLOC" "-dLIBPQBINDIR=$LIBPQBINDIR" "-dLIBPQMSVCDLL=$LIBPQMSVCDLL" "-dLIBPQMSVCSYS=$LIBPQMSVCSYS" "-dPODBCMSVCDLL=$PODBCMSVCDLL" "-dPODBCMSVPDLL=$PODBCMSVPDLL" "-dPODBCMSVCSYS=$PODBCMSVCSYS" "-dPODBCMSVPSYS=$PODBCMSVPSYS" "-dNoPDB=$NoPDB" "-dBINBASE=$BINBASE" -o $INSTBASE\psqlodbcm.wixobj psqlodbcm_cpu.wxs
if ($LASTEXITCODE -ne 0) {
throw "Failed to build merge module"
}
Expand All @@ -282,7 +282,7 @@ function buildInstaller([string]$CPUTYPE)

Write-Host ".`nBuilding psqlODBC installer database..."

candle -nologo "-dPlatform=$CPUTYPE" "-dVERSION=$VERSION" "-dSUBLOC=$SUBLOC" "-dINSTBASE=$INSTBASE" -o $INSTBASE\psqlodbc.wixobj psqlodbc_cpu.wxs
candle -nologo -arch $CPUTYPE "-dVERSION=$VERSION" "-dSUBLOC=$SUBLOC" "-dINSTBASE=$INSTBASE" -o $INSTBASE\psqlodbc.wixobj psqlodbc_cpu.wxs
if ($LASTEXITCODE -ne 0) {
throw "Failed to build installer database"
}
Expand Down
32 changes: 13 additions & 19 deletions installer/psqlodbc_cpu.wxs
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

<!-- Default to x86 platform -->
<?ifndef var.Platform ?>
<?define Platform = "x86" ?>
<?else?>
<?if $(var.Platform) != x64 and $(var.Platform) != x86 ?>
<?error Invalid Platform variable ?>
<?endif?>
<?endif?>

<?ifndef var.INSTBASE ?>
<?define INSTBASE = $(var.Platform) ?>
<?endif?>

<?if $(var.Platform) = x64 ?>
<?if $(sys.BUILDARCH) = x64 ?>
<?define Platform = "x64" ?>
<?define PKGNAME = "psqlODBC_x64" ?>
<?define BIT64 = "yes" ?>
<?define PGFOLDER = "ProgramFiles64Folder" ?>
Expand All @@ -24,7 +12,8 @@
<?define CIDSMD = "{E6410EE8-96DC-4d84-8D07-94F8093BF3EF}" ?>
<?define UPGCOD = "BBD29DF5-89F6-4b8b-BDC9-C3EA3A4AFDBB" ?>
<?define ALLUSERS = "1" ?>
<?else?>
<?elseif $(sys.BUILDARCH) = x86 ?>
<?define Platform = "x86" ?>
<?define PKGNAME = "psqlODBC" ?>
<?define BIT64 = "no" ?>
<?define PGFOLDER = "ProgramFilesFolder" ?>
Expand All @@ -34,6 +23,12 @@
<?define CIDSMD = "{22288E09-B3B6-4181-907F-676099C20125}" ?>
<?define UPGCOD = "24BCA538-75A2-4a7f-B236-C99EFC2145DE" ?>
<?define ALLUSERS = "1" ?>
<?else?> <!-- sys.BUILDARCH -->
<?error Invalid build architecture ?>
<?endif?>

<?ifndef var.INSTBASE ?>
<?define INSTBASE = $(var.Platform) ?>
<?endif?>

<?define MERGEM = "$(var.INSTBASE)\psqlodbc_$(var.Platform).msm" ?>
Expand All @@ -55,7 +50,6 @@
Comments="PostgreSQL ODBC Driver"
Manufacturer="PostgreSQL Global Development Group"
InstallerVersion="300"
Platform="$(var.Platform)"
Languages="1033"
Compressed="yes"
SummaryCodepage="1252" />
Expand All @@ -67,13 +61,13 @@
<Directory Id="BASEDIR" Name="psqlODBC">
<Directory Id="SUBLOC" Name="$(var.SUBLOC)">
<Directory Id="BINDIR" Name="bin">
<Component Id="registration" Guid="$(var.CIDREG)" Win64="$(var.BIT64)">
<Component Id="registration" Guid="$(var.CIDREG)">
<RegistryValue KeyPath="yes" Type="string" Root="HKLM" Key="Software\$(var.PKGNAME)" Name="Version" Value="$(var.VERSION)" />
</Component>
<Merge Id="psqlodbcm" DiskId="1" Language="1033" SourceFile="$(var.MERGEM)" />
</Directory>
<Directory Id="DOCSDIR" Name="docs">
<Component Id="docs" Guid="$(var.CIDDOC)" Win64="$(var.BIT64)">
<Component Id="docs" Guid="$(var.CIDDOC)">
<File Id="docs.README.txt" Name="README.txt" DiskId="1" Source="../docs/README.txt" KeyPath="yes" />
<File Id="docs.config.html" Name="config.html" DiskId="1" Source="../docs/config.html" />
<File Id="docs.config_opt.html" Name="config-opt.html" DiskId="1" Source="../docs/config-opt.html" />
Expand All @@ -91,7 +85,7 @@
</Directory>
<Directory Id="ProgramMenuFolder" Name="." SourceName="Programs">
<Directory Id="SMDir" Name="$(var.PKGNAME)">
<Component Id="smdir" Guid="$(var.CIDSMD)" Win64="$(var.BIT64)">
<Component Id="smdir" Guid="$(var.CIDSMD)">
<RegistryValue KeyPath="yes" Type="string" Root="HKCU" Key="Software\$(var.PKGNAME)\SMDir Created" Value="y" />
<RemoveFolder Id="SMDir" On="uninstall" />
</Component>
Expand Down
72 changes: 33 additions & 39 deletions installer/psqlodbcm_cpu.wxs
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

<!-- Default to x86 platform -->
<?ifndef var.Platform ?>
<?define Platform = "x86" ?>
<?else?>
<?if $(var.Platform) != x64 and $(var.Platform) != x86 ?>
<?error Invalid Platform variable ?>
<?endif?>
<?endif?>

<?ifndef var.BINBASE ?>
<?define BINBASE = ".." ?>
<?endif?>

<?if $(var.Platform) = x64 ?>
<?define ModuleName = "psqlODBC_$(var.Platform)" ?>
<?if $(sys.BUILDARCH) = x64 ?>
<?define Platform = "x64" ?>
<?define ModuleName = "psqlODBC_x64" ?>
<?define BIT64 = "yes" ?>
<?define ANSIFOLDER = "x64_ANSI_Release" ?>
<?define UNICODEFOLDER = "x64_Unicode_Release" ?>
Expand All @@ -26,7 +18,8 @@
<?else?>
<?define SysFolder = "$(env.SystemRoot)\sysnative" ?>
<?endif?>
<?else?>
<?elseif $(sys.BUILDARCH) = x86 ?>
<?define Platform = "x86" ?>
<?define ModuleName = "psqlODBC" ?>
<?define BIT64 = "no" ?>
<?define ANSIFOLDER = "x86_ANSI_Release" ?>
Expand All @@ -38,6 +31,8 @@
<?else?>
<?define SysFolder = "$(env.SystemRoot)\system32" ?>
<?endif?>
<?else?> <!-- sys.BUILDARCH -->
<?error Invalid build architecture ?>
<?endif?>

<Module
Expand All @@ -51,7 +46,6 @@
Keywords="PostgreSQL, ODBC"
Manufacturer="PostgreSQL Global Development Group"
InstallerVersion="$(var.InstallerVersion)"
Platform="$(var.Platform)"
Languages="1033"
SummaryCodepage="1252" />

Expand All @@ -71,7 +65,7 @@
-->
<Directory Id="BINDIR" Name="." ComponentGuidGenerationSeed="495CEE94-BDB9-4309-9544-D98783259CD8">
<!-- PostgreSQL -->
<Component Id="psqlodbc.psqlodbc30a.dll" Win64="$(var.BIT64)">
<Component Id="psqlodbc.psqlodbc30a.dll">
<File Name="psqlodbc30a.dll" Source="$(var.BINBASE)\$(var.ANSIFOLDER)\psqlodbc30a.dll">
<ODBCDriver Id="Psqlodbc_9.0_Driver_ANSI" Name="PostgreSQL ANSI($(var.Platform))">
<Property Id="CPTimeout" Value="60"/>
Expand All @@ -81,18 +75,18 @@
</ODBCDriver>
</File>
</Component>
<Component Id="psqlodbc.pgenlista.dll" Win64="$(var.BIT64)">
<Component Id="psqlodbc.pgenlista.dll">
<File Name="pgenlista.dll" Source="$(var.BINBASE)\$(var.ANSIFOLDER)\pgenlista.dll" />
</Component>
<?if $(var.NoPDB) != True ?>
<Component Id="psqlodbc.psqlodbc30a.pdb" Win64="$(var.BIT64)">
<Component Id="psqlodbc.psqlodbc30a.pdb">
<File Name="psqlodbc30a.pdb" Source="$(var.BINBASE)\$(var.ANSIFOLDER)\psqlodbc30a.pdb" />
</Component>
<Component Id="psqlodbc.pgenlista.pdb" Win64="$(var.BIT64)">
<Component Id="psqlodbc.pgenlista.pdb">
<File Name="pgenlista.pdb" Source="$(var.BINBASE)\$(var.ANSIFOLDER)\pgenlista.pdb" />
</Component>
<?endif?>
<Component Id="psqlodbc.psqlodbc35w.dll" Win64="$(var.BIT64)">
<Component Id="psqlodbc.psqlodbc35w.dll">
<File Name="psqlodbc35w.dll" Source="$(var.BINBASE)\$(var.UNICODEFOLDER)\psqlodbc35w.dll">
<ODBCDriver Id="Psqlodbc_9.0_Driver" Name="PostgreSQL Unicode($(var.Platform))">
<Property Id="CPTimeout" Value="60"/>
Expand All @@ -102,101 +96,101 @@
</ODBCDriver>
</File>
</Component>
<Component Id="psqlodbc.pgenlist.dll" Win64="$(var.BIT64)">
<Component Id="psqlodbc.pgenlist.dll">
<File Name="pgenlist.dll" Source="$(var.BINBASE)\$(var.UNICODEFOLDER)\pgenlist.dll" />
</Component>
<?if $(var.NoPDB) != True ?>
<Component Id="psqlodbc.psqlodbc35w.pdb" Win64="$(var.BIT64)">
<Component Id="psqlodbc.psqlodbc35w.pdb">
<File Name="psqlodbc35w.pdb" Source="$(var.BINBASE)\$(var.UNICODEFOLDER)\psqlodbc35w.pdb" />
</Component>
<Component Id="psqlodbc.pgenlist.pdb" Win64="$(var.BIT64)">
<Component Id="psqlodbc.pgenlist.pdb">
<File Name="pgenlist.pdb" Source="$(var.BINBASE)\$(var.UNICODEFOLDER)\pgenlist.pdb" />
</Component>
<?endif?>

<!-- MSVC Runtime -->
<?if "$(var.PODBCMSVCDLL)" != "" ?>
<Component Id="vcredist.vcruntime.dll.psqlodbc" Win64="$(var.BIT64)">
<Component Id="vcredist.vcruntime.dll.psqlodbc">
<File Source="$(var.PODBCMSVCDLL)" />
</Component>
<?endif?>
<?if "$(var.PODBCMSVPDLL)" != "" ?>
<Component Id="vcredist.msvcp.dll.psqlodbc" Win64="$(var.BIT64)">
<Component Id="vcredist.msvcp.dll.psqlodbc">
<File Source="$(var.PODBCMSVPDLL)" />
</Component>
<?endif?>
<?if "$(var.PODBCMSVCSYS)" != "" ?>
<Component Id="system.vcruntime.dll.psqlodbc" Win64="$(var.BIT64)">
<Component Id="system.vcruntime.dll.psqlodbc">
<File Source="$(var.SysFolder)\$(var.PODBCMSVCSYS)" />
</Component>
<?endif?>
<?if "$(var.PODBCMSVPSYS)" != "" ?>
<Component Id="system.msvcp.dll.psqlodbc" Win64="$(var.BIT64)">
<Component Id="system.msvcp.dll.psqlodbc">
<File Source="$(var.SysFolder)\$(var.PODBCMSVPSYS)" />
</Component>
<?endif?>
<?if "$(var.LIBPQMSVCDLL)" != "" ?>
<Component Id="vcredist.vcruntime.dll.libpq" Win64="$(var.BIT64)">
<Component Id="vcredist.vcruntime.dll.libpq">
<File Source="$(var.LIBPQMSVCDLL)" />
</Component>
<?endif?>
<?if "$(var.LIBPQMSVCSYS)" != "" ?>
<Component Id="system.vcruntime.dll.libpq" Win64="$(var.BIT64)">
<Component Id="system.vcruntime.dll.libpq">
<File Source="$(var.SysFolder)\$(var.LIBPQMSVCSYS)" />
</Component>
<?endif?>

<!-- libpq -->
<Component Id="libpq.libpq.dll" Win64="$(var.BIT64)">
<Component Id="libpq.libpq.dll">
<File Id="libpq.dll" Name="libpq.dll" Source="$(var.LIBPQBINDIR)\libpq.dll" />
</Component>
<?if "$(var.LIBPQMEM0)" != "" ?>
<Component Id="libpq.related0.dll" Win64="$(var.BIT64)">
<Component Id="libpq.related0.dll">
<File Source="$(var.LIBPQMEM0)" />
</Component>
<?endif ?>
<?if "$(var.LIBPQMEM1)" != "" ?>
<Component Id="libpq.related1.dll" Win64="$(var.BIT64)">
<Component Id="libpq.related1.dll">
<File Source="$(var.LIBPQMEM1)" />
</Component>
<?endif ?>
<?if "$(var.LIBPQMEM2)" != "" ?>
<Component Id="libpq.related2.dll" Win64="$(var.BIT64)">
<Component Id="libpq.related2.dll">
<File Source="$(var.LIBPQMEM2)" />
</Component>
<?endif ?>
<?if "$(var.LIBPQMEM3)" != "" ?>
<Component Id="libpq.related3.dll" Win64="$(var.BIT64)">
<Component Id="libpq.related3.dll">
<File Source="$(var.LIBPQMEM3)" />
</Component>
<?endif ?>
<?if "$(var.LIBPQMEM4)" != "" ?>
<Component Id="libpq.related4.dll" Win64="$(var.BIT64)">
<Component Id="libpq.related4.dll">
<File Source="$(var.LIBPQMEM4)" />
</Component>
<?endif ?>
<?if "$(var.LIBPQMEM5)" != "" ?>
<Component Id="libpq.related5.dll" Win64="$(var.BIT64)">
<Component Id="libpq.related5.dll">
<File Source="$(var.LIBPQMEM5)" />
</Component>
<?endif ?>
<?if "$(var.LIBPQMEM6)" != "" ?>
<Component Id="libpq.related6.dll" Win64="$(var.BIT64)">
<Component Id="libpq.related6.dll">
<File Source="$(var.LIBPQMEM6)" />
</Component>
<?endif ?>
<?if "$(var.LIBPQMEM7)" != "" ?>
<Component Id="libpq.related7.dll" Win64="$(var.BIT64)">
<Component Id="libpq.related7.dll">
<File Source="$(var.LIBPQMEM7)" />
</Component>
<?endif ?>
<?if "$(var.LIBPQMEM8)" != "" ?>
<Component Id="libpq.related8.dll" Win64="$(var.BIT64)">
<Component Id="libpq.related8.dll">
<File Source="$(var.LIBPQMEM8)" />
</Component>
<?endif ?>
<?if "$(var.LIBPQMEM9)" != "" ?>
<Component Id="libpq.related9.dll" Win64="$(var.BIT64)">
<Component Id="libpq.related9.dll">
<File Source="$(var.LIBPQMEM9)" />
</Component>
<?endif ?>
Expand All @@ -206,7 +200,7 @@
32bit machines. We had better register the XA DLL on
installation.
-->
<Component Id="pgxalib.files" Win64="$(var.BIT64)">
<Component Id="pgxalib.files">
<?if $(var.BIT64) = no ?> <!-- On x64 OS only install from x64 package. -->
<Condition>
<![CDATA[NOT VersionNT64]]>
Expand Down

0 comments on commit e71947d

Please sign in to comment.