Merge pull request #553 from andreasb242/windows-build

Windows build
presentation
andreasb242 7 years ago committed by GitHub
commit 36ca40c32f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      src/control/XournalMain.cpp
  2. 6
      windows-setup/.gitignore
  3. 11
      windows-setup/build-launcher.sh
  4. 14
      windows-setup/build-setup.sh
  5. BIN
      windows-setup/xournalpp.ico
  6. 116
      windows-setup/xournalpp.nsi
  7. 112
      windows-setup/xournalpp_launcher.cpp
  8. 3
      windows-setup/xpp.rc

@ -59,6 +59,12 @@ void XournalMain::initLocalisation()
//locale generator
boost::locale::generator gen;
#ifdef ENABLE_NLS
#ifdef WIN32
#undef PACKAGE_LOCALE_DIR
#define PACKAGE_LOCALE_DIR "../share/po/"
#endif
gen.add_messages_path(PACKAGE_LOCALE_DIR);
gen.add_messages_domain(GETTEXT_PACKAGE);

@ -1 +1,7 @@
setup
xournalpp-setup.exe
xournalpp_launcher
xournalpp.exe
xpp.res

@ -0,0 +1,11 @@
#!/bin/bash
## Build launcher
unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then
g++ xournalpp_launcher.cpp -o xournalpp_launcher
else
windres xpp.rc -O coff -o xpp.res
g++ xournalpp_launcher.cpp xpp.res -o setup/bin/xournalpp.exe -mwindows
fi

@ -14,20 +14,27 @@ cd "${0%/*}"
echo "clean setup folder"
rm -rf ./setup
rm -rf xournalpp-setup.exe
mkdir setup
mkdir setup/bin
mkdir setup/lib
mkdir setup/share
echo "build windows launcher"
./build-launcher.sh
# done in launcher build script: cp xournalpp.exe setup/bin/
echo "copy binaries"
cp ../build/src/xournalpp.exe ./setup/bin
cp ../build/src/xournalpp.exe ./setup/bin/xournalpp_bin.exe
ldd ../build/src/xournalpp.exe | grep '\/mingw.*\.dll' -o | xargs -I{} cp "{}" setup/bin/
echo "copy ui"
cp -r ../ui setup/
cp -r ../po setup/ui/
mkdir setup/share/po/
cp -r ../po/*.mo setup/share/po/
echo "copy pixbuf libs"
cp -r /mingw64/lib/gdk-pixbuf-2.0 setup/lib
@ -38,4 +45,7 @@ ldd /mingw64/lib/gdk-pixbuf-2.0/2.10.0/loaders/*.dll | grep '\/mingw.*\.dll' -o
echo "copy icons"
cp -r /mingw64/share/icons setup/share/
echo "pack setup"
"/c/Program Files (x86)/NSIS/Bin/makensis.exe" xournalpp.nsi
echo "finished"

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

@ -0,0 +1,116 @@
;NSIS Modern User Interface
;Start Menu Folder Selection Example Script
;Written by Joost Verburg
;--------------------------------
;Include Modern UI
!include "MUI2.nsh"
;--------------------------------
;General
;Name and file
Name "Xournal++"
OutFile "xournalpp-setup.exe"
;Default installation folder
InstallDir $PROGRAMFILES\Xournal++
;Get installation folder from registry if available
InstallDirRegKey HKCU "Software\Xournalpp" ""
;Request application privileges for Windows Vista
RequestExecutionLevel user
;--------------------------------
;Variables
Var StartMenuFolder
;--------------------------------
;Interface Settings
!define MUI_ABORTWARNING
;--------------------------------
;Pages
!insertmacro MUI_PAGE_LICENSE "..\LICENSE"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
;Start Menu Folder Page Configuration
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Xournalpp"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Xournal++"
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Installer Sections
Section "Xournal++" SecFeatures
SetOutPath "$INSTDIR"
; Files to put into the setup
File /r "setup\*"
;Store installation folder
WriteRegStr HKCU "Software\Xournalpp" "" $INSTDIR
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
;Create shortcuts
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
CreateShortcut "$SMPROGRAMS\$StartMenuFolder\Xournal++.lnk" "$INSTDIR\Bin\xournalpp.exe"
CreateShortcut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
;--------------------------------
;Descriptions
;Language strings
LangString DESC_SecFeatures ${LANG_ENGLISH} "Feature selection"
;Assign language strings to sections
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecFeatures} $(DESC_SecFeatures)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
;Uninstaller Section
Section "Uninstall"
;ADD YOUR OWN FILES HERE...
Delete "$INSTDIR\Uninstall.exe"
RMDir "$INSTDIR"
!insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk"
RMDir "$SMPROGRAMS\$StartMenuFolder"
DeleteRegKey /ifempty HKCU "Software\Xournalpp"
SectionEnd

@ -0,0 +1,112 @@
/*
* Xournal++
*
* Launcher to start Xournal++ in the correct dir on Windows
* Without this, pressure will not work
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#include <stdio.h>
#include <stdlib.h>
#include <string>
using std::string;
#ifdef WIN32
#include <Windows.h>
#include <direct.h>
#else
#include <unistd.h>
#endif
string escapeString(const char* str)
{
string escaped;
while (*str)
{
char c = *str;
if (c == '"')
{
escaped += "\\\"";
}
else
{
escaped += c;
}
str++;
}
return escaped;
}
int main(int argc, char* argv[])
{
string exePath;
#ifdef WIN32
char szFileName[MAX_PATH + 1];
GetModuleFileNameA(NULL, szFileName, MAX_PATH + 1);
exePath = szFileName;
#else
char result[1024];
ssize_t count = readlink("/proc/self/exe", result, 1024);
exePath = string(result, (count > 0) ? count : 0);
#endif
int slashPos = 0;
for(int i = exePath.size(); i > 0; i--)
{
if (exePath[i] == '/' || exePath[i] == '\\')
{
slashPos = i;
break;
}
}
string folder = exePath.substr(0, slashPos);
chdir(folder.c_str());
string command = "xournalpp_bin.exe";
for (int i = 1; i < argc; i++)
{
MessageBoxA(NULL, argv[i], "Debug IN", 0);
command += " \"";
command += escapeString(argv[i]);
command += "\"";
}
#ifdef WIN32
STARTUPINFO info = {};
PROCESS_INFORMATION processInfo;
char* cmd = new char[command.size() + 1];
strncpy(cmd, command.c_str(), command.size());
cmd[command.size()] = 0;
// MessageBoxA(NULL, cmd, "Debug", 0);
if (CreateProcessA(NULL, cmd, NULL, NULL, TRUE, 0, NULL, folder.c_str(), &info, &processInfo))
{
WaitForSingleObject(processInfo.hProcess, INFINITE);
CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread);
}
delete cmd;
#else
system(command.c_str());
#endif
return 0;
}

@ -0,0 +1,3 @@
0 ICON "xournalpp.ico"
Loading…
Cancel
Save