From e52293d78a61b7fa61b0e1589b60a544166c1a4e Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Sun, 11 Feb 2024 22:13:53 +0100 Subject: tweak README to add architecture, tweak makefile to make fast. --- README.md | 27 ++++++++++++++++++++------- makefile | 53 +++++++++++++++++++---------------------------------- rose | Bin 42896 -> 44856 bytes 3 files changed, 39 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 77b4a15..104e778 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,6 @@ Rosenrot is a small browser forked from an earlier version of [rose](https://git ![](https://raw.githubusercontent.com/NunoSempere/rosenrot-browser/master/images/6-hello-world.png) -![](https://raw.githubusercontent.com/NunoSempere/rosenrot-browser/master/images/0-architecture.png) - ### Installation You can see detailed instructions [here](./user-scripts/ubuntu-20.04/install-with-dependencies.sh), for Ubuntu 20.04 in particular—though they should generalize easily to other distributions. Or a video installing rosenrot in a fresh Ubuntu 20.04 virtual machine [here](https://video.nunosempere.com/w/t3oAvJLPHTSAMViQ6zbwTV). @@ -52,12 +50,27 @@ You can also create a rose.desktop file so that it will show up in your desktop You can see some screenshots in the [images](./images) folder. +## Architecture + +![](https://raw.githubusercontent.com/NunoSempere/rosenrot-browser/master/images/0-architecture.png) + ## Relationship with [rose](https://github.com/mini-rose/rose) - Rose is a minimal browser based on webkit2gtk. Previously, it described itself as aiming to be a "basement for creating your own browser using [the] gtk and webkit libraries". - Rosenrot is my (@NunoSempere's) fork from rose. It has accumulated quality of life features/cruft that I like, like a "readability" plugin that simplifies annoying websites like [Matt Levine's Money Stuff newsletter](https://www.bloomberg.com/opinion/articles/2022-10-18/matt-levine-s-money-stuff-credit-suisse-was-a-reverse-meme-stock). It also incorporates ad-blocking. - Rosenrot is also a song by the German hardcore rock band [Rammstein](https://www.youtube.com/watch?v=af59U2BRRAU). +## Comparison with [surf](https://git.suckless.org/surf/file/surf.c.html) + +- Surf is another browser based on GTK/Webkit, from the suckless community. +- It is more complex: surf.c has [2170](https://git.suckless.org/surf/file/surf.c.html) lines, vs rose.c's [454](https://git.nunosempere.com/open.source/rosenrot/src/branch/master/rose.c) +- I find its code messier and harder to understand +- Conversely, surf has significantly more configuration options, and digs deeper into webkit internals. +- Anecdotically, surf feels slower, though I haven't tested this rigorously. +- surf has a larger community, with patches and modifications +- surf is more opinionated, but also less amateurish. For instance, rosenrot +- My recommendation would be to use rose, and if you find some feature missing, either look how surf does it and import it to rose, or move to surf. + ### Contribute - Contribute upstream to [github.com/mini-rose/rose](https://github.com/mini-rose/) for core functionality changes. @@ -84,16 +97,14 @@ About my own system: #### Quality of life: -- [ ] Add css for js alerts - - [x] Add custom alert whose css can be customized - - [ ] Debug problems, e.g., this version is non-blocking. -- [ ] Figure out better way to have plugins -- [ ] Double check newtab/next-tab behavior - [ ] Document creating new applications, e.g., as in [Asana for Linux](https://git.nunosempere.com/NunoSempere/asana-for-linux) - [ ] Add list of similar projects: #### Maintenance +- [x] Add css for js alerts + - [x] Add custom alert whose css can be customized + - [ ] ~~Debug problems, e.g., this version is non-blocking.~~ => will leave as is - [ ] Set [`webkit_web_context_set_sandbox_enabled`](), as recommended [here]() - [ ] Use something other than Whatsapp as an example syslink. - [ ] Fix bug about distorted audio. Maybe related to [this pipewire issue]()? @@ -101,6 +112,8 @@ About my own system: #### Previously done +- [x] Figure out better way to have plugins => stand_in code seems superfluous +- [x] Double check newtab/next-tab behavior => custom style now loading correctly. - [x] Add a shortcut for hiding the search tab. => Already exists: Ctrl+K - [x] Find out what each of the css elements refers to. => done, see make inspect - [x] Figure out if downloading files is doable. => it is diff --git a/makefile b/makefile index 4413e59..7c60183 100644 --- a/makefile +++ b/makefile @@ -1,31 +1,19 @@ -# make -# make build -# (sudo) make install -# make format -# make clean -# make uninstall -## C compiler -CC=gcc # gcc: more options. Also I don't know whether tcc has error messages/debug options. -## CC=tcc # tcc: much faster compilation -## other alternatives; clang, zig cc +# C compiler +CC=gcc # other options: tcc, clang, zig cc WARNINGS=-Wall -OPTIMIZED=-O3 #-Ofast -LOCAL=-march=native # binary will not be compatible with other computers, but may be much faster - -## Main file -SRC=rose.c - -## Dependencies -DEPS='webkit2gtk-4.0' DEBUG= #'-g' +OPTIMIZED_SOME=-O3 +OPTIMIZED_MORE=-Ofast -march=native -funit-at-a-time -flto # binary will not be compatible with other computers, but may be much faster +# Dependencies +DEPS='webkit2gtk-4.0' INCS=`pkg-config --cflags ${DEPS}` LIBS=`pkg-config --libs ${DEPS}` -## Optional adblocking -## depends on https://github.com/jun7/wyebadblock -ADBLOCK=#'-L/usr/lib/wyebrowser/adblock.so' +# Code +SRC=rose.c +CONFIG=config.h ## Plugins LIBRE_REDIRECT=./plugins/libre_redirect/libre_redirect.c ./plugins/libre_redirect/str_replace_start.c ./plugins/libre_redirect/str_init.c @@ -33,22 +21,14 @@ CUSTOM_STYLES=./plugins/style/style.c READABILITY=./plugins/readability/readability.c SHORTCUTS=./plugins/shortcuts/shortcuts.c STAND_IN=./plugins/stand_in/stand_in.c # gives function definitions for the above, which do nothing - PLUGINS=$(LIBRE_REDIRECT) $(READABILITY) $(CUSTOM_STYLES) $(SHORTCUTS) -# PLUGINS=$(STAND_IN) -# Note that if you want some plugins but not others, -# You should edit the stand_in.c file - -# CONFIG -CONFIG=config.h -# cp -f config.def.h config.h +ADBLOCK='-L/usr/lib/wyebrowser/adblock.so' ## optional adblocking; depends on https://github.com/jun7/wyebadblock ## Formatter STYLE_BLUEPRINT=webkit FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) -## Commands -## Hardcoded paths +# Change hardcoded paths when building ## Cache USER=`whoami` DEFAULT_CACHE_DIR=/home/loki/.cache/rose @@ -71,11 +51,16 @@ build: $(SRC) $(PLUGINS) $(CONFIG) sed -i "s|$(DEFAULT_DIR)|$(CURRENT_DIR)|g" {} + # Compile rosenrot GIO_MODULE_DIR=/usr/lib/x86_64-linux-gnu/gio/modules/ - $(CC) $(WARNINGS) $(OPTIMIZED) $(DEBUG) $(INCS) $(PLUGINS) $(SRC) -o rose $(LIBS) $(ADBLOCK) + $(CC) $(WARNINGS) $(OPTIMIZED_SOME) $(DEBUG) $(INCS) $(PLUGINS) $(SRC) -o rose $(LIBS) $(ADBLOCK) -local: $(SRC) $(PLUGINS) $(CONFIG) +fast: $(SRC) $(PLUGINS) $(CONFIG) + rm -f *.gcda GIO_MODULE_DIR=/usr/lib/x86_64-linux-gnu/gio/modules/ - $(CC) $(WARNINGS) $(OPTIMIZED) $(LOCAL) $(INCS) $(PLUGINS) $(SRC) -o rose $(LIBS) $(ADBLOCK) + $(CC) $(WARNINGS) $(OPTIMIZED_MORE) -fprofile-generate $(INCS) $(PLUGINS) $(SRC) -o rose $(LIBS) $(ADBLOCK) + @echo "Now use the browser for a while to gather some profiling data" + ./rose + $(CC) $(WARNINGS) $(OPTIMIZED_MORE) -fprofile-use $(INCS) $(PLUGINS) $(SRC) -o rose $(LIBS) $(ADBLOCK) + rm -f *.gcda lint: clang-tidy $(SRC) $(PLUGINS) -- -Wall -O3 `pkg-config --cflags 'webkit2gtk-4.0'` -o rose `pkg-config --libs 'webkit2gtk-4.0'` diff --git a/rose b/rose index dfb2d6e..b98aa8c 100755 Binary files a/rose and b/rose differ -- cgit v1.2.3