summarylogtreecommitdiffstats
path: root/chromium-launcher-electron-app.patch
blob: 6346f3f5d1461ee9e3928306c28145dd6c9ae593 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
 PREFIX = /usr/local
 
 CHROMIUM_SUFFIX  =
+CHROMIUM_APP     = Chromium
 CHROMIUM_NAME    = chromium$(CHROMIUM_SUFFIX)
 CHROMIUM_BINARY  = /usr/lib/$(CHROMIUM_NAME)/$(CHROMIUM_NAME)
 CHROMIUM_VENDOR  = $(shell . /etc/os-release; echo $$NAME)
@@ -9,6 +10,7 @@ override CFLAGS += $(shell pkg-config --
 override LDLIBS += $(shell pkg-config --libs glib-2.0)
 override CPPFLAGS += \
 	-DLAUNCHER_VERSION=\"$(shell git describe 2>/dev/null || echo v8)\" \
+	-DCHROMIUM_APP="\"$(CHROMIUM_APP)\"" \
 	-DCHROMIUM_NAME=\"$(CHROMIUM_NAME)\" \
 	-DCHROMIUM_BINARY=\"$(CHROMIUM_BINARY)\" \
 	-DCHROMIUM_VENDOR="\"$(CHROMIUM_VENDOR)\""
@@ -17,9 +19,20 @@ ifeq ($(ENABLE_GCOV),1)
 	RUNTESTS_CFLAGS = -fprofile-arcs -ftest-coverage
 endif
 
-$(CHROMIUM_NAME): launcher.c
+ifneq ($(CHROMIUM_ARGS),)
+	, := ,
+	ARGS_FILE = args.h
+	override CPPFLAGS += -DCHROMIUM_ARGS
+endif
+
+$(CHROMIUM_NAME): launcher.c $(ARGS_FILE)
 	$(CC) -o $@ $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $< $(LDLIBS)
 
+$(ARGS_FILE):
+	echo "static char *default_system_flags[] = {" > $@
+	echo "$(addprefix \",$(addsuffix \"$(,),$(CHROMIUM_ARGS)))" >> $@
+	echo "NULL};" >> $@
+
 runtests: launcher_test.c minunit.h launcher.c
 	$(CC) -o $@ $(CPPFLAGS) $(CFLAGS) $(RUNTESTS_CFLAGS) $(LDFLAGS) $< $(LDLIBS)
 
@@ -38,4 +51,4 @@ uninstall:
 clean:
 	$(RM) $(CHROMIUM_NAME) runtests *.o *.{gcda,gcno,gcov}
 
-.PHONY: check install install-strip uninstall clean
+.PHONY: check install install-strip uninstall clean $(ARGS_FILE)
--- a/launcher.c
+++ b/launcher.c
@@ -5,6 +5,10 @@
 
 #include <glib.h>
 
+#ifdef CHROMIUM_ARGS
+#include "args.h"
+#endif
+
 static char *
 #ifdef TESTING
 real_default_system_flags_conf_path()
@@ -66,7 +70,7 @@ static void show_help(const char *system
   fprintf(
       stderr,
       "\n"
-      "Chromium launcher %s -- for Chromium help, see `man %s`\n"
+      CHROMIUM_APP " launcher %s -- for " CHROMIUM_APP " help, see `man %s`\n"
       "\n"
       "Custom flags are read in order from the following files:\n\n"
       "  %s\n  %s\n\n"
@@ -104,6 +108,12 @@ static int launcher(int argc, char const
   free(user_flags_conf_path);
 
   args = g_slist_append(args, g_strdup(CHROMIUM_BINARY));
+
+#ifdef CHROMIUM_ARGS
+  for (i = 0; default_system_flags[i] != NULL; i++)
+    args = g_slist_append(args, g_strdup(default_system_flags[i]));
+#endif
+
   args = g_slist_concat(args, flags);
 
   for (i = 1; i < argc; i++)