Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 74 additions & 43 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: build-and-release

# Builds the x64 plugin, runs the Catch2 test suite, and packages a
# Plugins-Admin-ready zip.
# Builds the plugin for x64, x86 (Win32) and ARM64 Notepad++, runs the Catch2
# test suite, and packages one Plugins-Admin-ready zip per architecture.
#
# * push / PR -> build + test + upload the zip as a CI artifact
# * push a "v*" tag -> additionally publish a GitHub Release with the zip
# and print the SHA-256 needed for the nppPluginList PR
# * push / PR -> build + test + upload the zips as CI artifacts
# * push a "v*" tag -> additionally publish a GitHub Release with the zips
# and print the SHA-256 needed for each nppPluginList PR
#
# The DLL is placed at the ROOT of the zip and named exactly LLMAssistant.dll,
# In each zip the DLL sits at the ROOT and is named exactly LLMAssistant.dll,
# which is what Notepad++ Plugins Admin requires.

on:
Expand Down Expand Up @@ -40,6 +40,25 @@ jobs:
/p:WindowsTargetPlatformVersion=10.0
/m

- name: Build plugin (Win32 Release)
run: >
msbuild LLMAssistant.vcxproj
/p:Configuration=Release
/p:Platform=Win32
/p:PlatformToolset=v143
/p:WindowsTargetPlatformVersion=10.0
/m

# The runner's v143 tools (MSVC 14.44) cover x64 and x86 only, so ARM64
# builds with the project's own toolset (v145).
- name: Build plugin (ARM64 Release)
run: >
msbuild LLMAssistant.vcxproj
/p:Configuration=Release
/p:Platform=ARM64
/p:WindowsTargetPlatformVersion=10.0
/m

- name: Configure tests (CMake)
run: cmake -S . -B CMakeBuild

Expand All @@ -49,7 +68,18 @@ jobs:
- name: Run tests
run: ctest --test-dir CMakeBuild --output-on-failure -C Debug

- name: Package Plugins-Admin zip
# The 32-bit DLL compiles the same core code, so run the tests as 32-bit
# too. (The x64 runner can't run ARM64 binaries.)
- name: Configure tests (CMake, Win32)
run: cmake -S . -B CMakeBuild-Win32 -A Win32

- name: Build tests (Win32)
run: cmake --build CMakeBuild-Win32 --config Debug

- name: Run tests (Win32)
run: ctest --test-dir CMakeBuild-Win32 --output-on-failure -C Debug

- name: Package Plugins-Admin zips
id: package
shell: pwsh
run: |
Expand All @@ -58,52 +88,53 @@ jobs:
} else {
$ver = "dev"
}
$zip = "LLMAssistant_v${ver}_x64.zip"

# DLL must sit at the zip root and be named exactly LLMAssistant.dll.
Copy-Item "x64\Release\LLMAssistant.dll" ".\LLMAssistant.dll" -Force
if (Test-Path $zip) { Remove-Item $zip -Force }
Compress-Archive -Path ".\LLMAssistant.dll" -DestinationPath $zip -Force

$hash = (Get-FileHash $zip -Algorithm SHA256).Hash.ToUpper()
"zip=$zip" >> $env:GITHUB_OUTPUT
"version=$ver" >> $env:GITHUB_OUTPUT
"sha256=$hash" >> $env:GITHUB_OUTPUT
$notes = @(
'### Notepad++ Plugins Admin metadata',
'',
'Each Notepad++ architecture has its own plugin list in nppPluginList. `id` is the SHA-256 of that architecture''s zip.'
)
foreach ($platform in "x64", "x86", "arm64") {
# Checks the DLL's CPU type, version and Notepad++ exports, zips it
# as LLMAssistant.dll at the zip root, prints the zip's SHA-256, and
# returns the nppPluginList entry with that SHA-256 as "id".
$entry = & .\packaging\make-release-zip.ps1 -Platform $platform -Version $ver -OutDir dist
$notes += '', "Add / update this in ``src/pl.$platform.json``:", '', '```json', $entry, '```'
}

Write-Host "==============================================="
Write-Host "Package : $zip"
Write-Host "SHA-256 : $hash <-- use as \"id\" in pl.x64.json"
Write-Host "==============================================="
$notes | Set-Content dist\release-notes.md
$notes | Add-Content $env:GITHUB_STEP_SUMMARY
"version=$ver" >> $env:GITHUB_OUTPUT

- name: Upload CI artifact
- name: Upload CI artifact (x64)
uses: actions/upload-artifact@v4
with:
name: LLMAssistant-x64
path: ${{ steps.package.outputs.zip }}
path: dist/LLMAssistant_v${{ steps.package.outputs.version }}_x64.zip
if-no-files-found: error

- name: Upload CI artifact (x86)
uses: actions/upload-artifact@v4
with:
name: LLMAssistant-x86
path: dist/LLMAssistant_v${{ steps.package.outputs.version }}_x86.zip
if-no-files-found: error

