Merge branch 'master' of github.com:royqh1979/RedPanda-CPP

This commit is contained in:
Roy Qu 2024-02-19 17:23:22 +08:00
commit 80265f78ca
5 changed files with 194 additions and 289 deletions

View File

@ -9,7 +9,6 @@ end
local gnuArchMap: {string:string} = {
i386 = "i686",
x86_64 = "x86_64",
arm = "armv7",
arm64 = "aarch64",
}
@ -199,19 +198,16 @@ global function main(): CompilerHint
resourceCompiler = binDir .. "/windres.exe",
binDirs = {binDir},
}
local extraObjects = {
utf8init = libDir .. "/utf8init.o",
utf8manifest = libDir .. "/utf8manifest.o",
}
local release, debug_, debugWithAsan = generateConfig(
if C_FileSystem.exists(libDir .. "/libutf8.a") then
local release, debug_, _ = generateConfig(
function (arch_: string, profile: string): string
return nameGeneratorMingwGcc(lang, arch_, profile, true)
end,
programs,
{
arch = arch,
customLinkParams = {extraObjects.utf8init, extraObjects.utf8manifest},
customLinkParams = {"-Wl,--whole-archive", "-lutf8", "-Wl,--no-whole-archive"},
}
)
table.insert(compilerList, release)
@ -219,8 +215,10 @@ global function main(): CompilerHint
if preferCompiler == 0 then
preferCompiler = 2
end
end
release, debug_, debugWithAsan = generateConfig(
do
local release, debug_, _ = generateConfig(
function (arch_: string, profile: string): string
return nameGeneratorMingwGcc(lang, arch_, profile, false)
end,
@ -232,6 +230,10 @@ global function main(): CompilerHint
)
table.insert(compilerList, release)
table.insert(compilerList, debug_)
if preferCompiler == 0 then
preferCompiler = 2
end
end
table.insert(noSearch, excludeBinDir)
end
@ -243,9 +245,9 @@ global function main(): CompilerHint
local binDir = libexecDir .. "/llvm-mingw/bin"
local appTriplet = gnuArchMap[appArch] .. "-w64-mingw32"
local appDllDir = libexecDir .. "/llvm-mingw/" .. appTriplet .. "/bin"
do
-- appArch is always debuggable
local libDir = libexecDir .. "/llvm-mingw/" .. appTriplet .. "/lib"
local programs: Programs = {
cCompiler = binDir .. "/" .. appTriplet .. "-clang.exe",
cxxCompiler = binDir .. "/" .. appTriplet .. "-clang++.exe",
@ -253,11 +255,7 @@ global function main(): CompilerHint
debugger = binDir .. "/lldb-mi.exe",
debugServer = binDir .. "/lldb-server.exe",
resourceCompiler = binDir .. "/" .. appTriplet .. "-windres.exe",
binDirs = {binDir},
}
local extraObjects = {
utf8init = libDir .. "/utf8init.o",
utf8manifest = libDir .. "/utf8manifest.o",
binDirs = {binDir, appDllDir},
}
local release, debug_, debugWithAsan = generateConfig(
function (arch_: string, profile: string): string
@ -266,7 +264,7 @@ global function main(): CompilerHint
programs,
{
arch = appArch,
customLinkParams = {extraObjects.utf8init, extraObjects.utf8manifest},
customLinkParams = {"-Wl,utf8init.o", "-Wl,utf8manifest.o"},
isClang = true,
}
)
@ -285,9 +283,10 @@ global function main(): CompilerHint
end
for _, foreignArch in ipairs(supportedAppArches) do
if foreignArch ~= appArch then
local foreignTriplet = gnuArchMap[foreignArch] .. "-w64-mingw32"
local libDir = libexecDir .. "/llvm-mingw/" .. foreignTriplet .. "/lib"
local gnuArch = gnuArchMap[foreignArch]
if foreignArch ~= appArch and gnuArch ~= nil then
local foreignTriplet = gnuArch .. "-w64-mingw32"
local foreignDllDir = libexecDir .. "/llvm-mingw/" .. foreignTriplet .. "/bin"
local programs: Programs = {
cCompiler = binDir .. "/" .. foreignTriplet .. "-clang.exe",
cxxCompiler = binDir .. "/" .. foreignTriplet .. "-clang++.exe",
@ -295,11 +294,7 @@ global function main(): CompilerHint
debugger = binDir .. "/lldb-mi.exe",
debugServer = binDir .. "/lldb-server.exe",
resourceCompiler = binDir .. "/" .. foreignTriplet .. "-windres.exe",
binDirs = {binDir},
}
local extraObjects = {
utf8init = libDir .. "/utf8init.o",
utf8manifest = libDir .. "/utf8manifest.o",
binDirs = {binDir, foreignDllDir},
}
local release, _, _ = generateConfig(
function (arch_: string, profile: string): string
@ -308,7 +303,7 @@ global function main(): CompilerHint
programs,
{
arch = foreignArch,
customLinkParams = {extraObjects.utf8init, extraObjects.utf8manifest},
customLinkParams = {"-Wl,utf8init.o", "-Wl,utf8manifest.o"},
isClang = true,
}
)
@ -337,10 +332,6 @@ global function main(): CompilerHint
binDirs = {llvmOrgBinDir},
libDirs = {libDir},
}
local extraObjects = {
utf8init = libDir .. "/utf8init.o",
utf8manifest = libDir .. "/utf8manifest.o",
}
local release, debug_, _ = generateConfig(
function (arch: string, profile: string): string
return nameGeneratorClang(lang, arch, profile, false)
@ -356,7 +347,7 @@ global function main(): CompilerHint
},
customLinkParams = {
"-target", msvcTriplet,
extraObjects.utf8init, extraObjects.utf8manifest,
"-Wl,utf8init.o", "-Wl,utf8manifest.o",
},
isClang = true,
}
@ -366,8 +357,9 @@ global function main(): CompilerHint
end
for _, foreignArch in ipairs(supportedAppArches) do
if foreignArch ~= appArch then
local foreignTriplet = gnuArchMap[foreignArch] .. "-w64-mingw32"
local gnuArch = gnuArchMap[foreignArch]
if foreignArch ~= appArch and gnuArch ~= nil then
local foreignTriplet = gnuArch .. "-w64-mingw32"
local msvcTriplet = gnuArchMap[foreignArch] .. "-pc-windows-msvc"
local libDir = libexecDir .. "/llvm-mingw/" .. msvcTriplet .. "/lib"
local programs: Programs = {
@ -380,10 +372,6 @@ global function main(): CompilerHint
binDirs = {llvmOrgBinDir},
libDirs = {libDir},
}
local extraObjects = {
utf8init = libDir .. "/utf8init.o",
utf8manifest = libDir .. "/utf8manifest.o",
}
local release, _, _ = generateConfig(
function (arch: string, profile: string): string
return nameGeneratorClang(lang, arch, profile, false)
@ -399,7 +387,7 @@ global function main(): CompilerHint
},
customLinkParams = {
"-target", msvcTriplet,
extraObjects.utf8init, extraObjects.utf8manifest,
"-Wl,utf8init.o", "-Wl,utf8manifest.o",
},
isClang = true,
}
@ -412,9 +400,12 @@ global function main(): CompilerHint
if appArch == "x86_64" then
checkAndAddMingw("x86_64")
checkAndAddMingw("i386")
checkAndAddClang()
elseif appArch == "arm64" then
checkAndAddClang()
checkAndAddMingw("x86_64")
checkAndAddMingw("i386")
else
checkAndAddMingw("i386")
checkAndAddClang()

