您好!
我很高兴地宣布 pg_msvc_generator 版本 1.0.0 beta 发布。
pg_msvc_generator 是一个新工具,用于帮助扩展作者提供其扩展的 Windows 版本。它使用 Perl 编写,并采用 PostgreSQL 许可的开源软件。
您可以参考 项目的 README 获取完整描述,或者在遇到任何问题时访问 bug 跟踪器。
此工具包含 2 个脚本
主要的 pg_msvc_generator.pl
脚本会在给定的扩展目录中生成一个 msvc 子目录,其中包含使用 Visual Studio 2019 编译扩展所需的 **.sln** 和 **.vcxproj** 文件,并支持 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
)您只需要执行 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 安装路径。
如果找到该注册表项,安装程序将通知用户并将其用作默认安装位置。否则,安装程序将通知用户未自动找到任何安装,并将强制用户在继续安装之前选择一个位置。