Skip to content

Commit 0f268ed

Browse files
arch1t3chtstefantalpalarusarnex
authored
Allow building without PCHs on Linux
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 when b_pch is disabled. If it's enabled, stick to acconf.h to not bloat the compiler command lines too much. For now this only works on Linux, Windows will need extra work due to windows.h being annoying, but there isn't as much of a need to build without PCHs there anyway. The added includes were mostly taken from #241 and #223. Co-authored-by: Ștefan Talpalaru <[email protected]> Co-authored-by: Nick Sarnie <[email protected]>
1 parent 08c084e commit 0f268ed

25 files changed

+54
-8
lines changed

.github/workflows/ci.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,25 @@ jobs:
4343
name: Ubuntu 22 Debug,
4444
os: ubuntu-22.04,
4545
buildtype: debugoptimized,
46-
args: ''
46+
args: -Db_pch=false
4747
}
4848
- {
4949
name: Ubuntu 22 Release,
5050
os: ubuntu-22.04,
5151
buildtype: release,
52-
args: ''
52+
args: -Db_pch=false
5353
}
5454
- {
5555
name: Ubuntu 24 Debug,
5656
os: ubuntu-24.04,
5757
buildtype: debugoptimized,
58-
args: ''
58+
args: -Db_pch=false
5959
}
6060
- {
6161
name: Ubuntu 24 Release,
6262
os: ubuntu-24.04,
6363
buildtype: release,
64-
args: ''
64+
args: -Db_pch=false
6565
}
6666
- {
6767
name: macOS Debug,

libaegisub/ass/uuencode.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <libaegisub/ass/uuencode.h>
1818

1919
#include <algorithm>
20+
#include <cstring>
2021

2122
// Despite being called uuencoding by ass_specs.doc, the format is actually
2223
// somewhat different from real uuencoding. Each 3-byte chunk is split into 4

libaegisub/audio/provider_dummy.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "libaegisub/fs.h"
2020

21+
#include <cstring>
2122
#include <random>
2223

2324
/*

libaegisub/common/cajun/reader.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Author: Terry Caton
88

99
#include "libaegisub/cajun/reader.h"
1010

11+
#include <algorithm>
1112
#include <boost/interprocess/streams/bufferstream.hpp>
1213
#include <cassert>
1314

libaegisub/common/calltip_provider.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "libaegisub/ass/dialogue_parser.h"
2020

2121
#include <algorithm>
22+
#include <cstring>
2223

2324
namespace {
2425
struct proto_lit {

libaegisub/common/mru.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "libaegisub/option.h"
2323
#include "libaegisub/option_value.h"
2424

25+
#include <algorithm>
26+
2527
namespace {
2628
std::string_view mru_names[] = {
2729
"Audio",

libaegisub/common/option.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "libaegisub/log.h"
2626
#include "libaegisub/option_value.h"
2727

28+
#include <algorithm>
2829
#include <boost/interprocess/streams/bufferstream.hpp>
2930
#include <cassert>
3031
#include <memory>

libaegisub/common/thesaurus.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "libaegisub/line_iterator.h"
2020
#include "libaegisub/split.h"
2121

22+
#include <algorithm>
2223
#include <boost/interprocess/streams/bufferstream.hpp>
2324

2425
namespace agi {

libaegisub/include/libaegisub/lua/ffi.h

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <libaegisub/type_name.h>
1818

1919
#include <cstdlib>
20+
#include <cstring>
2021
#include <lua.hpp>
2122

2223
namespace agi::lua {

libaegisub/lua/modules/unicode.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#include <unicode/unistr.h>
2020

21+
#include <cstring>
22+
2123
namespace {
2224
char *wrap(void (*fn)(icu::UnicodeString&), const char *str, char **err) {
2325
auto ustr = icu::UnicodeString::fromUTF8(str);

libaegisub/meson.build

+3-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ libaegisub_c_pch = ['include/lagi_pre_c.h']
8686

8787
libaegisub_inc = include_directories('include')
8888

89-
libaegisub = static_library('aegisub', libaegisub_src, acconf,
89+
libaegisub = static_library('aegisub', libaegisub_src, aegisub_order_dep,
90+
c_args: aegisub_defines,
91+
cpp_args: aegisub_defines,
9092
include_directories: [libaegisub_inc, deps_inc],
9193
cpp_pch: libaegisub_cpp_pch,
9294
c_pch: libaegisub_c_pch,

meson.build

+20-2
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,23 @@ elif cc.has_header_symbol('malloc.h', 'alloca', prefix: '#include <stdlib.h>')
375375
conf.set('HAVE_MALLOC_H', true)
376376
endif
377377

378-
acconf = configure_file(output: 'acconf.h', configuration: conf)
378+
aegisub_order_dep = []
379+
aegisub_defines = []
380+
381+
if get_option('b_pch')
382+
# Write the feature flags into a configure_file to not bloat the compiler args too much
383+
aegisub_order_dep += configure_file(output: 'acconf.h', configuration: conf)
384+
else
385+
# Manually pass the feature flags as compiler args
386+
foreach key : conf.keys()
387+
aegisub_defines += '-D@0@=@1@'.format(key, conf.get(key))
388+
endforeach
389+
390+
if host_machine.system() == 'windows'
391+
# This is also part of all the PCHs
392+
aegisub_defines += '-DWIN32_LEAN_AND_MEAN'
393+
endif
394+
endif
379395

380396
subdir('automation')
381397
subdir('libaegisub')
@@ -387,7 +403,9 @@ subdir('tests')
387403
aegisub_cpp_pch = ['src/include/agi_pre.h']
388404
aegisub_c_pch = ['src/include/agi_pre_c.h']
389405

390-
aegisub = executable('aegisub', aegisub_src, version_h, acconf, resrc,
406+
aegisub = executable('aegisub', aegisub_src, version_h, resrc, aegisub_order_dep,
407+
c_args: aegisub_defines,
408+
cpp_args: aegisub_defines,
391409
link_with: [libresrc, libaegisub],
392410
include_directories: [libaegisub_inc, libresrc_inc, version_inc, deps_inc, include_directories('src')],
393411
cpp_pch: aegisub_cpp_pch,

src/MatroskaParser.c

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
#define EVCBUG
5151
#endif
5252

53-
#include "acconf.h"
5453
#include "MatroskaParser.h"
5554

5655
#ifdef HAVE_ALLOCA_H

src/ass_parser.h

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1414

1515
#include <memory>
16+
#include <string>
1617

1718
class AssAttachment;
1819
class AssFile;

src/ass_style.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <libaegisub/format.h>
4141
#include <libaegisub/split.h>
4242

43+
#include <algorithm>
4344
#include <boost/lexical_cast.hpp>
4445
#include <wx/intl.h>
4546

src/audio_timing_dialogue.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@
3939
#include "selection_controller.h"
4040
#include "utils.h"
4141

42+
#include <list>
43+
4244
#include <libaegisub/ass/time.h>
4345

4446
#include <boost/range/algorithm.hpp>
47+
4548
#include <wx/pen.h>
4649

4750
namespace {

src/base_grid.h

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include <memory>
3333
#include <string>
3434
#include <vector>
35+
#include <wx/brush.h>
36+
#include <wx/scrolbar.h>
3537
#include <wx/window.h>
3638

3739
namespace agi {

src/command/command.h

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#pragma once
2020

2121
#include <map>
22+
#include <memory>
2223
#include <string>
2324
#include <vector>
2425

src/dialog_colorpicker.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
#include <libaegisub/scoped_ptr.h>
4040

41+
#include <algorithm>
4142
#include <memory>
4243
#include <vector>
4344

src/frame_main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
#include <wx/sizer.h>
6868
#include <wx/statline.h>
6969
#include <wx/sysopt.h>
70+
#include <wx/toolbar.h>
7071

7172
enum {
7273
ID_APP_TIMER_STATUSCLEAR = 12002

src/main.h

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
#include "aegisublocale.h"
3333

34+
#include <vector>
35+
3436
#ifndef wxUSE_EXCEPTIONS
3537
#error wxWidgets is compiled without exceptions support. Aegisub requires exceptions support in wxWidgets to run safely.
3638
#endif

src/preferences.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747

4848
#include <wx/checkbox.h>
4949
#include <wx/combobox.h>
50+
#include <wx/dc.h>
5051
#include <wx/event.h>
5152
#include <wx/listctrl.h>
5253
#include <wx/msgdlg.h>

src/spline_curve.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "spline_curve.h"
3636
#include "utils.h"
3737

38+
#include <algorithm>
3839
#include <limits>
3940

4041
SplineCurve::SplineCurve(Vector2D p1) : p1(p1), type(POINT) { }

src/utils.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#ifdef __UNIX__
4242
#include <unistd.h>
4343
#endif
44+
#include <algorithm>
4445
#include <map>
4546
#include <unicode/locid.h>
4647
#include <unicode/unistr.h>

src/video_frame.h

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//
1515
// Aegisub Project http://www.aegisub.org/
1616

17+
#include <stddef.h>
1718
#include <vector>
1819

1920
class wxImage;

0 commit comments

Comments
 (0)