View File

@ -26,7 +26,7 @@ set -euxo pipefail
GCC_VERSION="13.2.0"
MINGW_VERSION="rt_v11-rev1"
LLVM_MINGW_TAG="20231128"
REDPANDA_LLVM_VERSION="17-r0"
WINDOWS_TERMINAL_VERSION="1.18.3181.0"
_QMAKE="$MINGW_PREFIX/qt5-static/bin/qmake"
@ -43,10 +43,9 @@ _MINGW64_ARCHIVE="x86_64-$GCC_VERSION-release-posix-seh-ucrt-$MINGW_VERSION.7z"
_MINGW64_URL="https://github.com/niXman/mingw-builds-binaries/releases/download/$GCC_VERSION-$MINGW_VERSION/$_MINGW64_ARCHIVE"
_LLVM_DIR="llvm-mingw"
_LLVM_ARCHES=("x86_64" "i686" "aarch64" "armv7")
_LLVM_ORIGINAL_DIR="llvm-mingw-$LLVM_MINGW_TAG-ucrt-$_NATIVE_ARCH"
_LLVM_ARCHIVE="$_LLVM_ORIGINAL_DIR.zip"
_LLVM_URL="https://github.com/mstorsjo/llvm-mingw/releases/download/$LLVM_MINGW_TAG/$_LLVM_ARCHIVE"
_LLVM_ARCHES=("x86_64" "i686" "aarch64")
_LLVM_ARCHIVE="$_LLVM_DIR-$REDPANDA_LLVM_VERSION-$_NATIVE_ARCH.7z"
_LLVM_URL="https://github.com/redpanda-cpp/toolchain-win32-llvm/releases/download/$REDPANDA_LLVM_VERSION/$_LLVM_ARCHIVE"
_WINDOWS_TERMINAL_DIR="terminal-${WINDOWS_TERMINAL_VERSION}"
_WINDOWS_TERMINAL_ARCHIVE="Microsoft.WindowsTerminal_${WINDOWS_TERMINAL_VERSION}_$_DISPLAY_ARCH.zip"
@ -103,7 +102,7 @@ function check-deps() {
$MINGW_PACKAGE_PREFIX-{$compiler,make,qt5-static}
mingw-w64-i686-nsis
)
[[ _7Z_REPACK -eq 1 ]] || deps+=("$MINGW_PACKAGE_PREFIX-7zip")
[[ _7Z_REPACK -eq 1 ]] && deps+=("$MINGW_PACKAGE_PREFIX-7zip")
for dep in "${deps[@]}"; do
pacman -Q "$dep" >/dev/null 2>&1 || (
echo "Missing dependency: $dep"
@ -113,7 +112,10 @@ function check-deps() {
}
function prepare-dirs() {
[[ $_CLEAN -eq 1 ]] && rm -rf "$_BUILDDIR" "$_PKGDIR" || true
if [[ $_CLEAN -eq 1 ]]; then
[[ -d "$_BUILDDIR" ]] && rm -rf "$_BUILDDIR"
[[ -d "$_PKGDIR" ]] && rm -rf "$_PKGDIR"
fi
mkdir -p "$_ASSETSDIR" "$_BUILDDIR" "$_PKGDIR" "$_DISTDIR"
}
@ -144,37 +146,7 @@ function prepare-mingw() {
{
gcc -Os -fno-exceptions -nodefaultlibs -nostdlib -c -o "$mingw_lib_dir/utf8init.o" "$_SRCDIR/platform/windows/utf8/utf8init.cpp"
windres -O coff -o "$mingw_lib_dir/utf8manifest.o" "$_SRCDIR/platform/windows/utf8/utf8manifest.rc"
}
export PATH="$old_path"
fi
}
function prepare-llvm-mingw() {
local llvm_dir="$_BUILDDIR/$_LLVM_DIR"
if [[ ! -d "$llvm_dir" ]]; then
bsdtar -C "$_BUILDDIR" -xf "$_ASSETSDIR/$_LLVM_ARCHIVE"
mv "$_BUILDDIR/$_LLVM_ORIGINAL_DIR" "$llvm_dir"
local old_path="$PATH"
export PATH="$llvm_dir/bin:$PATH"
for arch in "${_LLVM_ARCHES[@]}"; do
local triplet="$arch-w64-mingw32"
local lib_dir="$llvm_dir/$triplet/lib"
$triplet-clang -Os -fno-exceptions -nodefaultlibs -nostdlib -c -o "$lib_dir/utf8init.o" "$_SRCDIR/platform/windows/utf8/utf8init.cpp"
$triplet-windres -O coff -o "$lib_dir/utf8manifest.o" "$_SRCDIR/platform/windows/utf8/utf8manifest.rc"
local msvc_triplet="$arch-pc-windows-msvc"
local lib_dir="$llvm_dir/$msvc_triplet/lib"
mkdir -p "$lib_dir"
$triplet-clang -target $msvc_triplet -Os -fno-exceptions -nodefaultlibs -nostdlib -c -o "$lib_dir/utf8init.o" "$_SRCDIR/platform/windows/utf8/utf8init.cpp"
$triplet-windres -O coff -o "$lib_dir/utf8manifest.o" "$_SRCDIR/platform/windows/utf8/utf8manifest.rc"
done
{
local triplet="x86_64-w64-mingw32"
local msvc_triplet="arm64ec-pc-windows-msvc"
local lib_dir="$llvm_dir/$msvc_triplet/lib"
mkdir -p "$lib_dir"
$triplet-clang -target $msvc_triplet -Os -fno-exceptions -nodefaultlibs -nostdlib -c -o "$lib_dir/utf8init.o" "$_SRCDIR/platform/windows/utf8/utf8init.cpp"
$triplet-windres -O coff -o "$lib_dir/utf8manifest.o" "$_SRCDIR/platform/windows/utf8/utf8manifest.rc"
ar rcs "$mingw_lib_dir/libutf8.a" "$mingw_lib_dir/utf8init.o" "$mingw_lib_dir/utf8manifest.o"
}
export PATH="$old_path"
fi
@ -210,17 +182,15 @@ function build() {
if [[ $_NATIVE_ARCH == x86_64 ]]; then
[[ -d "$_PKGDIR/mingw64" ]] || cp -r "mingw64" "$_PKGDIR"
fi
[[ -d "$_PKGDIR/llvm-mingw" ]] || cp -r "llvm-mingw" "$_PKGDIR"
[[ -d "$_PKGDIR/llvm-mingw" ]] || bsdtar -C "$_PKGDIR" -xf "$_ASSETSDIR/$_LLVM_ARCHIVE"
popd
}
function package() {
pushd "$_PKGDIR"
"$_NSIS" -DVERSION="$_REDPANDA_VERSION" -DARCH="$_DISPLAY_ARCH" main.nsi &
"$_NSIS" -DVERSION="$_REDPANDA_VERSION" -DARCH="$_DISPLAY_ARCH" -DUSER_MODE main.nsi &
wait
"$_NSIS" -DVERSION="$_REDPANDA_VERSION" -DARCH="$_DISPLAY_ARCH" main.nsi
if [[ _7Z_REPACK -eq 1 ]]; then
7z x "redpanda-cpp-$_REDPANDA_VERSION-$_DISPLAY_ARCH-user.exe" -o"RedPanda-CPP" -xr'!$PLUGINSDIR' -x"!uninstall.exe"
7z x "redpanda-cpp-$_REDPANDA_VERSION-$_DISPLAY_ARCH.exe" -o"RedPanda-CPP" -xr'!$PLUGINSDIR' -x"!uninstall.exe"
7z a -t7z -mx=9 -ms=on -mqs=on -mf=BCJ2 -m0="LZMA2:d=128m:fb=273:c=2g" "redpanda-cpp-$_REDPANDA_VERSION-$_DISPLAY_ARCH.7z" "RedPanda-CPP"
rm -rf "RedPanda-CPP"
fi
@ -228,8 +198,7 @@ function package() {
}
function dist() {
cp "$_PKGDIR/redpanda-cpp-$_REDPANDA_VERSION-$_DISPLAY_ARCH-system.exe" "$_DISTDIR"
cp "$_PKGDIR/redpanda-cpp-$_REDPANDA_VERSION-$_DISPLAY_ARCH-user.exe" "$_DISTDIR"
cp "$_PKGDIR/redpanda-cpp-$_REDPANDA_VERSION-$_DISPLAY_ARCH.exe" "$_DISTDIR"
[[ _7Z_REPACK -eq 1 ]] && cp "$_PKGDIR/redpanda-cpp-$_REDPANDA_VERSION-$_DISPLAY_ARCH.7z" "$_DISTDIR"
}
@ -238,7 +207,6 @@ prepare-dirs
download-assets
[[ $_NATIVE_ARCH == i686 ]] && prepare-mingw 32
[[ $_NATIVE_ARCH == x86_64 ]] && prepare-mingw 64
prepare-llvm-mingw
prepare-openconsole
prepare-src
trap restore-src EXIT INT TERM

View File

@ -9,7 +9,6 @@ end
local gnuArchMap = {
i386 = "i686",
x86_64 = "x86_64",
arm = "armv7",
arm64 = "aarch64",
}
@ -199,19 +198,16 @@ function main()
resourceCompiler = binDir .. "/windres.exe",
binDirs = { binDir },
}
local extraObjects = {
utf8init = libDir .. "/utf8init.o",
utf8manifest = libDir .. "/utf8manifest.o",
}
local release, debug_, debugWithAsan = generateConfig(
if C_FileSystem.exists(libDir .. "/libutf8.a") then
local release, debug_, _ = generateConfig(
function(arch_, profile)
return nameGeneratorMingwGcc(lang, arch_, profile, true)
end,
programs,
{
arch = arch,
customLinkParams = { extraObjects.utf8init, extraObjects.utf8manifest },
customLinkParams = { "-Wl,--whole-archive", "-lutf8", "-Wl,--no-whole-archive" },
})
table.insert(compilerList, release)
@ -219,8 +215,10 @@ function main()
if preferCompiler == 0 then
preferCompiler = 2
end
end
release, debug_, debugWithAsan = generateConfig(
do
local release, debug_, _ = generateConfig(
function(arch_, profile)
return nameGeneratorMingwGcc(lang, arch_, profile, false)
end,
@ -232,6 +230,10 @@ function main()
table.insert(compilerList, release)
table.insert(compilerList, debug_)
if preferCompiler == 0 then
preferCompiler = 2
end
end
table.insert(noSearch, excludeBinDir)
end
@ -243,9 +245,9 @@ function main()
local binDir = libexecDir .. "/llvm-mingw/bin"
local appTriplet = gnuArchMap[appArch] .. "-w64-mingw32"
local appDllDir = libexecDir .. "/llvm-mingw/" .. appTriplet .. "/bin"
do
local libDir = libexecDir .. "/llvm-mingw/" .. appTriplet .. "/lib"
local programs = {
cCompiler = binDir .. "/" .. appTriplet .. "-clang.exe",
cxxCompiler = binDir .. "/" .. appTriplet .. "-clang++.exe",
@ -253,11 +255,7 @@ function main()
debugger = binDir .. "/lldb-mi.exe",
debugServer = binDir .. "/lldb-server.exe",
resourceCompiler = binDir .. "/" .. appTriplet .. "-windres.exe",
binDirs = { binDir },
}
local extraObjects = {
utf8init = libDir .. "/utf8init.o",
utf8manifest = libDir .. "/utf8manifest.o",
binDirs = { binDir, appDllDir },
}
local release, debug_, debugWithAsan = generateConfig(
function(arch_, profile)
@ -266,7 +264,7 @@ function main()
programs,
{
arch = appArch,
customLinkParams = { extraObjects.utf8init, extraObjects.utf8manifest },
customLinkParams = { "-Wl,utf8init.o", "-Wl,utf8manifest.o" },
isClang = true,
})
@ -285,9 +283,10 @@ function main()
end
for _, foreignArch in ipairs(supportedAppArches) do
if foreignArch ~= appArch then
local foreignTriplet = gnuArchMap[foreignArch] .. "-w64-mingw32"
local libDir = libexecDir .. "/llvm-mingw/" .. foreignTriplet .. "/lib"
local gnuArch = gnuArchMap[foreignArch]
if foreignArch ~= appArch and gnuArch ~= nil then
local foreignTriplet = gnuArch .. "-w64-mingw32"
local foreignDllDir = libexecDir .. "/llvm-mingw/" .. foreignTriplet .. "/bin"
local programs = {
cCompiler = binDir .. "/" .. foreignTriplet .. "-clang.exe",
cxxCompiler = binDir .. "/" .. foreignTriplet .. "-clang++.exe",
@ -295,11 +294,7 @@ function main()
debugger = binDir .. "/lldb-mi.exe",
debugServer = binDir .. "/lldb-server.exe",
resourceCompiler = binDir .. "/" .. foreignTriplet .. "-windres.exe",
binDirs = { binDir },
}
local extraObjects = {
utf8init = libDir .. "/utf8init.o",
utf8manifest = libDir .. "/utf8manifest.o",
binDirs = { binDir, foreignDllDir },
}
local release, _, _ = generateConfig(
function(arch_, profile)
@ -308,7 +303,7 @@ function main()
programs,
{
arch = foreignArch,
customLinkParams = { extraObjects.utf8init, extraObjects.utf8manifest },
customLinkParams = { "-Wl,utf8init.o", "-Wl,utf8manifest.o" },
isClang = true,
})
@ -337,10 +332,6 @@ function main()
binDirs = { llvmOrgBinDir },
libDirs = { libDir },
}
local extraObjects = {
utf8init = libDir .. "/utf8init.o",
utf8manifest = libDir .. "/utf8manifest.o",
}
local release, debug_, _ = generateConfig(
function(arch, profile)
return nameGeneratorClang(lang, arch, profile, false)
@ -356,7 +347,7 @@ function main()
},
customLinkParams = {
"-target", msvcTriplet,
extraObjects.utf8init, extraObjects.utf8manifest,
"-Wl,utf8init.o", "-Wl,utf8manifest.o",
},
isClang = true,
})
@ -366,8 +357,9 @@ function main()
end
for _, foreignArch in ipairs(supportedAppArches) do
if foreignArch ~= appArch then
local foreignTriplet = gnuArchMap[foreignArch] .. "-w64-mingw32"
local gnuArch = gnuArchMap[foreignArch]
if foreignArch ~= appArch and gnuArch ~= nil then
local foreignTriplet = gnuArch .. "-w64-mingw32"
local msvcTriplet = gnuArchMap[foreignArch] .. "-pc-windows-msvc"
local libDir = libexecDir .. "/llvm-mingw/" .. msvcTriplet .. "/lib"
local programs = {
@ -380,10 +372,6 @@ function main()
binDirs = { llvmOrgBinDir },
libDirs = { libDir },
}
local extraObjects = {
utf8init = libDir .. "/utf8init.o",
utf8manifest = libDir .. "/utf8manifest.o",
}
local release, _, _ = generateConfig(
function(arch, profile)
return nameGeneratorClang(lang, arch, profile, false)
@ -399,7 +387,7 @@ function main()
},
customLinkParams = {
"-target", msvcTriplet,
extraObjects.utf8init, extraObjects.utf8manifest,
"-Wl,utf8init.o", "-Wl,utf8manifest.o",
},
isClang = true,
})
@ -412,9 +400,12 @@ function main()
if appArch == "x86_64" then
checkAndAddMingw("x86_64")
checkAndAddMingw("i386")
checkAndAddClang()
elseif appArch == "arm64" then
checkAndAddClang()
checkAndAddMingw("x86_64")
checkAndAddMingw("i386")
else
checkAndAddMingw("i386")
checkAndAddClang()

