From a05668dffc7705a25f4dd7ae48ba1e972a22e64d Mon Sep 17 00:00:00 2001 From: David Macek Date: Wed, 4 Nov 2015 12:11:00 +0100 Subject: [PATCH] Fixed bad value of "Start in" field after pinning; plus various fixed: - version information consolidated into version.h - removed strip from Makefile - updated PKGBUILD - fixed minor things in launcher.c - added header guards --- Makefile | 3 --- PKGBUILD | 27 +++++++++++++++++++-------- launcher.c | 15 ++++++--------- launcher.rc | 5 +++-- macros.h | 5 +++++ version.h | 7 +++++++ 6 files changed, 40 insertions(+), 22 deletions(-) create mode 100644 version.h diff --git a/Makefile b/Makefile index ee248c1..c0843b3 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,6 @@ msys2.res: launcher.rc msys2.ico $(PREFIX)windres -O COFF -o $@ $< -DMSYSTEM=MSYS -DICONFILE=msys2.ico msys2.exe: launcher.c msys2.res $(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -static -municode -mwindows -o $@ $^ - $(PREFIX)strip $@ mingw32.ini: launcher.ini cp -f $^ $@ @@ -20,7 +19,6 @@ mingw32.res: launcher.rc mingw32.ico $(PREFIX)windres -O COFF -o $@ $< -DMSYSTEM=MINGW32 -DICONFILE=mingw32.ico mingw32.exe: launcher.c mingw32.res $(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -static -municode -mwindows -o $@ $^ - $(PREFIX)strip $@ mingw64.ini: launcher.ini cp -f $^ $@ @@ -29,4 +27,3 @@ mingw64.res: launcher.rc mingw64.ico $(PREFIX)windres -O COFF -o $@ $< -DMSYSTEM=MINGW64 -DICONFILE=mingw64.ico mingw64.exe: launcher.c mingw64.res $(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -static -municode -mwindows -o $@ $^ - $(PREFIX)strip $@ diff --git a/PKGBUILD b/PKGBUILD index b0a8dfd..d95de5e 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,24 +1,35 @@ -pkgname=("msys2-launcher") -pkgver=0.2 +_realname="msys2-launcher" +pkgname=("${_realname}-git") +pkgver=0.3.15.551bb17 pkgrel=1 pkgdesc="Helper for launching MSYS2 shells" arch=('x86_64' 'i686') license=('MIT') +provides=("${_realname}") +conflicts=("${_realname}") +depends=("mintty>=2.2.1") makedepends=('mingw-w64-cross-gcc') -source=(launcher.c launcher.ini launcher.rc macros.h Makefile {mingw32,mingw64,msys2}.ico) -md5sums=('8c08150729060c402f492451786749ec' +source=(launcher.{c,ini,rc} {macros,version}.h Makefile {mingw32,mingw64,msys2}.ico) +md5sums=('052ba00d62b07adca186d57615b43834' 'b7fb06d6faaf530c187b817088228ce6' - '7ebf52f48d7184bb33e6db327bc091dc' - '6cec0c5886d59f8ac929a4955108d679' - 'dc25fea701fa71381b364ed9c5ae5399' + '3a3c9fd8d083716e5efd759641eb4f31' + '57a40ae9972dac94df0830a1ab480895' + 'fef245f65b6826502b953b81fb397d97' + '8d3fa1f8eb06343a13b72299c164f6cd' '797a8ea3012b22705caadcb17b1291c2' '0237b204a9d09dcadc955b435cefd311' '292ad5cdd78abac9d694cc06819a96fc') +pkgver() { + local _major=$(cat version.h | grep -F 'VER_MAJOR' | head -1 | sed -e 's/.* //') + local _minor=$(cat version.h | grep -F 'VER_MINOR' | head -1 | sed -e 's/.* //') + printf "%s.%s.%s.%s" "${_major}" "${_minor}" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" +} + build() { make PREFIX=/opt/bin/${CARCH}-w64-mingw32- } package() { - cp "${srcdir}"/{mingw32,mingw64,msys2}.{exe,ini} "${pkgdir}" + cp {mingw32,mingw64,msys2}.{exe,ini} "${pkgdir}" } diff --git a/launcher.c b/launcher.c index 86caa5c..69b9427 100644 --- a/launcher.c +++ b/launcher.c @@ -138,9 +138,6 @@ int wmain(int argc, wchar_t* argv[]) { wchar_t exepath[PATH_MAX]; wchar_t confpath[PATH_MAX]; - UNUSED(argc); - UNUSED(argv); - code = GetModuleFileName(NULL, exepath, sizeof(exepath) / sizeof(exepath[0])); if (code == 0) { ShowLastError(L"Could not determine executable path"); @@ -149,15 +146,15 @@ int wmain(int argc, wchar_t* argv[]) { tmp = exepath; while (true) { - tmp = wcschr(tmp, L'\\'); + tmp = wcschr(tmp, L'/'); if (tmp == NULL) { break; } - *tmp = L'/'; + *tmp = L'\\'; } wcscpy(msysdir, exepath); - tmp = wcsrchr(msysdir, L'/'); + tmp = wcsrchr(msysdir, L'\\'); if (tmp == NULL) { ShowError(L"Could not find root directory", msysdir, 0); return __LINE__; @@ -195,11 +192,11 @@ int wmain(int argc, wchar_t* argv[]) { // can break, but hopefully won't for most use cases args = GetCommandLine(); - if (args[0] == '"') { + if (args[0] == L'"') { args++; } args += wcslen(argv[0]); - if (args[0] == '"') { + if (args[0] == L'"') { args++; } @@ -212,7 +209,7 @@ int wmain(int argc, wchar_t* argv[]) { ShowError(L"Could not allocate memory", L"", 0); return __LINE__; } - code = swprintf(buf, buflen, L"%s/usr/bin/mintty.exe -i '%s' -o 'AppLaunchCmd=%s' -o 'AppID=MSYS2.Shell.%s.%d' -o 'AppName=MSYS2 %s Shell' --store-taskbar-properties -- /usr/bin/bash --login %s %s", msysdir, exepath, exepath, msystem, APPID_REVISION, msystem, argc == 1 ? L"-i" : L"-c '$0 \"$@\"'", args); + code = swprintf(buf, buflen, L"%s\\usr\\bin\\mintty.exe -i '%s' -o 'AppLaunchCmd=%s' -o 'AppID=MSYS2.Shell.%s.%d' -o 'AppName=MSYS2 %s Shell' --store-taskbar-properties -- /usr/bin/bash --login %s %s", msysdir, exepath, exepath, msystem, APPID_REVISION, msystem, argc == 1 ? L"-i" : L"-c '$0 \"$@\"'", args); buflen *= 2; } if (code < 0) { diff --git a/launcher.rc b/launcher.rc index 4a376ca..91bd89e 100644 --- a/launcher.rc +++ b/launcher.rc @@ -1,7 +1,8 @@ #include "macros.h" +#include "version.h" 1 VERSIONINFO -FILEVERSION 0,2,0,0 +FILEVERSION VER_MAJOR,VER_MINOR,0,0 BEGIN BLOCK "StringFileInfo" BEGIN @@ -9,7 +10,7 @@ BEGIN BEGIN VALUE "ProductName", "MSYS2" VALUE "FileDescription", "MSYS2 " STRINGIFY_A(MSYSTEM) " shell launcher" - VALUE "FileVersion", "0.2" + VALUE "FileVersion", STRINGIFY_A(VER_MAJOR) "." STRINGIFY_A(VER_MINOR) END END diff --git a/macros.h b/macros.h index e2a4277..f1430a3 100644 --- a/macros.h +++ b/macros.h @@ -1,3 +1,6 @@ +#ifndef M2L_MACROS_H +#define M2L_MACROS_H + #define UNUSED(x) ((void)(x)) #define STRINGIFY_A_(x) #x @@ -5,3 +8,5 @@ #define STRINGIFY_W_(x) L ## #x #define STRINGIFY_W(x) STRINGIFY_W_(x) + +#endif diff --git a/version.h b/version.h new file mode 100644 index 0000000..3e81f5e --- /dev/null +++ b/version.h @@ -0,0 +1,7 @@ +#ifndef M2L_VERSION_H +#define M2L_VERSION_H + +#define VER_MAJOR 0 +#define VER_MINOR 3 + +#endif