1 Commits

Author SHA1 Message Date
David Macek
541efef81b Add option to specify command to run in the .ini file 2015-11-17 22:15:24 +01:00
5 changed files with 38 additions and 37 deletions

3
.gitignore vendored
View File

@@ -7,9 +7,6 @@
/msys2.exe
/msys2.res
/msys2.ini
/cygwin.exe
/cygwin.res
/cygwin.ini
/pkg/
/src/
/*.pkg.tar.xz

View File

@@ -1,39 +1,29 @@
PREFIX=
msys2: msys2.exe msys2.ini mingw32.exe mingw32.ini mingw64.exe mingw64.ini
cygwin: cygwin.exe cygwin.ini
all: msys2 cygwin
all: msys2.exe msys2.ini mingw32.exe mingw32.ini mingw64.exe mingw64.ini
.PHONY: all msys2 cygwin
.PHONY: all
msys2.ini: launcher.ini
cp -f $^ $@
echo MSYSTEM=MSYS>> $@
msys2.res: launcher.rc msys2.ico
$(PREFIX)windres -O COFF -o $@ $< -DPRODUCT=MSYS2 -DMSYSTEM=MSYS -DICONFILE=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 $@ $^ -DPRODUCT=MSYS2 -DSHELLPATH='usr\\bin\\mintty.exe'
$(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -static -municode -mwindows -o $@ $^
mingw32.ini: launcher.ini
cp -f $^ $@
echo MSYSTEM=MINGW32>> $@
mingw32.res: launcher.rc mingw32.ico
$(PREFIX)windres -O COFF -o $@ $< -DPRODUCT=MSYS2 -DMSYSTEM=MINGW32 -DICONFILE=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 $@ $^ -DPRODUCT=MSYS2 -DSHELLPATH='usr\\bin\\mintty.exe'
$(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -static -municode -mwindows -o $@ $^
mingw64.ini: launcher.ini
cp -f $^ $@
echo MSYSTEM=MINGW64>> $@
mingw64.res: launcher.rc mingw64.ico
$(PREFIX)windres -O COFF -o $@ $< -DPRODUCT=MSYS2 -DMSYSTEM=MINGW64 -DICONFILE=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 $@ $^ -DPRODUCT=MSYS2 -DSHELLPATH='usr\\bin\\mintty.exe'
cygwin.ini: launcher.ini
cp -f $^ $@
echo MSYSTEM=CYGWIN>> $@
cygwin.res: launcher.rc cygwin.ico
$(PREFIX)windres -O COFF -o $@ $< -DPRODUCT=Cygwin -DMSYSTEM=CYGWIN -DICONFILE=cygwin.ico
cygwin.exe: launcher.c cygwin.res
$(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -static -municode -mwindows -o $@ $^ -DPRODUCT=Cygwin -DSHELLPATH='bin\\mintty.exe'
$(PREFIX)gcc -std=c11 -Wall -Wextra -Werror -static -municode -mwindows -o $@ $^

Binary file not shown.

Before

Width:  |  Height:  |  Size: 153 KiB

View File

@@ -56,7 +56,7 @@ static PROCESS_INFORMATION StartChild(wchar_t* cmdline) {
return pi;
}
static wchar_t* SetEnv(wchar_t* conffile) {
static wchar_t* SetEnv(wchar_t* conffile, wchar_t** command) {
int code;
size_t buflen;
size_t expandedlen;
@@ -65,7 +65,9 @@ static wchar_t* SetEnv(wchar_t* conffile) {
wchar_t* expanded;
wchar_t* msystem;
FILE* handle;
bool specialvar;
*command = NULL;
msystem = NULL;
handle = _wfopen(conffile, L"rt");
@@ -97,6 +99,10 @@ static wchar_t* SetEnv(wchar_t* conffile) {
}
if (*buf != L'\0' && *buf != L'#') {
specialvar = *buf == L'=';
if (specialvar) {
++buf;
}
tmp = wcschr(buf, L'=');
if (tmp != NULL) {
*tmp++ = L'\0';
@@ -118,9 +124,15 @@ static wchar_t* SetEnv(wchar_t* conffile) {
return NULL;
}
}
code = SetEnvironmentVariable(buf, expanded);
if (code == 0) {
ShowLastError(L"Could not set environment variable");
if (specialvar) {
if (0 == wcsicmp(L"command", buf)) {
*command = _wcsdup(expanded);
}
} else {
code = SetEnvironmentVariable(buf, expanded);
if (code == 0) {
ShowLastError(L"Could not set environment variable");
}
}
} else {
ShowError(L"Could not parse environment line", buf, 0);
@@ -194,7 +206,7 @@ int wmain(int argc, wchar_t* argv[]) {
}
}
msystem = SetEnv(confpath);
msystem = SetEnv(confpath, &args);
if (msystem == NULL) {
ShowError(L"Did not find the MSYSTEM variable", confpath, 0);
return __LINE__;
@@ -205,14 +217,16 @@ 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'"') {
args++;
}
args += wcslen(argv[0]);
if (args[0] == L'"') {
args++;
if (argc > 1) {
// can break, but hopefully won't for most use cases
args = GetCommandLine();
if (*args == L'"') {
args++;
}
args += wcslen(argv[0]);
if (*args == L'"') {
args++;
}
}
code = -1;
@@ -224,7 +238,7 @@ int wmain(int argc, wchar_t* argv[]) {
ShowError(L"Could not allocate memory", L"", 0);
return __LINE__;
}
code = swprintf(buf, buflen, L"%s\\%s -i '%s' -o 'AppLaunchCmd=%s' -o 'AppID=%s.Shell.%s.%d' -o 'AppName=%s %s Shell' --store-taskbar-properties -- /usr/bin/bash --login %s %s", msysdir, STRINGIFY_W(SHELLPATH), exepath, exepath, STRINGIFY_W(PRODUCT), msystem, APPID_REVISION, STRINGIFY_W(PRODUCT), 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, args != NULL ? L"-c '$0 \"$@\"'" : L"-i" , args != NULL ? args : L"");
buflen *= 2;
}
if (code < 0) {

View File

@@ -8,8 +8,8 @@ BEGIN
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "ProductName", STRINGIFY_A(PRODUCT)
VALUE "FileDescription", STRINGIFY_A(PRODUCT) " " STRINGIFY_A(MSYSTEM) " shell launcher"
VALUE "ProductName", "MSYS2"
VALUE "FileDescription", "MSYS2 " STRINGIFY_A(MSYSTEM) " shell launcher"
VALUE "FileVersion", STRINGIFY_A(VER_MAJOR) "." STRINGIFY_A(VER_MINOR)
END
END