您好,
我很高兴地宣布 pg_msvc_generator 1.0.0 beta 版发布。
pg_msvc_generator 是一个新工具,旨在帮助扩展作者提供其扩展的 Windows 版本。它使用 Perl 编写,并以 PostgreSQL 许可证开源。
您可以参考项目自述文件获取完整描述,或者如果遇到任何问题,可以参考错误跟踪器。
此工具由 2 个脚本组成
主要的 pg_msvc_generator.pl
脚本将在给定的扩展目录中生成一个 msvc 子目录,其中包含所需的 .sln 和 .vcxproj 文件,以便能够使用 Visual Studio 2019 编译扩展,并支持 Debug/Release 和 32/64 位构建。它还将复制 release.pl
并生成一个 build.bat
脚本,该脚本可以自动编译并为所有本地安装的 PostgreSQL 版本创建发布存档文件和安装程序。
pg_msvc_generator.pl [ options ]
Options:
--default version pgver : default PostgreSQL version. This is only used
if you compile the project without specifying a specific major
version, or when the project is opened with Visual Studio
IDE. If not provided, a default value based on the year will
be chosen (13 for 2021, 14 for 2022 and so on).
-d | --dir ext_directory : root directory of the extension source code.
-e | --extension : extension name. If not provided, the extension
name will be assumed using the last part of the given root
directory.
-h | --help : Show this message.
例如
pg_msvc_generator.pl -d C:\git\hypopg
在项目生成时:
在扩展编译时:
C:\Program Files\PostgreSQL\$MAJOR_VERSION
)C:\Program Files (x86)\NSIS
) 以生成安装程序您只需执行 msvc\release.bat
脚本即可。它将设置 MSVC 环境并调用 release.pl
脚本。该脚本将准备好在 msvc\${extension_name}-${extension_version}
目录下进行发布的所有内容。
它将自动读取 HKLM/SOFTWARE/PostgreSQL/Installations/
注册表来查找已安装的 PostgreSQL 版本,使用所有这些版本编译扩展,并为每个版本生成一个子目录,其中包含 dll 和 SQL 脚本(如果有),一个包含相同内容的 zip 存档,以及可选的安装程序。
例如,假设您安装了 PostgreSQL 12 和 13,并发布了 HypoPG 1.3.2 并且安装了 NSIS,您的 msvc
目录现在将有以下附加内容
如果您在默认位置 (C:\Program Files (x86)\NSIS
) 安装了 NSIS,则 release.pl
脚本将生成一个 .nsi
文件,并使用 makensis.exe 对其进行编译,以便为运行 release.pl
脚本时找到的每个 PostgreSQL 主要版本生成特定的安装程序。在执行时,安装程序将尝试通过读取注册表键 HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-$architecture-$majorversion\Base Directory 来发现服务器的 PostgreSQL 安装路径。
如果找到该键,安装程序将通知用户并将其用作默认安装位置。否则,安装程序将通知用户未自动找到安装,并将强制用户在继续安装之前选择一个位置。