Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement running as service as well as standalone exe #33

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.exe
/rcs
56 changes: 54 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,54 @@
winediscordipcbridge.exe: main.c
i686-w64-mingw32-gcc -masm=intel main.c -o winediscordipcbridge
OUTPUT ?= winediscordipcbridge.exe
DEBUG ?= false


CC := i686-w64-mingw32-gcc
MC := i686-w64-mingw32-windmc
RC := i686-w64-mingw32-windres

STRIP := i686-w64-mingw32-strip

<<sources>> := $(wildcard src/*.c)
<<mcs>> := $(wildcard res/*.mc)
<<rcs>> := $(wildcard res/*.rc)
<<objects>> := $(<<sources>>:src/%.c=obj/%.o)
<<objects>> += $(<<mcs>>:res/%.mc=obj/%.rc.o)
<<objects>> += $(<<rcs>>:res/%.rc=obj/%.rc.o)

<< := @echo
ifneq ($(shell eval 'echo -e'),-e)
<< += -e
endif

src/%.h rcs/%.rc : res/%.mc
$(<<) " MC\t"$(<)
@mkdir -p rcs && $(MC) -b -h src -r rcs $(<)

obj/%.rc.o: res/%.rc
$(<<) " RC\t"$(@)
@$(RC) -I src $(<) $(@)

obj/%.rc.o: rcs/%.rc
$(<<) " RC\t"$(@)
@$(RC) -I src $(<) $(@)

obj/%.o: src/%.c
$(<<) " CC\t$(<)"
@mkdir -p obj && $(CC) -masm=intel -c $(<) -o $(@)

all: $(OUTPUT)

obj/service-manager.o: src/error.h

$(OUTPUT): $(<<objects>>)
$(<<) " LINK\t$(@)"
@$(CC) $(^) -o $(@) -lshlwapi
@test "$(DEBUG)" = "true" || $(<<:@%=%) "STRIP\t$(@)"
@test "$(DEBUG)" = "true" || $(STRIP) $(@)

clean:
@rm -fv $(<<objects>>) rcs/* $(<<mcs>>:res/%.mc=src/%.h) $(<<rcs>>:res/%.rc=src/%.h) $(OUTPUT)
@rm -rf rcs obj

.PHONY: clean all
.INTERMEDIATE: $(<<mcs>>:res/%.mc=src/%.h) $(<<rcs>>:res/%.rc=src/%.h) $(<<mcs>>:res/%.mc=rcs/%.rc)
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ The way it works is simply by bridging the gap between Windows named pipes
Compiling
=========

i686-w64-mingw32-gcc -masm=intel main.c -o winediscordipcbridge
```sh
make
```

Usage (Wine)
============
Expand All @@ -24,6 +26,18 @@ Start the bridge first, wait for it to start listening to the pipe, and
then launch your program/game. The two programs need to be running under the
same wineprefix.

Usage (wine service)
====================

```sh
WINEPREFIX=<prefix-path> wine ./winediscordipcbridge.exe install
```

Run this (^) snippet to install the bridge as a service, next time you start
anything in wine, the bridge will automatically start and connect your game
and discord.


Usage (Steam Proton)
====================

Expand Down
Loading