12 Commits
v1.3 ... v1.4

Author SHA1 Message Date
Christoph Reiter
4db021b108 Release v1.4 2021-11-28 13:28:41 +01:00
jeremyd2019
c48fc7a171 add icon files generated from icons directory
Update Makefile to build clang32 launcher
2021-11-12 22:01:45 +01:00
jeremyd2019
ca3dab79a1 icons: add clang32 and clangarm64 2021-11-12 22:01:45 +01:00
David Macek
1817f53cae Improve command line parsing
Instead of allowing only one quote at the beginning and one at the end
of the command name, now we're reading the command line character by
character, also advancing in the CRT-parsed command name and skipping
any number of quotes.

As far as I can tell, there is no other hole in it, but just to be sure,
any parsing failure is now fatal.
2021-04-04 11:50:42 +02:00
David Macek
49787dc7b0 Follow common C conventions a bit more 2021-04-04 11:16:54 +02:00
David Macek
ff1f8ff198 Use different AppIDs for different MSYS2 roots
For default root of `C:\msys64`, the AppID stays the same.  For any
other, a hash of the root is appended.

Fixes #16
2021-04-04 11:07:25 +02:00
David Macek
cf1a24cc86 README: Explain environment configuration a bit better 2021-04-04 10:07:10 +02:00
David Macek
e6513f6bfc Explicitly enable ANSI stdio format specifiers
Seems like the `-std=c11` option is now automatically enabling the
ANSI stdio behavior as well.  I'd rather be explicit about it though.
2021-04-04 10:07:09 +02:00
David Macek
926eb2aca2 Unify order of subsystems 2021-04-04 09:59:19 +02:00
Christoph Reiter
80b13a5633 CI: Fix the upload 2021-03-26 14:01:27 +01:00
Christoph Reiter
829d0a3519 CI: install mingw-w64-cross-gcc 2021-03-26 13:59:26 +01:00
Christoph Reiter
55e038fd95 CI: Don't use makepkg
One shouldn't be forced to update the checksum all the time.
2021-03-26 13:53:34 +01:00
9 changed files with 93 additions and 35 deletions

View File

@@ -15,15 +15,17 @@ jobs:
with:
msystem: MSYS
update: true
install: msys2-devel base-devel
install: msys2-devel base-devel mingw-w64-cross-gcc
- name: Build
shell: msys2 {0}
run: |
makepkg -Csfri --noconfirm --nocheck
make PREFIX=/opt/bin/x86_64-w64-mingw32-
- name: Upload
uses: actions/upload-artifact@v2
with:
name: package
path: '*.pkg.tar.*'
path: |
*.exe
*.ini

View File

