forked from git/git
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathmeson.build
1928 lines (1761 loc) · 53.8 KB
/
meson.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Meson build system
# ==================
#
# The Meson build system is an alternative to our Makefile that you can use to
# build, test and install Git. Using Meson results in a couple of benefits:
#
# - Out-of-tree builds.
# - Better integration into IDEs.
# - Easy-to-use autoconfiguration of available features on your system.
#
# To use Meson from the command line you need to have both Meson and Ninja
# installed. Alternatively, if you do not have Python available on your system,
# you can also use Muon instead of Meson and Samurai instead of Ninja, both of
# which are drop-ins replacement that only depend on C.
#
# Basic usage
# ===========
#
# In the most trivial case, you can configure, build and install Git like this:
#
# 1. Set up the build directory. This only needs to happen once per build
# directory you want to have. You can also configure multiple different
# build directories with different configurations.
#
# $ meson setup build/
#
# The build directory gets ignored by Git automatically as Meson will write
# a ".gitignore" file into it. From hereon, we will assume that you execute
# commands inside this build directory.
#
# 2. Compile Git. You can either use Meson, Ninja or Samurai to do this, so all
# of the following invocations are equivalent:
#
# $ meson compile
# $ ninja
# $ samu
#
# The different invocations should ultimately not make much of a difference.
# Using Meson also works with other generators though, like when the build
# directory has been set up for use with Microsoft Visual Studio.
#
# Ninja and Samurai use multiple jobs by default, scaling with the number of
# processor cores available. You can pass the `-jN` flag to change this.
#
# Meson automatically picks up ccache and sccache when these are installed
# when setting up the build directory. You can override this behaviour when
# setting up the build directory by setting the `CC` environment variable to
# your desired compiler.
#
# 3. Execute tests. Again, you can either use Meson, Ninja or Samurai to do this:
#
# $ meson test
# $ ninja test
# $ samu test
#
# It is recommended to use Meson in this case though as it also provides you
# additional features that the other build systems don't have available.
# You can e.g. pass additional arguments to the test executables or run
# individual tests:
#
# # Execute the t0000-basic integration test and t-reftable-stack unit test.
# $ meson test t0000-basic t-reftable-stack
#
# # Execute all reftable unit tests.
# $ meson test t-reftable-*
#
# # Execute all tests and stop with the first failure.
# $ meson test --maxfail 1
#
# # Execute single test interactively such that features like `debug ()` work.
# $ meson test -i --test-args='-ix' t1400-update-ref
#
# Test execution is parallelized by default and scales with the number of
# processor cores available. You can change the number of processes by passing
# the `-jN` flag to `meson test`.
#
# 4. Install the Git distribution. Again, this can be done via Meson, Ninja or
# Samurai:
#
# $ meson install
# $ ninja install
# $ samu install
#
# The prefix into which Git shall be installed is defined when setting up
# the build directory. More on that in the "Configuration" section.
#
# Meson supports multiple backends. The default backend generates Ninja build
# instructions, but it also supports the generation of Microsoft Visual
# Studio solutions as well as Xcode projects by passing the `--backend` option
# to `meson setup`. IDEs like Eclipse and Visual Studio Code provide plugins to
# import Meson files directly.
#
# Configuration
# =============
#
# The exact configuration of Git is determined when setting up the build
# directory via `meson setup`. Unless told otherwise, Meson will automatically
# detect the availability of various bits and pieces. There are two different
# kinds of options that can be used to further tweak the build:
#
# - Built-in options provided by Meson.
#
# - Options defined by the project in the "meson_options.txt" file.
#
# Both kinds of options can be inspected by running `meson configure` in the
# build directory, which will give you a list of the current value for all
# options.
#
# Options can be configured either when setting up the build directory or can
# be changed in preexisting build directories:
#
# # Set up a new build directory with optimized settings that will be
# # installed into an alternative prefix.
# $ meson setup --buildtype release --optimization 3 --strip --prefix=/home/$USER build
#
# # Set up a new build directory with a higher warning level. Level 2 is
# # mostly equivalent to setting DEVELOPER=1, level 3 and "everything"
# # will enable even more warnings.
# $ meson setup -Dwarning_level=2 build
#
# # Set up a new build directory with 'address' and 'undefined' sanitizers
# # using Clang.
# $ CC=clang meson setup -Db_sanitize=address,undefined build
#
# # Disable tests in a preexisting build directory.
# $ meson configure -Dtests=false
#
# # Disable features based on Python
# $ meson configure -Dpython=disabled
#
# Options have a type like booleans, choices, strings or features. Features are
# somewhat special as they can have one of three values: enabled, disabled or
# auto. While the first two values are self-explanatory, "auto" will enable or
# disable the feature based on the availability of prerequisites to support it.
# Python-based features for example will be enabled automatically when a Python
# interpreter could be found. The default value of such features can be changed
# via `meson setup --auto-features={enabled,disabled,auto}`, which will set the
# value of all features with a value of "auto" to the provided one by default.
#
# It is also possible to store a set of configuration options in machine files.
# This can be useful in case you regularly want to reuse the same set of options:
#
# [binaries]
# c = ['clang']
# ar = ['ar']
#
# [project options]
# gettext = 'disabled'
# default_editor = 'vim'
#
# [built-in options]
# b_lto = true
# b_sanitize = 'address,undefined'
#
# These machine files can be passed to `meson setup` via the `--native-file`
# option.
#
# Subproject wrappers
# ===================
#
# Subproject wrappers are a feature provided by Meson that allows the automatic
# fallback to a "wrapped" dependency in case the dependency is not provided by
# the system. For example if the system is lacking curl, then Meson will use
# "subprojects/curl.wrap" to set up curl as a subproject and compile and link
# the dependency into Git itself. This is especially helpful on systems like
# Windows, where you typically don't have such dependencies installed.
#
# The use of subproject wrappers can be disabled by executing `meson setup`
# with the `--wrap-mode nofallback` option.
project('git', 'c',
meson_version: '>=0.61.0',
version: 'v2.47.GIT',
)
fs = import('fs')
program_path = []
# Git for Windows provides all the tools we need to build Git.
if host_machine.system() == 'windows'
program_path += [ 'C:/Program Files/Git/bin', 'C:/Program Files/Git/usr/bin' ]
endif
cygpath = find_program('cygpath', dirs: program_path, required: false)
diff = find_program('diff', dirs: program_path)
shell = find_program('sh', dirs: program_path)
tar = find_program('tar', dirs: program_path)
script_environment = environment()
foreach tool : ['cat', 'cut', 'grep', 'sed', 'sort', 'tr', 'uname']
program = find_program(tool, dirs: program_path)
script_environment.prepend('PATH', fs.parent(program.full_path()))
endforeach
git = find_program('git', dirs: program_path, required: false)
if git.found()
script_environment.prepend('PATH', fs.parent(git.full_path()))
endif
if get_option('sane_tool_path') != ''
script_environment.prepend('PATH', get_option('sane_tool_path'))
endif
# The environment used by GIT-VERSION-GEN. Note that we explicitly override
# environment variables that might be set by the user. This is by design so
# that we always use whatever Meson has configured instead of what is present
# in the environment.
version_gen_environment = script_environment
version_gen_environment.set('GIT_BUILT_FROM_COMMIT', get_option('built_from_commit'))
version_gen_environment.set('GIT_DATE', get_option('build_date'))
version_gen_environment.set('GIT_USER_AGENT', get_option('user_agent'))
version_gen_environment.set('GIT_VERSION', get_option('version'))
compiler = meson.get_compiler('c')
libgit_sources = [
'abspath.c',
'add-interactive.c',
'add-patch.c',
'advice.c',
'alias.c',
'alloc.c',
'apply.c',
'archive-tar.c',
'archive-zip.c',
'archive.c',
'attr.c',
'base85.c',
'bisect.c',
'blame.c',
'blob.c',
'bloom.c',
'branch.c',
'bulk-checkin.c',
'bundle-uri.c',
'bundle.c',
'cache-tree.c',
'cbtree.c',
'chdir-notify.c',
'checkout.c',
'chunk-format.c',
'color.c',
'column.c',
'combine-diff.c',
'commit-graph.c',
'commit-reach.c',
'commit.c',
'compat/nonblock.c',
'compat/obstack.c',
'compat/terminal.c',
'compat/zlib-uncompress2.c',
'config.c',
'connect.c',
'connected.c',
'convert.c',
'copy.c',
'credential.c',
'csum-file.c',
'ctype.c',
'date.c',
'decorate.c',
'delta-islands.c',
'diagnose.c',
'diff-delta.c',
'diff-merges.c',
'diff-lib.c',
'diff-no-index.c',
'diff.c',
'diffcore-break.c',
'diffcore-delta.c',
'diffcore-order.c',
'diffcore-pickaxe.c',
'diffcore-rename.c',
'diffcore-rotate.c',
'dir-iterator.c',
'dir.c',
'editor.c',
'entry.c',
'environment.c',
'ewah/bitmap.c',
'ewah/ewah_bitmap.c',
'ewah/ewah_io.c',
'ewah/ewah_rlw.c',
'exec-cmd.c',
'fetch-negotiator.c',
'fetch-pack.c',
'fmt-merge-msg.c',
'fsck.c',
'fsmonitor.c',
'fsmonitor-ipc.c',
'fsmonitor-settings.c',
'gettext.c',
'git-zlib.c',
'gpg-interface.c',
'graph.c',
'grep.c',
'hash-lookup.c',
'hashmap.c',
'help.c',
'hex.c',
'hex-ll.c',
'hook.c',
'ident.c',
'json-writer.c',
'kwset.c',
'levenshtein.c',
'line-log.c',
'line-range.c',
'linear-assignment.c',
'list-objects-filter-options.c',
'list-objects-filter.c',
'list-objects.c',
'lockfile.c',
'log-tree.c',
'loose.c',
'ls-refs.c',
'mailinfo.c',
'mailmap.c',
'match-trees.c',
'mem-pool.c',
'merge-blobs.c',
'merge-ll.c',
'merge-ort.c',
'merge-ort-wrappers.c',
'merge-recursive.c',
'merge.c',
'midx.c',
'midx-write.c',
'name-hash.c',
'negotiator/default.c',
'negotiator/noop.c',
'negotiator/skipping.c',
'notes-cache.c',
'notes-merge.c',
'notes-utils.c',
'notes.c',
'object-file-convert.c',
'object-file.c',
'object-name.c',
'object.c',
'oid-array.c',
'oidmap.c',
'oidset.c',
'oidtree.c',
'pack-bitmap-write.c',
'pack-bitmap.c',
'pack-check.c',
'pack-mtimes.c',
'pack-objects.c',
'pack-revindex.c',
'pack-write.c',
'packfile.c',
'pager.c',
'parallel-checkout.c',
'parse.c',
'parse-options-cb.c',
'parse-options.c',
'patch-delta.c',
'patch-ids.c',
'path.c',
'path-walk.c',
'pathspec.c',
'pkt-line.c',
'preload-index.c',
'pretty.c',
'prio-queue.c',
'progress.c',
'promisor-remote.c',
'prompt.c',
'protocol.c',
'protocol-caps.c',
'prune-packed.c',
'pseudo-merge.c',
'quote.c',
'range-diff.c',
'reachable.c',
'read-cache.c',
'rebase-interactive.c',
'rebase.c',
'ref-filter.c',
'reflog-walk.c',
'reflog.c',
'refs.c',
'refs/debug.c',
'refs/files-backend.c',
'refs/reftable-backend.c',
'refs/iterator.c',
'refs/packed-backend.c',
'refs/ref-cache.c',
'refspec.c',
'reftable/basics.c',
'reftable/error.c',
'reftable/block.c',
'reftable/blocksource.c',
'reftable/iter.c',
'reftable/merged.c',
'reftable/pq.c',
'reftable/reader.c',
'reftable/record.c',
'reftable/stack.c',
'reftable/system.c',
'reftable/tree.c',
'reftable/writer.c',
'remote.c',
'replace-object.c',
'repo-settings.c',
'repository.c',
'rerere.c',
'reset.c',
'resolve-undo.c',
'revision.c',
'run-command.c',
'send-pack.c',
'sequencer.c',
'serve.c',
'server-info.c',
'setup.c',
'shallow.c',
'sideband.c',
'sigchain.c',
'sparse-index.c',
'split-index.c',
'stable-qsort.c',
'statinfo.c',
'strbuf.c',
'streaming.c',
'string-list.c',
'strmap.c',
'strvec.c',
'sub-process.c',
'submodule-config.c',
'submodule.c',
'symlinks.c',
'tag.c',
'tempfile.c',
'thread-utils.c',
'tmp-objdir.c',
'trace.c',
'trace2.c',
'trace2/tr2_cfg.c',
'trace2/tr2_cmd_name.c',
'trace2/tr2_ctr.c',
'trace2/tr2_dst.c',
'trace2/tr2_sid.c',
'trace2/tr2_sysenv.c',
'trace2/tr2_tbuf.c',
'trace2/tr2_tgt_event.c',
'trace2/tr2_tgt_normal.c',
'trace2/tr2_tgt_perf.c',
'trace2/tr2_tls.c',
'trace2/tr2_tmr.c',
'trailer.c',
'transport-helper.c',
'transport.c',
'tree-diff.c',
'tree-walk.c',
'tree.c',
'unpack-trees.c',
'upload-pack.c',
'url.c',
'urlmatch.c',
'usage.c',
'userdiff.c',
'utf8.c',
'varint.c',
'versioncmp.c',
'walker.c',
'wildmatch.c',
'worktree.c',
'wrapper.c',
'write-or-die.c',
'ws.c',
'wt-status.c',
'xdiff-interface.c',
'xdiff/xdiffi.c',
'xdiff/xemit.c',
'xdiff/xhistogram.c',
'xdiff/xmerge.c',
'xdiff/xpatience.c',
'xdiff/xprepare.c',
'xdiff/xutils.c',
]
builtin_sources = [
'builtin/add.c',
'builtin/am.c',
'builtin/annotate.c',
'builtin/apply.c',
'builtin/archive.c',
'builtin/backfill.c',
'builtin/bisect.c',
'builtin/blame.c',
'builtin/branch.c',
'builtin/bugreport.c',
'builtin/bundle.c',
'builtin/cat-file.c',
'builtin/check-attr.c',
'builtin/check-ignore.c',
'builtin/check-mailmap.c',
'builtin/check-ref-format.c',
'builtin/checkout--worker.c',
'builtin/checkout-index.c',
'builtin/checkout.c',
'builtin/clean.c',
'builtin/clone.c',
'builtin/column.c',
'builtin/commit-graph.c',
'builtin/commit-tree.c',
'builtin/commit.c',
'builtin/config.c',
'builtin/count-objects.c',
'builtin/credential-cache--daemon.c',
'builtin/credential-cache.c',
'builtin/credential-store.c',
'builtin/credential.c',
'builtin/describe.c',
'builtin/diagnose.c',
'builtin/diff-files.c',
'builtin/diff-index.c',
'builtin/diff-tree.c',
'builtin/diff.c',
'builtin/difftool.c',
'builtin/fast-export.c',
'builtin/fast-import.c',
'builtin/fetch-pack.c',
'builtin/fetch.c',
'builtin/fmt-merge-msg.c',
'builtin/for-each-ref.c',
'builtin/for-each-repo.c',
'builtin/fsck.c',
'builtin/fsmonitor--daemon.c',
'builtin/gc.c',
'builtin/get-tar-commit-id.c',
'builtin/grep.c',
'builtin/hash-object.c',
'builtin/help.c',
'builtin/hook.c',
'builtin/index-pack.c',
'builtin/init-db.c',
'builtin/interpret-trailers.c',
'builtin/log.c',
'builtin/ls-files.c',
'builtin/ls-remote.c',
'builtin/ls-tree.c',
'builtin/mailinfo.c',
'builtin/mailsplit.c',
'builtin/merge-base.c',
'builtin/merge-file.c',
'builtin/merge-index.c',
'builtin/merge-ours.c',
'builtin/merge-recursive.c',
'builtin/merge-tree.c',
'builtin/merge.c',
'builtin/mktag.c',
'builtin/mktree.c',
'builtin/multi-pack-index.c',
'builtin/mv.c',
'builtin/name-rev.c',
'builtin/notes.c',
'builtin/pack-objects.c',
'builtin/pack-redundant.c',
'builtin/pack-refs.c',
'builtin/patch-id.c',
'builtin/prune-packed.c',
'builtin/prune.c',
'builtin/pull.c',
'builtin/push.c',
'builtin/range-diff.c',
'builtin/read-tree.c',
'builtin/rebase.c',
'builtin/receive-pack.c',
'builtin/reflog.c',
'builtin/refs.c',
'builtin/remote-ext.c',
'builtin/remote-fd.c',
'builtin/remote.c',
'builtin/repack.c',
'builtin/replace.c',
'builtin/replay.c',
'builtin/rerere.c',
'builtin/reset.c',
'builtin/rev-list.c',
'builtin/rev-parse.c',
'builtin/revert.c',
'builtin/rm.c',
'builtin/send-pack.c',
'builtin/shortlog.c',
'builtin/show-branch.c',
'builtin/show-index.c',
'builtin/show-ref.c',
'builtin/sparse-checkout.c',
'builtin/stash.c',
'builtin/stripspace.c',
'builtin/submodule--helper.c',
'builtin/survey.c',
'builtin/symbolic-ref.c',
'builtin/tag.c',
'builtin/unpack-file.c',
'builtin/unpack-objects.c',
'builtin/update-index.c',
'builtin/update-ref.c',
'builtin/update-server-info.c',
'builtin/upload-archive.c',
'builtin/upload-pack.c',
'builtin/var.c',
'builtin/verify-commit.c',
'builtin/verify-pack.c',
'builtin/verify-tag.c',
'builtin/worktree.c',
'builtin/write-tree.c',
]
libgit_sources += custom_target(
input: 'command-list.txt',
output: 'command-list.h',
command: [shell, meson.current_source_dir() + '/generate-cmdlist.sh', meson.current_source_dir(), '@OUTPUT@'],
env: script_environment,
)
libgit_sources += custom_target(
output: 'config-list.h',
command: [
shell,
meson.current_source_dir() + '/generate-configlist.sh',
meson.current_source_dir(),
'@OUTPUT@',
],
env: script_environment,
)
libgit_sources += custom_target(
input: 'Documentation/githooks.txt',
output: 'hook-list.h',
command: [
shell,
meson.current_source_dir() + '/generate-hooklist.sh',
meson.current_source_dir(),
'@OUTPUT@',
],
env: script_environment,
)
# This contains the variables for GIT-BUILD-OPTIONS, which we use to propagate
# build options to our tests.
build_options_config = configuration_data()
build_options_config.set('GIT_INTEROP_MAKE_OPTS', '')
build_options_config.set('GIT_PERF_LARGE_REPO', '')
build_options_config.set('GIT_PERF_MAKE_COMMAND', '')
build_options_config.set('GIT_PERF_MAKE_OPTS', '')
build_options_config.set('GIT_PERF_REPEAT_COUNT', '')
build_options_config.set('GIT_PERF_REPO', '')
build_options_config.set('GIT_TEST_CMP_USE_COPIED_CONTEXT', '')
build_options_config.set('GIT_TEST_INDEX_VERSION', '')
build_options_config.set('GIT_TEST_OPTS', '')
build_options_config.set('GIT_TEST_PERL_FATAL_WARNINGS', '')
build_options_config.set('GIT_TEST_UTF8_LOCALE', '')
build_options_config.set_quoted('LOCALEDIR', fs.as_posix(get_option('prefix') / get_option('localedir')))
build_options_config.set('GITWEBDIR', fs.as_posix(get_option('prefix') / get_option('datadir') / 'gitweb'))
if get_option('sane_tool_path') != ''
build_options_config.set_quoted('BROKEN_PATH_FIX', 's|^\# @BROKEN_PATH_FIX@$|git_broken_path_fix "' + get_option('sane_tool_path') + '"|')
else
build_options_config.set_quoted('BROKEN_PATH_FIX', '/^\# @BROKEN_PATH_FIX@$/d')
endif
test_output_directory = get_option('test_output_directory')
if test_output_directory == ''
test_output_directory = meson.project_build_root() / 'test-output'
endif
# These variables are used for building libgit.a.
libgit_c_args = [
'-DBINDIR="' + get_option('bindir') + '"',
'-DDEFAULT_EDITOR="' + get_option('default_editor') + '"',
'-DDEFAULT_GIT_TEMPLATE_DIR="' + get_option('datadir') / 'git-core/templates' + '"',
'-DDEFAULT_HELP_FORMAT="' + get_option('default_help_format') + '"',
'-DDEFAULT_PAGER="' + get_option('default_pager') + '"',
'-DETC_GITATTRIBUTES="' + get_option('gitattributes') + '"',
'-DETC_GITCONFIG="' + get_option('gitconfig') + '"',
'-DFALLBACK_RUNTIME_PREFIX="' + get_option('prefix') + '"',
'-DGIT_EXEC_PATH="' + get_option('prefix') / get_option('libexecdir') / 'git-core"',
'-DGIT_HOST_CPU="' + host_machine.cpu_family() + '"',
'-DGIT_HTML_PATH="' + get_option('datadir') / 'doc/git-doc"',
'-DGIT_INFO_PATH="' + get_option('infodir') + '"',
'-DGIT_LOCALE_PATH="' + get_option('localedir') + '"',
'-DGIT_MAN_PATH="' + get_option('mandir') + '"',
'-DPAGER_ENV="' + get_option('pager_environment') + '"',
'-DSHELL_PATH="' + fs.as_posix(shell.full_path()) + '"',
]
libgit_include_directories = [ '.' ]
libgit_dependencies = [ ]
# Treat any warning level above 1 the same as we treat DEVELOPER=1 in our
# Makefile.
if get_option('warning_level') in ['2','3', 'everything'] and compiler.get_argument_syntax() == 'gcc'
foreach cflag : [
'-Wdeclaration-after-statement',
'-Wformat-security',
'-Wold-style-definition',
'-Woverflow',
'-Wpointer-arith',
'-Wstrict-prototypes',
'-Wunused',
'-Wvla',
'-Wwrite-strings',
'-fno-common',
'-Wtautological-constant-out-of-range-compare',
# If a function is public, there should be a prototype and the right
# header file should be included. If not, it should be static.
'-Wmissing-prototypes',
# These are disabled because we have these all over the place.
'-Wno-empty-body',
'-Wno-missing-field-initializers',
'-Wno-sign-compare',
]
if compiler.has_argument(cflag)
libgit_c_args += cflag
endif
endforeach
endif
if get_option('b_sanitize').contains('address')
build_options_config.set('SANITIZE_ADDRESS', 'YesCompiledWithIt')
else
build_options_config.set('SANITIZE_ADDRESS', '')
endif
if get_option('b_sanitize').contains('leak')
build_options_config.set('SANITIZE_LEAK', 'YesCompiledWithIt')
else
build_options_config.set('SANITIZE_LEAK', '')
endif
if get_option('b_sanitize').contains('undefined')
libgit_c_args += '-DSHA1DC_FORCE_ALIGNED_ACCESS'
endif
executable_suffix = ''
if host_machine.system() == 'cygwin' or host_machine.system() == 'windows'
executable_suffix = '.exe'
libgit_c_args += '-DSTRIP_EXTENSION="' + executable_suffix + '"'
endif
build_options_config.set_quoted('X', executable_suffix)
python = import('python').find_installation('python3', required: get_option('python'))
if python.found()
build_options_config.set('NO_PYTHON', '')
else
libgit_c_args += '-DNO_PYTHON'
build_options_config.set('NO_PYTHON', '1')
endif
# Perl is used for two different things: our test harness and to provide some
# features. It is optional if you want to neither execute tests nor use any of
# these optional features.
perl_required = get_option('perl')
if get_option('tests') or get_option('gitweb').enabled()
perl_required = true
endif
# Note that we only set NO_PERL if the Perl features were disabled by the user.
# It may not be set when we have found Perl, but only use it to run tests.
perl = find_program('perl', version: '>=5.8.1', dirs: program_path, required: perl_required)
perl_features_enabled = perl.found() and get_option('perl').allowed()
if perl_features_enabled
build_options_config.set('NO_PERL', '')
if get_option('runtime_prefix')
build_options_config.set('PERL_LOCALEDIR', '')
else
build_options_config.set_quoted('PERL_LOCALEDIR', fs.as_posix(get_option('prefix') / get_option('localedir')))
endif
if get_option('perl_cpan_fallback')
build_options_config.set('NO_PERL_CPAN_FALLBACKS', '')
else
build_options_config.set_quoted('NO_PERL_CPAN_FALLBACKS', 'YesPlease')
endif
else
libgit_c_args += '-DNO_PERL'
build_options_config.set('NO_PERL', '1')
build_options_config.set('PERL_LOCALEDIR', '')
build_options_config.set('NO_PERL_CPAN_FALLBACKS', '')
endif
zlib = dependency('zlib', default_options: ['default_library=static', 'tests=disabled'])
if zlib.version().version_compare('<1.2.0')
libgit_c_args += '-DNO_DEFLATE_BOUND'
endif
libgit_dependencies += zlib
threads = dependency('threads', required: false)
if threads.found()
libgit_dependencies += threads
build_options_config.set('NO_PTHREADS', '')
else
libgit_c_args += '-DNO_PTHREADS'
build_options_config.set('NO_PTHREADS', '1')
endif
msgfmt = find_program('msgfmt', dirs: program_path, required: false)
gettext_option = get_option('gettext').disable_auto_if(not msgfmt.found())
if not msgfmt.found() and gettext_option.enabled()
error('Internationalization via libintl requires msgfmt')
endif
if gettext_option.allowed() and host_machine.system() == 'darwin' and get_option('macos_use_homebrew_gettext')
if host_machine.cpu_family() == 'x86_64'
libintl_prefix = '/usr/local'
elif host_machine.cpu_family() == 'aarch64'
libintl_prefix = '/opt/homebrew'
else
error('Homebrew workaround not supported on current architecture')
endif
intl = compiler.find_library('intl', dirs: libintl_prefix / 'lib', required: gettext_option)
if intl.found()
intl = declare_dependency(
dependencies: intl,
include_directories: libintl_prefix / 'include',
)
endif
else
intl = dependency('intl', required: gettext_option)
endif
if intl.found()
libgit_dependencies += intl
build_options_config.set('NO_GETTEXT', '')
build_options_config.set('USE_GETTEXT_SCHEME', '')
# POSIX nowadays requires `nl_langinfo()`, but some systems still don't have
# the function available. On such systems we instead fall back to libcharset.
# On native Windows systems we use our own emulation.
if host_machine.system() != 'windows' and not compiler.has_function('nl_langinfo')
libcharset = compiler.find_library('charset', required: true)
libgit_dependencies += libcharset
libgit_c_args += '-DHAVE_LIBCHARSET_H'
endif
else
libgit_c_args += '-DNO_GETTEXT'
build_options_config.set('NO_GETTEXT', '1')
build_options_config.set('USE_GETTEXT_SCHEME', 'fallthrough')
endif
iconv = dependency('iconv', required: get_option('iconv'))
if iconv.found()
libgit_dependencies += iconv
build_options_config.set('NO_ICONV', '')
have_old_iconv = false
if not compiler.compiles('''
#include <iconv.h>
extern size_t iconv(iconv_t cd,
char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft);
''', name: 'old iconv interface', dependencies: [iconv])
libgit_c_args += '-DOLD_ICONV'
have_old_iconv = true
endif
iconv_omits_bom_source = '''#
#include <iconv.h>
int main(int argc, const char **argv)
{
'''
if have_old_iconv
iconv_omits_bom_source += '''
typedef const char *iconv_ibp;
'''
else
iconv_omits_bom_source += '''
typedef char *iconv_ibp;
'''
endif
iconv_omits_bom_source += '''
int v;
iconv_t conv;
char in[] = "a"; iconv_ibp pin = in;
char out[20] = ""; char *pout = out;
size_t isz = sizeof in;
size_t osz = sizeof out;
conv = iconv_open("UTF-16", "UTF-8");
iconv(conv, &pin, &isz, &pout, &osz);
iconv_close(conv);
v = (unsigned char)(out[0]) + (unsigned char)(out[1]);
return v != 0xfe + 0xff;
}
'''
if compiler.run(iconv_omits_bom_source,
dependencies: iconv,
name: 'iconv omits BOM',
).returncode() != 0
libgit_c_args += '-DICONV_OMITS_BOM'
endif
else
libgit_c_args += '-DNO_ICONV'
build_options_config.set('NO_ICONV', '1')
endif
pcre2 = dependency('libpcre2-8', required: get_option('pcre2'), default_options: ['default_library=static', 'test=false'])
if pcre2.found()
libgit_dependencies += pcre2
libgit_c_args += '-DUSE_LIBPCRE2'
build_options_config.set('USE_LIBPCRE2', '1')
else
build_options_config.set('USE_LIBPCRE2', '')
endif
curl = dependency('libcurl', version: '>=7.21.3', required: get_option('curl'), default_options: ['default_library=static', 'tests=disabled', 'tool=disabled'])
use_curl_for_imap_send = false
if curl.found()
if curl.version().version_compare('>=7.34.0')
libgit_c_args += '-DUSE_CURL_FOR_IMAP_SEND'
use_curl_for_imap_send = true
endif
libgit_dependencies += curl
libgit_c_args += '-DCURL_DISABLE_TYPECHECK'
build_options_config.set('NO_CURL', '')
else
libgit_c_args += '-DNO_CURL'
build_options_config.set('NO_CURL', '1')
endif
expat = dependency('expat', required: get_option('expat'), default_options: ['default_library=static', 'build_tests=false'])
if expat.found()
libgit_dependencies += expat
if expat.version().version_compare('<=1.2')
libgit_c_args += '-DEXPAT_NEEDS_XMLPARSE_H'
endif
build_options_config.set('NO_EXPAT', '')
else
libgit_c_args += '-DNO_EXPAT'
build_options_config.set('NO_EXPAT', '1')
endif
if not compiler.has_header('sys/select.h')
libgit_c_args += '-DNO_SYS_SELECT_H'
endif
has_poll_h = compiler.has_header('poll.h')
if not has_poll_h
libgit_c_args += '-DNO_POLL_H'
endif
has_sys_poll_h = compiler.has_header('sys/poll.h')
if not has_sys_poll_h
libgit_c_args += '-DNO_SYS_POLL_H'
endif
if not has_poll_h and not has_sys_poll_h
libgit_c_args += '-DNO_POLL'
libgit_sources += 'compat/poll/poll.c'
libgit_include_directories += 'compat/poll'
endif
if not compiler.has_header('inttypes.h')
libgit_c_args += '-DNO_INTTYPES_H'
endif
if compiler.has_header('alloca.h')
libgit_c_args += '-DHAVE_ALLOCA_H'
endif
if compiler.has_header('sys/sysinfo.h')
libgit_c_args += '-DHAVE_SYSINFO'
endif
# Windows has libgen.h and a basename implementation, but we still need our own
# implementation to threat things like drive prefixes specially.
if host_machine.system() == 'windows' or not compiler.has_header('libgen.h')
libgit_c_args += '-DNO_LIBGEN_H'
libgit_sources += 'compat/basename.c'
endif
if compiler.has_header('paths.h')
libgit_c_args += '-DHAVE_PATHS_H'
endif
if compiler.has_header('strings.h')
libgit_c_args += '-DHAVE_STRINGS_H'
endif
networking_dependencies = [ ]
if host_machine.system() == 'windows'
winsock = compiler.find_library('ws2_32', required: false)
if winsock.found()
networking_dependencies += winsock
endif
else
libresolv = compiler.find_library('resolv', required: false)
if libresolv.found()
networking_dependencies += libresolv
endif
endif
libgit_dependencies += networking_dependencies