Commit Graph

30 Commits (next)

Author SHA1 Message Date
Orestis Floros 0b62129224
Remove unused headers
With help from
https://github.com/include-what-you-use/include-what-you-use/
2020-04-20 04:25:06 +02:00
Orestis Floros 3c522d9f2f
Sort includes in *.c files
Not enabling in .clang-format because it breaks headers files.

Used:
    IncludeCategories:
      - Regex:           '^<config'
        Priority:        0
      - Regex:           '^".*"'
        Priority:        1
      - Regex:           '^<(xcb|xkb|yajl|X11)'
        Priority:        3
      - Regex:           '.*'
        Priority:        2
2020-04-19 09:58:25 +02:00
Albert Safin d3976fee8c Code style: fix misaligned and trailing whitespaces 2020-02-21 02:06:48 +00:00
Michael Stapelberg 2d6e09a66a
i3-dump-log: make log message a little more clear (#3618)
This came up when trying to debug an issue.
2019-02-12 09:22:26 +01:00
Michael Stapelberg 1facb450c0 i3-dump-log: enable shmlog on demand
fixes #3055
2017-11-26 18:07:02 +01:00
Michael Stapelberg d968d39b27 Replace http:// with https:// where applicable
The testcases will be updated automatically in a separate commit.
2017-09-24 10:19:07 +02:00
Michael Stapelberg f354f53435 Ensure all *.[ch] files include config.h
Including config.h is necessary to get e.g. the _GNU_SOURCE define and
any other definitions that autoconf declares. Hence, config.h needs to
be included as the first header in each file.

This is done either via:
1. Including "common.h" (i3bar)
2. Including "libi3.h"
3. Including "all.h" (i3)
4. Including <config.h> directly

Also remove now-unused I3__FILE__, add copyright/license statement
where missing and switch include/all.h to #pragma once.
2016-10-23 21:09:24 +02:00
Michael Stapelberg 4a52a7e9fb Switch to autotools (GNU build system)
This commit probably comes as a surprise to some, given that one of i3’s
explicitly stated goals used to be “Do not use programs such as
autoconf/automake for configuration and creating unreadable/broken makefiles”.

I phrased this goal over 7 years ago, based largely on a grudge that I
inherited, which — as I’ve realized in the meantime — was largely held against
FOSS in general, and not actually nuanced criticism of autotools.

In the meantime, I have come to realize that the knee-jerk reaction of “I could
do this better!” (i.e. writing our own build system in this particular case) is
usually misguided, and nowadays I strongly suggest trying hard to fix the
existing system for the benefit of all existing and future users.

Further, I recently got to experience the other side of the coin, as I packaged
a new version of FreeRADIUS for Debian, which at the time of writing used
autoconf in combination with boilermake, a custom make-based build system that
only FreeRADIUS uses. Understanding the build system enough to fix issues and
enable parallel compilation took me an entire day. That time is time which
potentially every downstream maintainer needs to invest, and the resulting
knowledge cannot be applied to any other project.

Hence, I believe it’s a good idea switch i3 to autotools. Yes, it might be that
particular features were easier to implement/understand in our custom
Makefiles, and there might be individuals who have an easier time reading
through our custom Makefiles than learning autotools. All of these
considerations are outweighed by the benefits we get from using the same build
system as literally thousands of other FOSS software packages.

Aside from these somewhat philosophical considerations, there’s also practical
improvements which this change brings us. See the “changes” section below.

┌──────────────────────────────────────────────────────────────────────────────┐
│ new workflow                                                                 │
└──────────────────────────────────────────────────────────────────────────────┘

You can now build i3 like you build any other software package which uses
autotools. Here’s a memory refresher:

    autoreconf -fi
    mkdir -p build && cd build
    ../configure
    make -j8

(The autoreconf -fi step is unnecessary if you are building from a release
 tarball, but shouldn’t hurt either.)

┌──────────────────────────────────────────────────────────────────────────────┐
│ recommended reading                                                          │
└──────────────────────────────────────────────────────────────────────────────┘

I very much recommend reading “A Practitioner's Guide to GNU Autoconf,
Automake, and Libtool” by John Calcote (https://www.nostarch.com/autotools.htm).
That book is from 2010 and, AFAICT, is the most up to date comprehensive
description of autotools. Do not read older documentation. In particular, if a
document you’re reading mentions configure.in (deprecated filename) or
recursive make (now considered harmful), it’s likely outdated.

┌──────────────────────────────────────────────────────────────────────────────┐
│ changes                                                                      │
└──────────────────────────────────────────────────────────────────────────────┘

This commit implements the following new functionality/changes in behavior:

• We use the AX_ENABLE_BUILDDIR macro to enforce builds happening in a separate
  directory. This is a prerequisite for the AX_EXTEND_SRCDIR macro and building
  in a separate directory is common practice anyway. In case this causes any
  trouble when packaging i3 for your distribution, please let me know.

• “make check” runs the i3 testsuite.
  You can still use ./testcases/complete-run.pl to get the interactive progress
  output.

• “make distcheck” (runs testsuite on “make dist” result, tiny bit quicker
  feedback cycle than waiting for the travis build to catch the issue).

• “make uninstall” (occasionally requested by users who compile from source)

• “make” will build manpages/docs by default if the tools are installed.
  Conversely, manpages/docs are not tried to be built for users who don’t want
  to install all these dependencies to get started hacking on i3.

• non-release builds will enable address sanitizer by default. Use the
  --disable-sanitizers configure option to turn off all sanitizers, and see
  --help for available sanitizers.

• Support for pre-compiled headers (PCH) has been dropped for now in the
  interest of simplicitly. Maybe we can re-add it later.

• coverage reports are now generated using “make check-code-coverage”, which
  requires specifying --enable-code-coverage when calling configure.

┌──────────────────────────────────────────────────────────────────────────────┐
│ build system feature parity/testing                                          │
└──────────────────────────────────────────────────────────────────────────────┘

In addition to what’s described above, I tested the following features:

• “make install” installs the same files (plus documentation and manpages)
  cd i3-old && make install PREFIX=/tmp/inst/old
  cd i3-new && ./configure --prefix=/tmp/inst/new
  cd /tmp/inst
  (cd old && for f in $(find); do [ -e "../new/$f" ] || echo "$f missing"; done)

• make dist generates a tarball which includes the same files
  cd i3-old && make dist
  cd i3-new/x86_64-pc-linux-gnu && make dist
  colordiff -u <(tar tf i3-old/i3-4.12.tar.bz2 | sort) \
               <(tar tf i3-new/x86_64-pc-linux-gnu/i3-4.12.tar.gz | sort)
  There are some expected differences:
  • Some files have been renamed (e.g. the new etc/ and share/ subdirectories)
  • Some files will now be generated at build-time, so only their corresponding
    .in file is shipped (e.g. testcases/complete-run.pl)
  • The generated parser files are shipped in the dist tarball (they only
    depend on the parser-specs/* files, not on the target system)
  • autotools infrastructure is shipped (e.g. “configure”, “missing”, etc.)

• DLOG and ELOG statements still produce the same file name in logfiles

• Listing source code in gdb still works.

• gdb backtraces contain the i3-<version> path component

• release.sh still works

• version embedding
  1. git checkout shows “4.12-136-gf720023 (2016-10-10, branch "autotools")”
  2. tarball of a git version shows “4.12-non-git”
  3. release tarball shows 4.13

• debug mode is enabled by default for non-release builds

• enabling verbose builds via V=1

┌──────────────────────────────────────────────────────────────────────────────┐
│ speed                                                                        │
└──────────────────────────────────────────────────────────────────────────────┘

There is no noticeable difference in compilation speed itself (of binaries,
documentation and manpages):

i3-old $ time make all docs mans -j8
make all docs mans -j8  28.92s user 2.15s system 640% cpu 4.852 total

i3-new $ time make -j8
make -j8  27.08s user 1.92s system 620% cpu 4.669 total

In terms of one-time costs:
configuring the build system (../configure) takes about 2.7s on my machine,
generating the build system (autoreconf -fi) takes about 3.1s on my machine.

┌──────────────────────────────────────────────────────────────────────────────┐
│ m4 macros                                                                    │
└──────────────────────────────────────────────────────────────────────────────┘

All files in m4/ have been copied from the autoconf-archive package in version
b6aeb1988f4b6c78bf39d97b6c4f6e1d594d59b9 and should be updated whenever they
change.

This commit has been tested with autoconf 2.69 and automake 1.15.
2016-10-23 21:09:21 +02:00
Michael Stapelberg 9bf346c7a0 Remove compatibility definitions for xcb-util < 0.3.8 (#2473)
Even Debian oldstable has xcb-util 0.3.8.
2016-09-24 09:48:32 -07:00
Christopher Zimmermann 1322af1e4f Don't use pthread on OpenBSD
since OpenBSD pthread does not support pthread_condattr_setpshared().
This patch could also stay in the OpenBSD ports tree or depend on a
configure test macro rather than defined __OpenBSD__.
2016-06-11 14:47:26 +02:00
Michael Stapelberg 55bc2ae6a9 i3-dump-log: explicitly free shmname
Reduces memory usage and makes LeakSanitizer more quiet.
2016-01-08 20:17:34 +01:00
Deiz 884214f14f Update copyright notices and get rid of ranges
The script used to make these changes can be found at:

   https://gist.github.com/Deiz/32322020f76d23e2bf8f
2015-04-20 17:50:21 -04:00
Thomas Anderson 196e1d0971 Respect EXEC_PREFIX and a users' choice of PKG_CONFIG.
The Makefiles should put binaries in $(EXEC_PREFIX) and
architecture-independent files in $(PREFIX). Also a user may have a
prefixed- pkg-config, as in the case of cross compiling on Exherbo
Linux, so respect the well-accepted $(PKG_CONFIG) variable for this
purpose.
2015-04-12 17:59:30 -07:00
hwangcc 42515308e7 Add a safe wrapper for write and fix some warnings
1. Add a function writeall and make swrite wrap that function. Use either writeall or swrite, depending on whether we want to exit on errors or not.
2. Fix warnings when compiling with a higher optimisation level.
(CFLAGS ?= -pipe -O3 -march=native -mtune=native -freorder-blocks-and-partition)

Signed-off-by: hwangcc <hwangcc@csie.nctu.edu.tw>
2015-03-29 10:22:34 +08:00
Michael Stapelberg 9200094203 format **/*.c with clang-format-3.5
This has multiple effects:

1) The i3 codebase is now consistently formatted. clang-format uncovered
   plenty of places where inconsistent code made it into our code base.

2) When writing code, you don’t need to think or worry about our coding
   style. Write it in yours, then run clang-format-3.5

3) When submitting patches, we don’t need to argue about coding style.

