Skip to content

Commit 6f97aff

Browse files
committed
Revert "Merge branch 'ps/build-meson-fixes-0130' into next"
This reverts commit 6cd5b60, reversing changes made to 89ad48d.
1 parent 4e5a29b commit 6f97aff

File tree

8 files changed

+97
-85
lines changed

8 files changed

+97
-85
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ build:msvc-meson:
164164
extends: .msvc-meson
165165
stage: build
166166
script:
167-
- meson setup build -Dperl=disabled -Dbackend_max_links=1
167+
- meson setup build -Dperl=disabled
168168
- meson compile -C build
169169
artifacts:
170170
paths:

Documentation/howto/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ custom_target(
4141
foreach howto : howto_sources
4242
howto_stripped = custom_target(
4343
command: [
44-
sed,
44+
find_program('sed'),
4545
'-e',
4646
'1,/^$/d',
4747
'@INPUT@',

Documentation/meson.build

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,17 +207,17 @@ manpages = {
207207

208208
docs_backend = get_option('docs_backend')
209209
if docs_backend == 'auto'
210-
if find_program('asciidoc', dirs: program_path, required: false).found()
210+
if find_program('asciidoc', required: false).found()
211211
docs_backend = 'asciidoc'
212-
elif find_program('asciidoctor', dirs: program_path, required: false).found()
212+
elif find_program('asciidoctor', required: false).found()
213213
docs_backend = 'asciidoctor'
214214
else
215215
error('Neither asciidoc nor asciidoctor were found.')
216216
endif
217217
endif
218218

219219
if docs_backend == 'asciidoc'
220-
asciidoc = find_program('asciidoc', dirs: program_path)
220+
asciidoc = find_program('asciidoc', required: true)
221221
asciidoc_html = 'xhtml11'
222222
asciidoc_docbook = 'docbook'
223223
xmlto_extra = [ ]
@@ -246,7 +246,7 @@ if docs_backend == 'asciidoc'
246246
asciidoc_conf,
247247
]
248248
elif docs_backend == 'asciidoctor'
249-
asciidoctor = find_program('asciidoctor', dirs: program_path)
249+
asciidoctor = find_program('asciidoctor', required: true)
250250
asciidoc_html = 'xhtml5'
251251
asciidoc_docbook = 'docbook5'
252252
xmlto_extra = [
@@ -284,7 +284,8 @@ elif docs_backend == 'asciidoctor'
284284
]
285285
endif
286286

287-
xmlto = find_program('xmlto', dirs: program_path)
287+
git = find_program('git', required: false)
288+
xmlto = find_program('xmlto')
288289

289290
cmd_lists = [
290291
'cmds-ancillaryinterrogators.adoc',
@@ -405,7 +406,7 @@ if get_option('docs').contains('html')
405406
pointing_to: 'git.html',
406407
)
407408

408-
xsltproc = find_program('xsltproc', dirs: program_path)
409+
xsltproc = find_program('xsltproc')
409410

410411
user_manual_xml = custom_target(
411412
command: asciidoc_common_options + [

meson.build

Lines changed: 81 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -191,30 +191,31 @@ project('git', 'c',
191191
fs = import('fs')
192192

193193
program_path = []
194-
if get_option('sane_tool_path').length() != 0
195-
program_path = get_option('sane_tool_path')
196-
elif host_machine.system() == 'windows'
197-
# Git for Windows provides all the tools we need to build Git.
198-
program_path = [ 'C:/Program Files/Git/bin', 'C:/Program Files/Git/usr/bin' ]
194+
# Git for Windows provides all the tools we need to build Git.
195+
if host_machine.system() == 'windows'
196+
program_path += [ 'C:/Program Files/Git/bin', 'C:/Program Files/Git/usr/bin' ]
199197
endif
200198

201199
cygpath = find_program('cygpath', dirs: program_path, required: false)
202200
diff = find_program('diff', dirs: program_path)
203-
git = find_program('git', dirs: program_path, required: false)
204-
sed = find_program('sed', dirs: program_path)
205201
shell = find_program('sh', dirs: program_path)
206202
tar = find_program('tar', dirs: program_path)
207203

208-
# Sanity-check that programs required for the build exist.
209-
foreach tool : ['cat', 'cut', 'grep', 'sort', 'tr', 'uname']
210-
find_program(tool, dirs: program_path)
211-
endforeach
212-
213204
script_environment = environment()
214-
foreach path : program_path
215-
script_environment.prepend('PATH', path)
205+
foreach tool : ['cat', 'cut', 'grep', 'sed', 'sort', 'tr', 'uname']
206+
program = find_program(tool, dirs: program_path)
207+
script_environment.prepend('PATH', fs.parent(program.full_path()))
216208
endforeach
217209

210+
git = find_program('git', dirs: program_path, required: false)
211+
if git.found()
212+
script_environment.prepend('PATH', fs.parent(git.full_path()))
213+
endif
214+
215+
if get_option('sane_tool_path') != ''
216+
script_environment.prepend('PATH', get_option('sane_tool_path'))
217+
endif
218+
218219
# The environment used by GIT-VERSION-GEN. Note that we explicitly override
219220
# environment variables that might be set by the user. This is by design so
220221
# that we always use whatever Meson has configured instead of what is present
@@ -478,7 +479,6 @@ libgit_sources = [
478479
'userdiff.c',
479480
'utf8.c',
480481
'varint.c',
481-
'version.c',
482482
'versioncmp.c',
483483
'walker.c',
484484
'wildmatch.c',
@@ -678,9 +678,8 @@ else
678678
build_options_config.set('WITH_BREAKING_CHANGES', '')
679679
endif
680680

681-
if get_option('sane_tool_path').length() != 0
682-
sane_tool_path = (host_machine.system() == 'windows' ? ';' : ':').join(get_option('sane_tool_path'))
683-
build_options_config.set_quoted('BROKEN_PATH_FIX', 's|^\# @BROKEN_PATH_FIX@$|git_broken_path_fix "' + sane_tool_path + '"|')
681+
if get_option('sane_tool_path') != ''
682+
build_options_config.set_quoted('BROKEN_PATH_FIX', 's|^\# @BROKEN_PATH_FIX@$|git_broken_path_fix "' + get_option('sane_tool_path') + '"|')
684683
else
685684
build_options_config.set_quoted('BROKEN_PATH_FIX', '/^\# @BROKEN_PATH_FIX@$/d')
686685
endif
@@ -700,6 +699,7 @@ libgit_c_args = [
700699
'-DETC_GITATTRIBUTES="' + get_option('gitattributes') + '"',
701700
'-DETC_GITCONFIG="' + get_option('gitconfig') + '"',
702701
'-DFALLBACK_RUNTIME_PREFIX="' + get_option('prefix') + '"',
702+
'-DGIT_EXEC_PATH="' + get_option('prefix') / get_option('libexecdir') / 'git-core"',
703703
'-DGIT_HOST_CPU="' + host_machine.cpu_family() + '"',
704704
'-DGIT_HTML_PATH="' + get_option('datadir') / 'doc/git-doc"',
705705
'-DGIT_INFO_PATH="' + get_option('infodir') + '"',
@@ -963,9 +963,7 @@ if curl.found()
963963
use_curl_for_imap_send = true
964964
endif
965965

966-
# Most executables don't have to link against libcurl, but we still need its
967-
# include directories so that we can resolve LIBCURL_VERSION in "help.c".
968-
libgit_dependencies += curl.partial_dependency(includes: true)
966+
libgit_dependencies += curl
969967
libgit_c_args += '-DCURL_DISABLE_TYPECHECK'
970968
build_options_config.set('NO_CURL', '')
971969
else
@@ -1390,11 +1388,7 @@ if https_backend == 'auto' and security_framework.found()
13901388
endif
13911389

13921390
openssl_required = 'openssl' in [csprng_backend, https_backend, sha1_backend, sha1_unsafe_backend, sha256_backend]
1393-
openssl = dependency('openssl',
1394-
required: openssl_required,
1395-
allow_fallback: openssl_required or https_backend == 'auto',
1396-
default_options: ['default_library=static'],
1397-
)
1391+
openssl = dependency('openssl', required: openssl_required, default_options: ['default_library=static'])
13981392
if https_backend == 'auto' and openssl.found()
13991393
https_backend = 'openssl'
14001394
endif
@@ -1408,7 +1402,6 @@ elif https_backend == 'openssl'
14081402
else
14091403
# We either couldn't find any dependencies with 'auto' or the user requested
14101404
# 'none'. Both cases are benign.
1411-
https_backend = 'none'
14121405
endif
14131406

14141407
if https_backend != 'openssl'
@@ -1508,7 +1501,6 @@ endif
15081501
if get_option('runtime_prefix')
15091502
libgit_c_args += '-DRUNTIME_PREFIX'
15101503
build_options_config.set('RUNTIME_PREFIX', 'true')
1511-
git_exec_path = get_option('libexecdir') / 'git-core'
15121504

15131505
if compiler.has_header('mach-o/dyld.h')
15141506
libgit_c_args += '-DHAVE_NS_GET_EXECUTABLE_PATH'
@@ -1545,9 +1537,7 @@ if get_option('runtime_prefix')
15451537
endif
15461538
else
15471539
build_options_config.set('RUNTIME_PREFIX', 'false')
1548-
git_exec_path = get_option('prefix') / get_option('libexecdir') / 'git-core'
15491540
endif
1550-
libgit_c_args += '-DGIT_EXEC_PATH="' + git_exec_path + '"'
15511541

15521542
git_version_file = custom_target(
15531543
command: [
@@ -1578,18 +1568,32 @@ version_def_h = custom_target(
15781568
depends: [git_version_file],
15791569
env: version_gen_environment,
15801570
)
1581-
libgit_sources += version_def_h
1571+
1572+
# Build a separate library for "version.c" so that we do not have to rebuild
1573+
# everything when the current Git commit changes.
1574+
libgit_version_library = static_library('git-version',
1575+
sources: [
1576+
'version.c',
1577+
version_def_h,
1578+
],
1579+
c_args: libgit_c_args + [
1580+
'-DGIT_VERSION_H="' + version_def_h.full_path() + '"',
1581+
],
1582+
dependencies: libgit_dependencies,
1583+
include_directories: libgit_include_directories,
1584+
)
1585+
1586+
libgit_library = static_library('git',
1587+
sources: libgit_sources,
1588+
c_args: libgit_c_args,
1589+
link_with: libgit_version_library,
1590+
dependencies: libgit_dependencies,
1591+
include_directories: libgit_include_directories,
1592+
)
15821593

15831594
libgit = declare_dependency(
1584-
link_with: static_library('git',
1585-
sources: libgit_sources,
1586-
c_args: libgit_c_args + [
1587-
'-DGIT_VERSION_H="' + version_def_h.full_path() + '"',
1588-
],
1589-
dependencies: libgit_dependencies,
1590-
include_directories: libgit_include_directories,
1591-
),
15921595
compile_args: libgit_c_args,
1596+
link_with: libgit_library,
15931597
dependencies: libgit_dependencies,
15941598
include_directories: libgit_include_directories,
15951599
)
@@ -1630,95 +1634,97 @@ if host_machine.system() == 'windows'
16301634
error('Unsupported compiler ' + compiler.get_id())
16311635
endif
16321636
endif
1633-
1634-
libgit_commonmain = declare_dependency(
1637+
common_main_library = static_library('common-main',
16351638
sources: common_main_sources,
1639+
c_args: libgit_c_args,
1640+
dependencies: libgit_dependencies,
1641+
include_directories: libgit_include_directories,
1642+
)
1643+
common_main = declare_dependency(
1644+
link_with: common_main_library,
16361645
link_args: common_main_link_args,
1637-
dependencies: [ libgit ],
16381646
)
16391647

16401648
bin_wrappers = [ ]
16411649
test_dependencies = [ ]
16421650

1643-
git_builtin = executable('git',
1651+
git = executable('git',
16441652
sources: builtin_sources + 'git.c',
1645-
dependencies: [libgit_commonmain],
1653+
dependencies: [libgit, common_main],
16461654
install: true,
16471655
install_dir: get_option('libexecdir') / 'git-core',
16481656
)
1649-
bin_wrappers += git_builtin
1657+
bin_wrappers += git
16501658

16511659
test_dependencies += executable('git-daemon',
16521660
sources: 'daemon.c',
1653-
dependencies: [libgit_commonmain],
1661+
dependencies: [libgit, common_main],
16541662
install: true,
16551663
install_dir: get_option('libexecdir') / 'git-core',
16561664
)
16571665

16581666
test_dependencies += executable('git-sh-i18n--envsubst',
16591667
sources: 'sh-i18n--envsubst.c',
1660-
dependencies: [libgit_commonmain],
1668+
dependencies: [libgit, common_main],
16611669
install: true,
16621670
install_dir: get_option('libexecdir') / 'git-core',
16631671
)
16641672

16651673
bin_wrappers += executable('git-shell',
16661674
sources: 'shell.c',
1667-
dependencies: [libgit_commonmain],
1675+
dependencies: [libgit, common_main],
16681676
install: true,
16691677
install_dir: get_option('libexecdir') / 'git-core',
16701678
)
16711679

16721680
test_dependencies += executable('git-http-backend',
16731681
sources: 'http-backend.c',
1674-
dependencies: [libgit_commonmain],
1682+
dependencies: [libgit, common_main],
16751683
install: true,
16761684
install_dir: get_option('libexecdir') / 'git-core',
16771685
)
16781686

16791687
bin_wrappers += executable('scalar',
16801688
sources: 'scalar.c',
1681-
dependencies: [libgit_commonmain],
1689+
dependencies: [libgit, common_main],
16821690
install: true,
16831691
install_dir: get_option('libexecdir') / 'git-core',
16841692
)
16851693

16861694
if get_option('curl').enabled()
1687-
libgit_curl = declare_dependency(
1688-
sources: [
1689-
'http.c',
1690-
'http-walker.c',
1691-
],
1692-
dependencies: [libgit_commonmain, curl],
1693-
)
1695+
curl_sources = [
1696+
'http.c',
1697+
'http-walker.c',
1698+
]
16941699

1695-
test_dependencies += executable('git-remote-http',
1696-
sources: 'remote-curl.c',
1697-
dependencies: [libgit_curl],
1700+
git_remote_http = executable('git-remote-http',
1701+
sources: curl_sources + 'remote-curl.c',
1702+
dependencies: [libgit, common_main],
16981703
install: true,
16991704
install_dir: get_option('libexecdir') / 'git-core',
17001705
)
1706+
test_dependencies += git_remote_http
17011707

17021708
test_dependencies += executable('git-http-fetch',
1703-
sources: 'http-fetch.c',
1704-
dependencies: [libgit_curl],
1709+
sources: curl_sources + 'http-fetch.c',
1710+
dependencies: [libgit, common_main],
17051711
install: true,
17061712
install_dir: get_option('libexecdir') / 'git-core',
17071713
)
17081714

17091715
if expat.found()
17101716
test_dependencies += executable('git-http-push',
1711-
sources: 'http-push.c',
1712-
dependencies: [libgit_curl],
1717+
sources: curl_sources + 'http-push.c',
1718+
dependencies: [libgit, common_main],
17131719
install: true,
17141720
install_dir: get_option('libexecdir') / 'git-core',
17151721
)
17161722
endif
17171723

17181724
foreach alias : [ 'git-remote-https', 'git-remote-ftp', 'git-remote-ftps' ]
17191725
test_dependencies += executable(alias,
1720-
sources: 'remote-curl.c',
1721-
dependencies: [libgit_curl],
1726+
objects: git_remote_http.extract_all_objects(recursive: false),
1727+
dependencies: [libgit, common_main],
17221728
)
17231729

17241730
install_symlink(alias + executable_suffix,
@@ -1728,17 +1734,22 @@ if get_option('curl').enabled()
17281734
endforeach
17291735
endif
17301736

1737+
imap_send_sources = ['imap-send.c']
1738+
if use_curl_for_imap_send
1739+
imap_send_sources += curl_sources
1740+
endif
1741+
17311742
test_dependencies += executable('git-imap-send',
1732-
sources: 'imap-send.c',
1733-
dependencies: [ use_curl_for_imap_send ? libgit_curl : libgit_commonmain ],
1743+
sources: imap_send_sources,
1744+
dependencies: [libgit, common_main],
17341745
install: true,
17351746
install_dir: get_option('libexecdir') / 'git-core',
17361747
)
17371748

17381749
foreach alias : [ 'git-receive-pack', 'git-upload-archive', 'git-upload-pack' ]
17391750
bin_wrappers += executable(alias,
1740-
objects: git_builtin.extract_all_objects(recursive: false),
1741-
dependencies: [libgit],
1751+
objects: git.extract_all_objects(recursive: false),
1752+
dependencies: [libgit, common_main],
17421753
)
17431754

17441755
install_symlink(alias + executable_suffix,

meson_options.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ option('perl_cpan_fallback', type: 'boolean', value: true,
1313
description: 'Install bundled copies of CPAN modules that serve as a fallback in case the modules are not available on the system.')
1414
option('runtime_prefix', type: 'boolean', value: false,
1515
description: 'Resolve ancillary tooling and support files relative to the location of the runtime binary instead of hard-coding them into the binary.')
16-
option('sane_tool_path', type: 'array', value: [],
17-
description: 'An array of paths to pick up tools from in case the normal tools are broken or lacking.')
16+
option('sane_tool_path', type: 'string', value: '',
17+
description: 'A colon-separated list of paths to prepend to PATH if your tools in /usr/bin are broken.')
1818

1919
# Build information compiled into Git and other parts like documentation.
2020
option('build_date', type: 'string', value: '',

0 commit comments

Comments
 (0)