diff --git a/nsis/cagire.nsi b/nsis/cagire.nsi index a44d95c..daa8822 100644 --- a/nsis/cagire.nsi +++ b/nsis/cagire.nsi @@ -39,8 +39,12 @@ Unicode True Section "Cagire (required)" SecCore SectionIn RO SetOutPath "$INSTDIR" - File "/oname=cagire.exe" "${CLI_EXE}" - File "/oname=cagire-desktop.exe" "${DESKTOP_EXE}" + !ifdef CLI_EXE + File "/oname=cagire.exe" "${CLI_EXE}" + !endif + !ifdef DESKTOP_EXE + File "/oname=cagire-desktop.exe" "${DESKTOP_EXE}" + !endif WriteUninstaller "$INSTDIR\uninstall.exe" WriteRegStr HKLM "Software\Cagire" "InstallDir" "$INSTDIR" @@ -50,7 +54,11 @@ Section "Cagire (required)" SecCore WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cagire" "DisplayVersion" "${VERSION}" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cagire" "Publisher" "Raphael Forment" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cagire" "UninstallString" '"$INSTDIR\uninstall.exe"' - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cagire" "DisplayIcon" '"$INSTDIR\cagire-desktop.exe"' + !ifdef DESKTOP_EXE + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cagire" "DisplayIcon" '"$INSTDIR\cagire-desktop.exe"' + !else + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cagire" "DisplayIcon" '"$INSTDIR\cagire.exe"' + !endif WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cagire" "URLInfoAbout" "https://git.raphaelforment.fr/BuboBubo/cagire" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cagire" "HelpLink" "https://cagire.raphaelforment.fr" WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cagire" "NoModify" 1 @@ -64,21 +72,29 @@ Section "Add to PATH" SecPath SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 SectionEnd +!ifdef DESKTOP_EXE Section "Start Menu Shortcut" SecStartMenu CreateDirectory "$SMPROGRAMS\Cagire" CreateShortCut "$SMPROGRAMS\Cagire\Cagire.lnk" "$INSTDIR\cagire-desktop.exe" "" "$INSTDIR\cagire-desktop.exe" 0 CreateShortCut "$SMPROGRAMS\Cagire\Uninstall.lnk" "$INSTDIR\uninstall.exe" SectionEnd +!endif !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "Installs Cagire CLI and Desktop binaries." !insertmacro MUI_DESCRIPTION_TEXT ${SecPath} "Add the install location to the PATH system environment variable." - !insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenu} "Add a Cagire shortcut to the Start Menu." + !ifdef DESKTOP_EXE + !insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenu} "Add a Cagire shortcut to the Start Menu." + !endif !insertmacro MUI_FUNCTION_DESCRIPTION_END Section "Uninstall" - Delete "$INSTDIR\cagire.exe" - Delete "$INSTDIR\cagire-desktop.exe" + !ifdef CLI_EXE + Delete "$INSTDIR\cagire.exe" + !endif + !ifdef DESKTOP_EXE + Delete "$INSTDIR\cagire-desktop.exe" + !endif Delete "$INSTDIR\uninstall.exe" RMDir "$INSTDIR" diff --git a/scripts/build.py b/scripts/build.py index 17884a5..c3a6f76 100755 --- a/scripts/build.py +++ b/scripts/build.py @@ -442,22 +442,25 @@ def make_appimage(root: Path, binary: Path, arch: str, output_dir: Path, log: li # --------------------------------------------------------------------------- -def make_nsis(root: Path, rd: Path, version: str, output_dir: Path, log: list[str]) -> str | None: +def make_nsis(root: Path, rd: Path, version: str, output_dir: Path, config: BuildConfig, log: list[str]) -> str | None: if not shutil.which("makensis"): log.append(" makensis not found, skipping NSIS installer") return None log.append(" Building NSIS installer") abs_root = str(root.resolve()) - run_cmd([ + cmd = [ "makensis", f"-DVERSION={version}", - f"-DCLI_EXE={abs_root}/{rd.relative_to(root)}/cagire.exe", - f"-DDESKTOP_EXE={abs_root}/{rd.relative_to(root)}/cagire-desktop.exe", f"-DICON={abs_root}/assets/Cagire.ico", f"-DOUTDIR={abs_root}/{OUT}", - str(root / "nsis" / "cagire.nsi"), - ], log) + ] + if config.cli: + cmd.append(f"-DCLI_EXE={abs_root}/{rd.relative_to(root)}/cagire.exe") + if config.desktop: + cmd.append(f"-DDESKTOP_EXE={abs_root}/{rd.relative_to(root)}/cagire-desktop.exe") + cmd.append(str(root / "nsis" / "cagire.nsi")) + run_cmd(cmd, log) installer = f"cagire-{version}-windows-x86_64-setup.exe" log.append(f" Installer -> {output_dir / installer}") @@ -506,7 +509,7 @@ def copy_artifacts(root: Path, p: Platform, config: BuildConfig, log: list[str]) artifacts.append(dmg) if p.os == "windows": - nsis = make_nsis(root, rd, version, out, log) + nsis = make_nsis(root, rd, version, out, config, log) if nsis: artifacts.append(nsis)