- name: Upload CI artifact (arm64)
uses: actions/upload-artifact@v4
with:
name: LLMAssistant-arm64
path: dist/LLMAssistant_v${{ steps.package.outputs.version }}_arm64.zip
if-no-files-found: error

- name: Publish GitHub Release
if: github.ref_type == 'tag'
uses: softprops/action-gh-release@v2
with:
files: ${{ steps.package.outputs.zip }}
files: |
dist/LLMAssistant_v${{ steps.package.outputs.version }}_x64.zip
dist/LLMAssistant_v${{ steps.package.outputs.version }}_x86.zip
dist/LLMAssistant_v${{ steps.package.outputs.version }}_arm64.zip
fail_on_unmatched_files: true
generate_release_notes: true
body: |
### Notepad++ Plugins Admin metadata

Add / update this in `nppPluginList` (`src/pl.x64.json`):

```json
{
"folder-name": "LLMAssistant",
"display-name": "LLM Assistant",
"version": "${{ steps.package.outputs.version }}",
"id": "${{ steps.package.outputs.sha256 }}",
"repository": "${{ github.server_url }}/${{ github.repository }}/releases/download/${{ github.ref_name }}/${{ steps.package.outputs.zip }}",
"description": "AI-powered text processing (enhance, translate, summarize, grammar, code) via the OpenAI API, directly inside Notepad++.",
"author": "Gvo87",
"homepage": "${{ github.server_url }}/${{ github.repository }}"
}
```

`id` is the SHA-256 of the attached zip: `${{ steps.package.outputs.sha256 }}`
body_path: dist/release-notes.md
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# x64 build directory
# Build directories (one per platform)
x64/
CMakeBuild/
Win32/
ARM64/
CMakeBuild*/
_deps/

# Release packaging output
Expand Down
42 changes: 34 additions & 8 deletions LLMAssistant.vcxproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- One DLL per Notepad++ architecture: x64, Win32 (32-bit) and ARM64. The
settings below depend only on the configuration, so every platform builds
the same way. -->
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
Expand All @@ -9,6 +12,22 @@
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
Expand All @@ -18,13 +37,13 @@
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v145</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v145</PlatformToolset>
Expand All @@ -36,24 +55,31 @@
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)'=='Debug'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)'=='Release'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<!-- Output goes to <Platform>\<Configuration>\, e.g. Win32\Release\LLMAssistant.dll.
MSBuild's default already does this for x64 and ARM64, but puts Win32
output in Release\ and Debug\. -->
<PropertyGroup>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<LinkIncremental>true</LinkIncremental>
<TargetName>LLMAssistant</TargetName>
<TargetExt>.dll</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<LinkIncremental>false</LinkIncremental>
<TargetName>LLMAssistant</TargetName>
<TargetExt>.dll</TargetExt>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
Expand All @@ -72,7 +98,7 @@
<AdditionalIncludeDirectories>$(ProjectDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ The **Custom Prompt** option allows maximum flexibility:
### Prerequisites
- **Visual Studio 2022 or later** (any edition, or Build Tools) with the "Desktop development with C++" workload
- **Windows SDK** (installed with that workload)
- **For ARM64 builds only**: the "MSVC Build Tools for ARM64/ARM64EC (Latest)" component (on Visual Studio 2022: "MSVC v143 - VS 2022 C++ ARM64/ARM64EC build tools (Latest)"), added under Individual components in the Visual Studio Installer
- **Git** (for cloning the repository)

### Build Steps
Expand All @@ -103,16 +104,22 @@ cd NotepadPlusPlus-LLM-Plugin

# The compiled DLL will be in:
# x64\Release\LLMAssistant.dll

# Or build for 32-bit or ARM64 Notepad++:
.\build.bat x86 # Win32\Release\LLMAssistant.dll
.\build.bat arm64 # ARM64\Release\LLMAssistant.dll
```

Notepad++ only loads a plugin built for its own architecture, so use the DLL that matches your Notepad++ (x64, x86 or ARM64).

### Development Environment
The build script automatically:
- Finds the newest Visual Studio with the C++ tools (using `vswhere`)
- Sets up the build environment
- Compiles with the project's platform toolset (v145), or with the newest installed toolset if v145 is missing (for example v143 on Visual Studio 2022)
- Links required Windows libraries

`deploy.bat` builds the same way, then copies the DLL into `C:\Program Files\Notepad++\plugins\LLMAssistant\`. Run it as Administrator. It closes Notepad++ the same way its close button does, so unsaved files are handled as usual: Notepad++ asks whether to save them, or, if session snapshot is on, keeps them in its backup for the next start. It won't copy anything while Notepad++ is still open.
`deploy.bat` builds the x64 DLL the same way, then copies it into `C:\Program Files\Notepad++\plugins\LLMAssistant\`. Run it as Administrator. It closes Notepad++ the same way its close button does, so unsaved files are handled as usual: Notepad++ asks whether to save them, or, if session snapshot is on, keeps them in its backup for the next start. It won't copy anything while Notepad++ is still open.

### Automated Tests
The portable request, JSON, and UTF-8 regression tests use Catch2. Configure them with CMake:
Expand Down
Loading
Loading