-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support building pgsodium on windows (#72)
* adding scripts to generate root secret key * add PGDLLEXPORT * support executing and reading getkey_script on windows * add visual studio solution/project files * add windows build instructions and update gitignore * remove nonfunctional powershell root key script * use compiler defined _WIN32 * remove check for write permissions * define getline function for windows builds * update windows build process to use msbuild from the command line * - Adding github action to build pgsodium using msbuild and the v143 platform toolset - Unit tests do not yet run, requires pgtap * windows tests: adding pgtap and running test suite --------- Co-authored-by: Michel Pelletier <[email protected]>
- Loading branch information
1 parent
54ee412
commit dc411ab
Showing
12 changed files
with
328 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<Project DefaultTargets="Build" ToolsVersion="16.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
|
||
<ItemGroup> | ||
<ProjectConfiguration Include="Debug|x64"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>Win64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|x64"> | ||
<Configuration>Release</Configuration> | ||
<Platform>Win64</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
|
||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.default.props"/> | ||
|
||
<PropertyGroup Label="Globals"> | ||
<PreferredToolArchitecture>x64</PreferredToolArchitecture> | ||
<ConfigurationType>DynamicLibrary</ConfigurationType> | ||
<UseDynamicLibraries>true</UseDynamicLibraries> | ||
<RootNamespace>pgsodium</RootNamespace> | ||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> | ||
<PlatformToolset>$(platformToolset)</PlatformToolset> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration"> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<LinkIncremental>false</LinkIncremental> | ||
<GenerateManifest>false</GenerateManifest> | ||
<WarningLevel>Level3</WarningLevel> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration"> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<LinkIncremental>true</LinkIncremental> | ||
<GenerateManifest>false</GenerateManifest> | ||
<WarningLevel>All</WarningLevel> | ||
</PropertyGroup> | ||
|
||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
|
||
<ItemGroup> | ||
<ClInclude Include="..\src\crypto_aead_det_xchacha20.h" /> | ||
<ClInclude Include="..\src\pgsodium.h" /> | ||
<ClInclude Include="..\src\signcrypt_tbsbr.h" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ClCompile Include="..\src\aead.c" /> | ||
<ClCompile Include="..\src\auth.c" /> | ||
<ClCompile Include="..\src\box.c" /> | ||
<ClCompile Include="..\src\crypto_aead_det_xchacha20.c" /> | ||
<ClCompile Include="..\src\derive.c" /> | ||
<ClCompile Include="..\src\hash.c" /> | ||
<ClCompile Include="..\src\helpers.c" /> | ||
<ClCompile Include="..\src\hmac.c" /> | ||
<ClCompile Include="..\src\kdf.c" /> | ||
<ClCompile Include="..\src\kx.c" /> | ||
<ClCompile Include="..\src\pgsodium.c" /> | ||
<ClCompile Include="..\src\pwhash.c" /> | ||
<ClCompile Include="..\src\random.c" /> | ||
<ClCompile Include="..\src\secretbox.c" /> | ||
<ClCompile Include="..\src\secretstream.c" /> | ||
<ClCompile Include="..\src\sha.c" /> | ||
<ClCompile Include="..\src\sign.c" /> | ||
<ClCompile Include="..\src\signcrypt.c" /> | ||
<ClCompile Include="..\src\signcrypt_tbsbr.c" /> | ||
<ClCompile Include="..\src\stream.c" /> | ||
</ItemGroup> | ||
|
||
<ItemDefinitionGroup> | ||
<ClCompile> | ||
<ExceptionHandling>false</ExceptionHandling> | ||
<SDLCheck>true</SDLCheck> | ||
<CompileAs>CompileAsC</CompileAs> | ||
<AdditionalIncludeDirectories> | ||
$(PostgreSQLLocation)\include\server\port\win32_msvc; | ||
$(PostgreSQLLocation)\include\server\port\win32; | ||
$(PostgreSQLLocation)\include\server; | ||
$(PostgreSQLLocation)\include; | ||
$(libsodiumLocation)\include; | ||
%(AdditionalIncludeDirectories) | ||
</AdditionalIncludeDirectories> | ||
<LanguageStandard>stdcpp17</LanguageStandard> | ||
</ClCompile> | ||
|
||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<AdditionalLibraryDirectories> | ||
$(libsodiumLocation)\x64\Release\$(platformToolset)\dynamic; | ||
$(PostgreSQLLocation)\lib; | ||
%(AdditionalLibraryDirectories) | ||
</AdditionalLibraryDirectories> | ||
<AdditionalDependencies> | ||
postgres.lib; | ||
libsodium.lib; | ||
%(AdditionalDependencies) | ||
</AdditionalDependencies> | ||
</Link> | ||
|
||
</ItemDefinitionGroup> | ||
|
||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Targets" /> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#### Building on Windows | ||
--------- | ||
|
||
- Download [libsodium](https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable-msvc.zip) >= 1.018 and unzip | ||
- Download and run the [postgresql installer](https://www.postgresql.org/download/windows/) | ||
- From the `/pgsodium/build` directory, run `msbuild` on `pgsodium.vcxproj` | ||
- `msbuild` can be invoked though the *x64 Native Tools Command Prompt for VS 2022* | ||
|
||
The following properties ( **`/p`** or **`/property`** ) must be specified: | ||
- `libsodiumLocation`: root libsodium directory | ||
- `PostgreSQLLocation`: root postgresql directory, typically `C:\Program Files\PostgreSQL\<version> | ||
- `Configuration`: [`Release`, `Debug`] | ||
- `Platform`: [x64] | ||
- `platformToolset`: [`v142`, `v143`] | ||
|
||
ie. | ||
|
||
``` | ||
msbuild pgsodium.vcxproj /p:libsodiumLocation="C:\libsodium" /p:PostgreSQLLocation="C:\Program Files\PostgreSQL\15" /p:Configuration=Release /p:Platform=x64 /p:platformToolset=v143 | ||
``` | ||
|
||
- Copy the `libsodium.dll` (from `libsodium\x64\Release\<platformToolset>\dynamic`) and the newly built `pgsodium.dll` into your `\PostgreSQL\<version>\lib` directory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@echo off | ||
set KEY_FILE="%PGDATA%/pgsodium_root.key" | ||
|
||
IF NOT EXIST %KEY_FILE% ( | ||
openssl rand -hex 32 > %KEY_FILE% | ||
) | ||
type "%PGDATA%/pgsodium_root.key" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.