140 lines
4.8 KiB
NSIS
140 lines
4.8 KiB
NSIS
; L Language 编译器 Windows 安装包
|
|
; 构建: makensis -DVERSION=x.y.z installer.nsi
|
|
|
|
Unicode true
|
|
|
|
!ifndef VERSION
|
|
!define VERSION "0.6.0"
|
|
!endif
|
|
|
|
!define PRODUCT "L Language"
|
|
!define PUBLISHER "Liu Hangyu (LHY0125)"
|
|
!define EXE "l_lang.exe"
|
|
|
|
Name "${PRODUCT} ${VERSION}"
|
|
OutFile "..\build\L-Language-${VERSION}-setup.exe"
|
|
InstallDir "$PROGRAMFILES\L Language"
|
|
RequestExecutionLevel admin
|
|
SetCompressor /SOLID lzma
|
|
SetCompressorDictSize 32
|
|
|
|
!include "MUI2.nsh"
|
|
|
|
!define MUI_ABORTWARNING
|
|
!insertmacro MUI_PAGE_WELCOME
|
|
!insertmacro MUI_PAGE_LICENSE "..\LICENSE"
|
|
!insertmacro MUI_PAGE_DIRECTORY
|
|
!insertmacro MUI_PAGE_INSTFILES
|
|
!insertmacro MUI_PAGE_FINISH
|
|
|
|
!insertmacro MUI_UNPAGE_CONFIRM
|
|
!insertmacro MUI_UNPAGE_INSTFILES
|
|
!insertmacro MUI_LANGUAGE "SimpChinese"
|
|
|
|
; ── 核心文件 ──
|
|
Section "Install"
|
|
SetOutPath "$INSTDIR"
|
|
|
|
; 编译器
|
|
File "..\build\${EXE}"
|
|
; LLVM 运行时 (编译必须)
|
|
File "D:\settings\Language\LLVM\bin\LLVM-C.dll"
|
|
; 链接器 (.o -> .exe)
|
|
File "D:\settings\Language\LLVM\bin\clang.exe"
|
|
File "D:\settings\Language\LLVM\bin\ld.lld.exe"
|
|
; MinGW 线程运行时
|
|
File "D:\settings\Language\C\mingw64\bin\libmcfgthread-2.dll"
|
|
|
|
; 示例程序
|
|
SetOutPath "$INSTDIR\examples"
|
|
File "..\test\programs\01_arithmetic.l"
|
|
File "..\test\programs\02_if_else.l"
|
|
File "..\test\programs\04_fib_recursive.l"
|
|
File "..\test\programs\12_struct.l"
|
|
File "..\test\programs\17_enum.l"
|
|
File "..\test\programs\27_named_args.l"
|
|
File "..\test\programs\28_pipe.l"
|
|
File "..\test\programs\29_interp.l"
|
|
|
|
; 示例说明
|
|
FileOpen $0 "$INSTDIR\examples\README.txt" w
|
|
FileWrite $0 "L Language 示例程序$\r$\n"
|
|
FileWrite $0 "==================$\r$\n$\r$\n"
|
|
FileWrite $0 "01_arithmetic.l - 基本算术运算$\r$\n"
|
|
FileWrite $0 "02_if_else.l - if/else 分支$\r$\n"
|
|
FileWrite $0 "04_fib_recursive.l - 递归斐波那契$\r$\n"
|
|
FileWrite $0 "12_struct.l - 结构体定义和使用$\r$\n"
|
|
FileWrite $0 "17_enum.l - 枚举类型$\r$\n"
|
|
FileWrite $0 "27_named_args.l - 命名参数$\r$\n"
|
|
FileWrite $0 "28_pipe.l - 管道运算符 |>$\r$\n"
|
|
FileWrite $0 "29_interp.l - 字符串插值$\r$\n$\r$\n"
|
|
FileWrite $0 "编译运行:$\r$\n"
|
|
FileWrite $0 ' "$INSTDIR\${EXE}" 文件名.l -o 程序.exe$\r$\n'
|
|
FileWrite $0 " 程序.exe$\r$\n"
|
|
FileClose $0
|
|
|
|
; 快速入门 bat
|
|
FileOpen $0 "$INSTDIR\快速入门.bat" w
|
|
FileWrite $0 '@echo off$\r$\n'
|
|
FileWrite $0 'title L Language - 快速入门$\r$\n'
|
|
FileWrite $0 'echo.$\r$\n'
|
|
FileWrite $0 'echo ===================================$\r$\n'
|
|
FileWrite $0 'echo L Language ${VERSION} 快速入门$\r$\n'
|
|
FileWrite $0 'echo ===================================$\r$\n'
|
|
FileWrite $0 'echo.$\r$\n'
|
|
FileWrite $0 'echo 编译并运行字符串插值示例:$\r$\n'
|
|
FileWrite $0 'echo.$\r$\n'
|
|
FileWrite $0 '"$INSTDIR\${EXE}" "$INSTDIR\examples\29_interp.l" -o "$INSTDIR\hello.exe"$\r$\n'
|
|
FileWrite $0 'if %errorlevel% equ 0 ($\r$\n'
|
|
FileWrite $0 ' echo.$\r$\n'
|
|
FileWrite $0 ' echo --- 程序输出 ---$\r$\n'
|
|
FileWrite $0 ' "$INSTDIR\hello.exe"$\r$\n'
|
|
FileWrite $0 ' echo.$\r$\n'
|
|
FileWrite $0 ' echo 编译运行成功!$\r$\n'
|
|
FileWrite $0 ') else ($\r$\n'
|
|
FileWrite $0 ' echo 编译失败,请检查环境。$\r$\n'
|
|
FileWrite $0 ')$\r$\n'
|
|
FileWrite $0 'echo.$\r$\n'
|
|
FileWrite $0 'pause$\r$\n'
|
|
FileClose $0
|
|
|
|
; 开始菜单
|
|
CreateDirectory "$SMPROGRAMS\${PRODUCT}"
|
|
CreateShortCut "$SMPROGRAMS\${PRODUCT}\快速入门.lnk" \
|
|
"$INSTDIR\快速入门.bat" "" "$INSTDIR\快速入门.bat" 0
|
|
CreateShortCut "$SMPROGRAMS\${PRODUCT}\示例目录.lnk" \
|
|
"$INSTDIR\examples" "" "$INSTDIR\examples" 0
|
|
CreateShortCut "$SMPROGRAMS\${PRODUCT}\卸载.lnk" \
|
|
"$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
|
|
|
|
; 控制面板注册
|
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\L Language" \
|
|
"DisplayName" "${PRODUCT} ${VERSION}"
|
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\L Language" \
|
|
"UninstallString" "$INSTDIR\uninstall.exe"
|
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\L Language" \
|
|
"DisplayVersion" "${VERSION}"
|
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\L Language" \
|
|
"Publisher" "${PUBLISHER}"
|
|
|
|
WriteUninstaller "$INSTDIR\uninstall.exe"
|
|
SectionEnd
|
|
|
|
; ── 卸载 ──
|
|
Section "Uninstall"
|
|
Delete "$INSTDIR\${EXE}"
|
|
Delete "$INSTDIR\LLVM-C.dll"
|
|
Delete "$INSTDIR\clang.exe"
|
|
Delete "$INSTDIR\ld.lld.exe"
|
|
Delete "$INSTDIR\libmcfgthread-2.dll"
|
|
Delete "$INSTDIR\快速入门.bat"
|
|
Delete "$INSTDIR\uninstall.exe"
|
|
RMDir /r "$INSTDIR\examples"
|
|
RMDir "$INSTDIR"
|
|
|
|
Delete "$SMPROGRAMS\${PRODUCT}\*"
|
|
RMDir "$SMPROGRAMS\${PRODUCT}"
|
|
|
|
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\L Language"
|
|
SectionEnd
|