Commit Graph

147 Commits

Author SHA1 Message Date
Ben Wiederhake
e1baf9ec92 Meta: Refresh ALL_THE_DEBUG_MACROS set 2020-12-01 11:06:53 +01:00
Ben Wiederhake
f82b2948cf Meta: Fix BMP_DEBUG, and always build on CI 2020-12-01 11:06:53 +01:00
Ben Wiederhake
2b3113cd2a Meta: Fix ACPI_DEBUG, and always build on CI 2020-12-01 11:06:53 +01:00
Tom
78f1b5e359 Kernel: Fix some problems with Thread::wait_on and Lock
This changes the Thread::wait_on function to not enable interrupts
upon leaving, which caused some problems with page fault handlers
and in other situations. It may now be called from critical
sections, with interrupts enabled or disabled, and returns to the
same state.

This also requires some fixes to Lock. To aid debugging, a new
define LOCK_DEBUG is added that enables checking for Lock leaks
upon finalization of a Thread.
2020-12-01 09:48:34 +01:00
Emanuel Sprung
55450055d8 LibRegex: Add a regular expression library
This commit is a mix of several commits, squashed into one because the
commits before 'Move regex to own Library and fix all the broken stuff'
were not fixable in any elegant way.
The commits are listed below for "historical" purposes:

- AK: Add options/flags and Errors for regular expressions

Flags can be provided for any possible flavour by adding a new scoped enum.
Handling of flags is done by templated Options class and the overloaded
'|' and '&' operators.

- AK: Add Lexer for regular expressions

The lexer parses the input and extracts tokens needed to parse a regular
expression.

- AK: Add regex Parser and PosixExtendedParser

This patchset adds a abstract parser class that can be derived to implement
different parsers. A parser produces bytecode to be executed within the
regex matcher.

- AK: Add regex matcher

This patchset adds an regex matcher based on the principles of the T-REX VM.
The bytecode pruduced by the respective Parser is put into the matcher and
the VM will recursively execute the bytecode according to the available OpCodes.
Possible improvement: the recursion could be replaced by multi threading capabilities.

To match a Regular expression, e.g. for the Posix standard regular expression matcher
use the following API:

```
Pattern<PosixExtendedParser> pattern("^.*$");
auto result = pattern.match("Well, hello friends!\nHello World!"); // Match whole needle

EXPECT(result.count == 1);
EXPECT(result.matches.at(0).view.starts_with("Well"));
EXPECT(result.matches.at(0).view.end() == "!");

result = pattern.match("Well, hello friends!\nHello World!", PosixFlags::Multiline); // Match line by line

EXPECT(result.count == 2);
EXPECT(result.matches.at(0).view == "Well, hello friends!");
EXPECT(result.matches.at(1).view == "Hello World!");

EXPECT(pattern.has_match("Well,....")); // Just check if match without a result, which saves some resources.
```

- AK: Rework regex to work with opcodes objects

This patchsets reworks the matcher to work on a more structured base.
For that an abstract OpCode class and derived classes for the specific
OpCodes have been added. The respective opcode logic is contained in
each respective execute() method.

- AK: Add benchmark for regex

- AK: Some optimization in regex for runtime and memory

- LibRegex: Move regex to own Library and fix all the broken stuff

Now regex works again and grep utility is also in place for testing.
This commit also fixes the use of regex.h in C by making `regex_t`
an opaque (-ish) type, which makes its behaviour consistent between
C and C++ compilers.
Previously, <regex.h> would've blown C compilers up, and even if it
didn't, would've caused a leak in C code, and not in C++ code (due to
the existence of `OwnPtr` inside the struct).

To make this whole ordeal easier to deal with (for now), this pulls the
definitions of `reg*()` into LibRegex.

pros:
- The circular dependency between LibC and LibRegex is broken
- Eaiser to test (without accidentally pulling in the host's libc!)

cons:
- Using any of the regex.h functions will require the user to link -lregex
- The symbols will be missing from libc, which will be a big surprise
  down the line (especially with shared libs).

Co-Authored-By: Ali Mohammad Pur <ali.mpfard@gmail.com>
2020-11-27 21:32:41 +01:00
Andreas Kling
bb9c705fc2 Ext2FS: Move some EXT2_DEBUG logging behind EXT2_VERY_DEBUG
This makes the build actually somewhat usable with EXT2_DEBUG. :^)
2020-11-23 16:08:42 +01:00
Lenny Maiorani
ad72158ee0 CMake: compile_commands.json output
Problem:
- CMake is not outputting `compile_commands.json`.
- `compile_commands.json` is used by build integration tooling such as
  `clang-tidy`.

Solution:
- Enable `CMAKE_EXPORT_COMPILE_COMMANDS` option so that the file is
  output.
