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

This commit is contained in:
Roy Qu 2024-03-28 22:55:43 +08:00
commit 8f4fc16c33
57 changed files with 343 additions and 2507 deletions

View File

@ -103,6 +103,7 @@ Red Panda C++ Version 2.27
- change: Don't turn on the code format option "indent class" by default.
- enhancement: Add compiler set by choose the executable.
- fix: Compile info for project doesn't have name of the project executable.
- enhancement: Highlight words in the string/comments.
Red Panda C++ Version 2.26
- enhancement: Code suggestion for embedded std::vectors.

View File

@ -611,11 +611,11 @@ iconsets_files.files += $$files(resources/iconsets/*.json, true)
ENABLE_LUA_ADDON {
theme_files.files += $$files(themes/*.lua, false)
} else {
theme_files.files += $$files(themes/*.json, false)
theme_files.files += $$files(resources/themes/*.json, false)
}
theme_files.files += $$files(themes/*.png, false)
theme_files.files += $$files(resources/themes/*.png, false)
colorscheme_files.files += $$files(colorschemes/*.scheme, false)
colorscheme_files.files += $$files(resources/colorschemes/*.scheme, false)
RESOURCES += qmake_qm_files
RESOURCES += iconsets_files

View File

@ -1340,8 +1340,10 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
}
}
if (((attr->tokenType() == QSynedit::TokenType::Identifier)
|| (attr->tokenType() == QSynedit::TokenType::Keyword)
|| (attr->tokenType() == QSynedit::TokenType::Preprocessor)
|| (attr->tokenType() == QSynedit::TokenType::Keyword)
|| (attr->tokenType() == QSynedit::TokenType::Preprocessor)
|| (attr->tokenType() == QSynedit::TokenType::String)
|| (attr->tokenType() == QSynedit::TokenType::Comment)
)
&& (token == mCurrentHighlightedWord)) {
// occurrencies of the selected identifier
@ -1881,9 +1883,12 @@ void Editor::onStatusChanged(QSynedit::StatusChanges changes)
if (getTokenAttriAtRowCol(caretXY(), token,attri)
&& (
(attri->tokenType()==QSynedit::TokenType::Identifier)
|| (attri->tokenType() == QSynedit::TokenType::Keyword)
|| (attri->tokenType() == QSynedit::TokenType::Preprocessor)
)) {
|| (attri->tokenType() == QSynedit::TokenType::Keyword)
|| (attri->tokenType() == QSynedit::TokenType::Preprocessor)
|| (attri->tokenType() == QSynedit::TokenType::String)
|| (attri->tokenType() == QSynedit::TokenType::Comment))
&& !token.isEmpty()
&& isIdentStartChar(token[0])) {
mCurrentHighlightedWord = token;
} else {
mCurrentHighlightedWord = "";

View File

@ -1481,6 +1481,8 @@ void Project::buildPrivateResource()
case ProjectType::DynamicLib:
contents.append("FILETYPE VFT_DLL");
break;
default:
break;
}
contents.append("{");
contents.append(" BLOCK \"StringFileInfo\"");

View File

Before

Width:  |  Height:  |  Size: 917 B

After

Width:  |  Height:  |  Size: 917 B

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -251,11 +251,11 @@ QString Settings::Dirs::data(Settings::Dirs::DataType dataType) const
case DataType::None:
return dataDir;
case DataType::ColorScheme:
return ":/colorschemes";
return ":/resources/colorschemes";
case DataType::IconSet:
return ":/resources/iconsets";
case DataType::Theme:
return ":/themes";
return ":/resources/themes";
case DataType::Template:
return includeTrailingPathDelimiter(appResourceDir()) + "templates";
}
@ -3186,7 +3186,6 @@ bool Settings::CompilerSets::addSets(const QString &folder, const QString& c_pro
if (set->binDirs().contains(folder) && extractFileName(set->CCompiler())==c_prog)
return false;
}
qDebug()<<folder<<c_prog;
// Default, release profile
PCompilerSet baseSet = addSet(folder,c_prog);
if (!baseSet || baseSet->name().isEmpty())

View File

@ -75,7 +75,9 @@ public:
enum class ThemeType {
JSON,
#ifdef ENABLE_LUA_ADDON
Lua,
#endif
};
AppTheme(const QString& filename, ThemeType type, QObject* parent=nullptr);

View File

@ -76,16 +76,10 @@ unix:!macos: {
win32: {
!isEmpty(PREFIX) {
target.path = $${PREFIX}
QMAKE_SUBSTITUTES += platform/windows/installer-scripts/config.nsh.in
QMAKE_SUBSTITUTES += platform/windows/installer-scripts/config32.nsh.in
QMAKE_SUBSTITUTES += platform/windows/installer-scripts/config-clang.nsh.in
resources.path = $${PREFIX}
resources.files += platform/windows/templates
resources.files += platform/windows/installer-scripts/config.nsh
resources.files += platform/windows/installer-scripts/config32.nsh
resources.files += platform/windows/installer-scripts/config-clang.nsh
resources.files += platform/windows/qt.conf
resources.files += README.md
resources.files += NEWS.md

View File

@ -495,12 +495,19 @@ void QSynEditPainter::paintEditAreas(const EditingAreaList &areaList)
rc.setBottom(rc.bottom()-1);
for (const PEditingArea& p:areaList) {
int penWidth;
if (mEdit->font().pixelSize()>=32)
penWidth = mEdit->font().pixelSize() / 16;
else if (mEdit->font().pixelSize()>=14)
penWidth = 2;
else
penWidth = 1;
if (p->type == EditingAreaType::eatWaveUnderLine) {
if (mEdit->font().pixelSize()>=16)
penWidth = mEdit->font().pixelSize() / 16;
else
penWidth = 1;
} else {
if (mEdit->font().pixelSize()>=32)
penWidth = mEdit->font().pixelSize() / 16;
else if (mEdit->font().pixelSize()>=14)
penWidth = 2;
else
penWidth = 1;
}
if (p->beginX > mRight)
continue;
if (p->endX < mLeft)
@ -517,7 +524,7 @@ void QSynEditPainter::paintEditAreas(const EditingAreaList &areaList)
rc.setRight(fixXValue(x2));
QPen pen;
pen.setColor(p->color);
pen.setWidth(penWidth);
pen.setWidthF(penWidth);
mPainter->setPen(pen);
mPainter->setBrush(Qt::NoBrush);
int lineHeight = rc.height();

View File

@ -2933,7 +2933,6 @@ void QSynEdit::synFontChanged()
{
incPaintLock();
recalcCharExtent();
onSizeOrFontChanged(true);
decPaintLock();
}
@ -3161,8 +3160,6 @@ void QSynEdit::recalcCharExtent()
}
}
mTextHeight = 0;
mCharWidth = 0;
QFontMetrics fm(font());
mTextHeight = fm.lineSpacing();
mCharWidth = fm.horizontalAdvance("M");
@ -3224,6 +3221,8 @@ void QSynEdit::recalcCharExtent()
mCharWidth = fm.horizontalAdvance("M");
}
mTextHeight *= mLineSpacingFactor;
onSizeOrFontChanged();
}
QString QSynEdit::expandAtWideGlyphs(const QString &S)
@ -3451,25 +3450,8 @@ void QSynEdit::rescanForFoldRanges()
void QSynEdit::scanForFoldRanges(PCodeFoldingRanges topFoldRanges)
{
PCodeFoldingRanges parentFoldRanges = topFoldRanges;
// qint64 begin=QDateTime::currentMSecsSinceEpoch();
findSubFoldRange(topFoldRanges, parentFoldRanges,PCodeFoldingRange());
// qint64 diff= QDateTime::currentMSecsSinceEpoch() - begin;
// qDebug()<<"?"<<diff;
}
//this func should only be used in findSubFoldRange
int QSynEdit::lineHasChar(int Line, int startChar, QChar character, const QString& tokenAttrName) {
QString CurLine = mDocument->getLine(Line);
QString token;
while (!mSyntaxer->eol()) {
token = mSyntaxer->getToken();
PTokenAttribute attr = mSyntaxer->getTokenAttribute();
if (token == character && attr->name()==tokenAttrName)
return mSyntaxer->getTokenPos();
mSyntaxer->next();
}
return -1;
}
void QSynEdit::findSubFoldRange(PCodeFoldingRanges topFoldRanges, PCodeFoldingRanges& parentFoldRanges, PCodeFoldingRange parent)
@ -3482,12 +3464,6 @@ void QSynEdit::findSubFoldRange(PCodeFoldingRanges topFoldRanges, PCodeFoldingRa
while (line < mDocument->count()) { // index is valid for LinesToScan and fLines
// If there is a collapsed fold over here, skip it
// collapsedFold = collapsedFoldStartAtLine(line + 1); // only collapsed folds remain
// if (collapsedFold) {
// line = collapsedFold->toLine;
// continue;
// }
// Find an opening character on this line
curLine = mDocument->getLine(line);
int blockEnded=mDocument->blockEnded(line);
@ -3522,8 +3498,6 @@ void QSynEdit::findSubFoldRange(PCodeFoldingRanges topFoldRanges, PCodeFoldingRa
}
line++;
}
}
PCodeFoldingRange QSynEdit::collapsedFoldStartAtLine(int Line)
@ -3740,26 +3714,15 @@ EditCommand QSynEdit::TranslateKeyCode(int key, Qt::KeyboardModifiers modifiers)
return cmd;
}
void QSynEdit::onSizeOrFontChanged(bool bFont)
void QSynEdit::onSizeOrFontChanged()
{
if (mCharWidth != 0) {
mLinesInWindow = clientHeight() / mTextHeight;
if (bFont) {
if (mGutter.showLineNumbers())
onGutterChanged();
else {
updateHScrollbar();
}
mStateFlags.setFlag(StateFlag::sfCaretChanged,false);
invalidate();
} else {
updateHScrollbar();
}
//if (!mOptions.testFlag(SynEditorOption::eoScrollPastEol))
setLeftPos(mLeftPos);
//if (!mOptions.testFlag(SynEditorOption::eoScrollPastEof))
setTopPos(mTopPos);
}
mLinesInWindow = clientHeight() / mTextHeight;
if (mGutter.showLineNumbers())
onGutterChanged();
updateHScrollbar();
updateVScrollbar();
mStateFlags.setFlag(StateFlag::sfCaretChanged,false);
invalidate();
}
void QSynEdit::onChanged()
@ -4686,7 +4649,7 @@ void QSynEdit::setSyntaxer(const PSyntaxer &syntaxer)
});
reparseDocument();
}
onSizeOrFontChanged(true);
//onSizeOrFontChanged(true);
invalidate();
}
@ -5963,15 +5926,8 @@ void QSynEdit::resizeEvent(QResizeEvent *)
mContentImage = std::make_shared<QImage>(clientWidth()*dpr,clientHeight()*dpr,
QImage::Format_ARGB32);
mContentImage->setDevicePixelRatio(dpr);
// QRect newRect = image->rect().intersected(mContentImage->rect());
// QPainter painter(image.get());
//painter.drawImage(newRect,*mContentImage);
// mContentImage = image;
onSizeOrFontChanged(false);
onSizeOrFontChanged();
}
void QSynEdit::timerEvent(QTimerEvent *event)

View File

@ -546,7 +546,6 @@ private:
void rescanFolds(); // rescan for folds
void rescanForFoldRanges();
void scanForFoldRanges(PCodeFoldingRanges topFoldRanges);
int lineHasChar(int Line, int startChar, QChar character, const QString& tokenAttrName);
void findSubFoldRange(PCodeFoldingRanges topFoldRanges,PCodeFoldingRanges& parentFoldRanges, PCodeFoldingRange Parent);
PCodeFoldingRange collapsedFoldStartAtLine(int Line);
void initializeCaret();
@ -663,7 +662,7 @@ private slots:
void onScrollTimeout();
void onDraggingScrollTimeout();
void onUndoAdded();
void onSizeOrFontChanged(bool bFont);
void onSizeOrFontChanged();
void onChanged();
void onScrolled(int value);

View File

@ -349,9 +349,19 @@ void CppSyntaxer::procCppStyleComment()
return;
}
mTokenId = TokenId::Comment;
bool isWord = isIdentChar(mLine[mRun]);
while (mRun<mLineSize) {
if (isSpaceChar(mLine[mRun]))
if (isSpaceChar(mLine[mRun])) {
break;
} else {
if (isWord) {
if (!isIdentChar(mLine[mRun]))
break;
} else {
if (isIdentChar(mLine[mRun]))
break;
}
}
mRun++;
}
if (mRun<mLineSize) {
@ -364,48 +374,51 @@ void CppSyntaxer::procCppStyleComment()
void CppSyntaxer::procDocstring()
{
bool finishProcess = false;
mTokenId = TokenId::Comment;
if (mRun>=mLineSize) {
procNull();
return;
}
bool isWord = isIdentChar(mLine[mRun]);
while (mRun<mLineSize) {
switch(mLine[mRun].unicode()) {
case ' ':
case '\t':
return;
case '*':
if(isSpaceChar(mLine[mRun]))
break;
else if (mLine[mRun] == '*') {
if (mRun+1<mLineSize && mLine[mRun+1] == '/') {
if (isWord)
break;
mRun += 2;
mRange.state = RangeState::rsUnknown;
finishProcess = true;
} else
mRun+=1;
break;
default:
mRun+=1;
break;
}
} else {
if (isWord) {
if (!isIdentChar(mLine[mRun]))
break;
} else {
if (isIdentChar(mLine[mRun]))
break;
}
}
if (finishProcess)
break;
mRun++;
}
}
void CppSyntaxer::procAnsiCStyleComment()
{
bool finishProcess = false;
mTokenId = TokenId::Comment;
if (mRun>=mLineSize) {
procNull();
return;
}
bool isWord = isIdentChar(mLine[mRun]);
while (mRun<mLineSize) {
switch(mLine[mRun].unicode()) {
case ' ':
case '\t':
return;
case '*':
if(isSpaceChar(mLine[mRun])) {
break;
} else if (mLine[mRun] == '*') {
if (mRun+1<mLineSize && mLine[mRun+1] == '/') {
if (isWord)
break;
mRun += 2;
if (mRange.state == RangeState::rsDirectiveComment &&
mRun<mLineSize && mLine[mRun]!='\r' && mLine[mRun]!='\n') {
@ -413,15 +426,18 @@ void CppSyntaxer::procAnsiCStyleComment()
} else {
mRange.state = RangeState::rsUnknown;
}
finishProcess = true;
} else
mRun+=1;
break;
default:
mRun+=1;
break;
}
} else {
if (isWord) {
if (!isIdentChar(mLine[mRun]))
break;
} else {
if (isIdentChar(mLine[mRun]))
break;
}
}
if (finishProcess)
break;
mRun++;
}
}
@ -1126,9 +1142,7 @@ void CppSyntaxer::procSlash()
if (mRun < mLineSize) {
if (mRange.state == RangeState::rsAnsiC && mLine[mRun] == '*' ) {
mRange.state = RangeState::rsDocstring;
procDocstring();
} else
procAnsiCStyleComment();
}
}
return;
case '=':
@ -1208,63 +1222,6 @@ void CppSyntaxer::procStar()
}
}
//void CppSyntaxer::stringEndProc()
//{
// mTokenId = TokenId::String;
// if (mRun>=mLineSize) {
// nullProc();
// return;
// }
// mRange.state = RangeState::rsUnknown;
// while (mRun<mLineSize) {
// if (mLine[mRun]=='"') {
// mRun += 1;
// break;
// } else if (isSpaceChar(mLine[mRun])) {
// mRange.state = RangeState::rsString;
// return;
// } else if (mLine[mRun]=='\\') {
// if (mRun == mLineSize-1) {
// mRun+=1;
// mRange.state = RangeState::rsMultiLineString;
// return;
// }
// if (mRun+1<mLineSize) {
// switch(mLine[mRun+1].unicode()) {
// case '\'':
// case '"':
// case '\\':
// case '?':
// case 'a':
// case 'b':
// case 'f':
// case 'n':
// case 'r':
// case 't':
// case 'v':
// case '0':
// case '1':
// case '2':
// case '3':
// case '4':
// case '5':
// case '6':
// case '7':
// case '8':
// case '9':
// case 'x':
// case 'u':
// case 'U':
// mRange.state = RangeState::rsMultiLineStringEscapeSeq;
// return;
// }
// }
// }
// mRun += 1;
// }
//}
void CppSyntaxer::procStringEscapeSeq()
{
mTokenId = TokenId::StringEscapeSeq;
@ -1341,8 +1298,11 @@ void CppSyntaxer::procString()
return;
}
mTokenId = TokenId::String;
bool isWord = isIdentChar(mLine[mRun]);
while (mRun < mLineSize) {
if (mLine[mRun]=='"') {
if (isWord)
break;
mRun++;
mRange.state = RangeState::rsUnknown;
return;
@ -1384,6 +1344,16 @@ void CppSyntaxer::procString()
return;
}
}
} else {
if (isWord) {
if (!isIdentChar(mLine[mRun])) {
break;
}
} else {
if (isIdentChar(mLine[mRun])) {
break;
}
}
}
mRun+=1;
}
@ -1395,7 +1365,7 @@ void CppSyntaxer::procStringStart()
{
mTokenId = TokenId::String;
mRange.state = RangeState::rsString;
mRun += 1;
mRun++; //skip \"
if (mRun>=mLineSize) {
mRange.state = RangeState::rsStringUnfinished;
return;
@ -1710,6 +1680,7 @@ void CppSyntaxer::next()
break;
case RangeState::rsString:
case RangeState::rsStringNextLine:
case RangeState::rsStringUnfinished:
//qDebug()<<"*1-0-0*";
procString();
break;

View File

@ -1,82 +0,0 @@
#!/bin/bash
BUILD_DIR="${TEMP}/redpandacpp-build"
PACKAGE_DIR="${TEMP}/RedPanda-CPP"
GCC_DIR="/mingw64"
PATH="${GCC_DIR}/bin:${PATH}"
QMAKE="${GCC_DIR}/qt5-static/bin/qmake"
NSIS="/d/Program Files (x86)/NSIS/bin/makensis.exe"
SOURCE_DIR=`pwd`
MINGW="/e/Workspaces/contributes/MinGW/Clang64"
MINGW_NAME="Clang64"
rm -rf "${BUILD_DIR}"
test -z "${BUILD_DIR}" | mkdir "${BUILD_DIR}"
rm -rf "${PACKAGE_DIR}"
mkdir "${PACKAGE_DIR}"
echo "Building..."
pushd .
cd "${BUILD_DIR}"
make distclean
"$QMAKE" PREFIX="${PACKAGE_DIR}" -o Makefile "${SOURCE_DIR}\Red_Panda_Cpp.pro" -r -spec win32-g++
make -j16
make install
popd
#echo "Making no-compiler installer ..."
#pushd .
#cd "${PACKAGE_DIR}"
#cp "${SOURCE_DIR}/windows/installer-scripts/lang.nsh" .
#cp "${SOURCE_DIR}/windows/installer-scripts/redpanda-nocompiler.nsi" .
#"${NSIS}" redpanda-nocompiler.nsi
#rm -f lang.nsh
#rm -f config.nsh
#rm -f config32.nsh
#rm -f redpanda-nocompiler.nsi
#SETUP_NAME=`ls *.Setup.exe`
#PORTABLE_NAME=`echo $SETUP_NAME | sed 's/Setup.exe/Portable.7z/'`
#mv "$SETUP_NAME" "${SOURCE_DIR}"
#popd
#echo "Making no-compiler Portable Package..."
#7z a -mmt8 -mx9 "${PORTABLE_NAME}" "${PACKAGE_DIR}"
# we need reinstall config.nsh
#pushd .
#cd "${BUILD_DIR}"
#make install
#popd
echo "Making installer..."
pushd .
cd "${PACKAGE_DIR}"
ln -s "${MINGW}" $MinGW_NAME
cp "${SOURCE_DIR}/platform/windows/qt.conf" .
cp "${SOURCE_DIR}/windows/installer-scripts/lang.nsh" .
cp "${SOURCE_DIR}/windows/installer-scripts/redpanda-clang.nsi" .
"${NSIS}" redpanda-clang.nsi
rm -f lang.nsh
rm -f config.nsh
rm -f config32.nsh
rm -f redpanda-clang.nsi
SETUP_NAME=`ls *.Setup.exe`
PORTABLE_NAME=`echo $SETUP_NAME | sed 's/Setup.exe/Portable.7z/'`
mv "$SETUP_NAME" "${SOURCE_DIR}"
popd
echo "Making Portable Package..."
7z a -mmt8 -mx9 "${PORTABLE_NAME}" "${PACKAGE_DIR}"
echo "Clean up..."
rm -rf "${PACKAGE_DIR}"

View File

@ -1,138 +0,0 @@
#!/bin/bash
set -euxo pipefail
# Usage:
# packages/msys/build-i686.sh [-c|--clean] [-nd|--no-deps] [-t|--target-dir <dir>]
if [[ ! -v MSYSTEM || ${MSYSTEM} != "MINGW32" ]]; then
echo "This script must be run in a MinGW32 shell"
exit 1
fi
CLEAN=0
CHECK_DEPS=1
TARGET_DIR="$(pwd)/dist"
while [[ $# -gt 0 ]]; do
case $1 in
-c|--clean)
CLEAN=1
shift
;;
-nd|--no-deps)
CHECK_DEPS=0
shift
;;
-t|--target-dir)
TARGET_DIR="$2"
shift 2
;;
*)
echo "Unknown argument: $1"
exit 1
;;
esac
done
BUILD_DIR="${TEMP}/redpanda-mingw-${MSYSTEM}-build"
PACKAGE_DIR="${TEMP}/redpanda-mingw-${MSYSTEM}-pkg"
QMAKE="${MINGW_PREFIX}/qt5-static/bin/qmake"
NSIS="/mingw32/bin/makensis"
SOURCE_DIR="$(pwd)"
MINGW_ARCHIVE="mingw32.7z"
function fn_print_progress() {
echo -e "\e[1;32;44m$1\e[0m"
}
## check deps
if [[ ${CHECK_DEPS} -eq 1 ]]; then
deps=(
${MINGW_PACKAGE_PREFIX}-{gcc,make,qt5-static,7zip}
mingw-w64-i686-nsis
git
)
for dep in ${deps[@]}; do
pacman -Q ${dep} &>/dev/null || {
echo "Missing dependency: ${dep}"
exit 1
}
done
fi
if [[ ! -f "${SOURCE_DIR}/assets/${MINGW_ARCHIVE}" ]]; then
echo "Missing ${MINGW_ARCHIVE}"
exit 1
fi
## prepare dirs
if [[ ${CLEAN} -eq 1 ]]; then
rm -rf "${BUILD_DIR}"
rm -rf "${PACKAGE_DIR}"
fi
mkdir -p "${BUILD_DIR}" "${PACKAGE_DIR}" "${TARGET_DIR}"
## build
fn_print_progress "Building..."
pushd .
cd "${BUILD_DIR}"
"$QMAKE" PREFIX="${PACKAGE_DIR}" -o Makefile "${SOURCE_DIR}\Red_Panda_Cpp.pro" -r -spec win32-g++
mingw32-make -j$(nproc)
mingw32-make install
popd
## prepare packaging resources
echo "Making no-compiler installer ..."
pushd .
cd "${PACKAGE_DIR}"
cp "${SOURCE_DIR}/platform/windows/qt.conf" .
cp "${SOURCE_DIR}/platform/windows/installer-scripts/lang.nsh" .
cp "${SOURCE_DIR}/platform/windows/installer-scripts/redpanda-i686-nocompiler.nsi" .
cp "${SOURCE_DIR}/platform/windows/installer-scripts/redpanda-i686.nsi" .
popd
## make no-compiler package
pushd .
cd "${PACKAGE_DIR}"
fn_print_progress "Making no-compiler installer ..."
"${NSIS}" redpanda-i686-nocompiler.nsi
SETUP_NAME="$(ls *.Setup.exe)"
PORTABLE_NAME="$(echo $SETUP_NAME | sed 's/Setup.exe/Portable.7z/')"
fn_print_progress "Making no-compiler Portable Package..."
7z x "${SETUP_NAME}" -o"RedPanda-CPP" -xr'!$PLUGINSDIR' -x"!uninstall.exe"
7z a -mmt -mx9 -ms=on -mqs=on -mf=BCJ2 "${PORTABLE_NAME}" "RedPanda-CPP"
rm -rf "RedPanda-CPP"
mv "${SETUP_NAME}" "${TARGET_DIR}"
mv "${PORTABLE_NAME}" "${TARGET_DIR}"
popd
## make mingw package
pushd .
cd "${PACKAGE_DIR}"
fn_print_progress "Making installer..."
[[ ! -d mingw32 ]] && 7z x "${SOURCE_DIR}/assets/${MINGW_ARCHIVE}" -o"${PACKAGE_DIR}"
"${NSIS}" redpanda-i686.nsi
SETUP_NAME="$(ls *.Setup.exe)"
PORTABLE_NAME="$(echo $SETUP_NAME | sed 's/Setup.exe/Portable.7z/')"
fn_print_progress "Making Portable Package..."
7z x "${SETUP_NAME}" -o"RedPanda-CPP" -xr'!$PLUGINSDIR' -x"!uninstall.exe"
7z a -mmt -mx9 -ms=on -mqs=on -mf=BCJ2 "${PORTABLE_NAME}" "RedPanda-CPP"
rm -rf "RedPanda-CPP"
mv "${SETUP_NAME}" "${TARGET_DIR}"
mv "${PORTABLE_NAME}" "${TARGET_DIR}"
popd

View File

@ -0,0 +1,203 @@
#!/bin/bash
set -euxo pipefail
# Usage:
# packages/msys/build-mingw.sh [-m|--msystem <MSYSTEM>] [-c|--clean] [-nd|--no-deps] [-t|--target-dir <dir>]
# Options:
# -m, --msystem <MSYSTEM> switch to other MSYS2 environment
# (MINGW32, MINGW64, UCRT64, CLANG32, CLANG64)
# MUST be used before other options
# -c, --clean clean build and package directories
# -nd, --no-deps skip dependency check
# -t, --target-dir <dir> set target directory for the packages
source version.inc
[[ -n "${APP_VERSION_SUFFIX}" ]] && APP_VERSION="${APP_VERSION}${APP_VERSION_SUFFIX}"
if [[ ! -v MSYSTEM ]]; then
echo "This script must be run in MSYS2 shell"
exit 1
fi
if [[ $# -gt 1 && ($1 == "-m" || $1 == "--msystem") ]]; then
msystem=$2
shift 2
case "${msystem}" in
MINGW32|MINGW64|UCRT64|CLANG32|CLANG64)
export MSYSTEM="${msystem}"
exec /bin/bash --login "$0" "$@"
;;
*)
echo "Invalid MSYSTEM: ${msystem}"
exit 1
;;
esac
fi
case "${MSYSTEM}" in
MINGW32|CLANG32) # there is no UCRT32
NSIS_ARCH=x86
BITNESS=32
COMPILER_NAME="MinGW-w64 i686 GCC 8.1"
ARCHIVE_MINGW_COMPILER_BASENAME="RedPanda.C++.${APP_VERSION}.win32.${COMPILER_NAME}"
ARCHIVE_NO_COMPILER_BASENAME="RedPanda.C++.${APP_VERSION}.win32.No.Compiler"
;;
MINGW64|UCRT64|CLANG64)
NSIS_ARCH=x64
BITNESS=64
COMPILER_NAME="MinGW-w64 X86_64 GCC 11.4"
ARCHIVE_MINGW_COMPILER_BASENAME="RedPanda.C++.${APP_VERSION}.win64.${COMPILER_NAME}"
ARCHIVE_NO_COMPILER_BASENAME="RedPanda.C++.${APP_VERSION}.win64.No.Compiler"
;;
*)
echo "This script must be run in one of the following MSYS2 shells:"
echo " - MINGW32 / CLANG32"
echo " - MINGW64 / UCRT64 / CLANG64"
exit 1
;;
esac
CLEAN=0
CHECK_DEPS=1
TARGET_DIR="$(pwd)/dist"
while [[ $# -gt 0 ]]; do
case $1 in
-c|--clean)
CLEAN=1
shift
;;
-nd|--no-deps)
CHECK_DEPS=0
shift
;;
-t|--target-dir)
TARGET_DIR="$2"
shift 2
;;
*)
echo "Unknown argument: $1"
exit 1
;;
esac
done
BUILD_DIR="${TEMP}/redpanda-mingw-${MSYSTEM}-build"
PACKAGE_DIR="${TEMP}/redpanda-mingw-${MSYSTEM}-pkg"
QMAKE="${MINGW_PREFIX}/qt5-static/bin/qmake"
NSIS="/mingw32/bin/makensis"
SOURCE_DIR="$(pwd)"
MINGW_ARCHIVE="mingw${BITNESS}.7z"
function fn_print_progress() {
echo -e "\e[1;32;44m$1\e[0m"
}
## check deps
if [[ ${CHECK_DEPS} -eq 1 ]]; then
case "${MSYSTEM}" in
MINGW32|MINGW64|UCRT64)
compiler=gcc
;;
CLANG32|CLANG64)
compiler=clang
;;
esac
deps=(
${MINGW_PACKAGE_PREFIX}-{$compiler,make,qt5-static,7zip}
mingw-w64-i686-nsis
git
)
for dep in ${deps[@]}; do
pacman -Q ${dep} &>/dev/null || {
echo "Missing dependency: ${dep}"
exit 1
}
done
fi
if [[ ! -f "${SOURCE_DIR}/assets/${MINGW_ARCHIVE}" ]]; then
echo "Missing MinGW archive: assets/${MINGW_ARCHIVE}"
exit 1
fi
## prepare dirs
if [[ ${CLEAN} -eq 1 ]]; then
rm -rf "${BUILD_DIR}"
rm -rf "${PACKAGE_DIR}"
fi
mkdir -p "${BUILD_DIR}" "${PACKAGE_DIR}" "${TARGET_DIR}"
## build
fn_print_progress "Building..."
pushd .
cd "${BUILD_DIR}"
qmake_flags=()
[[ NSIS_ARCH == x64 ]] && qmake_flags+=("X86_64=ON")
"$QMAKE" PREFIX="${PACKAGE_DIR}" ${qmake_flags[@]} -o Makefile "${SOURCE_DIR}/Red_Panda_Cpp.pro" -r
mingw32-make -j$(nproc)
mingw32-make install
popd
## prepare packaging resources
pushd .
cd "${PACKAGE_DIR}"
cp "${SOURCE_DIR}/platform/windows/qt.conf" .
cp "${SOURCE_DIR}/platform/windows/installer-scripts/lang.nsh" .
cp "${SOURCE_DIR}/platform/windows/installer-scripts/redpanda.nsi" .
popd
## make no-compiler package
pushd .
cd "${PACKAGE_DIR}"
SETUP_NAME="${ARCHIVE_NO_COMPILER_BASENAME}.Setup.exe"
PORTABLE_NAME="${ARCHIVE_NO_COMPILER_BASENAME}.Portable.7z"
fn_print_progress "Making no-compiler installer ..."
"${NSIS}" \
-DAPP_VERSION="${APP_VERSION}" \
-DARCH="${NSIS_ARCH}" \
-DFINALNAME="${SETUP_NAME}" \
redpanda.nsi
fn_print_progress "Making no-compiler Portable Package..."
7z x "${SETUP_NAME}" -o"RedPanda-CPP" -xr'!$PLUGINSDIR' -x"!uninstall.exe"
7z a -mmt -mx9 -ms=on -mqs=on -mf=BCJ2 "${PORTABLE_NAME}" "RedPanda-CPP"
rm -rf "RedPanda-CPP"
mv "${SETUP_NAME}" "${TARGET_DIR}"
mv "${PORTABLE_NAME}" "${TARGET_DIR}"
popd
## make mingw package
pushd .
cd "${PACKAGE_DIR}"
SETUP_NAME="${ARCHIVE_MINGW_COMPILER_BASENAME}.Setup.exe"
PORTABLE_NAME="${ARCHIVE_MINGW_COMPILER_BASENAME}.Portable.7z"
fn_print_progress "Making installer..."
[[ ! -d "mingw${BITNESS}" ]] && 7z x "${SOURCE_DIR}/assets/${MINGW_ARCHIVE}" -o"${PACKAGE_DIR}"
"${NSIS}" \
-DAPP_VERSION="${APP_VERSION}" \
-DARCH="${NSIS_ARCH}" \
-DFINALNAME="${SETUP_NAME}" \
-DHAVE_MINGW -DCOMPILERNAME="${COMPILER_NAME}" -DCOMPILERFOLDER="mingw${BITNESS}" \
redpanda.nsi
fn_print_progress "Making Portable Package..."
7z x "${SETUP_NAME}" -o"RedPanda-CPP" -xr'!$PLUGINSDIR' -x"!uninstall.exe"
7z a -mmt -mx9 -ms=on -mqs=on -mf=BCJ2 "${PORTABLE_NAME}" "RedPanda-CPP"
rm -rf "RedPanda-CPP"
mv "${SETUP_NAME}" "${TARGET_DIR}"
mv "${PORTABLE_NAME}" "${TARGET_DIR}"
popd

View File

@ -1,137 +0,0 @@
#!/bin/bash
set -euxo pipefail
# Usage:
# packages/msys/build-x64.sh [-c|--clean] [-nd|--no-deps] [-t|--target-dir <dir>]
if [[ ! -v MSYSTEM || ( ${MSYSTEM} != "MINGW64" && ${MSYSTEM} != "UCRT64" ) ]]; then
echo "This script must be run in a MinGW64 or UCRT64 shell"
exit 1
fi
CLEAN=0
CHECK_DEPS=1
TARGET_DIR="$(pwd)/dist"
while [[ $# -gt 0 ]]; do
case $1 in
-c|--clean)
CLEAN=1
shift
;;
-nd|--no-deps)
CHECK_DEPS=0
shift
;;
-t|--target-dir)
TARGET_DIR="$2"
shift 2
;;
*)
echo "Unknown argument: $1"
exit 1
;;
esac
done
BUILD_DIR="${TEMP}/redpanda-mingw-${MSYSTEM}-build"
PACKAGE_DIR="${TEMP}/redpanda-mingw-${MSYSTEM}-pkg"
QMAKE="${MINGW_PREFIX}/qt5-static/bin/qmake"
NSIS="/mingw32/bin/makensis"
SOURCE_DIR="$(pwd)"
MINGW_ARCHIVE="mingw64.7z"
function fn_print_progress() {
echo -e "\e[1;32;44m$1\e[0m"
}
## check deps
if [[ ${CHECK_DEPS} -eq 1 ]]; then
deps=(
${MINGW_PACKAGE_PREFIX}-{gcc,make,qt5-static,7zip}
mingw-w64-i686-nsis
git
)
for dep in ${deps[@]}; do
pacman -Q ${dep} &>/dev/null || {
echo "Missing dependency: ${dep}"
exit 1
}
done
fi
if [[ ! -f "${SOURCE_DIR}/assets/${MINGW_ARCHIVE}" ]]; then
echo "Missing MinGW archive: assets/${MINGW_ARCHIVE}"
exit 1
fi
## prepare dirs
if [[ ${CLEAN} -eq 1 ]]; then
rm -rf "${BUILD_DIR}"
rm -rf "${PACKAGE_DIR}"
fi
mkdir -p "${BUILD_DIR}" "${PACKAGE_DIR}" "${TARGET_DIR}"
## build
fn_print_progress "Building..."
pushd .
cd "${BUILD_DIR}"
"$QMAKE" PREFIX="${PACKAGE_DIR}" X86_64=ON -o Makefile "${SOURCE_DIR}/Red_Panda_Cpp.pro" -r -spec win32-g++
mingw32-make -j$(nproc)
mingw32-make install
popd
## prepare packaging resources
pushd .
cd "${PACKAGE_DIR}"
cp "${SOURCE_DIR}/platform/windows/qt.conf" .
cp "${SOURCE_DIR}/platform/windows/installer-scripts/lang.nsh" .
cp "${SOURCE_DIR}/platform/windows/installer-scripts/redpanda-nocompiler.nsi" .
cp "${SOURCE_DIR}/platform/windows/installer-scripts/redpanda-x64.nsi" .
popd
## make no-compiler package
pushd .
cd "${PACKAGE_DIR}"
fn_print_progress "Making no-compiler installer ..."
"${NSIS}" redpanda-nocompiler.nsi
SETUP_NAME="$(ls *.Setup.exe)"
PORTABLE_NAME="$(echo $SETUP_NAME | sed 's/Setup.exe/Portable.7z/')"
fn_print_progress "Making no-compiler Portable Package..."
7z x "${SETUP_NAME}" -o"RedPanda-CPP" -xr'!$PLUGINSDIR' -x"!uninstall.exe"
7z a -mmt -mx9 -ms=on -mqs=on -mf=BCJ2 "${PORTABLE_NAME}" "RedPanda-CPP"
rm -rf "RedPanda-CPP"
mv "${SETUP_NAME}" "${TARGET_DIR}"
mv "${PORTABLE_NAME}" "${TARGET_DIR}"
popd
## make mingw package
pushd .
cd "${PACKAGE_DIR}"
fn_print_progress "Making installer..."
[[ ! -d mingw64 ]] && 7z x "${SOURCE_DIR}/assets/${MINGW_ARCHIVE}" -o"${PACKAGE_DIR}"
"${NSIS}" redpanda-x64.nsi
SETUP_NAME="$(ls *.Setup.exe)"
PORTABLE_NAME="$(echo $SETUP_NAME | sed 's/Setup.exe/Portable.7z/')"
fn_print_progress "Making Portable Package..."
7z x "${SETUP_NAME}" -o"RedPanda-CPP" -xr'!$PLUGINSDIR' -x"!uninstall.exe"
7z a -mmt -mx9 -ms=on -mqs=on -mf=BCJ2 "${PORTABLE_NAME}" "RedPanda-CPP"
rm -rf "RedPanda-CPP"
mv "${SETUP_NAME}" "${TARGET_DIR}"
mv "${PORTABLE_NAME}" "${TARGET_DIR}"
popd

View File

@ -1,6 +0,0 @@
####################################################################
# Startup
!define COMPILERNAME \"Clang 14.0.0\"
!define DEVCPP_VERSION \"$${APP_VERSION}\"

View File

@ -1,6 +0,0 @@
####################################################################
# Startup
!define COMPILERNAME \"MinGW-w64 X86_64 GCC 11.4\"
!define DEVCPP_VERSION \"$${APP_VERSION}\"

View File

@ -1,6 +0,0 @@
####################################################################
# Startup
!define COMPILERNAME \"MinGW-w64 i686 GCC 8.1\"
!define DEVCPP_VERSION \"$${APP_VERSION}\"

View File

@ -1,491 +0,0 @@
####################################################################
# Startup
SetFont "Segoe UI" 11
!include "config-clang.nsh"
!define COMPILERFOLDER "Clang64"
!define FINALNAME "RedPanda.C++.${DEVCPP_VERSION}.win64.${COMPILERNAME}.Setup.exe"
!define DISPLAY_NAME "Red Panda C++ ${DEVCPP_VERSION}"
!include "MUI2.nsh"
!include "lang.nsh"
!define MUI_CUSTOMFUNCTION_GUIINIT myGuiInit
####################################################################
# Installer Attributes
Name "${DISPLAY_NAME}"
OutFile "${FINALNAME}"
Caption "${DISPLAY_NAME}"
LicenseData "LICENSE"
InstallDir $PROGRAMFILES64\RedPanda-Cpp
####################################################################
# Interface Settings
ShowInstDetails show
AutoCloseWindow false
SilentInstall normal
CRCCheck on
SetCompressor /SOLID /FINAL lzma
SetCompressorDictSize 64
SetDatablockOptimize on
SetOverwrite try
XPStyle on
ManifestDPIAware true
InstType "Full";1
InstType "Minimal";2
InstType "Safe";3
## Remember the installer language
!define MUI_LANGDLL_REGISTRY_ROOT "HKLM"
!define MUI_LANGDLL_REGISTRY_KEY "Software\RedPanda-C++"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
####################################################################
# Pages
!define MUI_ICON "devcpp.ico"
!define MUI_UNICON "devcpp.ico"
!define MUI_ABORTWARNING
!define MUI_LANGDLL_ALLLANGUAGES
!define MUI_FINISHPAGE_RUN "$INSTDIR\RedPandaIDE.exe"
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!define MUI_COMPONENTSPAGE_SMALLDESC
!insertmacro MUI_PAGE_LICENSE "LICENSE"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
####################################################################
# Languages
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "SimpChinese"
####################################################################
# Files, by option section
Section "$(SectionMainName)" SectionMain
SectionIn 1 2 3 RO
SetOutPath $INSTDIR
SetRegView 64
; Allways create an uninstaller
WriteUninstaller "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayName" "Redpanda-C++"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayVersion" "${DEVCPP_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)"
; Write required files
File "RedPandaIDE.exe"
File "ConsolePauser.exe"
File "redpanda-win-git-askpass.exe"
File "astyle.exe"
File "LICENSE"
File "NEWS.md"
File "README.md"
File "qt.conf"
; Write required paths
SetOutPath $INSTDIR\Templates
File /nonfatal /r "Templates\*"
SectionEnd
Section "$(SectionMinGWName)" SectionMinGW
SectionIn 1 3
SetOutPath $INSTDIR\Clang64
File /nonfatal /r "${COMPILERFOLDER}\*"
SectionEnd
####################################################################
# File association
SubSection "$(SectionAssocsName)" SectionAssocs
Section "$(SectionAssocExtNameBegin) .dev $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".dev"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .c $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".c"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .cpp $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".cpp"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .cxx $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".cxx"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .cc $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".cc"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .hxx $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".hxx"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .h $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".h"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .hpp $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".hpp"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
SubSectionEnd
####################################################################
# Shortcuts
SubSection "$(SectionShortcutsName)" SectionShortcuts
Section "$(SectionMenuLaunchName)" SectionMenuLaunch
SectionIn 1 3
; always use all user start menu, normal users can delete these
SetShellVarContext all
StrCpy $0 $SMPROGRAMS ; start menu Programs folder
CreateDirectory "$0\$(MessageAppName)"
CreateShortCut "$0\$(MessageAppName)\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe"
CreateShortCut "$0\$(MessageAppName)\License.lnk" "$INSTDIR\LICENSE"
CreateShortCut "$0\$(MessageAppName)\Uninstall $(MessageAppName).lnk" "$INSTDIR\uninstall.exe"
SectionEnd
Section "$(SectionDesktopLaunchName)" SectionDesktopLaunch
SectionIn 1 3
; always use current user desktop, normal users can't delete all users' shortcuts
SetShellVarContext current
CreateShortCut "$DESKTOP\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe"
SectionEnd
SubSectionEnd
Section "$(SectionConfigName)" SectionConfig
SectionIn 3
RMDir /r "$APPDATA\RedPandaIDE"
SectionEnd
####################################################################
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SectionMain} "$(MessageSectionMain)"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionMinGW} "$(MessageSectionMinGW)"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionShortcuts} "$(MessageSectionShortcuts)"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionAssocs} "$(MessageSectionAssocs)"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionConfig} "$(MessageSectionConfig)"
!insertmacro MUI_FUNCTION_DESCRIPTION_END
####################################################################
# Functions, utilities
Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
IfFileExists "C:\Dev-Cpp\devcpp.exe" 0 +2
SectionSetFlags ${SectionConfig} ${SF_SELECTED} # Remove old Dev-Cpp config files
IfFileExists "$APPDATA\Dev-Cpp\devcpp.cfg" 0 +2 # deprecated config file
SectionSetFlags ${SectionConfig} ${SF_SELECTED}
FunctionEnd
Function myGuiInit
; uninstall existing
SetRegView 32
Call UninstallExisting
SetRegView 64
Call UninstallExisting
FunctionEnd
;backup file association
Function BackupAssoc
;$0 is an extension - for example ".dev"
;check if backup already exists
ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0"
;don't backup if backup exists in registry
StrCmp $1 "" 0 no_assoc
ReadRegStr $1 HKCR "$0" ""
;don't backup dev-cpp associations
StrCmp $1 "DevCpp$0" no_assoc
StrCmp $1 "" no_assoc
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0" "$1"
no_assoc:
FunctionEnd
Function un.onInit
!insertmacro MUI_UNGETLANGUAGE
FunctionEnd
;restore file association
Function un.RestoreAssoc
;$0 is an extension - for example ".dev"
DeleteRegKey HKCR "$0"
ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0"
StrCmp $1 "" no_backup
WriteRegStr HKCR "$0" "" "$1"
Call un.RefreshShellIcons
no_backup:
FunctionEnd
;http://nsis.sourceforge.net/archive/viewpage.php?pageid=202
;After changing file associations, you can call this macro to refresh the shell immediatly.
;It calls the shell32 function SHChangeNotify. This will force windows to reload your changes from the registry.
!define SHCNE_ASSOCCHANGED 0x08000000
!define SHCNF_IDLIST 0
Function RefreshShellIcons
; By jerome tremblay - april 2003
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v \
(${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
FunctionEnd
Function un.RefreshShellIcons
; By jerome tremblay - april 2003
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v \
(${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
FunctionEnd
Function un.DeleteDirIfEmpty
FindFirst $R0 $R1 "$0\*.*"
strcmp $R1 "." 0 NoDelete
FindNext $R0 $R1
strcmp $R1 ".." 0 NoDelete
ClearErrors
FindNext $R0 $R1
IfErrors 0 NoDelete
FindClose $R0
Sleep 1000
RMDir "$0"
NoDelete:
FindClose $R0
FunctionEnd
Function GetParent
Exch $R0
Push $R1
Push $R2
Push $R3
StrCpy $R1 0
StrLen $R2 $R0
loop:
IntOp $R1 $R1 + 1
IntCmp $R1 $R2 get 0 get
StrCpy $R3 $R0 1 -$R1
StrCmp $R3 "\" get
Goto loop
get:
StrCpy $R0 $R0 -$R1
Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
Function UninstallExisting
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString"
StrCmp $R0 "" done
Push $R0
Call GetParent
Pop $R1
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"$(MessageUninstallExisting)" \
IDOK uninst
Abort
;Run the uninstaller
uninst:
ClearErrors
HideWindow
ClearErrors
ExecWait '"$R0" _?=$R1'
BringToFront
done:
FunctionEnd
####################################################################
# uninstall
UninstallText "$(MessageUninstallText)"
ShowUninstDetails show
Section "Uninstall"
; Remove uninstaller
Delete "$INSTDIR\uninstall.exe"
; Remove start menu stuff, located in all users folder
SetShellVarContext all
Delete "$SMPROGRAMS\$(MessageAppName)\$(MessageAppName).lnk"
Delete "$SMPROGRAMS\$(MessageAppName)\License.lnk"
Delete "$SMPROGRAMS\$(MessageAppName)\Uninstall $(MessageAppName).lnk"
RMDir "$SMPROGRAMS\$(MessageAppName)"
; Remove desktop stuff, located in current user folder
SetShellVarContext current
Delete "$QUICKLAUNCH\$(MessageAppName).lnk"
Delete "$DESKTOP\$(MessageAppName).lnk"
; Restore file associations
StrCpy $0 ".dev"
Call un.RestoreAssoc
StrCpy $0 ".c"
Call un.RestoreAssoc
StrCpy $0 ".cpp"
Call un.RestoreAssoc
StrCpy $0 ".h"
Call un.RestoreAssoc
StrCpy $0 ".hpp"
Call un.RestoreAssoc
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"
Delete "$INSTDIR\NEWS.md"
Delete "$INSTDIR\RedPandaIDE.exe"
Delete "$INSTDIR\ConsolePauser.exe"
Delete "$INSTDIR\redpanda-win-git-askpass.exe"
Delete "$INSTDIR\astyle.exe"
Delete "$INSTDIR\LICENSE"
Delete "$INSTDIR\README.md"
Delete "$INSTDIR\qt.conf"
RMDir /r "$INSTDIR\Lang"
RMDir /r "$INSTDIR\Templates"
RMDir /r "$INSTDIR\MinGW32"
RMDir /r "$INSTDIR\MinGW64"
RMDir /r "$INSTDIR\Clang64"
StrCpy $0 "$INSTDIR"
Call un.DeleteDirIfEmpty
; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++"
DeleteRegKey HKCU "Software\RedPanda-C++"
IfSilent +2 ; Don't ask when running in silent mode
MessageBox MB_YESNO "$(MessageRemoveConfig)" IDNO Done
RMDir /r "$APPDATA\RedPandaIDE"
Done:
SectionEnd

View File

@ -1,482 +0,0 @@
####################################################################
# Startup
SetFont "Segoe UI" 11
Unicode True
!include "config32.nsh"
!define FINALNAME "RedPanda.C++.${DEVCPP_VERSION}.win32.No.Compiler.Setup.exe"
!define DISPLAY_NAME "Red Panda C++ 32bit ${DEVCPP_VERSION}"
!include "MUI2.nsh"
!include "lang.nsh"
!define MUI_CUSTOMFUNCTION_GUIINIT myGuiInit
####################################################################
# Installer Attributes
Name "${DISPLAY_NAME}"
OutFile "${FINALNAME}"
Caption "${DISPLAY_NAME}"
LicenseData "LICENSE"
InstallDir $PROGRAMFILES64\RedPanda-Cpp
####################################################################
# Interface Settings
ShowInstDetails show
AutoCloseWindow false
SilentInstall normal
CRCCheck on
SetCompressor /SOLID /FINAL lzma
SetCompressorDictSize 64
SetDatablockOptimize on
SetOverwrite try
XPStyle on
ManifestDPIAware true
InstType "Full";1
InstType "Minimal";2
InstType "Safe";3
## Remember the installer language
!define MUI_LANGDLL_REGISTRY_ROOT "ShCtx"
!define MUI_LANGDLL_REGISTRY_KEY "Software\RedPanda-C++"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
####################################################################
# Pages
!define MUI_ICON "devcpp.ico"
!define MUI_UNICON "devcpp.ico"
!define MUI_ABORTWARNING
!define MUI_LANGDLL_ALLLANGUAGES
!define MUI_FINISHPAGE_RUN "$INSTDIR\RedPandaIDE.exe"
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!define MUI_COMPONENTSPAGE_SMALLDESC
!insertmacro MUI_PAGE_LICENSE "LICENSE"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
####################################################################
# Languages
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "SimpChinese"
####################################################################
# Files, by option section
Section "$(SectionMainName)" SectionMain
SectionIn 1 2 3 RO
SetOutPath $INSTDIR
; Allways create an uninstaller
WriteUninstaller "$INSTDIR\uninstall.exe"
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayName" "Redpanda-C++"
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayVersion" "${DEVCPP_VERSION}"
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayIcon" "$INSTDIR\RedPandaIDE.exe"
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "Publisher" "Roy Qu(royqh1979@gmail.com)"
; Write required files
File "RedPandaIDE.exe"
File "ConsolePauser.exe"
File "redpanda-win-git-askpass.exe"
File "astyle.exe"
File "LICENSE"
File "NEWS.md"
File "README.md"
File "qt.conf"
; Write required paths
SetOutPath $INSTDIR\Templates
File /nonfatal /r "Templates\*"
SectionEnd
####################################################################
# File association
SubSection "$(SectionAssocsName)" SectionAssocs
Section "$(SectionAssocExtNameBegin) .dev $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".dev"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .c $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".c"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .cpp $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".cpp"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .cxx $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".cxx"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .cc $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".cc"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .hxx $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".hxx"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .h $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".h"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .hpp $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".hpp"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
SubSectionEnd
####################################################################
# Shortcuts
SubSection "$(SectionShortcutsName)" SectionShortcuts
Section "$(SectionMenuLaunchName)" SectionMenuLaunch
SectionIn 1 3
StrCpy $0 $SMPROGRAMS ; start menu Programs folder
CreateDirectory "$0\$(MessageAppName)"
CreateShortCut "$0\$(MessageAppName)\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe"
CreateShortCut "$0\$(MessageAppName)\License.lnk" "$INSTDIR\LICENSE"
CreateShortCut "$0\$(MessageAppName)\Uninstall $(MessageAppName).lnk" "$INSTDIR\uninstall.exe"
SectionEnd
Section "$(SectionDesktopLaunchName)" SectionDesktopLaunch
SectionIn 1 3
CreateShortCut "$DESKTOP\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe"
SectionEnd
SubSectionEnd
Section "$(SectionConfigName)" SectionConfig
SectionIn 3
RMDir /r "$APPDATA\RedPandaIDE"
SectionEnd
####################################################################
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SectionMain} "$(MessageSectionMain)"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionShortcuts} "$(MessageSectionShortcuts)"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionAssocs} "$(MessageSectionAssocs)"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionConfig} "$(MessageSectionConfig)"
!insertmacro MUI_FUNCTION_DESCRIPTION_END
####################################################################
# Functions, utilities
Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
IfFileExists "C:\Dev-Cpp\devcpp.exe" 0 +2
SectionSetFlags ${SectionConfig} ${SF_SELECTED} # Remove old Dev-Cpp config files
IfFileExists "$APPDATA\Dev-Cpp\devcpp.cfg" 0 +2 # deprecated config file
SectionSetFlags ${SectionConfig} ${SF_SELECTED}
SetShellVarContext all
SetRegView 32
FunctionEnd
Function myGuiInit
; uninstall existing
SetRegView 32
Call UninstallExisting
SetRegView 64
Call UninstallExisting
SetRegView 32
FunctionEnd
;backup file association
Function BackupAssoc
;$0 is an extension - for example ".dev"
;check if backup already exists
ReadRegStr $1 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0"
;don't backup if backup exists in registry
StrCmp $1 "" 0 no_assoc
ReadRegStr $1 HKCR "$0" ""
;don't backup dev-cpp associations
StrCmp $1 "DevCpp$0" no_assoc
StrCmp $1 "" no_assoc
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0" "$1"
no_assoc:
FunctionEnd
Function un.onInit
!insertmacro MUI_UNGETLANGUAGE
SetShellVarContext all
SetRegView 32
FunctionEnd
;restore file association
Function un.RestoreAssoc
;$0 is an extension - for example ".dev"
DeleteRegKey HKCR "$0"
ReadRegStr $1 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0"
StrCmp $1 "" no_backup
WriteRegStr HKCR "$0" "" "$1"
Call un.RefreshShellIcons
no_backup:
FunctionEnd
;http://nsis.sourceforge.net/archive/viewpage.php?pageid=202
;After changing file associations, you can call this macro to refresh the shell immediatly.
;It calls the shell32 function SHChangeNotify. This will force windows to reload your changes from the registry.
!define SHCNE_ASSOCCHANGED 0x08000000
!define SHCNF_IDLIST 0
Function RefreshShellIcons
; By jerome tremblay - april 2003
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v \
(${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
FunctionEnd
Function un.RefreshShellIcons
; By jerome tremblay - april 2003
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v \
(${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
FunctionEnd
Function un.DeleteDirIfEmpty
FindFirst $R0 $R1 "$0\*.*"
strcmp $R1 "." 0 NoDelete
FindNext $R0 $R1
strcmp $R1 ".." 0 NoDelete
ClearErrors
FindNext $R0 $R1
IfErrors 0 NoDelete
FindClose $R0
Sleep 1000
RMDir "$0"
NoDelete:
FindClose $R0
FunctionEnd
Function GetParent
Exch $R0
Push $R1
Push $R2
Push $R3
StrCpy $R1 0
StrLen $R2 $R0
loop:
IntOp $R1 $R1 + 1
IntCmp $R1 $R2 get 0 get
StrCpy $R3 $R0 1 -$R1
StrCmp $R3 "\" get
Goto loop
get:
StrCpy $R0 $R0 -$R1
Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
Function UninstallExisting
ReadRegStr $R0 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString"
StrCmp $R0 "" done
Push $R0
Call GetParent
Pop $R1
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"$(MessageUninstallExisting)" \
IDOK uninst
Abort
;Run the uninstaller
uninst:
ClearErrors
HideWindow
ClearErrors
ExecWait '"$R0" _?=$R1'
BringToFront
done:
FunctionEnd
####################################################################
# uninstall
UninstallText "$(MessageUninstallText)"
ShowUninstDetails show
Section "Uninstall"
; Remove uninstaller
Delete "$INSTDIR\uninstall.exe"
; Remove start menu stuff
Delete "$SMPROGRAMS\$(MessageAppName)\$(MessageAppName).lnk"
Delete "$SMPROGRAMS\$(MessageAppName)\License.lnk"
Delete "$SMPROGRAMS\$(MessageAppName)\Uninstall $(MessageAppName).lnk"
RMDir "$SMPROGRAMS\$(MessageAppName)"
; Remove desktop stuff
Delete "$QUICKLAUNCH\$(MessageAppName).lnk"
Delete "$DESKTOP\$(MessageAppName).lnk"
; Restore file associations
StrCpy $0 ".dev"
Call un.RestoreAssoc
StrCpy $0 ".c"
Call un.RestoreAssoc
StrCpy $0 ".cpp"
Call un.RestoreAssoc
StrCpy $0 ".h"
Call un.RestoreAssoc
StrCpy $0 ".hpp"
Call un.RestoreAssoc
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"
Delete "$INSTDIR\NEWS.md"
Delete "$INSTDIR\RedPandaIDE.exe"
Delete "$INSTDIR\ConsolePauser.exe"
Delete "$INSTDIR\redpanda-win-git-askpass.exe"
Delete "$INSTDIR\astyle.exe"
Delete "$INSTDIR\LICENSE"
Delete "$INSTDIR\README.md"
Delete "$INSTDIR\qt.conf"
RMDir /r "$INSTDIR\Lang"
RMDir /r "$INSTDIR\Templates"
RMDir /r "$INSTDIR\MinGW32"
RMDir /r "$INSTDIR\MinGW64"
RMDir /r "$INSTDIR\Clang64"
StrCpy $0 "$INSTDIR"
Call un.DeleteDirIfEmpty
; Remove registry keys
DeleteRegKey ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++"
DeleteRegKey ShCtx "Software\RedPanda-C++"
IfSilent +2 ; Don't ask when running in silent mode
MessageBox MB_YESNO "$(MessageRemoveConfig)" IDNO Done
RMDir /r "$APPDATA\RedPandaIDE"
Done:
SectionEnd

View File

@ -1,492 +0,0 @@
####################################################################
# Startup
SetFont "Segoe UI" 11
Unicode True
!include "config32.nsh"
!define COMPILERFOLDER "MinGW32"
!define FINALNAME "RedPanda.C++.${DEVCPP_VERSION}.win32.${COMPILERNAME}.Setup.exe"
!define DISPLAY_NAME "Red Panda C++ 32 bit ${DEVCPP_VERSION}"
!include "MUI2.nsh"
!include "lang.nsh"
!define MUI_CUSTOMFUNCTION_GUIINIT myGuiInit
####################################################################
# Installer Attributes
Name "${DISPLAY_NAME}"
OutFile "${FINALNAME}"
Caption "${DISPLAY_NAME}"
LicenseData "LICENSE"
InstallDir $PROGRAMFILES\RedPanda-Cpp
####################################################################
# Interface Settings
ShowInstDetails show
AutoCloseWindow false
SilentInstall normal
CRCCheck on
SetCompressor /SOLID /FINAL lzma
SetCompressorDictSize 64
SetDatablockOptimize on
SetOverwrite try
XPStyle on
ManifestDPIAware true
InstType "Full";1
InstType "Minimal";2
InstType "Safe";3
## Remember the installer language
!define MUI_LANGDLL_REGISTRY_ROOT "ShCtx"
!define MUI_LANGDLL_REGISTRY_KEY "Software\RedPanda-C++"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
####################################################################
# Pages
!define MUI_ICON "devcpp.ico"
!define MUI_UNICON "devcpp.ico"
!define MUI_ABORTWARNING
!define MUI_LANGDLL_ALLLANGUAGES
!define MUI_FINISHPAGE_RUN "$INSTDIR\RedPandaIDE.exe"
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!define MUI_COMPONENTSPAGE_SMALLDESC
!insertmacro MUI_PAGE_LICENSE "LICENSE"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
####################################################################
# Languages
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "SimpChinese"
####################################################################
# Files, by option section
Section "$(SectionMainName)" SectionMain
SectionIn 1 2 3 RO
SetOutPath $INSTDIR
; Allways create an uninstaller
WriteUninstaller "$INSTDIR\uninstall.exe"
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayName" "Redpanda-C++"
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayVersion" "${DEVCPP_VERSION}"
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayIcon" "$INSTDIR\RedPandaIDE.exe"
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "Publisher" "Roy Qu(royqh1979@gmail.com)"
; Write required files
File "RedPandaIDE.exe"
File "ConsolePauser.exe"
File "redpanda-win-git-askpass.exe"
File "astyle.exe"
File "LICENSE"
File "NEWS.md"
File "README.md"
File "qt.conf"
; Write required paths
SetOutPath $INSTDIR\Templates
File /nonfatal /r "Templates\*"
SectionEnd
Section "$(SectionMinGWName)" SectionMinGW
SectionIn 1 3
SetOutPath $INSTDIR\MinGW32
File /nonfatal /r "${COMPILERFOLDER}\*"
SectionEnd
####################################################################
# File association
SubSection "$(SectionAssocsName)" SectionAssocs
Section "$(SectionAssocExtNameBegin) .dev $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".dev"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .c $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".c"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .cpp $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".cpp"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .cxx $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".cxx"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .cc $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".cc"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .hxx $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".hxx"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .h $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".h"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .hpp $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".hpp"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
SubSectionEnd
####################################################################
# Shortcuts
SubSection "$(SectionShortcutsName)" SectionShortcuts
Section "$(SectionMenuLaunchName)" SectionMenuLaunch
SectionIn 1 3
StrCpy $0 $SMPROGRAMS ; start menu Programs folder
CreateDirectory "$0\$(MessageAppName)"
CreateShortCut "$0\$(MessageAppName)\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe"
CreateShortCut "$0\$(MessageAppName)\License.lnk" "$INSTDIR\LICENSE"
CreateShortCut "$0\$(MessageAppName)\Uninstall $(MessageAppName).lnk" "$INSTDIR\uninstall.exe"
SectionEnd
Section "$(SectionDesktopLaunchName)" SectionDesktopLaunch
SectionIn 1 3
CreateShortCut "$DESKTOP\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe"
SectionEnd
SubSectionEnd
Section "$(SectionConfigName)" SectionConfig
SectionIn 3
RMDir /r "$APPDATA\RedPandaIDE"
SectionEnd
####################################################################
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SectionMain} "$(MessageSectionMain)"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionMinGW} "$(MessageSectionMinGW)"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionShortcuts} "$(MessageSectionShortcuts)"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionAssocs} "$(MessageSectionAssocs)"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionConfig} "$(MessageSectionConfig)"
!insertmacro MUI_FUNCTION_DESCRIPTION_END
####################################################################
# Functions, utilities
Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
IfFileExists "C:\Dev-Cpp\devcpp.exe" 0 +2
SectionSetFlags ${SectionConfig} ${SF_SELECTED} # Remove old Dev-Cpp config files
IfFileExists "$APPDATA\Dev-Cpp\devcpp.cfg" 0 +2 # deprecated config file
SectionSetFlags ${SectionConfig} ${SF_SELECTED}
SetShellVarContext all
SetRegView 32
FunctionEnd
Function myGuiInit
; uninstall existing
SetRegView 32
Call UninstallExisting
SetRegView 64
Call UninstallExisting
SetRegView 32
FunctionEnd
;backup file association
Function BackupAssoc
;$0 is an extension - for example ".dev"
;check if backup already exists
ReadRegStr $1 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0"
;don't backup if backup exists in registry
StrCmp $1 "" 0 no_assoc
ReadRegStr $1 HKCR "$0" ""
;don't backup dev-cpp associations
StrCmp $1 "DevCpp$0" no_assoc
StrCmp $1 "" no_assoc
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0" "$1"
no_assoc:
FunctionEnd
Function un.onInit
!insertmacro MUI_UNGETLANGUAGE
SetShellVarContext all
SetRegView 32
FunctionEnd
;restore file association
Function un.RestoreAssoc
;$0 is an extension - for example ".dev"
DeleteRegKey HKCR "$0"
ReadRegStr $1 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0"
StrCmp $1 "" no_backup
WriteRegStr HKCR "$0" "" "$1"
Call un.RefreshShellIcons
no_backup:
FunctionEnd
;http://nsis.sourceforge.net/archive/viewpage.php?pageid=202
;After changing file associations, you can call this macro to refresh the shell immediatly.
;It calls the shell32 function SHChangeNotify. This will force windows to reload your changes from the registry.
!define SHCNE_ASSOCCHANGED 0x08000000
!define SHCNF_IDLIST 0
Function RefreshShellIcons
; By jerome tremblay - april 2003
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v \
(${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
FunctionEnd
Function un.RefreshShellIcons
; By jerome tremblay - april 2003
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v \
(${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
FunctionEnd
Function un.DeleteDirIfEmpty
FindFirst $R0 $R1 "$0\*.*"
strcmp $R1 "." 0 NoDelete
FindNext $R0 $R1
strcmp $R1 ".." 0 NoDelete
ClearErrors
FindNext $R0 $R1
IfErrors 0 NoDelete
FindClose $R0
Sleep 1000
RMDir "$0"
NoDelete:
FindClose $R0
FunctionEnd
Function GetParent
Exch $R0
Push $R1
Push $R2
Push $R3
StrCpy $R1 0
StrLen $R2 $R0
loop:
IntOp $R1 $R1 + 1
IntCmp $R1 $R2 get 0 get
StrCpy $R3 $R0 1 -$R1
StrCmp $R3 "\" get
Goto loop
get:
StrCpy $R0 $R0 -$R1
Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
Function UninstallExisting
ReadRegStr $R0 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString"
StrCmp $R0 "" done
Push $R0
Call GetParent
Pop $R1
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"$(MessageUninstallExisting)" \
IDOK uninst
Abort
;Run the uninstaller
uninst:
ClearErrors
HideWindow
ClearErrors
ExecWait '"$R0" _?=$R1'
BringToFront
done:
FunctionEnd
####################################################################
# uninstall
UninstallText "$(MessageUninstallText)"
ShowUninstDetails show
Section "Uninstall"
; Remove uninstaller
Delete "$INSTDIR\uninstall.exe"
; Remove start menu stuff
Delete "$SMPROGRAMS\$(MessageAppName)\$(MessageAppName).lnk"
Delete "$SMPROGRAMS\$(MessageAppName)\License.lnk"
Delete "$SMPROGRAMS\$(MessageAppName)\Uninstall $(MessageAppName).lnk"
RMDir "$SMPROGRAMS\$(MessageAppName)"
; Remove desktop stuff
Delete "$QUICKLAUNCH\$(MessageAppName).lnk"
Delete "$DESKTOP\$(MessageAppName).lnk"
; Restore file associations
StrCpy $0 ".dev"
Call un.RestoreAssoc
StrCpy $0 ".c"
Call un.RestoreAssoc
StrCpy $0 ".cpp"
Call un.RestoreAssoc
StrCpy $0 ".h"
Call un.RestoreAssoc
StrCpy $0 ".hpp"
Call un.RestoreAssoc
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"
Delete "$INSTDIR\NEWS.md"
Delete "$INSTDIR\RedPandaIDE.exe"
Delete "$INSTDIR\ConsolePauser.exe"
Delete "$INSTDIR\redpanda-win-git-askpass.exe"
Delete "$INSTDIR\astyle.exe"
Delete "$INSTDIR\LICENSE"
Delete "$INSTDIR\README.md"
Delete "$INSTDIR\qt.conf"
RMDir /r "$INSTDIR\Lang"
RMDir /r "$INSTDIR\Templates"
RMDir /r "$INSTDIR\MinGW32"
RMDir /r "$INSTDIR\MinGW64"
RMDir /r "$INSTDIR\Clang64"
StrCpy $0 "$INSTDIR"
Call un.DeleteDirIfEmpty
; Remove registry keys
DeleteRegKey ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++"
DeleteRegKey ShCtx "Software\RedPanda-C++"
IfSilent +2 ; Don't ask when running in silent mode
MessageBox MB_YESNO "$(MessageRemoveConfig)" IDNO Done
RMDir /r "$APPDATA\RedPandaIDE"
Done:
SectionEnd

View File

@ -1,481 +0,0 @@
####################################################################
# Startup
SetFont "Segoe UI" 11
Unicode True
!include "config.nsh"
!define FINALNAME "RedPanda.C++.${DEVCPP_VERSION}.win64.No.Compiler.Setup.exe"
!define DISPLAY_NAME "Red Panda C++ ${DEVCPP_VERSION}"
!include "MUI2.nsh"
!include "lang.nsh"
!define MUI_CUSTOMFUNCTION_GUIINIT myGuiInit
####################################################################
# Installer Attributes
Name "${DISPLAY_NAME}"
OutFile "${FINALNAME}"
Caption "${DISPLAY_NAME}"
LicenseData "LICENSE"
InstallDir $PROGRAMFILES64\RedPanda-Cpp
####################################################################
# Interface Settings
ShowInstDetails show
AutoCloseWindow false
SilentInstall normal
CRCCheck on
SetCompressor /SOLID /FINAL lzma
SetCompressorDictSize 64
SetDatablockOptimize on
SetOverwrite try
XPStyle on
ManifestDPIAware true
InstType "Full";1
InstType "Minimal";2
InstType "Safe";3
## Remember the installer language
!define MUI_LANGDLL_REGISTRY_ROOT "ShCtx"
!define MUI_LANGDLL_REGISTRY_KEY "Software\RedPanda-C++"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
####################################################################
# Pages
!define MUI_ICON "devcpp.ico"
!define MUI_UNICON "devcpp.ico"
!define MUI_ABORTWARNING
!define MUI_LANGDLL_ALLLANGUAGES
!define MUI_FINISHPAGE_RUN "$INSTDIR\RedPandaIDE.exe"
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!define MUI_COMPONENTSPAGE_SMALLDESC
!insertmacro MUI_PAGE_LICENSE "LICENSE"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
####################################################################
# Languages
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "SimpChinese"
####################################################################
# Files, by option section
Section "$(SectionMainName)" SectionMain
SectionIn 1 2 3 RO
SetOutPath $INSTDIR
; Allways create an uninstaller
WriteUninstaller "$INSTDIR\uninstall.exe"
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayName" "Redpanda-C++"
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayVersion" "${DEVCPP_VERSION}"
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayIcon" "$INSTDIR\RedPandaIDE.exe"
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "Publisher" "Roy Qu(royqh1979@gmail.com)"
; Write required files
File "RedPandaIDE.exe"
File "ConsolePauser.exe"
File "redpanda-win-git-askpass.exe"
File "astyle.exe"
File "LICENSE"
File "NEWS.md"
File "README.md"
File "qt.conf"
; Write required paths
SetOutPath $INSTDIR\Templates
File /nonfatal /r "Templates\*"
SectionEnd
####################################################################
# File association
SubSection "$(SectionAssocsName)" SectionAssocs
Section "$(SectionAssocExtNameBegin) .dev $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".dev"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .c $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".c"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .cpp $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".cpp"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .cxx $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".cxx"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .cc $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".cc"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .hxx $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".hxx"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .h $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".h"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
Section "$(SectionAssocExtNameBegin) .hpp $(SectionAssocExtNameEnd)"
SectionIn 1 3
StrCpy $0 ".hpp"
Call BackupAssoc
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"'
Call RefreshShellIcons
SectionEnd
SubSectionEnd
####################################################################
# Shortcuts
SubSection "$(SectionShortcutsName)" SectionShortcuts
Section "$(SectionMenuLaunchName)" SectionMenuLaunch
SectionIn 1 3
StrCpy $0 $SMPROGRAMS ; start menu Programs folder
CreateDirectory "$0\$(MessageAppName)"
CreateShortCut "$0\$(MessageAppName)\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe"
CreateShortCut "$0\$(MessageAppName)\License.lnk" "$INSTDIR\LICENSE"
CreateShortCut "$0\$(MessageAppName)\Uninstall $(MessageAppName).lnk" "$INSTDIR\uninstall.exe"
SectionEnd
Section "$(SectionDesktopLaunchName)" SectionDesktopLaunch
SectionIn 1 3
CreateShortCut "$DESKTOP\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe"
SectionEnd
SubSectionEnd
Section "$(SectionConfigName)" SectionConfig
SectionIn 3
RMDir /r "$APPDATA\RedPandaIDE"
SectionEnd
####################################################################
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SectionMain} "$(MessageSectionMain)"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionShortcuts} "$(MessageSectionShortcuts)"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionAssocs} "$(MessageSectionAssocs)"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionConfig} "$(MessageSectionConfig)"
!insertmacro MUI_FUNCTION_DESCRIPTION_END
####################################################################
# Functions, utilities
Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
IfFileExists "C:\Dev-Cpp\devcpp.exe" 0 +2
SectionSetFlags ${SectionConfig} ${SF_SELECTED} # Remove old Dev-Cpp config files
IfFileExists "$APPDATA\Dev-Cpp\devcpp.cfg" 0 +2 # deprecated config file
SectionSetFlags ${SectionConfig} ${SF_SELECTED}
SetShellVarContext all
SetRegView 64
FunctionEnd
Function myGuiInit
; uninstall existing
SetRegView 32
Call UninstallExisting
SetRegView 64
Call UninstallExisting
FunctionEnd
;backup file association
Function BackupAssoc
;$0 is an extension - for example ".dev"
;check if backup already exists
ReadRegStr $1 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0"
;don't backup if backup exists in registry
StrCmp $1 "" 0 no_assoc
ReadRegStr $1 HKCR "$0" ""
;don't backup dev-cpp associations
StrCmp $1 "DevCpp$0" no_assoc
StrCmp $1 "" no_assoc
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0" "$1"
no_assoc:
FunctionEnd
Function un.onInit
!insertmacro MUI_UNGETLANGUAGE
SetShellVarContext all
SetRegView 64
FunctionEnd
;restore file association
Function un.RestoreAssoc
;$0 is an extension - for example ".dev"
DeleteRegKey HKCR "$0"
ReadRegStr $1 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0"
StrCmp $1 "" no_backup
WriteRegStr HKCR "$0" "" "$1"
Call un.RefreshShellIcons
no_backup:
FunctionEnd
;http://nsis.sourceforge.net/archive/viewpage.php?pageid=202
;After changing file associations, you can call this macro to refresh the shell immediatly.
;It calls the shell32 function SHChangeNotify. This will force windows to reload your changes from the registry.
!define SHCNE_ASSOCCHANGED 0x08000000
!define SHCNF_IDLIST 0
Function RefreshShellIcons
; By jerome tremblay - april 2003
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v \
(${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
FunctionEnd
Function un.RefreshShellIcons
; By jerome tremblay - april 2003
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v \
(${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
FunctionEnd
Function un.DeleteDirIfEmpty
FindFirst $R0 $R1 "$0\*.*"
strcmp $R1 "." 0 NoDelete
FindNext $R0 $R1
strcmp $R1 ".." 0 NoDelete
ClearErrors
FindNext $R0 $R1
IfErrors 0 NoDelete
FindClose $R0
Sleep 1000
RMDir "$0"
NoDelete:
FindClose $R0
FunctionEnd
Function GetParent
Exch $R0
Push $R1
Push $R2
Push $R3
StrCpy $R1 0
StrLen $R2 $R0
loop:
IntOp $R1 $R1 + 1
IntCmp $R1 $R2 get 0 get
StrCpy $R3 $R0 1 -$R1
StrCmp $R3 "\" get
Goto loop
get:
StrCpy $R0 $R0 -$R1
Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
Function UninstallExisting
ReadRegStr $R0 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString"
StrCmp $R0 "" done
Push $R0
Call GetParent
Pop $R1
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"$(MessageUninstallExisting)" \
IDOK uninst
Abort
;Run the uninstaller
uninst:
ClearErrors
HideWindow
ClearErrors
ExecWait '"$R0" _?=$R1'
BringToFront
done:
FunctionEnd
####################################################################
# uninstall
UninstallText "$(MessageUninstallText)"
ShowUninstDetails show
Section "Uninstall"
; Remove uninstaller
Delete "$INSTDIR\uninstall.exe"
; Remove start menu stuff
Delete "$SMPROGRAMS\$(MessageAppName)\$(MessageAppName).lnk"
Delete "$SMPROGRAMS\$(MessageAppName)\License.lnk"
Delete "$SMPROGRAMS\$(MessageAppName)\Uninstall $(MessageAppName).lnk"
RMDir "$SMPROGRAMS\$(MessageAppName)"
; Remove desktop stuff
Delete "$QUICKLAUNCH\$(MessageAppName).lnk"
Delete "$DESKTOP\$(MessageAppName).lnk"
; Restore file associations
StrCpy $0 ".dev"
Call un.RestoreAssoc
StrCpy $0 ".c"
Call un.RestoreAssoc
StrCpy $0 ".cpp"
Call un.RestoreAssoc
StrCpy $0 ".h"
Call un.RestoreAssoc
StrCpy $0 ".hpp"
Call un.RestoreAssoc
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"
Delete "$INSTDIR\NEWS.md"
Delete "$INSTDIR\RedPandaIDE.exe"
Delete "$INSTDIR\ConsolePauser.exe"
Delete "$INSTDIR\redpanda-win-git-askpass.exe"
Delete "$INSTDIR\astyle.exe"
Delete "$INSTDIR\LICENSE"
Delete "$INSTDIR\README.md"
Delete "$INSTDIR\qt.conf"
RMDir /r "$INSTDIR\Lang"
RMDir /r "$INSTDIR\Templates"
RMDir /r "$INSTDIR\MinGW32"
RMDir /r "$INSTDIR\MinGW64"
RMDir /r "$INSTDIR\Clang64"
StrCpy $0 "$INSTDIR"
Call un.DeleteDirIfEmpty
; Remove registry keys
DeleteRegKey ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++"
DeleteRegKey ShCtx "Software\RedPanda-C++"
IfSilent +2 ; Don't ask when running in silent mode
MessageBox MB_YESNO "$(MessageRemoveConfig)" IDNO Done
RMDir /r "$APPDATA\RedPandaIDE"
Done:
SectionEnd

View File

@ -2,10 +2,7 @@
# Startup
SetFont "Segoe UI" 11
Unicode True
!include "config.nsh"
!define COMPILERFOLDER "MinGW64"
!define FINALNAME "RedPanda.C++.${DEVCPP_VERSION}.win64.${COMPILERNAME}.Setup.exe"
!define DISPLAY_NAME "Red Panda C++ ${DEVCPP_VERSION}"
!define DISPLAY_NAME "Red Panda C++ ${APP_VERSION} (${ARCH})"
!include "MUI2.nsh"
!include "lang.nsh"
@ -20,7 +17,11 @@ OutFile "${FINALNAME}"
Caption "${DISPLAY_NAME}"
LicenseData "LICENSE"
InstallDir $PROGRAMFILES64\RedPanda-Cpp
!if "${ARCH}" == "x86"
InstallDir $PROGRAMFILES\RedPanda-Cpp
!else
InstallDir $PROGRAMFILES64\RedPanda-Cpp
!endif
####################################################################
# Interface Settings
@ -82,7 +83,7 @@ Section "$(SectionMainName)" SectionMain
WriteUninstaller "$INSTDIR\uninstall.exe"
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayName" "Redpanda-C++"
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayVersion" "${DEVCPP_VERSION}"
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayVersion" "${APP_VERSION}"
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayIcon" "$INSTDIR\RedPandaIDE.exe"
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "Publisher" "Roy Qu(royqh1979@gmail.com)"
@ -103,12 +104,14 @@ Section "$(SectionMainName)" SectionMain
SectionEnd
Section "$(SectionMinGWName)" SectionMinGW
SectionIn 1 3
SetOutPath $INSTDIR\MinGW64
!ifdef HAVE_MINGW
Section "$(SectionMinGWName)" SectionMinGW
SectionIn 1 3
SetOutPath $INSTDIR\${COMPILERFOLDER}
File /nonfatal /r "${COMPILERFOLDER}\*"
SectionEnd
File /nonfatal /r "${COMPILERFOLDER}\*"
SectionEnd
!endif
####################################################################
# File association
@ -260,7 +263,9 @@ SectionEnd
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SectionMain} "$(MessageSectionMain)"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionMinGW} "$(MessageSectionMinGW)"
!ifdef HAVE_MINGW
!insertmacro MUI_DESCRIPTION_TEXT ${SectionMinGW} "$(MessageSectionMinGW)"
!endif
!insertmacro MUI_DESCRIPTION_TEXT ${SectionShortcuts} "$(MessageSectionShortcuts)"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionAssocs} "$(MessageSectionAssocs)"
!insertmacro MUI_DESCRIPTION_TEXT ${SectionConfig} "$(MessageSectionConfig)"
@ -279,7 +284,11 @@ Function .onInit
SectionSetFlags ${SectionConfig} ${SF_SELECTED}
SetShellVarContext all
SetRegView 64
!if "${ARCH}" == "x86"
SetRegView 32
!else
SetRegView 64
!endif
FunctionEnd
Function myGuiInit
@ -290,6 +299,11 @@ Function myGuiInit
SetRegView 64
Call UninstallExisting
!if "${ARCH}" == "x86"
SetRegView 32
!else
SetRegView 64
!endif
FunctionEnd
;backup file association
@ -315,7 +329,11 @@ Function un.onInit
!insertmacro MUI_UNGETLANGUAGE
SetShellVarContext all
SetRegView 64
!if "${ARCH}" == "x86"
SetRegView 32
!else
SetRegView 64
!endif
FunctionEnd
;restore file association