Commit graph

32 commits

Author SHA1 Message Date
Vadim Peretokin
2d4d9b9ca5
infrastructure: harden the Widgets audit script and refresh its baseline (#9516)
#### Brief overview of PR changes/additions

Follow-up to #9508. Hardens `cmake/audit-core-widgets.sh` against five
silent-wrong-count failure modes (each reproduced by running the script
against crafted inputs), and refreshes the committed baseline/report to
the current count.

- **CMakeLists parser** now strips `#` comments and a trailing `\r`, and
tracks multi-line `list(APPEND mudlet_SRCS ...)` blocks. Previously a
`)` inside a comment truncated the file list, a commented-out filename
got audited, a wrapped `APPEND` dropped its continuation lines, and a
CRLF checkout only partially parsed.
- **Comment/string stripper** now matches a `/* ... */` comment whose
body contains `*` (the `/** ... */` one-liner that used to latch the
scanner into comment mode and silently swallow the rest of a file), and
hard-fails (exit 2) on an unterminated comment at EOF rather than
under-counting.
- **`--enforce`** is now a real gate: a source file listed in
`CMakeLists.txt` but missing from disk is fatal, and the baseline is
strict-parsed (bare integer on line 1). The old `tr -cd 0-9` pooled
every digit in the file, so a `# updated 2026-07-20` comment produced a
baseline like `20260720158` that out-ranked any real count and passed
forever.
- **Qt sanity**: if the `QtGui`/`QtCore` header listings come out empty
while `QtWidgets` is non-empty (a partial/broken Qt), the script aborts
instead of miscounting relocated forwarder headers (`qaction.h`,
`qshortcut.h`, ...) as Widgets dependencies.
- **Baseline + report refreshed** from `160` to `158`: #9507 decoupled
the telnet engine from UI dialogs after the original report was
generated, so `ctelnet.cpp`/`ctelnet.h` are now clean.

The script stays POSIX `sh`, deterministic (`LC_ALL=C`), and fast
(~0.2s). The parser change is count-neutral: old and new parsers produce
an identical 392-file list on the current `src/CMakeLists.txt`.

#### Motivation for adding to Mudlet

The audit becomes a CI gate once the count reaches 0 (#8681, #9011).
Before that, it must never report a wrong number quietly - every one of
these paths could have made the count drift (up or down) with no visible
error, which would erode trust in the gate. Loud failure beats a
silently passing check.

#### Other info (issues closed, discussion etc)

Follow-up to #9508. No build required (shell + docs only). Self-tested
with a 17-assertion harness that crafts each proven failure input and
confirms the fixed script returns the correct count or exits 2, while
the pre-fix script mis-parses.

**Test case:**

```
bash cmake/audit-core-widgets.sh --summary
# expected: mudlet_core Qt Widgets audit: 158 of 392 files depend on Qt Widgets

bash cmake/audit-core-widgets.sh --enforce
# expected: mudlet_core Qt Widgets audit: 158 offending files (baseline 158).  (exit 0)
```

Assisted-by: Claude:claude-opus-4-8
2026-07-26 18:05:59 +02:00
Vadim Peretokin
113d1fe930
infrastructure: add Qt Widgets dependency audit for the core library (#9508)
#### Brief overview of PR changes/additions

- Adds `cmake/audit-core-widgets.sh`: measures how many `mudlet_core`
source files depend on Qt Widgets (direct QtWidgets includes plus
class-symbol references, with the QtWidgets header/class sets derived
from the installed Qt's module layout).
- Commits the generated `docs/libmudlet-widgets-report.md` (per-file
breakdown, regenerated via the script) and
`cmake/core-widgets-baseline.txt`.
- Script modes: Markdown report (default), `--summary` one-liner,
`--enforce` ratchet that fails if the count rises above the baseline.

#### Motivation for adding to Mudlet

Gives the libmudlet split a measurable metric - files in `mudlet_core`
still coupled to Qt Widgets - and a future CI ratchet to stop that
number from creeping back up as it is driven down.

#### Other info (issues closed, discussion etc)

Part of the libmudlet refactor discussed in #8681 and #9011. Current
baseline: 160 of 392 `mudlet_core` files depend on Qt Widgets.
`--enforce` is intended to become a CI guard in a follow-up once wired
into a workflow; output is byte-deterministic (pinned C locale) so the
committed report regenerates identically on any machine.

Assisted-by: Claude:claude-fable-5

**Test case:**

```
bash cmake/audit-core-widgets.sh --summary
```

Expected output: `mudlet_core Qt Widgets audit: 160 of 392 files depend
on Qt Widgets`. Also `bash cmake/audit-core-widgets.sh >
docs/libmudlet-widgets-report.md` should leave the committed report
unchanged, and `bash cmake/audit-core-widgets.sh --enforce` should exit
0.
2026-07-26 10:32:26 +02:00
Stephen Lyons
68aa3e63cf
Infrastructure: update edbee-lib submodule & use system oniguruma if present (#9156)
#### Brief overview of PR changes/additions
With edbee-lib being revised to use a system oniguruma library instead
of compiling it from bundled source code (a change suggested by myself)
update our build processes to install the required dependency in order
for the CMake build process to make use of this change.

#### Motivation for adding to Mudlet
To make edbee-lib, and thus Mudlet, use a system provided library if it
is available rather than building it from source. This should decrease
the time to compile the application a little and to improve the
situation for packagers of the Mudlet application.

#### Other info (issues closed, discussion etc)
The change required a `FindONIGURUMA.cmake` file and I created one from
our `FindPUGIXML.cmake` file to suggest upstream to the `edbee-lib`
project, so that it could use the file when its license is MIT whereas
the Mudlet one is GPU 2.0 or later and not compatible in that direction
I have negotiated with our creators of the latter file to release it
with a public domain (a.k.a. Creative Commons Zero) waiver and I have
added suitable header text to both files.

---------

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2026-04-06 16:28:46 +01:00
Stephen Lyons
4db76845d5
Fix: handle CMake aliasing problems when PCRE2::8BIT is itself an alias (#9128)
#### Brief overview of PR changes/additions
Detect when the library target `PCRE2::8BIT` is an alias and in that
case assign the `PCRE2::PCRE2` alias to the target of that alias. This
is required because CMake does not allow an alias to an alias. This
happens for the FreeBSD OS.

#### Motivation for adding to Mudlet
Solve CMake error of the form:
> add_library cannot create ALIAS target "PCRE2::PCRE2" because target
"PCRE2::8BIT" is itself an ALIAS.

for FreeBSD.

#### Other info (issues closed, discussion etc)
The issue hasn't arise for any other OS so far but it could!

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2026-03-30 00:06:42 +01:00
Stephen Lyons
67261edf9a
Infrastructure: allow CMake initGitSubmodule.cmake to act recursively (#8717)
#### Brief overview of PR changes/additions
Add a `RECURSIVE` option to this CMake function (`initGitSubmodule()`)
to recursively clone all the submodules of a submodule.

#### Motivation for adding to Mudlet
To allow CMake builds of Mudlet to pull in a submodule that itself
contains its own submodules. This is intended to aid a revision to the
meta-build system so that end-users will not have to clone every git
submodule themselves but instead to restore the original design that
would do it. This also means it would no longer be needed to use the
`submodules: recursive` option in the GH `actions/checkout@v6` Action -
thereby speeding things up and reducing the disk space used a bit.

#### Other info (issues closed, discussion etc)
I need this to fixup developer builds - particular on Windows - where
and when the Sentry crash-reporting functionality is NOT required given
that it uses a number of submodules and subsubmodules of its own.

As presented in this PR the new option is not actually used so should
not alter the build in any way (other than to also add the "normal" text
output from running any `git submodule update --init` action which were
previously discarded0 but it is a section of code that can be done as a
separate item.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2025-12-29 15:16:28 +00:00
Mike Conley
f06096fd0e
Add: Optional static analysis during build (#8708)
#### Brief overview of PR changes/additions

Adds optional static analysis integration to the CMake build system.
Developers can now enable clang-tidy and cppcheck during compilation by
passing `-DENABLE_STATIC_ANALYSIS=ON` to cmake. The analysis runs
automatically during builds and helps catch bugs, performance issues,
and code quality problems.

**Changes:**
- New `cmake/StaticAnalysis.cmake` module with clang-tidy and cppcheck
configuration
- Enabled by default in `CMakeLists.txt` but requires opt-in flag to
activate
- Updated AI assistant instructions with wiki reference
- Performs performance-*, bugprone-*, and clang-analyzer-* checks

#### Motivation for adding to Mudlet

Static analysis helps developers catch issues early without requiring
manual code review:
- **Bug detection**: Identifies null pointer dereferences, memory leaks,
and logic errors
- **Performance**: Finds unnecessary copies and inefficient patterns
- **Code quality**: Enforces best practices and consistent patterns
- **Developer experience**: Optional feature - doesn't impact regular
builds

Mudlet already uses static analysis in CI, but this makes it available
locally for faster feedback during development.

#### Other info (issues closed, discussion etc)

- Static analysis is **disabled by default** - developers opt-in with
the cmake flag
- Build output can be captured and filtered to focus on Mudlet-specific
issues
- Uses existing `.clang-tidy` configuration already in the repository
- Wiki documentation will be added at
https://wiki.mudlet.org/w/Compiling_Mudlet#Static_Analysis
2025-12-28 23:12:20 +01:00
Vadim Peretokin
df035f163c
Improve: Migrate C++ regex engine from PCRE to PCRE2 (#8533)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
     the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Replace the deprecated PCRE library with its successor PCRE2 for all C++
regex operations in triggers and aliases. This modernizes the regex
engine while maintaining full API compatibility with existing Lua
scripts.
#### Motivation for adding to Mudlet
PCRE2 provides better Unicode support, improved performance, and is
actively maintained, while PCRE (version 1) is end-of-life.
#### Other info (issues closed, discussion etc)

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Vadim Peretokin <vadi2@users.noreply.github.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2025-11-29 07:21:06 +01:00
Vadim Peretokin
387fb0bd9b
Improve: add a new, experimental 3D mapper (#8087)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
     the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
This adds an experimental, new 3D mapper that uses shaders, more modern
openGL, and a far better code reorganization that makes it an easier
foundation to build upon.

The new 3D mapper is here side by side with the original and can be
toggled on for experimentation. There's a lot of work to be done, so I'd
rather merge it early instead of making a mega-PR.
#### Motivation for adding to Mudlet
So we have a new foundation to build upon and improve.
#### Other info (issues closed, discussion etc)
Old and new mapper can be toggled dynamically with:
```lua
-- this can be a keybinding
setConfig("experiment.3dmap.modernmapper", not getConfig("experiment.3dmap.modernmapper"))
```

Smooth movement is one experiment in the new mapper, and it can be
enabled with:
```lua
lua setConfig("experiment.rendering.smooth-camera", true)
```

As you notice an experiments system has been added so we can implement
things at once and experiment to choose the one that works best. This
system can be used in other places in Mudlet as well.

<details><summary>Details</summary>
<p>

 ## Experiments System

  ### Overview
Allows enabling/disabling experimental features via
`setConfig`/`getConfig` with validation against a predefined
  whitelist.

  ### Usage
  ```lua
  -- Enable experiment
  setConfig("experiment.rendering.more-transparent", true)

  -- Check if enabled
local enabled = getConfig("experiment.rendering.more-transparent") --
returns true/false

  -- Get active experiment in group
local active = getConfig("experiment.rendering.active") -- returns
"more-transparent"

  -- List all valid experiments
local experiments = getConfig("experiment.list") -- returns table of
valid keys
```

### Behavior

  - Grouped experiments: Mutually exclusive (enabling one disables others in same group)
  - Validation: Only predefined experiments allowed, invalid keys return errors
  - Persistence: Experiment states saved/loaded with profiles


  ### Adding New Experiments

  Edit Host::mValidExperiments in src/Host.cpp:
```cpp
  const QSet<QString> Host::mValidExperiments = {
      qsl("experiment.rendering.originalish"),
      qsl("experiment.rendering.more-transparent"),
      qsl("experiment.newfeature.option1"),  // Add here
  };
```

  ### Current Experiments

  - experiment.rendering.originalish
  - experiment.rendering.more-transparent


</p>
</details>

---------

Co-authored-by: Vadim Peretokin <vadi2@users.noreply.github.com>
2025-08-29 12:15:48 +02:00
Vadim Peretokin
e595ba7c30
Fix 50 typos in the rest of the code (#5389) 2021-08-22 07:19:30 +02:00
Vadim Peretokin
c993ae52c2
Add Windows 64bit build to Github Actions (#4348)
* Add mingw-64 build

* Add --trace-expand

* Use correct variable for checking dev/ptb status

* Update dblsqd

* Re-enable updater

* Disable checking APP_BUILD in src/CMakeLists.txt

* Show CMakeOutput if it exists

* Remove trace output

* Re-enable PCRE hack

* Clarify APP_BUILD disablement

* Remove commented out updater disable

* Nicer way of specifying the arguments

* Update build-mudlet.yml

* Set Windows version explicitly
2020-11-13 20:30:10 +01:00
Vadim Peretokin
59bc01c9e7
Fix finding Sparkle with CMake (#4144) 2020-10-09 14:31:21 +02:00
Stephen Lyons
2a90a8afc7
Enhance: enable builds in a full Windows MSYS2 environment (#3889)
* Enhance: enable builds in a full Windows MSYS2 environment (QMake only)

By defining `WITH_MAIN_BUILD_SYSTEM` to the value `NO` this PR makes enough
changes to the qmake project file to enable Mudlet to be compiled in a full
MSYS2 development environment (in the MSYS2 Qt Creator) - this will enable
easier development by Windows users (particularly those who also have some
familiarity with *nix systems) as I have documented at:
"Compiling on Windows 7+ (MSYS2_Alternative)" but it seems that the URL is
causing GitHub to forget about the PR as it seems to push and is recorded
in my local repository but never actually lands there!

It also makes some changes to the setting up of the LUA package paths for
the lua code formatter so that the paths are all entered with Unix style
directory separators but converted to whatever the Lua package handler is
set to use. In a Windows environment it is not unheard of to get both '\'
and '/' being used within the same path as different parts get generated
in stages - and using the backslash one can produce surprising error
messages if the back slash is not properly escaped when displaying those
messages in the main console or elsewhere (they dissappear entirely or
end up escaping following characters producing misleading information).

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>

* Update src/mudlet.pro

BugFix: fix a typo in qmake project file.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>

* Revise: reduce almost duplicate comments

Fix an addition to the `package.cpath` which would not have worked as it
did not specify the file extension which is OS dependent.

Also remove LuaJIT remenent, which we dropped support for a long time back.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>

* Apply suggestions from code review

Revise: fix an error in a comment.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>

* Revise: take out some pre-processor stuff as run-time code works without it

I was a bit sceptical at first but it *seems* to work.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>

* Enhance: modifications to get CMake working on Windows

Revise a Mudlet specific CMake macro to not include the word "module" as
that is not appropriate for all usages now.

Fix an obscure CMake build error caused by the use of:
`LIBRARYNAME::LIBRARYNAME` in `target_link_libraries(...)` which is the
form for an interface usage of a library - this causes a failure of the
build with an error message of the form:
`src/CMakeFiles/mudlet.dir/build.make:1954: *** target pattern contains
no '%'.  Stop.` that line is actually one about one of the libraries
concerned - and it is the first one which shows up in that file with a
LIBRARYNAME-NOTFOUND entry. The fix seems to be to use only a LIBRARYNAME
form.

Fix a problem in `(static QString) mudlet::getShortPathName(const QString&
name)` which is cause by a Windows specific function that takes.returns
template/typedef type arguments which only work if the symbols
`UNICODE` and `_UNICODE` to be defined and which aren't in an MSYS2/
Mingw-w64 environment.

Revise some usages of the APP_BUILD defined value so that they are
handled correctly (using `QStringLiteral`/`QByteArray` wrapppers).

Change the CMake find module for Pugixml so that it uses a variable name in
ALL_UPPER_CASE to remove a developer warning about using a mixed case one.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>

* Edit: fix copy paste issue

I thought something needed to be more conditional than it was but didn't
get it undone in last commit.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>

* Refactor: simplify the code to set up the Lua/C additional paths for LCF

Peer-review suggested I needed to shrink the code.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>

* Revise: shrink some comments

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>

* Revise: implement some changes requested by peer-review

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>

* Revise: shorten multi-line comment in initIndenterGlobals()

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>

* Revise: further change suggested in peer-review

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>

* Fix recognition of static libraries in own Find modules

Co-authored-by: keneanung <keneanung@googlemail.com>
2020-08-25 21:01:41 +02:00
Vadim Peretokin
a9652b89fc
Add Linux build to Github Actions (#3657)
* Add a Ubuntu build

* Install homebrew dependencies only on macOS

* Add Linux dependencies separate

* Don't stop other builds on fail

* Install libzip-dev on Linux

* Sudo please

* Try installing libglu1-mesa-dev

* Install Pulse dev libraries

* Add a workaround for Lua linking

* Correct YAML

* Back to a single line

* Debug locations of libraries

* Correct an extra /

* Build Mudlet with tracing

* Try -GNinja Multi-Config

* Try not specifying a generator

* Add link information against libdl.so as well (#33)

* Add link information against libdl.so as well

* Remove (harmful?) lua library path definition

* Show built output in the end

* Added a run tests flag

* Try appending gcc argument as well

* Debug plugin loading

* Use a single, generic compiler line

* Remove the x's

* Install libxkbcommon-x11-0

* Try launching Achaea profile

* Finalise Linux CI build

* Remove comment

Co-authored-by: keneanung <keneanung@googlemail.com>
2020-04-21 06:04:47 +02:00
Vadim Peretokin
e3abb77e52
Build Mudlet for macOS with Github Actions (#3630) 2020-04-19 09:31:57 +02:00
Vadim Peretokin
4ee1f4671d
Format cmake files (#3598) 2020-04-12 18:07:31 +02:00
keneanung
30726e8fed
Improve cmake osx (#3477)
* Create a bundle on macOS and fix Sparkle linking for cmake

* Make finding sparkle a find module

* More tweaks to root CMakeLists.txt

* Update sparkle-glue submodule to latest

* Create a bundle on macOS and fix Sparkle linking for cmake

* More tweaks to root CMakeLists.txt

* Make finding sparkle a find module

* Update sparkle-glue submodule to latest
2020-03-17 19:12:39 +01:00
keneanung
52536a7f7c Fix FindLua51.cmake before cmake 3.11
Before that, IMPORTED libraries were not allowed to be changed with
target_link_libraries(). My tests were done on cmake 3.13, so I didn't notice
this.
2019-10-19 20:22:30 +02:00
keneanung
0383ea53ba
Cmake improve optional module check (#3174)
* Add file to define macro for optional modules

* Use new macro include_optional_module

* Move messages about inclusion/exclusion of optional modules
2019-10-18 15:53:37 +02:00
keneanung
f9984ebbfd
Cmake improve git submodule initialization (#3171)
* Add function to initialize git submodules

* Use function for retrieving git submodules

* Add GPL header
2019-10-18 14:25:06 +02:00
keneanung
d962e7cf01
Modernize cmake files (part 1) (#3167)
* Modernize FindHUNSPELL

It now exports a target so we don't need to manually add variables to
the Mudlet binary and uses pkg-config enhanced search functionality
if the tool is available.

* Modernize FindPCRE

It now exports a target so we don't need to manually add variables to
the Mudlet binary and uses pkg-config enhanced search functionality
if the tool is available.

* Allow CI builds for this branch

* Modernize FindPUGIXML

* Fix and improve static finding of hunspell and PCRE libraries

* Modernize FindYAJL

* Use exported Qt targets instead of manually including variables

* Use cmake AUTO* capbilities for Qt

This makes handling the file lists nicer as we don't have to take care which
lists to put what in. And cmake is much more efficient in the way it's using the
meta-compiler things than if called manually.

* Remove manual finding of lua

This should be done by the lua find module. If that is not enough, we may have
to write our own in the future.

* Use exported target ZLIB instead of exported variables

* Some reordering and cleanup

* Modernize FindZIP.cmake

* Use exported target instead of variables

* Use own copy of FindLua51 to export targets

* Use exported target for OpenGL

* Add forgotten explicit target

* Avoid hardcoding position independent code flags

* Don't set the stdlibC++ manually

* Move most compiler flags around to modify only the mudlet target

* Undo: Allow travis builds for this branch

* Remove MSVC references in our CMakeLists.txt

* Use header-only boost target
2019-10-17 11:16:37 +02:00
Nikolay Amiantov
3c8f12b6d7 Detect hunspell 1.7 (#3046) 2019-09-05 16:07:46 +02:00
Vadim Peretokin
66bc668c58
Save profiles faster (#1629)
Use pugixml which stores data quicker the xml object, and offload unprintable character escaping and serialization off to another thread to return control quicker.
2018-05-15 09:19:10 +02:00
Dmitry Marakasov
76cca52a5d Add support for newer versions of hunspell library 2017-03-28 17:17:42 +03:00
Ahmed Charles
d29a4b6b56 Fix cmake's ability to find hunspell on homebrew. 2014-08-12 23:32:10 -07:00
Ahmed Charles
0072c18a34 Remove HUNSPELL hack in travis build. 2014-08-04 11:45:37 -07:00
Ahmed Charles
e0b49829ef Add zip to the cmake build in a generic way. 2014-04-21 03:21:54 -07:00
Ahmed Charles
7e09d0794b Add hunspell into the cmake build in a generic way. 2014-04-21 03:21:41 -07:00
Ahmed Charles
c2f608dedb Add yajl into the cmake build in a generic way.
Use yajl2 for MSVC.
2014-04-21 03:21:31 -07:00
Ahmed Charles
8b9bda1ef9 Add pcre into the cmake build in a generic way. 2014-04-21 03:21:14 -07:00
Heiko Koehn
d9fa473a41 misc 2011-06-11 09:00:21 +02:00
Heiko Koehn
27de4e9f96 misc 2011-05-24 08:01:28 +02:00
Bruno Bigras
c42f827561 Move files to the root of the tree 2009-03-05 02:11:35 -05:00