Skip to content

Commit

Permalink
Allow building without PCHs
Browse files Browse the repository at this point in the history
It seems that Aegisub used to be able to be built without precompiled
headers, but this broke with the meson port since there the PCHs are
needed to include acconf.h. (On the old build system(s), the feature
flags were passed directly as defines to the compiler on Visual Studio,
and acconf.h was forcibly included via -include acconf.h with autoconf.)

Some distributions (gentoo in particular) disable PCHs by default for
meson due to various bugs, and PCHs can also be quite a headache with
language servers (I ended up running an sed one-liner after every
configure to replace -include-pch in my compile_commands.json with the
respective -include).

Since meson doesn't seem to be able to forcibly include headers for
every source file, just pass the config as a set of preprocessor
defines.

Disable b_pch on most of the CI lanes to catch missing includes but keep
it enabled on one of the Ubuntu lanes just in cases something breaks
with PCH enabled.

Co-authored-by: Ștefan Talpalaru <stefantalpalaru@yahoo.com>
Co-authored-by: Nick Sarnie <sarnex@gentoo.org>
  • Loading branch information
3 people committed Jan 21, 2025
1 parent 08c084e commit 753e3c6
Show file tree
Hide file tree
Showing 27 changed files with 46 additions and 26 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
msvc: true
buildtype: release
args: >-
-Db_pch=false
-Ddefault_library=static
--force-fallback-for=zlib,harfbuzz,freetype2,fribidi,libpng
-Dfreetype2:harfbuzz=disabled
Expand All @@ -43,37 +44,37 @@ jobs:
name: Ubuntu 22 Debug,
os: ubuntu-22.04,
buildtype: debugoptimized,
args: ''
args: -Db_pch=true
}
- {
name: Ubuntu 22 Release,
os: ubuntu-22.04,
buildtype: release,
args: ''
args: -Db_pch=false
}
- {
name: Ubuntu 24 Debug,
os: ubuntu-24.04,
buildtype: debugoptimized,
args: ''
args: -Db_pch=true
}
- {
name: Ubuntu 24 Release,
os: ubuntu-24.04,
buildtype: release,
args: ''
args: -Db_pch=false
}
- {
name: macOS Debug,
os: macos-13,
buildtype: debugoptimized,
args: -Ddefault_library=static -Dbuild_osx_bundle=true -Dlocal_boost=true --force-fallback-for=ffms2
args: -Db_pch=false -Ddefault_library=static -Dbuild_osx_bundle=true -Dlocal_boost=true --force-fallback-for=ffms2
}
- {
name: macOS Release,
os: macos-13,
buildtype: release,
args: -Ddefault_library=static -Dbuild_osx_bundle=true -Dlocal_boost=true --force-fallback-for=ffms2
args: -Db_pch=false -Ddefault_library=static -Dbuild_osx_bundle=true -Dlocal_boost=true --force-fallback-for=ffms2
}

steps:
Expand Down
1 change: 1 addition & 0 deletions libaegisub/ass/uuencode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <libaegisub/ass/uuencode.h>

#include <algorithm>
#include <cstring>

// Despite being called uuencoding by ass_specs.doc, the format is actually
// somewhat different from real uuencoding. Each 3-byte chunk is split into 4
Expand Down
1 change: 1 addition & 0 deletions libaegisub/audio/provider_dummy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "libaegisub/fs.h"

#include <cstring>
#include <random>