@@ -1,6 +1,6 @@
PREFIX=
all: msys2.exe msys2.ini mingw32.exe mingw32.ini mingw64.exe mingw64.ini ucrt64.exe ucrt64.ini clang64.exe clang64.ini
all: msys2.exe msys2.ini mingw32.exe mingw32.ini mingw64.exe mingw64.ini ucrt64.exe ucrt64.ini clang64.exe clang64.ini clang32.exe clang32.ini
.PHONY: all
@@ -43,3 +43,11 @@ clang64.res: launcher.rc clang64.ico
$(PREFIX)windres -O COFF -o $@ $< -DMSYSTEM=CLANG64 -DICONFILE=clang64.ico
clang64.exe: launcher.c clang64.res
$(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -static -municode -mwindows -o $@ $^
clang32.ini: launcher.ini
cp -f $^ $@
echo MSYSTEM=CLANG32>> $@
clang32.res: launcher.rc clang32.ico
$(PREFIX)windres -O COFF -o $@ $< -DMSYSTEM=CLANG32 -DICONFILE=clang32.ico
clang32.exe: launcher.c clang32.res
$(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -static -municode -mwindows -o $@ $^

View File

@@ -1,27 +1,28 @@
_realname="msys2-launcher"
pkgname=("${_realname}-git")
pkgver=1.3
pkgver=1.4
pkgrel=1
pkgdesc="Helper for launching MSYS2 shells"
arch=('x86_64' 'i686')
license=('MIT')
backup=({mingw32,mingw64,msys2}.ini)
backup=({msys2,mingw32,mingw64,ucrt64,clang64}.ini)
provides=("${_realname}")
conflicts=("${_realname}")
depends=("mintty>=2.2.1")
makedepends=('mingw-w64-cross-gcc')
source=(launcher.{c,ini,rc} {macros,version}.h Makefile {mingw32,mingw64,msys2,ucrt64,clang64}.ico)
sha512sums=('02ec6ae0b6622e2aef7b20a1b4b0ce26b79225dcbb0c30e9bb281087cf0335c5be8cbbedade5d676002ec19fe30134166b70b1629d5432f750bfc7de6b64df60'
source=(launcher.{c,ini,rc} {macros,version}.h Makefile {msys2,mingw32,mingw64,ucrt64,clang64,clang32}.ico)
sha512sums=('ed2937084cc7d176bb9f06af96121dbf4433a05cfc8fa260918a5f96ed5e8c4201fa2b45aa196a858ece0c8a86f7ffc617a8330b57b7231a4ea4ab23d75920b0'
'5ed8a2e9997d9d2c1e17940292d68542f897e2716b274741d8a3ba7c8f46235c175b7e0a1252a879ba3c79b571504d25de2a8d6b004aedd117d263195bc2b185'
'cf257f1f5b7fc69a32c63fe5bf5299db078621850b1e12358654d71da7777a94a0668d657c1834be308db099cad9d48a42fa7877ad58dfdbd576248150913a12'
'6019ca0d67375c1261dda0d54d45fc411b02244c51b71d5c57d2613e9edfb4e8f9000754e5c7d632ed0101005c01cd0a98c3961d5b5f51c94d83eceba4296d35'
'd1340b950bf1cb1c5359fc9139109f80c679d31a918c8b7d635b5538b8cc8d5c9440e5dc00bbd25c043ad1bbb3e18d0537ede6f21771ecec69c15a67e9fb5756'
'a8f7568ae878481641422a8e9c1d19e84b3d33815f179af179fa9c83ebac9fb5834a939b97b38b5b5c53f9f86753daf06d1e1551019764d3f8305571e6fe32d5'
'b5482fe167ab3143cf56cdc2eadab440923c7375307094f73b6376e9e7ff6f3509af65fa5dbacb1b872473bd8fbeadd0f74a4d0caf2bdb4c4dfa93ef48301ea0'
'd3370e83a16078354cd6bc80c2ccbd5dadb8b0a32dde3fa38dc00375862766c53cad0f6f2936c1061920971c20abea4ccd924308acb45e810bfa0aaedd70a19d'
'b0eb5a71d4611fd79a681e89ce1c915a12858c7be4d64740b9d127576d39cba352696a594cfb8392aaf00dad0f12c40c78e8fd2019b15c88507286efa0171e0d'
'24e05f79df6aa51ca85fee43f1d10eeace85739d60ab5b2bfc82b2b6edd3040e6ae0355fdd3f4455eb7adb83e3c6269457b2462552fd3b5d5a5e14c0771c3437'
'7749d962dd19b4e93bf74ca339fd1c06fd457dd92ea501d4a19b34973ce2b0ddd9c9ed09921c26bea3adc7dfbbd821042b467ffc6d4050b6301c025d4f0c844d'
'b0eb5a71d4611fd79a681e89ce1c915a12858c7be4d64740b9d127576d39cba352696a594cfb8392aaf00dad0f12c40c78e8fd2019b15c88507286efa0171e0d'
'e77d67d33fb364d84416a727d24a5fabdedc4b42ddccffd296ac6c2049cbdc8b7df700a492f386a812867924c8dc2a34b0c858bc1a252957db06e9f1869d7ff2'
'a1fcffd0b7fe7f3e2c18d03206909aba830e983925a85ef69dc165606e543e53eb17164a089d84a40cc53d6a626cce2302071aec8519b7e44f001b2d4602d5e2')
'a1fcffd0b7fe7f3e2c18d03206909aba830e983925a85ef69dc165606e543e53eb17164a089d84a40cc53d6a626cce2302071aec8519b7e44f001b2d4602d5e2'
'13118938dc6a084a005d723f329fffa3364284254d9167fe04e93c0ca870b7b3bef1e9a5f0b5b2a7df14f3f1af9a589fc2709d1593231fa3615174b062e62d70')
pkgver() {
local _major=$(cat version.h | grep -F 'VER_MAJOR' | head -1 | sed -e 's/.* //')
@@ -34,5 +35,5 @@ build() {
}
package() {
cp {mingw32,mingw64,ucrt64,clang64,msys2}.{exe,ini} "${pkgdir}"
cp {msys2,mingw32,mingw64,ucrt64,clang64,clang32}.{exe,ini} "${pkgdir}"
}

View File

@@ -1,23 +1,25 @@
MSYS2 launcher
==============
A helper for launching MSYS2 shells. Features blink-less launching and correct taskbar/start pinning.
A helper for launching MSYS2 shells. Features blink-less launching and correct taskbar/start pinning.
Installation
------------
Just `make` and put the .exe and .ini files inside your MSYS2 root. Needs mintty v2.1.6 or newer.
Just `make` and put the .exe and .ini files inside your MSYS2 root. Needs mintty v2.1.6 or newer.
Configuration
-------------
All three default launchers are the same (except for embedded icons and descriptions) and are configured by corresponding .ini files. The .ini file has to be in the same directory as the .exe file and have the same filename (except for the `.exe` -> `.ini` change).
All three default launchers are the same (except for embedded icons and descriptions) and are configured by corresponding .ini files. The .ini file has to be in the same directory as the .exe file and have the same filename (except for the `.exe` -> `.ini` change).
By default, only `MSYSTEM` is set, but options for inheriting `PATH` and tweaking `MSYS` are prepared, as well as `CHERE_INVOKING` for the shell to stay in the current working directory (instead of changing to the home directory).
The .ini file contains environment variables, each on a separate line, in the usual `VAR=val` format. Lines starting with `#` are ignored. The values are expanded using the current environment (use Windows `%var%` syntax), evaluated from top to bottom. By default, only `MSYSTEM` is set and the rest is inherited from the outside environment, but some common options are prepared and commented out in the files:
The .ini file contains environment variables, each on a separate line, in the usual `VAR=val` format. Lines starting with `#` are ignored. The values are expanded using the current environment (use Windows `%var%` syntax).
- `MSYS=...`: configures runtime behavior
- `CHERE_INVOKING=1`: prevent the login scripts from changing the working directory to the user's home directory
- `MSYS2_PATH_TYPE=strict|minimal|inherit`: configures how the login scripts set up `PATH`
Pinning
-------
As with many other applications, the correct way to pin a shortcut to the taskbar is by right-clicking the button of a running MSYS2 shell (started by this launcher) on the taskbar and choosing "Pin this program to taskbar". Pinning the `.exe` file itself won't create the shortcut correctly. There are tools to diagnose and fix such a situation (7+ Taskbar Tweaker and Win7AppId) in case re-pinning is not preferred.
As with many other applications, the correct way to pin a shortcut to the taskbar is by right-clicking the button of a running MSYS2 shell (started by this launcher) on the taskbar and choosing "Pin this program to taskbar". Pinning the `.exe` file itself won't create the shortcut correctly. There are tools to diagnose and fix such a situation (7+ Taskbar Tweaker and Win7AppId) in case re-pinning is not preferred.

BIN
clang32.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
clangarm64.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -1,4 +1,4 @@
all: ../msys2.ico ../mingw32.ico ../mingw64.ico ../clang64.ico ../ucrt64.ico
all: ../msys2.ico ../mingw32.ico ../mingw64.ico ../ucrt64.ico ../clang64.ico ../clang32.ico ../clangarm64.ico
sources=icon-large.svg icon-medium.svg icon-small.svg
@@ -11,8 +11,14 @@ sources=icon-large.svg icon-medium.svg icon-small.svg
../mingw64.ico: $(sources)
./build.sh '#276597' $@
../ucrt64.ico: $(sources)
./build.sh '#8b7b16' $@
../clang64.ico: $(sources)
./build.sh '#be643e' $@
../ucrt64.ico: $(sources)
./build.sh '#8b7b16' $@
../clang32.ico: $(sources)
./build.sh '#d49b63' $@
../clangarm64.ico: $(sources)
./build.sh '#238423' $@

View File

@@ -1,3 +1,4 @@
#define __USE_MINGW_ANSI_STDIO 1
#define _UNICODE
#define _WIN32_WINNT 0x0601
#define WIN32_LEAN_AND_MEAN
@@ -38,6 +39,22 @@ static void ShowErrno(const wchar_t* desc) {
ShowError(desc, err, errno);
}
// adapted from http://www.partow.net/programming/hashfunctions/index.html
// MIT licensed
static unsigned int APHash(const wchar_t* str, size_t length) {
unsigned int hash = 0xAAAAAAAA;
size_t i = 0;
for (i = 0; i < length; ++str, ++i) {
hash ^= ((i & 1) == 0)
? ((hash << 7) ^ (*str) * (hash >> 3))
: (~((hash << 11) + ((*str) ^ (hash >> 5))))
;
}
return hash;
}
static PROCESS_INFORMATION StartChild(wchar_t* cmdline) {
STARTUPINFOW si;
PROCESS_INFORMATION pi;
@@ -150,22 +167,19 @@ int wmain(int argc, wchar_t* argv[]) {
wchar_t* tmp;
wchar_t* args;
wchar_t* msystem;
wchar_t* msysdirhash;
wchar_t msysdir[PATH_MAX];
wchar_t exepath[PATH_MAX];
wchar_t confpath[PATH_MAX];
code = GetModuleFileName(NULL, exepath, sizeof(exepath) / sizeof(exepath[0]));
code = GetModuleFileName(NULL, exepath, sizeof(exepath) / sizeof(*exepath));
if (code == 0) {
ShowLastError(L"Could not determine executable path");
return __LINE__;
}
tmp = exepath;
while (true) {
tmp = wcschr(tmp, L'/');
if (tmp == NULL) {
break;
}
while ((tmp = wcschr(tmp, L'/')) != NULL) {
*tmp = L'\\';
}
@@ -177,9 +191,24 @@ int wmain(int argc, wchar_t* argv[]) {
}
*tmp = L'\0';
msysdirhash = (wchar_t*)alloca(10 * sizeof(wchar_t)); // dot + unsigned int as %x + null
if (msysdirhash == NULL) {
ShowError(L"Could not allocate memory", L"", 0);
return __LINE__;
}
if (wcsicmp(msysdir, L"C:\\msys64") == 0) {
code = swprintf(msysdirhash, 10, L""); // no change in AppID for default installations
} else {
code = swprintf(msysdirhash, 10, L".%8x", APHash(msysdir, wcslen(msysdir)));
}
if (code < 0) {
ShowErrno(L"Could not write to buffer");
return __LINE__;
}
wcscpy(confpath, exepath);
tmp = confpath + wcslen(confpath) - 4;
if (0 != wcsicmp(L".exe", tmp)) {
if (wcsicmp(L".exe", tmp) != 0) {
ShowError(L"Could not find configuration file", confpath, 0);
return __LINE__;
}
@@ -206,13 +235,23 @@ int wmain(int argc, wchar_t* argv[]) {
ShowLastError(L"Could not set environment variable");
}
// can break, but hopefully won't for most use cases
args = GetCommandLine();
if (args[0] == L'"') {
tmp = argv[0];
while (*tmp != L'\0') {
if (*args == *tmp) {
args++;
tmp++;
} else if (*args == L'"') {
args++;
} else {
ShowError(L"Could not parse command name", argv[0], 0);
return __LINE__;
}
}
while (*args == L'"') {
args++;
}
args += wcslen(argv[0]);
if (args[0] == L'"') {
while (*args == L' ') {
args++;
}
@@ -225,7 +264,7 @@ int wmain(int argc, wchar_t* argv[]) {
ShowError(L"Could not allocate memory", L"", 0);
return __LINE__;
}
code = swprintf(buf, buflen, L"%ls\\usr\\bin\\mintty.exe -i '%ls' -o 'AppLaunchCmd=%ls' -o 'AppID=MSYS2.Shell.%ls.%d' -o 'AppName=MSYS2 %ls Shell' -t 'MSYS2 %ls Shell' --store-taskbar-properties -- %ls %ls", msysdir, exepath, exepath, msystem, APPID_REVISION, msystem, msystem, argc == 1 ? L"-" : L"/usr/bin/sh -lc '\"$@\"' sh", args);
code = swprintf(buf, buflen, L"%ls\\usr\\bin\\mintty.exe -i '%ls' -o 'AppLaunchCmd=%ls' -o 'AppID=MSYS2.Shell.%ls.%d%ls' -o 'AppName=MSYS2 %ls Shell' -t 'MSYS2 %ls Shell' --store-taskbar-properties -- %ls %ls", msysdir, exepath, exepath, msystem, APPID_REVISION, msysdirhash, msystem, msystem, argc == 1 ? L"-" : L"/usr/bin/sh -lc '\"$@\"' sh", args);
buflen *= 2;
}
if (code < 0) {

View File

@@ -2,6 +2,6 @@
#define M2L_VERSION_H
#define VER_MAJOR 1
#define VER_MINOR 3
#define VER_MINOR 4
#endif