The basic idea is that we don’t want to care about _how_ we write the
code, but _what_ it does :). The coding style that we use is defined in
the .clang-format config file and is based on the google style, but
adapted in such a way that the number of modifications to the i3 code
base is minimal.
2014-06-15 19:07:02 +02:00
Michael Stapelberg d3beff2339 make i3bar use libi3’s root_atom_contents()
This removes code duplication, which will be useful for a subsequent
commit.

Furthermore, we now don’t open X11 connections unnecessarily in some
corner cases.
2013-11-22 15:48:45 +01:00
Sascha Kruse 5a567057ab i3-dump-log/main.c: error handling for write(...) 2012-12-24 15:11:19 +01:00
Axel Wagner 4273db0444 i3-dump-log: Correct comment to reflect truth 2012-12-14 21:46:40 +01:00
Michael Stapelberg 4636eb840d fix compilation with older xcb-util with -DXCB_COMPAT (Thanks okraits) 2012-09-03 14:55:27 +02:00
Fernando Tarlá Cardoso Lemos 6ff3f7abad libi3: Implement Pango rendering 2012-08-13 11:39:30 +02:00
Michael Stapelberg e68a8dd86c shm-logging: implement i3-dump-log -f (follow)
This changes the SHM log format, it doesn’t use 0-bytes to separate
entries anymore. Instead of using lots of printf() calls in i3-dump-log,
we now do precisely one big write().