2020-11-12 10:19:43 +01:00
Linus Groh
15642874f3 LibJS: Support all line terminators (LF, CR, LS, PS)
https://tc39.es/ecma262/#sec-line-terminators
2020-10-22 10:06:30 +02:00
Tibor Nagy
b85af075b7 Build: Emit paths in macros and debug sections relative to repo root
To avoid including paths from the build environment in the binaries.
A step towards having reproducible builds.
2020-10-08 10:04:02 +02:00
Andreas Kling
0245e0f03a DevTools: Remove VisualBuilder and FormCompiler
This functionality is being moved to HackStudio so let's not confuse
people by keeping the old stuff around.
2020-10-01 21:07:12 +02:00
Andreas Kling
f67c876df0 Build+TextEditor: Add a compile_json_gui() CMake helper
This makes it easier to include JSON GUI declarations in any app. :^)
2020-09-14 16:16:36 +02:00
Andreas Kling
2e547ce7a3 TextEditor: Move the main window UI to JSON
This is our first client of the new JSON GUI declaration thingy.
The skeleton of the TextEditor app GUI is now declared separately from
the C++ logic, and we use the Core::Object::name() of widgets to locate
them once they have been instantiated by the GUI builder.
2020-09-14 16:16:36 +02:00
Andreas Kling
633e0bc944 Revert "Meta: Enable gcc warning about struct vs. class"
This reverts commit d25860f53c.

This broke the Travis build.
2020-09-12 14:49:29 +02:00
Ben Wiederhake
d25860f53c Meta: Enable gcc warning about struct vs. class
I know, the tags don't actually matter. However, clang warns by default,
and instead of disabling the warning for clang I'd rather enable the warning
for gcc.
2020-09-12 13:46:15 +02:00
Ben Wiederhake
04e3122526 HackStudio: Reduce debug spam 2020-09-12 13:46:15 +02:00
Ben Wiederhake
da966ac8d8 LibMarkdown: Make warning messages conditional
This is especially a problem during fuzzing.
2020-09-12 13:46:15 +02:00
Andreas Kling
e002cbb06b Build: Add some -Wno-unknown-warning-option flags to CXXFLAGS
Patch from Anonymous.
2020-09-01 12:00:53 +02:00
Ben Wiederhake
b29f4add6b Meta: Provide option to build with ALL debug macros 2020-08-30 09:43:49 +02:00
Ben Wiederhake
1d638c6a78 Meta: Enable -Wmissing-declarations
Concludes #3096.

Phew! From here on, build system and CI will ensure that all new code
defines compilation-unit-only code as 'static', and that dead code can
be found more easily. Also, this style encourages type checking
by suggesting that you put a proper declaration in a shared header.
2020-08-28 11:37:33 +02:00
Itamar
310063fed8 Meta: Install source files at /usr/src/serenity 2020-08-15 15:06:35 +02:00
Linus Groh
7072806234 Meta: Replace remaining LibM/math.h includes with math.h 2020-08-12 16:18:33 +02:00
Nico Weber
a9fb317a63 Build: Clang should get -Werror too
I accidentally removed it in a619943001 and #3002 only restored
it for gcc.
2020-08-05 17:29:15 +02:00
Brian Gianforcaro
5a984b811c Build: Re-enable -Werror when building with GCC
It looks like PR #2986 mistakenly removed this from both the
Clang and GCC CXX_FLAGS, when the intention seems to have been
to only disable it for Clang.
2020-08-05 12:07:20 +02:00
Nico Weber
a619943001 Build: Make things build with clang without needing local changes
Useful for sanitizer fuzzer builds.

clang doesn't have a -fconcepts switch (I'm guessing it just enables
concepts automatically with -std=c++2a, but I haven't checked),
and at least the version on my system doesn't understand
-Wno-deprecated-move, so pass these two flags only to gcc.
In return, disable -Woverloaded-virtual which fires in many places.

The preceding commits fixed the handful of -Wunused-private-field
warnings that clang emitted.
2020-08-04 17:42:08 +02:00
Nico Weber
d8b6314018 Build: Support make's and ninja's restat optimization
After running a build command, make by default stat()s the command's
output, and if it wasn't touched, then it cancels all build steps
that were scheduled only because this command was expected to change
the output.

Ninja has the same feature, but it's opt-in behind the per-command
"restat = 1" setting. However, CMake enables it by default for all
custom commands.

Use Meta/write-only-on-difference.sh to write the output to a temporary
file, and then copy the temporary file only to the final location if the
contents of the output have changed since last time.
write-only-on-difference.sh automatically creates the output's parent
directory, so stop doing that in CMake.

Reduces the number of build steps that run after touching a file
in LibCore from 522 to 312.

Since we now no longer trigger the CMake special case "If COMMAND
specifies an executable target name (created by the add_executable()
command), it will automatically be replaced by the location of the
executable created at build time", we now need to use qualified paths to
the generators.

Somewhat related to #2877.
2020-08-04 15:58:08 +02:00
Emanuele Torre
75a4b1a27e Build: Use -fconcepts flag to enable C++20 concepts. 2020-08-01 10:44:42 +02:00
Andreas Kling
dc4327c54b Build: Remove two unnecessary CXXFLAGS
Seems like we can build without these two flags now:

    -Wno-sized-deallocation
    -fno-sized-deallocation

