1
0
Fork 0

Show version, Print shader error, Check update

master
May B. 2020-11-16 21:29:26 +01:00
parent 84b185fc12
commit 3020cd7c71
9 changed files with 372 additions and 138 deletions

View File

@ -66,7 +66,8 @@ if(USE_FMA)
endif(USE_FMA)
file(GLOB_RECURSE CORE_SOURCES "src/core/*.cpp" "deps/tracy/TracyClient.cpp")
set(CORE_HEADERS "deps/toml++" "deps/robin_hood" "deps/libguarded" "deps/tracy")
configure_file(src/version.h.in generated/version.h @ONLY)
set(CORE_HEADERS "${CMAKE_CURRENT_BINARY_DIR}/generated" "deps/toml++" "deps/robin_hood" "deps/libguarded" "deps/tracy")
set(CORE_LIBS glm::glm_static zstd::zstd_static) # picoquic
file(GLOB_RECURSE CLIENT_SOURCES "src/client/*.cpp" "deps/imgui/*.cpp" "deps/meshoptimizer/*.cpp" "deps/gl3w/gl3w.c" "deps/volk/volk.c")
@ -88,7 +89,7 @@ endif()
if (WIN32)
configure_file(resource/package/info.rc.in info.rc @ONLY)
set(ICON resource/package/icon.rc ${CMAKE_CURRENT_BINARY_DIR}/info.rc)
file(COPY resource/package/install.nsi DESTINATION ${CMAKE_BINARY_DIR})
configure_file(resource/package/install.nsi.in install.nsi @ONLY)
elseif (APPLE)
set(ICON univerxel.icns)
endif()

View File

@ -1,126 +0,0 @@
!include "MUI2.nsh"
;--------------------------------
; The name of the installer
Name "Univerxel"
Icon "../resource/package/univerxel.ico"
; Request application privileges for Windows Vista and higher
RequestExecutionLevel user
; Build Unicode installer
Unicode True
SetCompressor /SOLID LZMA
; The default installation directory
InstallDir $LOCALAPPDATA\Univerxel
; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\Univerxel" "Install_Dir"
VIAddVersionKey "CompanyName" "Shu"
VIAddVersionKey "FileDescription" "Univerxel installer"
VIAddVersionKey "ProductName" "Univerxel installer"
VIAddVersionKey "LegalCopyright" "MIT - Shu"
VIAddVersionKey "FileVersion" "0.0.1"
VIProductVersion "0.0.1.1"
OutFile "Univerxel-installer.exe"
;--------------------------------
; Pages
!define MUI_ABORTWARNING
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
; The stuff to install
Section "Dependencies"
SectionIn RO
SetOutPath $INSTDIR
File "package\libcrypto-1_1-x64.dll"
File "package\openssl-license.txt"
; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\Univerxel "Install_Dir" "$INSTDIR"
; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Univerxel" "DisplayName" "Univerxel"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Univerxel" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Univerxel" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Univerxel" "NoRepair" 1
WriteUninstaller "$INSTDIR\uninstall.exe"
CreateDirectory "$SMPROGRAMS\Univerxel"
SectionEnd
Section "All in one"
SetOutPath $INSTDIR
File "Release\univerxel.exe"
File /r content
SetOverwrite off
File /oname=config.toml "..\resource\package\config.full.toml"
SetOverwrite on
CreateShortcut "$SMPROGRAMS\Univerxel\Univerxel (Full).lnk" "$INSTDIR\univerxel.exe"
SectionEnd
Section /o "Client"
SetOutPath $INSTDIR
File "Release\univerxel-client.exe"
File /r /x *.pem /x *.dict content
SetOverwrite off
File /oname=config.toml "..\resource\package\config.client.toml"
SetOverwrite on
CreateShortcut "$SMPROGRAMS\Univerxel\Univerxel (Client).lnk" "$INSTDIR\univerxel-client.exe"
SectionEnd
Section /o "Server"
SetOutPath $INSTDIR
File "Release\univerxel-server.exe"
CreateDirectory "$INSTDIR\content"
File /oname=content\cert.pem content\cert.pem
File /oname=content\key.pem content\key.pem
File /oname=content\zstd.dict content\zstd.dict
SetOverwrite off
File /oname=config.toml "..\resource\package\config.server.toml"
SetOverwrite on
CreateShortcut "$SMPROGRAMS\Univerxel\Univerxel (Server).lnk" "$INSTDIR\univerxel-server.exe"
SectionEnd
;--------------------------------
; Uninstaller
Section "Uninstall"
; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Univerxel"
DeleteRegKey HKLM SOFTWARE\Univerxel
; Remove files and uninstaller
Delete "$INSTDIR\libcrypto-1_1-x64.dll"
Delete "$INSTDIR\openssl-license.txt"
Delete "$INSTDIR\univerxel.exe"
Delete "$INSTDIR\univerxel-client.exe"
Delete "$INSTDIR\univerxel-server.exe"
RMDir /r "$INSTDIR\content"
Delete "$INSTDIR\uninstall.exe"
; Remove shortcuts, if any
Delete "$SMPROGRAMS\Univerxel\*.lnk"
; Remove directories
RMDir /r "$SMPROGRAMS\Univerxel"
RMDir /r "$INSTDIR"
SectionEnd