/*
Expand Down
1 change: 1 addition & 0 deletions libaegisub/common/cajun/reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Author: Terry Caton

#include "libaegisub/cajun/reader.h"

#include <algorithm>
#include <boost/interprocess/streams/bufferstream.hpp>
#include <cassert>

Expand Down
1 change: 1 addition & 0 deletions libaegisub/common/calltip_provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "libaegisub/ass/dialogue_parser.h"

#include <algorithm>
#include <cstring>

namespace {
struct proto_lit {
Expand Down
2 changes: 2 additions & 0 deletions libaegisub/common/mru.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "libaegisub/option.h"
#include "libaegisub/option_value.h"

#include <algorithm>

namespace {
std::string_view mru_names[] = {
"Audio",
Expand Down
1 change: 1 addition & 0 deletions libaegisub/common/option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "libaegisub/log.h"
#include "libaegisub/option_value.h"

#include <algorithm>
#include <boost/interprocess/streams/bufferstream.hpp>
#include <cassert>
#include <memory>
Expand Down
1 change: 1 addition & 0 deletions libaegisub/common/thesaurus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "libaegisub/line_iterator.h"
#include "libaegisub/split.h"

#include <algorithm>
#include <boost/interprocess/streams/bufferstream.hpp>

namespace agi {
Expand Down
3 changes: 0 additions & 3 deletions libaegisub/include/lagi_pre.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#ifdef __cplusplus
#include "../acconf.h"

#define WIN32_LEAN_AND_MEAN

// Common C
#include <cassert>
Expand Down
3 changes: 0 additions & 3 deletions libaegisub/include/lagi_pre_c.h

This file was deleted.

1 change: 1 addition & 0 deletions libaegisub/include/libaegisub/lua/ffi.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <libaegisub/type_name.h>

#include <cstdlib>
#include <cstring>
#include <lua.hpp>

namespace agi::lua {
Expand Down
2 changes: 2 additions & 0 deletions libaegisub/lua/modules/unicode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#include <unicode/unistr.h>

#include <cstring>

namespace {
char *wrap(void (*fn)(icu::UnicodeString&), const char *str, char **err) {
auto ustr = icu::UnicodeString::fromUTF8(str);
Expand Down
6 changes: 3 additions & 3 deletions libaegisub/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ else
endif

libaegisub_cpp_pch = ['include/lagi_pre.h']
libaegisub_c_pch = ['include/lagi_pre_c.h']

libaegisub_inc = include_directories('include')

libaegisub = static_library('aegisub', libaegisub_src, acconf,
libaegisub = static_library('aegisub', libaegisub_src,
c_args: aegisub_defines,
cpp_args: aegisub_defines,
include_directories: [libaegisub_inc, deps_inc],
cpp_pch: libaegisub_cpp_pch,
c_pch: libaegisub_c_pch,
dependencies: deps)
13 changes: 11 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,14 @@ elif cc.has_header_symbol('malloc.h', 'alloca', prefix: '#include <stdlib.h>')
conf.set('HAVE_MALLOC_H', true)
endif

acconf = configure_file(output: 'acconf.h', configuration: conf)
aegisub_defines = []
foreach key : conf.keys()
aegisub_defines += '-D@0@=@1@'.format(key, conf.get(key))
endforeach

if host_machine.system() == 'windows'
aegisub_defines += '-DWIN32_LEAN_AND_MEAN'
endif

subdir('automation')
subdir('libaegisub')
Expand All @@ -387,7 +394,9 @@ subdir('tests')
aegisub_cpp_pch = ['src/include/agi_pre.h']
aegisub_c_pch = ['src/include/agi_pre_c.h']

aegisub = executable('aegisub', aegisub_src, version_h, acconf, resrc,
aegisub = executable('aegisub', aegisub_src, version_h, resrc,
c_args: aegisub_defines,
cpp_args: aegisub_defines,
link_with: [libresrc, libaegisub],
include_directories: [libaegisub_inc, libresrc_inc, version_inc, deps_inc, include_directories('src')],
cpp_pch: aegisub_cpp_pch,
Expand Down
1 change: 0 additions & 1 deletion src/MatroskaParser.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
#define EVCBUG
#endif

#include "acconf.h"
#include "MatroskaParser.h"

#ifdef HAVE_ALLOCA_H
Expand Down
1 change: 1 addition & 0 deletions src/ass_style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <libaegisub/format.h>
#include <libaegisub/split.h>

#include <algorithm>
#include <boost/lexical_cast.hpp>
#include <wx/intl.h>

Expand Down
3 changes: 3 additions & 0 deletions src/audio_timing_dialogue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@
#include "selection_controller.h"
#include "utils.h"

#include <list>

#include <libaegisub/ass/time.h>

#include <boost/range/algorithm.hpp>

#include <wx/pen.h>

namespace {
Expand Down
2 changes: 2 additions & 0 deletions src/base_grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include <memory>
#include <string>
#include <vector>
#include <wx/brush.h>
#include <wx/scrolbar.h>
#include <wx/window.h>

namespace agi {
Expand Down
1 change: 1 addition & 0 deletions src/command/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#pragma once

#include <map>
#include <memory>
#include <string>
#include <vector>

Expand Down
1 change: 1 addition & 0 deletions src/dialog_colorpicker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

#include <libaegisub/scoped_ptr.h>

#include <algorithm>
#include <memory>
#include <vector>

Expand Down
1 change: 1 addition & 0 deletions src/frame_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
#include <wx/sizer.h>
#include <wx/statline.h>
#include <wx/sysopt.h>
#include <wx/toolbar.h>

enum {
ID_APP_TIMER_STATUSCLEAR = 12002
Expand Down
4 changes: 0 additions & 4 deletions src/include/agi_pre.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@
#define _CRT_SECURE_NO_WARNINGS
#endif

#include "../../acconf.h"

#define WIN32_LEAN_AND_MEAN

// Common C
#include <cassert>
#include <cerrno>
Expand Down
4 changes: 0 additions & 4 deletions src/include/agi_pre_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
//
// Aegisub Project http://www.aegisub.org/

#include "../../acconf.h"

#define WIN32_LEAN_AND_MEAN

#ifdef _WIN32
#include <objbase.h>
#include <mmsystem.h>
Expand Down
2 changes: 2 additions & 0 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

#include "aegisublocale.h"

#include <vector>

#ifndef wxUSE_EXCEPTIONS
#error wxWidgets is compiled without exceptions support. Aegisub requires exceptions support in wxWidgets to run safely.
#endif
Expand Down
1 change: 1 addition & 0 deletions src/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

#include <wx/checkbox.h>
#include <wx/combobox.h>
#include <wx/dc.h>
#include <wx/event.h>
#include <wx/listctrl.h>
#include <wx/msgdlg.h>
Expand Down
1 change: 1 addition & 0 deletions src/spline_curve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "spline_curve.h"
#include "utils.h"

#include <algorithm>
#include <limits>

SplineCurve::SplineCurve(Vector2D p1) : p1(p1), type(POINT) { }
Expand Down
1 change: 1 addition & 0 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#ifdef __UNIX__
#include <unistd.h>
#endif
#include <algorithm>
#include <map>
#include <unicode/locid.h>
#include <unicode/unistr.h>
Expand Down

0 comments on commit 753e3c6

Please sign in to comment.