View File

@ -16,7 +16,7 @@ LangString MessageSectionAssocs 1033 "Use Red Panda C++ as the default applicati
LangString MessageSectionShortcuts 1033 "Create shortcuts to Red Panda C++ in various folders."
LangString MessageSectionConfig 1033 "Remove all leftover configuration files from previous installs."
LangString MessageUninstallText 1033 "This program will uninstall Red Panda C++, continue?"
LangString MessageUninstallExisting 1033 "Red Panda C++ is already installed.$\n$\nClick OK to remove the previous version or Cancel to cancel the installation."
LangString MessageUninstallingExisting 1033 "Removing previous installation."
LangString MessageRemoveConfig 1033 "Do you want to remove all the remaining configuration files?"
LangString SectionMainName 1033 "Program files (required)"
LangString SectionOpenConsoleName 1033 "OpenConsole.exe terminal emulator"
@ -49,7 +49,7 @@ LangString MessageSectionAssocs 2052 "使用小熊猫 C++ 打开这些文件。"
LangString MessageSectionShortcuts 2052 "开始菜单和快捷方式。"
LangString MessageSectionConfig 2052 "删除之前安装遗留的所有配置文件。"
LangString MessageUninstallText 2052 "将要删除小熊猫 C++,是否继续?"
LangString MessageUninstallExisting 2052 "本机上已经安装了旧版本小熊猫 C++。 $\n$\n点击“确定”以将其删除并继续或者“取消”中止安装。"
LangString MessageUninstallingExisting 2052 "正在删除之前的安装。"
LangString MessageRemoveConfig 2052 "你想要删除所有的配置文件吗?"
LangString SectionMainName 2052 "程序文件(必需)"
LangString SectionOpenConsoleName 2052 "OpenConsole.exe 终端模拟器"