So, to be clear: i3-dump-log and i3 both need to be upgraded.
Mismatching versions will lead to garbage output (no crashes of i3, just
garbage output).

The -f flag uses an inter-process pthread_cond_t in the shared memory
header to broadcast the arrival of new messages to all i3-dump-log
processes. This internally uses futexes and thus doesn’t even mean a
kernel call in most cases. inter-process pthread_cond_ts require NPTL
(the Native Posix Thread Library, introduce in Linux 2.6).
2012-08-13 01:06:09 +02:00
Michael Stapelberg 0f22b105c1 Fix linking by linking libi3 first and its dependencies afterwards
Interestingly, compilation was only broken on some systems apparently
2012-07-23 10:56:44 +02:00
Quentin Glidic 0b4ee7a1da common.mk: Split XCB common flags 2012-07-23 00:12:55 +02:00
Quentin Glidic c7029a5e21 common.mk: Introduce I3_*FLAGS
CPPFLGES, CFLAGS and LDFLAGS should be user variables
We now provide default flags but use I3_*FLAGS flags for our own needed
flags

Also reoder lib flags a bit
2012-07-22 23:53:49 +02:00
Quentin Glidic 3b1b72ecbb *.mk: Support passing specific CFLAGS/LIBS 2012-07-22 23:53:13 +02:00
Quentin Glidic e452acb30e Add stub Makefiles to allow subdir make calls 2012-07-22 19:57:48 +02:00
Quentin Glidic 4c0b519976 Move i3-dump-log to the new Makefile layout 2012-07-22 19:57:22 +02:00
Michael Stapelberg 1b536d70cc Improve the main error message of i3-dump-log 2012-05-09 19:46:44 +02:00
Michael Stapelberg dee7c07ad2 shmlog: store meta information in the buffer itself, store path as X11 atom
This makes i3-dump-log completely independent of a running i3 instance.
2012-01-06 23:40:07 +00:00
Michael Stapelberg 0af05710b2 add i3-dump-log, a tool to dump the SHM log 2011-12-10 11:27:40 +00:00