@@ -191,30 +191,29 @@ project('git', 'c',
191
191
fs = import (' fs' )
192
192
193
193
program_path = []
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' ]
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' ]
197
199
endif
198
200
199
201
cygpath = find_program (' cygpath' , dirs : program_path, required : false )
200
202
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)
201
205
shell = find_program (' sh' , dirs : program_path)
202
206
tar = find_program (' tar' , dirs : program_path)
203
207
204
- script_environment = environment ()
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()))
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)
208
211
endforeach
209
212
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
213
+ script_environment = environment ()
214
+ foreach path : program_path
215
+ script_environment.prepend(' PATH' , path)
216
+ endforeach
218
217
219
218
# The environment used by GIT-VERSION-GEN. Note that we explicitly override
220
219
# environment variables that might be set by the user. This is by design so
@@ -479,6 +478,7 @@ libgit_sources = [
479
478
' userdiff.c' ,
480
479
' utf8.c' ,
481
480
' varint.c' ,
481
+ ' version.c' ,
482
482
' versioncmp.c' ,
483
483
' walker.c' ,
484
484
' wildmatch.c' ,
678
678
build_options_config.set(' WITH_BREAKING_CHANGES' , '' )
679
679
endif
680
680
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' ) + ' "|' )
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 + ' "|' )
683
684
else
684
685
build_options_config.set_quoted(' BROKEN_PATH_FIX' , ' /^\# @BROKEN_PATH_FIX@$/d' )
685
686
endif
@@ -699,7 +700,6 @@ libgit_c_args = [
699
700
' -DETC_GITATTRIBUTES="' + get_option (' gitattributes' ) + ' "' ,
700
701
' -DETC_GITCONFIG="' + get_option (' gitconfig' ) + ' "' ,
701
702
' -DFALLBACK_RUNTIME_PREFIX="' + get_option (' prefix' ) + ' "' ,
702
- ' -DGIT_EXEC_PATH="' + get_option (' prefix' ) / get_option (' libexecdir' ) / ' git-core"' ,
703
703
' -DGIT_HOST_CPU="' + host_machine .cpu_family() + ' "' ,
704
704
' -DGIT_HTML_PATH="' + get_option (' datadir' ) / ' doc/git-doc"' ,
705
705
' -DGIT_INFO_PATH="' + get_option (' infodir' ) + ' "' ,
@@ -963,7 +963,9 @@ if curl.found()
963
963
use_curl_for_imap_send = true
964
964
endif
965
965
966
- libgit_dependencies += curl
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 )
967
969
libgit_c_args += ' -DCURL_DISABLE_TYPECHECK'
968
970
build_options_config.set(' NO_CURL' , '' )
969
971
else
@@ -1388,7 +1390,11 @@ if https_backend == 'auto' and security_framework.found()
1388
1390
endif
1389
1391
1390
1392
openssl_required = ' openssl' in [csprng_backend, https_backend, sha1_backend, sha1_unsafe_backend, sha256_backend]
1391
- openssl = dependency (' openssl' , required : openssl_required, default_options : [' default_library=static' ])
1393
+ openssl = dependency (' openssl' ,
1394
+ required : openssl_required,
1395
+ allow_fallback : openssl_required or https_backend == ' auto' ,
1396
+ default_options : [' default_library=static' ],
1397
+ )
1392
1398
if https_backend == ' auto' and openssl.found()
1393
1399
https_backend = ' openssl'
1394
1400
endif
@@ -1402,6 +1408,7 @@ elif https_backend == 'openssl'
1402
1408
else
1403
1409
# We either couldn't find any dependencies with 'auto' or the user requested
1404
1410
# 'none'. Both cases are benign.
1411
+ https_backend = ' none'
1405
1412
endif
1406
1413
1407
1414
if https_backend != ' openssl'
@@ -1501,6 +1508,7 @@ endif
1501
1508
if get_option (' runtime_prefix' )
1502
1509
libgit_c_args += ' -DRUNTIME_PREFIX'
1503
1510
build_options_config.set(' RUNTIME_PREFIX' , ' true' )
1511
+ git_exec_path = get_option (' libexecdir' ) / ' git-core'
1504
1512
1505
1513
if compiler.has_header(' mach-o/dyld.h' )
1506
1514
libgit_c_args += ' -DHAVE_NS_GET_EXECUTABLE_PATH'
@@ -1537,7 +1545,9 @@ if get_option('runtime_prefix')
1537
1545
endif
1538
1546
else
1539
1547
build_options_config.set(' RUNTIME_PREFIX' , ' false' )
1548
+ git_exec_path = get_option (' prefix' ) / get_option (' libexecdir' ) / ' git-core'
1540
1549
endif
1550
+ libgit_c_args += ' -DGIT_EXEC_PATH="' + git_exec_path + ' "'
1541
1551
1542
1552
git_version_file = custom_target (
1543
1553
command : [
@@ -1568,32 +1578,18 @@ version_def_h = custom_target(
1568
1578
depends : [git_version_file],
1569
1579
env : version_gen_environment,
1570
1580
)
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
- )
1581
+ libgit_sources += version_def_h
1593
1582
1594
1583
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
+ ),
1595
1592
compile_args : libgit_c_args,
1596
- link_with : libgit_library,
1597
1593
dependencies : libgit_dependencies,
1598
1594
include_directories : libgit_include_directories,
1599
1595
)
@@ -1634,97 +1630,98 @@ if host_machine.system() == 'windows'
1634
1630
error (' Unsupported compiler ' + compiler.get_id())
1635
1631
endif
1636
1632
endif
1637
- common_main_library = static_library (' common-main' ,
1638
- 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,
1633
+
1634
+ libgit_commonmain = declare_dependency (
1635
+ link_with : static_library (' common-main' ,
1636
+ sources : common_main_sources,
1637
+ dependencies : [ libgit ],
1638
+ ),
1645
1639
link_args : common_main_link_args,
1640
+ dependencies : [ libgit ],
1646
1641
)
1647
1642
1648
1643
bin_wrappers = [ ]
1649
1644
test_dependencies = [ ]
1650
1645
1651
- git = executable (' git' ,
1646
+ git_builtin = executable (' git' ,
1652
1647
sources : builtin_sources + ' git.c' ,
1653
- dependencies : [libgit, common_main ],
1648
+ dependencies : [libgit_commonmain ],
1654
1649
install : true ,
1655
1650
install_dir : get_option (' libexecdir' ) / ' git-core' ,
1656
1651
)
1657
- bin_wrappers += git
1652
+ bin_wrappers += git_builtin
1658
1653
1659
1654
test_dependencies += executable (' git-daemon' ,
1660
1655
sources : ' daemon.c' ,
1661
- dependencies : [libgit, common_main ],
1656
+ dependencies : [libgit_commonmain ],
1662
1657
install : true ,
1663
1658
install_dir : get_option (' libexecdir' ) / ' git-core' ,
1664
1659
)
1665
1660
1666
1661
test_dependencies += executable (' git-sh-i18n--envsubst' ,
1667
1662
sources : ' sh-i18n--envsubst.c' ,
1668
- dependencies : [libgit, common_main ],
1663
+ dependencies : [libgit_commonmain ],
1669
1664
install : true ,
1670
1665
install_dir : get_option (' libexecdir' ) / ' git-core' ,
1671
1666
)
1672
1667
1673
1668
bin_wrappers += executable (' git-shell' ,
1674
1669
sources : ' shell.c' ,
1675
- dependencies : [libgit, common_main ],
1670
+ dependencies : [libgit_commonmain ],
1676
1671
install : true ,
1677
1672
install_dir : get_option (' libexecdir' ) / ' git-core' ,
1678
1673
)
1679
1674
1680
1675
test_dependencies += executable (' git-http-backend' ,
1681
1676
sources : ' http-backend.c' ,
1682
- dependencies : [libgit, common_main ],
1677
+ dependencies : [libgit_commonmain ],
1683
1678
install : true ,
1684
1679
install_dir : get_option (' libexecdir' ) / ' git-core' ,
1685
1680
)
1686
1681
1687
1682
bin_wrappers += executable (' scalar' ,
1688
1683
sources : ' scalar.c' ,
1689
- dependencies : [libgit, common_main ],
1684
+ dependencies : [libgit_commonmain ],
1690
1685
install : true ,
1691
1686
install_dir : get_option (' libexecdir' ) / ' git-core' ,
1692
1687
)
1693
1688
1694
1689
if get_option (' curl' ).enabled()
1695
- curl_sources = [
1696
- ' http.c' ,
1697
- ' http-walker.c' ,
1698
- ]
1690
+ libgit_curl = declare_dependency (
1691
+ sources : [
1692
+ ' http.c' ,
1693
+ ' http-walker.c' ,
1694
+ ],
1695
+ dependencies : [libgit_commonmain, curl],
1696
+ )
1699
1697
1700
- git_remote_http = executable (' git-remote-http' ,
1701
- sources : curl_sources + ' remote-curl.c' ,
1702
- dependencies : [libgit, common_main ],
1698
+ test_dependencies + = executable (' git-remote-http' ,
1699
+ sources : ' remote-curl.c' ,
1700
+ dependencies : [libgit_curl ],
1703
1701
install : true ,
1704
1702
install_dir : get_option (' libexecdir' ) / ' git-core' ,
1705
1703
)
1706
- test_dependencies += git_remote_http
1707
1704
1708
1705
test_dependencies += executable (' git-http-fetch' ,
1709
- sources : curl_sources + ' http-fetch.c' ,
1710
- dependencies : [libgit, common_main ],
1706
+ sources : ' http-fetch.c' ,
1707
+ dependencies : [libgit_curl ],
1711
1708
install : true ,
1712
1709
install_dir : get_option (' libexecdir' ) / ' git-core' ,
1713
1710
)
1714
1711
1715
1712
if expat.found()
1716
1713
test_dependencies += executable (' git-http-push' ,
1717
- sources : curl_sources + ' http-push.c' ,
1718
- dependencies : [libgit, common_main ],
1714
+ sources : ' http-push.c' ,
1715
+ dependencies : [libgit_curl ],
1719
1716
install : true ,
1720
1717
install_dir : get_option (' libexecdir' ) / ' git-core' ,
1721
1718
)
1722
1719
endif
1723
1720
1724
1721
foreach alias : [ ' git-remote-https' , ' git-remote-ftp' , ' git-remote-ftps' ]
1725
1722
test_dependencies += executable (alias,
1726
- objects : git_remote_http.extract_all_objects( recursive : false ) ,
1727
- dependencies : [libgit, common_main ],
1723
+ sources : ' remote-curl.c ' ,
1724
+ dependencies : [libgit_curl ],
1728
1725
)
1729
1726
1730
1727
install_symlink(alias + executable_suffix,
@@ -1734,22 +1731,17 @@ if get_option('curl').enabled()
1734
1731
endforeach
1735
1732
endif
1736
1733
1737
- imap_send_sources = [' imap-send.c' ]
1738
- if use_curl_for_imap_send
1739
- imap_send_sources += curl_sources
1740
- endif
1741
-
1742
1734
test_dependencies += executable (' git-imap-send' ,
1743
- sources : imap_send_sources ,
1744
- dependencies : [libgit, common_main ],
1735
+ sources : ' imap-send.c ' ,
1736
+ dependencies : [ use_curl_for_imap_send ? libgit_curl : libgit_commonmain ],
1745
1737
install : true ,
1746
1738
install_dir : get_option (' libexecdir' ) / ' git-core' ,
1747
1739
)
1748
1740
1749
1741
foreach alias : [ ' git-receive-pack' , ' git-upload-archive' , ' git-upload-pack' ]
1750
1742
bin_wrappers += executable (alias,
1751
- objects : git .extract_all_objects(recursive : false ),
1752
- dependencies : [libgit, common_main ],
1743
+ objects : git_builtin .extract_all_objects(recursive : false ),
1744
+ dependencies : [libgit_commonmain ],
1753
1745
)
1754
1746
1755
1747
install_symlink(alias + executable_suffix,
0 commit comments