View File

@ -7,16 +7,24 @@ SetCompressorDictSize 128
SetDatablockOptimize on
Unicode True
!ifdef USER_MODE
!define MODE "user"
!else
!define MODE "system"
!define FINALNAME "redpanda-cpp-${VERSION}-${ARCH}.exe"
!define DISPLAY_NAME "Red Panda C++ ${VERSION} (${ARCH})"
!define UNINSTKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++"
!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "${UNINSTKEY}"
!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME "CurrentUser"
!define MULTIUSER_INSTALLMODE_INSTDIR "RedPanda-CPP"
!define MULTIUSER_EXECUTIONLEVEL Highest
!define MULTIUSER_MUI
!define MULTIUSER_INSTALLMODE_COMMANDLINE
!if "${ARCH}" != "x86"
!define MULTIUSER_USE_PROGRAMFILES64
!endif
!define FINALNAME "redpanda-cpp-${VERSION}-${ARCH}-${MODE}.exe"
!define DISPLAY_NAME "Red Panda C++ ${VERSION} (${ARCH} ${MODE})"
!include "x64.nsh"
!include "WinVer.nsh"
!include "MultiUser.nsh"
!include "MUI2.nsh"
!include "lang.nsh"
@ -31,18 +39,6 @@ Caption "${DISPLAY_NAME}"
LicenseData "LICENSE"
!ifdef USER_MODE
RequestExecutionLevel user
InstallDir "$LOCALAPPDATA\RedPanda-CPP"
!else
RequestExecutionLevel admin
!if "${ARCH}" == "x86"
InstallDir "$PROGRAMFILES\RedPanda-CPP"
!else
InstallDir "$PROGRAMFILES64\RedPanda-CPP"
!endif
!endif
####################################################################
# Interface Settings
@ -56,15 +52,6 @@ ManifestDPIAware true
InstType "Full" ;1
InstType "Minimal" ;2
## Remember the installer language
!ifdef USER_MODE
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
!else
!define MUI_LANGDLL_REGISTRY_ROOT "HKLM"
!endif
!define MUI_LANGDLL_REGISTRY_KEY "Software\RedPanda-C++"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
####################################################################
# Pages
@ -77,6 +64,7 @@ InstType "Minimal" ;2
!define MUI_COMPONENTSPAGE_SMALLDESC
!insertmacro MUI_PAGE_LICENSE "LICENSE"
!insertmacro MULTIUSER_PAGE_INSTALLMODE
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
@ -90,6 +78,16 @@ InstType "Minimal" ;2
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "SimpChinese"
Section "" SecUninstallPrevious
SetRegView 32
Call UninstallExisting
SetRegView 64
Call UninstallExisting
!if "${ARCH}" == "x86"
SetRegView 32
!endif
SectionEnd
####################################################################
# Files, by option section
@ -100,21 +98,13 @@ Section "$(SectionMainName)" SectionMain
; Allways create an uninstaller
WriteUninstaller "$INSTDIR\uninstall.exe"
!ifdef USER_MODE
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayName" "Red Panda C++"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "InstallLocation" "$INSTDIR"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayVersion" "${VERSION}"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayIcon" "$INSTDIR\RedPandaIDE.exe"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "Publisher" "Roy Qu (royqh1979@gmail.com)"
!else
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayName" "Red Panda C++"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "InstallLocation" "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayVersion" "${VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayIcon" "$INSTDIR\RedPandaIDE.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "Publisher" "Roy Qu (royqh1979@gmail.com)"
!endif
WriteRegStr ShCtx "${UNINSTKEY}" "DisplayName" "Red Panda C++"
WriteRegStr ShCtx "${UNINSTKEY}" "InstallLocation" "$INSTDIR"
WriteRegStr ShCtx "${UNINSTKEY}" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr ShCtx "${UNINSTKEY}" "DisplayVersion" "${VERSION}"
WriteRegStr ShCtx "${UNINSTKEY}" "DisplayIcon" "$INSTDIR\RedPandaIDE.exe"
WriteRegStr ShCtx "${UNINSTKEY}" "Publisher" "Roy Qu (royqh1979@gmail.com)"
WriteRegStr ShCtx "${UNINSTKEY}" $MultiUser.InstallMode 1
; Write required files
File "RedPandaIDE.exe"
@ -167,80 +157,80 @@ SectionGroup "$(SectionAssocsName)" SectionAssocs
SectionIn 1
StrCpy $0 $INSTDIR\RedPandaIDE.exe
WriteRegStr HKCR ".dev" "" "DevCpp.dev"
WriteRegStr HKCR "DevCpp.dev" "" "Dev-C++ Project File"
WriteRegStr HKCR "DevCpp.dev\DefaultIcon" "" '$0,3'
WriteRegStr HKCR "DevCpp.dev\Shell\Open\Command" "" '$0 "%1"'
WriteRegStr ShCtx "Software\Classes\.dev" "" "DevCpp.dev"
WriteRegStr ShCtx "Software\Classes\DevCpp.dev" "" "Dev-C++ Project File"
WriteRegStr ShCtx "Software\Classes\DevCpp.dev\DefaultIcon" "" '$0,3'
WriteRegStr ShCtx "Software\Classes\DevCpp.dev\Shell\Open\Command" "" '$0 "%1"'
SectionEnd
Section "$(SectionAssocExtNameBegin) .c $(SectionAssocExtNameEnd)"
SectionIn 1
StrCpy $0 $INSTDIR\RedPandaIDE.exe
WriteRegStr HKCR ".c" "" "DevCpp.c"
WriteRegStr HKCR "DevCpp.c" "" "C Source File"
WriteRegStr HKCR "DevCpp.c\DefaultIcon" "" '$0,4'
WriteRegStr HKCR "DevCpp.c\Shell\Open\Command" "" '$0 "%1"'
WriteRegStr ShCtx "Software\Classes\.c" "" "DevCpp.c"
WriteRegStr ShCtx "Software\Classes\DevCpp.c" "" "C Source File"
WriteRegStr ShCtx "Software\Classes\DevCpp.c\DefaultIcon" "" '$0,4'
WriteRegStr ShCtx "Software\Classes\DevCpp.c\Shell\Open\Command" "" '$0 "%1"'
SectionEnd
Section "$(SectionAssocExtNameBegin) .cpp $(SectionAssocExtNameEnd)"
SectionIn 1
StrCpy $0 $INSTDIR\RedPandaIDE.exe
WriteRegStr HKCR ".cpp" "" "DevCpp.cpp"
WriteRegStr HKCR "DevCpp.cpp" "" "C++ Source File"
WriteRegStr HKCR "DevCpp.cpp\DefaultIcon" "" '$0,5'
WriteRegStr HKCR "DevCpp.cpp\Shell\Open\Command" "" '$0 "%1"'
WriteRegStr ShCtx "Software\Classes\.cpp" "" "DevCpp.cpp"
WriteRegStr ShCtx "Software\Classes\DevCpp.cpp" "" "C++ Source File"
WriteRegStr ShCtx "Software\Classes\DevCpp.cpp\DefaultIcon" "" '$0,5'
WriteRegStr ShCtx "Software\Classes\DevCpp.cpp\Shell\Open\Command" "" '$0 "%1"'
SectionEnd
Section "$(SectionAssocExtNameBegin) .cxx $(SectionAssocExtNameEnd)"
SectionIn 1
StrCpy $0 $INSTDIR\RedPandaIDE.exe
WriteRegStr HKCR ".cxx" "" "DevCpp.cxx"
WriteRegStr HKCR "DevCpp.cxx" "" "C++ Source File"
WriteRegStr HKCR "DevCpp.cxx\DefaultIcon" "" '$0,5'
WriteRegStr HKCR "DevCpp.cxx\Shell\Open\Command" "" '$0 "%1"'
WriteRegStr ShCtx "Software\Classes\.cxx" "" "DevCpp.cxx"
WriteRegStr ShCtx "Software\Classes\DevCpp.cxx" "" "C++ Source File"
WriteRegStr ShCtx "Software\Classes\DevCpp.cxx\DefaultIcon" "" '$0,5'
WriteRegStr ShCtx "Software\Classes\DevCpp.cxx\Shell\Open\Command" "" '$0 "%1"'
SectionEnd
Section "$(SectionAssocExtNameBegin) .cc $(SectionAssocExtNameEnd)"
SectionIn 1
StrCpy $0 $INSTDIR\RedPandaIDE.exe
WriteRegStr HKCR ".cc" "" "DevCpp.cc"
WriteRegStr HKCR "DevCpp.cc" "" "C++ Source File"
WriteRegStr HKCR "DevCpp.cc\DefaultIcon" "" '$0,5'
WriteRegStr HKCR "DevCpp.cc\Shell\Open\Command" "" '$0 "%1"'
WriteRegStr ShCtx "Software\Classes\.cc" "" "DevCpp.cc"
WriteRegStr ShCtx "Software\Classes\DevCpp.cc" "" "C++ Source File"
WriteRegStr ShCtx "Software\Classes\DevCpp.cc\DefaultIcon" "" '$0,5'
WriteRegStr ShCtx "Software\Classes\DevCpp.cc\Shell\Open\Command" "" '$0 "%1"'
SectionEnd
Section "$(SectionAssocExtNameBegin) .hxx $(SectionAssocExtNameEnd)"
SectionIn 1
StrCpy $0 $INSTDIR\RedPandaIDE.exe
WriteRegStr HKCR ".hxx" "" "DevCpp.hxx"
WriteRegStr HKCR "DevCpp.hxx" "" "C++ Header File"
WriteRegStr HKCR "DevCpp.hxx\DefaultIcon" "" '$0,7'
WriteRegStr HKCR "DevCpp.hxx\Shell\Open\Command" "" '$0 "%1"'
WriteRegStr ShCtx "Software\Classes\.hxx" "" "DevCpp.hxx"
WriteRegStr ShCtx "Software\Classes\DevCpp.hxx" "" "C++ Header File"
WriteRegStr ShCtx "Software\Classes\DevCpp.hxx\DefaultIcon" "" '$0,7'
WriteRegStr ShCtx "Software\Classes\DevCpp.hxx\Shell\Open\Command" "" '$0 "%1"'
SectionEnd
Section "$(SectionAssocExtNameBegin) .h $(SectionAssocExtNameEnd)"
SectionIn 1
StrCpy $0 $INSTDIR\RedPandaIDE.exe
WriteRegStr HKCR ".h" "" "DevCpp.h"
WriteRegStr HKCR "DevCpp.h" "" "C Header File"
WriteRegStr HKCR "DevCpp.h\DefaultIcon" "" '$0,6'
WriteRegStr HKCR "DevCpp.h\Shell\Open\Command" "" '$0 "%1"'
WriteRegStr ShCtx "Software\Classes\.h" "" "DevCpp.h"
WriteRegStr ShCtx "Software\Classes\DevCpp.h" "" "C Header File"
WriteRegStr ShCtx "Software\Classes\DevCpp.h\DefaultIcon" "" '$0,6'
WriteRegStr ShCtx "Software\Classes\DevCpp.h\Shell\Open\Command" "" '$0 "%1"'
SectionEnd
Section "$(SectionAssocExtNameBegin) .hpp $(SectionAssocExtNameEnd)"
SectionIn 1
StrCpy $0 $INSTDIR\RedPandaIDE.exe
WriteRegStr HKCR ".hpp" "" "DevCpp.hpp"
WriteRegStr HKCR "DevCpp.hpp" "" "C++ Header File"
WriteRegStr HKCR "DevCpp.hpp\DefaultIcon" "" '$0,7'
WriteRegStr HKCR "DevCpp.hpp\Shell\Open\Command" "" '$0 "%1"'
WriteRegStr ShCtx "Software\Classes\.hpp" "" "DevCpp.hpp"
WriteRegStr ShCtx "Software\Classes\DevCpp.hpp" "" "C++ Header File"
WriteRegStr ShCtx "Software\Classes\DevCpp.hpp\DefaultIcon" "" '$0,7'
WriteRegStr ShCtx "Software\Classes\DevCpp.hpp\Shell\Open\Command" "" '$0 "%1"'
SectionEnd
SectionGroupEnd
@ -264,11 +254,9 @@ SectionGroup "$(SectionShortcutsName)" SectionShortcuts
SectionEnd
SectionGroupEnd
!ifdef USER_MODE
Section "$(SectionConfigName)" SectionConfig
RMDir /r "$APPDATA\RedPandaIDE"
SectionEnd
!endif
####################################################################
@ -284,23 +272,17 @@ SectionEnd
!insertmacro MUI_DESCRIPTION_TEXT ${SectionLlvm} "$(MessageSectionLlvm)"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionShortcuts} "$(MessageSectionShortcuts)"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionAssocs} "$(MessageSectionAssocs)"
!ifdef USER_MODE
!insertmacro MUI_DESCRIPTION_TEXT ${SectionConfig} "$(MessageSectionConfig)"
!endif
!insertmacro MUI_FUNCTION_DESCRIPTION_END
####################################################################
# Functions, utilities
Function .onInit
!insertmacro MULTIUSER_INIT
!insertmacro MUI_LANGDLL_DISPLAY
!if "${ARCH}" != "x86"
SetRegView 64
!endif
!ifdef USER_MODE
SetShellVarContext current
!else
SetShellVarContext all
!endif
${IfNot} ${AtLeastBuild} 17763 ; OpenConsole.exe requires Windows 10 v1809 ConPTY
!if "${ARCH}" == "x86"
@ -343,14 +325,6 @@ Function myGuiInit
Abort
${EndIf}
!endif
SetRegView 32
Call UninstallExisting
SetRegView 64
Call UninstallExisting
!if "${ARCH}" == "x86"
SetRegView 32
!endif
FunctionEnd
Function .onSelChange
@ -363,32 +337,21 @@ Function .onSelChange
FunctionEnd
Function un.onInit
!insertmacro MULTIUSER_UNINIT
!insertmacro MUI_UNGETLANGUAGE
!if "${ARCH}" != "x86"
SetRegView 64
!endif
!ifdef USER_MODE
SetShellVarContext current
!else
SetShellVarContext all
!endif
FunctionEnd
Function UninstallExisting
!ifdef USER_MODE
ReadRegStr $R0 HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString"
!else
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString"
!endif
ReadRegStr $R0 ShCtx "${UNINSTKEY}" "UninstallString"
${If} $R0 != ""
GetFullPathName $R1 "$R0\.." ; remove \uninstall.exe
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"$(MessageUninstallExisting)" \
IDOK uninst
Abort
uninst:
ClearErrors
DetailPrint "$(MessageUninstallingExisting)"
ExecWait '"$R0" /S _?=$R1'
Delete $R0
RMDir $R1
${EndIf}
FunctionEnd
@ -412,14 +375,14 @@ Section "Uninstall"
Delete "$QUICKLAUNCH\$(MessageAppName).lnk"
Delete "$DESKTOP\$(MessageAppName).lnk"
DeleteRegKey HKCR "DevCpp.dev"
DeleteRegKey HKCR "DevCpp.c"
DeleteRegKey HKCR "DevCpp.cpp"
DeleteRegKey HKCR "DevCpp.cxx"
DeleteRegKey HKCR "DevCpp.cc"
DeleteRegKey HKCR "DevCpp.h"
DeleteRegKey HKCR "DevCpp.hpp"
DeleteRegKey HKCR "DevCpp.hxx"
DeleteRegKey ShCtx "Software\Classes\DevCpp.dev"
DeleteRegKey ShCtx "Software\Classes\DevCpp.c"
DeleteRegKey ShCtx "Software\Classes\DevCpp.cpp"
DeleteRegKey ShCtx "Software\Classes\DevCpp.cxx"
DeleteRegKey ShCtx "Software\Classes\DevCpp.cc"
DeleteRegKey ShCtx "Software\Classes\DevCpp.h"
DeleteRegKey ShCtx "Software\Classes\DevCpp.hpp"
DeleteRegKey ShCtx "Software\Classes\DevCpp.hxx"
Delete "$INSTDIR\NEWS.md"
Delete "$INSTDIR\RedPandaIDE.exe"
@ -440,17 +403,9 @@ Section "Uninstall"
RMDir "$INSTDIR"
; Remove registry keys
!ifdef USER_MODE
DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++"
DeleteRegKey HKCU "Software\RedPanda-C++"
!else
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++"
DeleteRegKey HKLM "Software\RedPanda-C++"
!endif
DeleteRegKey ShCtx "${UNINSTKEY}"
!ifdef USER_MODE
MessageBox MB_YESNO "$(MessageRemoveConfig)" /SD IDNO IDNO SkipRemoveConfig
RMDir /r "$APPDATA\RedPandaIDE"
SkipRemoveConfig:
!endif
SectionEnd