scripts: not hardcode MSYSTEM (#1739)
This commit is contained in:
parent
e69f3b8c13
commit
74c8d03aa0
|
@ -77,11 +77,17 @@ get_platform_arch() {
|
||||||
platform=$(get_platform_name)
|
platform=$(get_platform_name)
|
||||||
arch=${CROSS_ARCH:-$(uname -m)}
|
arch=${CROSS_ARCH:-$(uname -m)}
|
||||||
if [[ $MSYSTEM != "" ]]; then
|
if [[ $MSYSTEM != "" ]]; then
|
||||||
if [[ $MSYSTEM == "MINGW64" ]]; then
|
case "$MSYSTEM" in
|
||||||
|
MINGW64|UCRT64|CLANG64)
|
||||||
arch=x86_64
|
arch=x86_64
|
||||||
else
|
;;
|
||||||
|
MINGW32|CLANG32)
|
||||||
arch=i686
|
arch=i686
|
||||||
fi
|
;;
|
||||||
|
CLANGARM64)
|
||||||
|
arch=aarch64
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
echo "$arch"
|
echo "$arch"
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,16 @@ AppPublisherURL={#MyAppURL}
|
||||||
AppSupportURL={#MyAppURL}
|
AppSupportURL={#MyAppURL}
|
||||||
AppUpdatesURL={#MyAppURL}
|
AppUpdatesURL={#MyAppURL}
|
||||||
|
|
||||||
#if Arch=="x64"
|
#if Arch=="x86"
|
||||||
ArchitecturesAllowed=x64
|
|
||||||
ArchitecturesInstallIn64BitMode=x64
|
|
||||||
#define ArchInternal "x86_64"
|
|
||||||
#else
|
|
||||||
#define ArchInternal "i686"
|
#define ArchInternal "i686"
|
||||||
|
#else
|
||||||
|
ArchitecturesAllowed={#Arch}
|
||||||
|
ArchitecturesInstallIn64BitMode={#Arch}
|
||||||
|
#if Arch=="x64"
|
||||||
|
#define ArchInternal "x86_64"
|
||||||
|
#elif Arch=="arm64"
|
||||||
|
#define ArchInternal "aarch64"
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
AllowNoIcons=yes
|
AllowNoIcons=yes
|
||||||
|
@ -57,9 +61,13 @@ OutputBaseFilename=LiteXL-{#MyAppVersion}-{#ArchInternal}-setup
|
||||||
|
|
||||||
LicenseFile={#SourceDir}/LICENSE
|
LicenseFile={#SourceDir}/LICENSE
|
||||||
SetupIconFile={#SourceDir}/resources/icons/icon.ico
|
SetupIconFile={#SourceDir}/resources/icons/icon.ico
|
||||||
|
UninstallDisplayIcon={app}\{#MyAppExeName}, 0
|
||||||
WizardImageFile="{#SourceDir}/scripts/innosetup/wizard-modern-image.bmp"
|
WizardImageFile="{#SourceDir}/scripts/innosetup/wizard-modern-image.bmp"
|
||||||
WizardSmallImageFile="{#SourceDir}/scripts/innosetup/litexl-55px.bmp"
|
WizardSmallImageFile="{#SourceDir}/scripts/innosetup/litexl-55px.bmp"
|
||||||
|
|
||||||
|
; Required for the add to path option to refresh environment
|
||||||
|
ChangesEnvironment=yes
|
||||||
|
|
||||||
[Languages]
|
[Languages]
|
||||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||||
|
|
||||||
|
@ -67,6 +75,7 @@ Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||||
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
||||||
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 6.1; Check: not IsAdminInstallMode
|
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 6.1; Check: not IsAdminInstallMode
|
||||||
Name: "portablemode"; Description: "Portable Mode"; Flags: unchecked
|
Name: "portablemode"; Description: "Portable Mode"; Flags: unchecked
|
||||||
|
Name: "envPath"; Description: "Add lite-xl to the PATH variable, allowing it to be run from a command line."
|
||||||
|
|
||||||
[Files]
|
[Files]
|
||||||
Source: "{#SourceDir}/lite-xl/*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs
|
Source: "{#SourceDir}/lite-xl/*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs
|
||||||
|
@ -95,3 +104,62 @@ Filename: "{app}/{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChang
|
||||||
|
|
||||||
[Setup]
|
[Setup]
|
||||||
Uninstallable=not WizardIsTaskSelected('portablemode')
|
Uninstallable=not WizardIsTaskSelected('portablemode')
|
||||||
|
|
||||||
|
; Code to add installation path to environment taken from:
|
||||||
|
; https://stackoverflow.com/a/46609047
|
||||||
|
[Code]
|
||||||
|
const EnvironmentKey = 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
|
||||||
|
|
||||||
|
procedure EnvAddPath(Path: string);
|
||||||
|
var
|
||||||
|
Paths: string;
|
||||||
|
begin
|
||||||
|
{ Retrieve current path (use empty string if entry not exists) }
|
||||||
|
if not RegQueryStringValue(HKEY_LOCAL_MACHINE, EnvironmentKey, 'Path', Paths)
|
||||||
|
then Paths := '';
|
||||||
|
|
||||||
|
{ Skip if string already found in path }
|
||||||
|
if Pos(';' + Uppercase(Path) + ';', ';' + Uppercase(Paths) + ';') > 0 then exit;
|
||||||
|
|
||||||
|
{ App string to the end of the path variable }
|
||||||
|
Paths := Paths + ';'+ Path +';'
|
||||||
|
|
||||||
|
{ Overwrite (or create if missing) path environment variable }
|
||||||
|
if RegWriteStringValue(HKEY_LOCAL_MACHINE, EnvironmentKey, 'Path', Paths)
|
||||||
|
then Log(Format('The [%s] added to PATH: [%s]', [Path, Paths]))
|
||||||
|
else Log(Format('Error while adding the [%s] to PATH: [%s]', [Path, Paths]));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure EnvRemovePath(Path: string);
|
||||||
|
var
|
||||||
|
Paths: string;
|
||||||
|
P: Integer;
|
||||||
|
begin
|
||||||
|
{ Skip if registry entry not exists }
|
||||||
|
if not RegQueryStringValue(HKEY_LOCAL_MACHINE, EnvironmentKey, 'Path', Paths) then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
{ Skip if string not found in path }
|
||||||
|
P := Pos(';' + Uppercase(Path) + ';', ';' + Uppercase(Paths) + ';');
|
||||||
|
if P = 0 then exit;
|
||||||
|
|
||||||
|
{ Update path variable }
|
||||||
|
Delete(Paths, P - 1, Length(Path) + 1);
|
||||||
|
|
||||||
|
{ Overwrite path environment variable }
|
||||||
|
if RegWriteStringValue(HKEY_LOCAL_MACHINE, EnvironmentKey, 'Path', Paths)
|
||||||
|
then Log(Format('The [%s] removed from PATH: [%s]', [Path, Paths]))
|
||||||
|
else Log(Format('Error while removing the [%s] from PATH: [%s]', [Path, Paths]));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure CurStepChanged(CurStep: TSetupStep);
|
||||||
|
begin
|
||||||
|
if (CurStep = ssPostInstall) and WizardIsTaskSelected('envPath')
|
||||||
|
then EnvAddPath(ExpandConstant('{app}'));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
|
||||||
|
begin
|
||||||
|
if CurUninstallStep = usPostUninstall
|
||||||
|
then EnvRemovePath(ExpandConstant('{app}'));
|
||||||
|
end;
|
||||||
|
|
|
@ -29,13 +29,24 @@ main() {
|
||||||
local version
|
local version
|
||||||
local output
|
local output
|
||||||
|
|
||||||
if [[ $MSYSTEM == "MINGW64" ]]; then
|
case "$MSYSTEM" in
|
||||||
|
MINGW64|UCRT64|CLANG64)
|
||||||
arch=x64
|
arch=x64
|
||||||
arch_file=x86_64
|
arch_file=x86_64
|
||||||
else
|
;;
|
||||||
arch=i686;
|
MINGW32|CLANG32)
|
||||||
|
arch=x86
|
||||||
arch_file=i686
|
arch_file=i686
|
||||||
fi
|
;;
|
||||||
|
CLANGARM64)
|
||||||
|
arch=arm64
|
||||||
|
arch_file=aarch64
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "error: unsupported MSYSTEM type: $MSYSTEM"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
initial_arg_count=$#
|
initial_arg_count=$#
|
||||||
|
|
||||||
|
|
|
@ -213,14 +213,18 @@ main() {
|
||||||
if [[ $platform == "windows" ]]; then
|
if [[ $platform == "windows" ]]; then
|
||||||
exe_file="${exe_file}.exe"
|
exe_file="${exe_file}.exe"
|
||||||
stripcmd="strip --strip-all"
|
stripcmd="strip --strip-all"
|
||||||
# Copy MinGW libraries dependencies.
|
if command -v ntldd >/dev/null 2>&1; then
|
||||||
# MSYS2 ldd command seems to be only 64bit, so use ntldd
|
# Copy MinGW libraries dependencies.
|
||||||
# see https://github.com/msys2/MINGW-packages/issues/4164
|
# MSYS2 ldd command seems to be only 64bit, so use ntldd
|
||||||
ntldd -R "${exe_file}" \
|
# see https://github.com/msys2/MINGW-packages/issues/4164
|
||||||
| grep mingw \
|
ntldd -R "${exe_file}" \
|
||||||
| awk '{print $3}' \
|
| grep mingw \
|
||||||
| sed 's#\\#/#g' \
|
| awk '{print $3}' \
|
||||||
| xargs -I '{}' cp -v '{}' "$(pwd)/${dest_dir}/"
|
| sed 's#\\#/#g' \
|
||||||
|
| xargs -I '{}' cp -v '{}' "$(pwd)/${dest_dir}/"
|
||||||
|
else
|
||||||
|
echo "WARNING: ntldd not found; assuming program is static"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# Windows archive is always portable
|
# Windows archive is always portable
|
||||||
package_name+="-portable"
|
package_name+="-portable"
|
||||||
|
|
Loading…
Reference in New Issue