I don't remember why they were needed in the first place.
2020-07-24 02:57:11 +02:00
Andreas Kling
91f25c8f91 Build: Build with minimal debug info (-g1)
This allows us to look up source file/line information from addresses
without bloating the build too much. It could probably be made smaller
with some tricks.
2020-07-21 19:08:01 +02:00
Stefano Cristiano
a1e1aa96fb Toolchain: Allow building using CMake on macOS 2020-07-13 08:46:44 +02:00
Linus Groh
4684e9a80f Build: Support GENERATED_SOURCES in serenity_{bin,libc}() as well 2020-06-21 20:24:28 +02:00
Emanuele Torre
22aa4cbf92 Build: rename image target => qemu-image
Also add a new `image` target which is just an alias to `qemu-image`.

This makes the CMakeLists.txt file more readable in my opinion.
2020-06-21 10:13:04 +02:00
Emanuele Torre
4a784d4d1b Meta: get rid of sync.sh using the technique used in the previous commit 2020-06-21 10:13:04 +02:00
Nico Weber
35c4a4971a CMake: Make the install step more zen
The "Installing $foo..." messages are just noise, so turn them off.
2020-06-19 20:34:25 +02:00
Nico Weber
e162b59a5e cmake: Make setting CMAKE_BUILD_TYPE an error.
I tried setting it to Release, then noticed that it didn't build
due to gcc's optimizer-level dependent warnings and -Werror, then
started fixing the warnings for a bit (all false positives),
then looked at the global CMakeLists.txt and realized that the
default build is aleady using compiler optimizations. It looks like
people aren't supposed to change this, so make that explicit to
be friendly to people familiar with cmake but new to serenity.
2020-06-06 10:04:29 +02:00
Paul Redmond
4d4e578edf Ports: Fix CMake-based ports
The SDL port failed to build because the CMake toolchain filed pointed
to the old root. Now the toolchain file assumes that the Root is in
Build/Root.

Additionally, the AK/ and Kernel/ headers need to be installed in the
root too.
2020-05-29 20:21:10 +02:00
Emanuele Torre
83c11434e4 CMake: Add convenience targets to run lint-shell-scripts and check-style 2020-05-29 07:59:45 +02:00
etaIneLp
330aecb5d8
Build: Use a separate byproduct name for the GRUB disk image (#2424)
The grub-image target no longer conflicts with normal image target.
This unbreaks using CMake with Ninja.

Fixes #2423.
2020-05-28 10:08:38 +02:00
etaIneLp
775d44efb5 Build: Add grub-image target to CMake 2020-05-28 00:50:55 +02:00
Andreas Kling
250c3b363d Revert "Build: Include headers from LibC, LibM, and LibPthread with -isystem"
This reverts commit c1eb744ff0.
2020-05-20 16:24:26 +02:00
Andrew Kaster
c1eb744ff0 Build: Include headers from LibC, LibM, and LibPthread with -isystem
Make sure that userspace is always referencing "system" headers in a way
that would build on target :). This means removing the explicit
include_directories of Libraries/LibC in favor of having it export its
headers as SYSTEM. Also remove a redundant include_directories of
Libraries in the 'serenity build' part of the build script. It's already
set at the top.

This causes issues for the Kernel, and for crt0.o. These special cases
are handled individually.
2020-05-20 08:37:50 +02:00
Dominik Madarasz
b7357d1a3a Build: Use -Wno-expansion-to-defined 2020-05-16 22:41:09 +02:00
Andreas Kling
c12cfdea87 Build: Remove -Wno-volatile flag
I've fixed all the warnings about invalid use of the "volatile" keyword
so it should be fine to enable this now.
2020-05-16 11:35:16 +02:00
Andreas Kling
76bcd284f9 AK: Remove experimental clang -Wconsumed stuff
This stopped working quite some time ago due to Clang losing track of
typestates for some reason and everything becoming "unknown".

Since we're primarily using GCC anyway, it doesn't seem worth it to try
and maintain this non-working experiment for a secondary compiler.

Also it doesn't look like the Clang team is actively maintaining this
flag anyway. So good-bye, -Wconsumed. :/
2020-05-16 10:55:54 +02:00
Shannon Booth
3d153e5ed3 Build: Disable deprecated volatile warning
We will probably need to fix this at some stage, but for now let's just
disable the warning.
2020-05-16 09:51:31 +02:00
Sergey Bugaev
32f8e57834 Build: Ask GCC to always emit colorful diagnostics 2020-05-15 10:01:35 +02:00
Sergey Bugaev
486540fa90 Build: Allow using CMake 3.16
Because apparently that's what a lot of people have,
and they report it works fine.
2020-05-15 10:01:35 +02:00
Sergey Bugaev
450a2a0f9c Build: Switch to CMake :^)
Closes https://github.com/SerenityOS/serenity/issues/2080
2020-05-14 20:15:18 +02:00