View File

@ -0,0 +1,349 @@
!include "MUI2.nsh"
;--------------------------------
; The name of the installer
Name "Univerxel @CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@.@CMAKE_PROJECT_VERSION_PATCH@"
Icon "../resource/package/univerxel.ico"
!define MUI_ICON "../resource/package/univerxel.ico"
; Request application privileges for Windows Vista and higher
RequestExecutionLevel user
; Build Unicode installer
Unicode True
SetCompressor /SOLID LZMA
; The default installation directory
InstallDir $LOCALAPPDATA\Univerxel
; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\Univerxel" "Install_Dir"
VIAddVersionKey "CompanyName" "Shu"
VIAddVersionKey "FileDescription" "Univerxel installer"
VIAddVersionKey "ProductName" "Univerxel installer"
VIAddVersionKey "LegalCopyright" "MIT - Shu"
VIAddVersionKey "FileVersion" "@CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@.@CMAKE_PROJECT_VERSION_PATCH@"
VIProductVersion "@CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@.@CMAKE_PROJECT_VERSION_PATCH@.1"
OutFile "Univerxel-installer.exe"
;--------------------------------
;Variables
Var StartMenuFolder
;--------------------------------
; Pages
!define MUI_ABORTWARNING
!define MUI_COMPONENTSPAGE_NODESC
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "Univerxel"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Univerxel"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
Function WordFind2X
!define WordFind2X `!insertmacro WordFind2XCall`
!macro WordFind2XCall _STRING _DELIMITER1 _DELIMITER2 _NUMBER _RESULT
Push `${_STRING}`
Push `${_DELIMITER1}`
Push `${_DELIMITER2}`
Push `${_NUMBER}`
Call WordFind2X
Pop ${_RESULT}
!macroend
Exch $2
Exch
Exch $1
Exch
Exch 2
Exch $0
Exch 2
Exch 3
Exch $R0
Exch 3
Push $3
Push $4
Push $5
Push $6
Push $7
Push $8
Push $9
Push $R1
Push $R2
ClearErrors
StrCpy $R2 ''
StrCpy $3 $2 1
StrCpy $2 $2 '' 1
StrCmp $3 'E' 0 +3
StrCpy $R2 E
goto -4
StrCmp $3 '+' +5
StrCmp $3 '-' +4
StrCmp $3 '#' restart
StrCmp $3 '/' restart
goto error3
StrCpy $4 $2 2 -2
StrCmp $4 '{{' +9
StrCmp $4 '}}' +8
StrCmp $4 '{*' +7
StrCmp $4 '*{' +6
StrCmp $4 '*}' +5
StrCmp $4 '}*' +4
StrCmp $4 '{}' +3
StrCpy $4 ''
goto +2
StrCpy $2 $2 -2
IntOp $2 $2 + 0
StrCmp $2 0 error2
restart:
StrCmp $R0 '' error1
StrCpy $5 -1
StrCpy $6 0
StrCpy $7 ''
StrLen $8 $0
StrLen $9 $1
loop:
IntOp $5 $5 + 1
delim1:
StrCpy $R1 $R0 $8 $5
StrCmp $R1$6 0 error1
StrCmp $R1 '' minus
StrCmp $R1 $0 +2
StrCmp $7 '' loop delim2
StrCmp $0 $1 0 +2
StrCmp $7 '' 0 delim2
IntOp $7 $5 + $8
StrCpy $5 $7
goto delim1
delim2:
StrCpy $R1 $R0 $9 $5
StrCmp $R1 $1 0 loop
IntOp $6 $6 + 1
StrCmp $3$6 '+$2' plus
StrCmp $3 '/' 0 nextword
IntOp $R1 $5 - $7
StrCpy $R1 $R0 $R1 $7
StrCmp $R1 $2 0 +3
StrCpy $R1 $6
goto end
nextword:
IntOp $5 $5 + $9
StrCpy $7 ''
goto delim1
minus:
StrCmp $3 '-' 0 sum
StrCpy $3 +
IntOp $2 $6 - $2
IntOp $2 $2 + 1
IntCmp $2 0 error2 error2 restart
sum:
StrCmp $3 '#' 0 error2
StrCpy $R1 $6
goto end
plus:
StrCmp $4 '' 0 +4
IntOp $R1 $5 - $7
StrCpy $R1 $R0 $R1 $7
goto end
IntOp $5 $5 + $9
IntOp $7 $7 - $8
StrCmp $4 '{*' +2
StrCmp $4 '*{' 0 +3
StrCpy $R1 $R0 $5
goto end
StrCmp $4 '*}' +2
StrCmp $4 '}*' 0 +3
StrCpy $R1 $R0 '' $7
goto end
StrCmp $4 '}}' 0 +3
StrCpy $R1 $R0 '' $5
goto end
StrCmp $4 '{{' 0 +3
StrCpy $R1 $R0 $7
goto end
StrCmp $4 '{}' 0 error3
StrCpy $5 $R0 '' $5
StrCpy $7 $R0 $7
StrCpy $R1 '$7$5'
goto end
error3:
StrCpy $R1 3
goto error
error2:
StrCpy $R1 2
goto error
error1:
StrCpy $R1 1
error:
StrCmp $R2 'E' 0 +3
SetErrors
end:
StrCpy $R0 $R1
Pop $R2
Pop $R1
Pop $9
Pop $8
Pop $7
Pop $6
Pop $5
Pop $4
Pop $3
Pop $2
Pop $1
Pop $0
Exch $R0
FunctionEnd
; The stuff to install
Section "Check updates"
upretry:
inetc::get /canceltext "Skip updates !" "https://framagit.org/api/v4/projects/67835/packages?page=1&per_page=1&sort=desc&order_by=created_at&package_type=generic&package_name=Univerxel" "$TEMP\packages.json" /end
Pop $0
StrCmp $0 "OK" updlok
DetailPrint "Failed to check updates: $0"
MessageBox MB_ABORTRETRYIGNORE|MB_ICONEXCLAMATION "Failed to check updates, click IGNORE to skip updates" IDIGNORE upskip IDRETRY upretry
Abort
updlok:
FileOpen $4 "$TEMP\packages.json" r
FileRead $4 $1
FileClose $4
Delete "$TEMP\packages.json"
${WordFind2X} $1 `"version":"` `"` "E+1" $R0
IfErrors 0 upcmp
upmal:
DetailPrint "Malformed pacakges: $R0"
MessageBox MB_ABORTRETRYIGNORE|MB_ICONEXCLAMATION "Failed to check updates, click IGNORE to skip updates" IDIGNORE upskip IDRETRY upretry
upcmp:
StrCpy $4 $R0
StrCmp $4 "@CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@.@CMAKE_PROJECT_VERSION_PATCH@" upskip upfound
upfound:
DetailPrint "Update found: $R0"
${WordFind2X} $1 `"web_path":"` `"` "E+1" $R0
IfErrors upmal 0
StrCpy $3 $R0
MessageBox MB_YESNO|MB_ICONINFORMATION "Version: $4 found, click YES to download new one" IDNO upskip
ExecShell "open" "https://framagit.org/$3" SW_SHOWNORMAL
upskip:
DetailPrint "Updates check done"
SectionEnd
Section "Dependencies"
SectionIn RO
SetOutPath $INSTDIR
File "package\libcrypto-1_1-x64.dll"
File "package\openssl-license.txt"
; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\Univerxel "Install_Dir" "$INSTDIR"
; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Univerxel" "DisplayName" "Univerxel"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Univerxel" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Univerxel" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Univerxel" "NoRepair" 1
WriteUninstaller "$INSTDIR\uninstall.exe"
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
Section "All in one"
SetOutPath $INSTDIR
File "Release\univerxel.exe"
File /r content
SetOverwrite off
File /oname=config.toml "..\resource\package\config.full.toml"
SetOverwrite on
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateShortcut "$SMPROGRAMS\$StartMenuFolder\Univerxel (Full).lnk" "$INSTDIR\univerxel.exe"
!insertmacro MUI_STARTMENU_WRITE_END
!define MUI_FINISHPAGE_RUN "$INSTDIR\univerxel.exe"
!define MUI_FINISHPAGE_RUN_NOTCHECKED
SectionEnd
Section /o "Client"
SetOutPath $INSTDIR
File "Release\univerxel-client.exe"
File /r /x *.pem /x *.dict content
SetOverwrite off
File /oname=config.toml "..\resource\package\config.client.toml"
SetOverwrite on
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateShortcut "$SMPROGRAMS\$StartMenuFolder\Univerxel (Client).lnk" "$INSTDIR\univerxel-client.exe"
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
Section /o "Server"
SetOutPath $INSTDIR
File "Release\univerxel-server.exe"
CreateDirectory "$INSTDIR\content"
File /oname=content\cert.pem content\cert.pem
File /oname=content\key.pem content\key.pem
File /oname=content\zstd.dict content\zstd.dict
SetOverwrite off
File /oname=config.toml "..\resource\package\config.server.toml"
SetOverwrite on
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateShortcut "$SMPROGRAMS\$StartMenuFolder\Univerxel (Server).lnk" "$INSTDIR\univerxel-server.exe"
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
;--------------------------------
; Uninstaller
Section "Uninstall"
; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Univerxel"
DeleteRegKey HKLM SOFTWARE\Univerxel
; Remove files and uninstaller
Delete "$INSTDIR\libcrypto-1_1-x64.dll"
Delete "$INSTDIR\openssl-license.txt"
Delete "$INSTDIR\univerxel.exe"
Delete "$INSTDIR\univerxel-client.exe"
Delete "$INSTDIR\univerxel-server.exe"
RMDir /r "$INSTDIR\content"
Delete "$INSTDIR\uninstall.exe"
; Remove shortcuts, if any
!insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
Delete "$SMPROGRAMS\$StartMenuFolder\*.lnk"
; Remove directories
RMDir /r "$SMPROGRAMS\$StartMenuFolder"
RMDir /r "$INSTDIR"
DeleteRegKey /ifempty HKCU "Software\Univerxel"
SectionEnd

View File

@ -11,10 +11,11 @@
#include "client/Client.hpp"
#include "core/standalone_config.hpp"
#include "core/utils/tracy.hpp"
#include "version.h"
/// Entry point
int main(int argc, char *argv[]){
LOG("Univerxel client");
LOG("Univerxel client " << UNIVERXEL_VERSION);
#if TRACY_ENABLE
LOG("Profiling !");

View File

@ -3,6 +3,7 @@
#include <algorithm>
#include <stdexcept>
#include "../api/Images.hpp"
#include "../../../../core/utils/logger.hpp"
#define CONTENT_DIR "content/"
#define SHADER_DIR CONTENT_DIR "shaders/"
@ -24,9 +25,9 @@ void Program::load(const std::vector<Shader*>& shaders) {
glGetProgramiv(ProgramID, GL_LINK_STATUS, &result);
glGetProgramiv(ProgramID, GL_INFO_LOG_LENGTH, &infoLogLength);
if (infoLogLength > 0) {
std::vector<char> errorMessage(infoLogLength + 1);
glGetProgramInfoLog(ProgramID, infoLogLength, NULL, &errorMessage[0]);
throw std::runtime_error(&errorMessage[0]);
std::string errorMessage(infoLogLength, '\0');
glGetProgramInfoLog(ProgramID, infoLogLength, NULL, errorMessage.data());
FATAL("Failed to link GL program: " << errorMessage);
}
for(auto shader : shaders) {

View File

@ -3,6 +3,7 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include "../../../../core/utils/logger.hpp"
using namespace pass;
@ -37,10 +38,9 @@ Shader::Shader(GLenum type, const std::string& file_path, const std::vector<std:
glGetShaderiv(ShaderID, GL_COMPILE_STATUS, &result);
glGetShaderiv(ShaderID, GL_INFO_LOG_LENGTH, &infoLogLength);
if (infoLogLength > 0) {
std::vector<char> errorMessage(infoLogLength + 1);
glGetShaderInfoLog(ShaderID, infoLogLength, NULL, &errorMessage[0]);
std::cerr << "Compiling shader : " << file_path << "\n";
throw std::runtime_error(&errorMessage[0]);
std::string errorMessage(infoLogLength + 1, '\0');
glGetShaderInfoLog(ShaderID, infoLogLength, NULL, errorMessage.data());
FATAL("Failed to compile shader " << file_path << ": " << errorMessage);
}
}
Shader::~Shader() {

View File

@ -11,10 +11,11 @@
#include "server/Server.hpp"
#include "core/config.hpp"
#include "core/utils/tracy.hpp"
#include "version.h"
/// Entry point
int main(int argc, char *argv[]){
LOG("Univerxel");
LOG("Univerxel " << UNIVERXEL_VERSION);
#if TRACY_ENABLE
LOG("Profiling !");

View File

@ -11,10 +11,11 @@
#include "server/Server.hpp"
#include "core/standalone_config.hpp"
#include "core/utils/tracy.hpp"
#include "version.h"
/// Entry point
int main(int argc, char *argv[]){
LOG("Univerxel server");
LOG("Univerxel server " << UNIVERXEL_VERSION);
#if TRACY_ENABLE
LOG("Profiling !");

6
src/version.h.in Normal file
View File

@ -0,0 +1,6 @@
#pragma once
constexpr auto UNIVERXEL_MAJOR = @CMAKE_PROJECT_VERSION_MAJOR@;
constexpr auto UNIVERXEL_MINOR = @CMAKE_PROJECT_VERSION_MINOR@;
constexpr auto UNIVERXEL_PATCH = @CMAKE_PROJECT_VERSION_PATCH@;
constexpr auto UNIVERXEL_VERSION = "@CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@.@CMAKE_PROJECT_VERSION_PATCH@";