Skip to content

Commit e01db87

Browse files
committed
Merge branch 'ps/meson-weak-sha1-build' into next
meson-based build now supports the unsafe-sha1 build knob. * ps/meson-weak-sha1-build: meson: provide a summary of configured backends meson: wire up unsafe SHA1 backend meson: add missing dots for build options meson: simplify conditions for HTTPS and SHA1 dependencies meson: require SecurityFramework when it's used as SHA1 backend meson: deduplicate access to SHA1/SHA256 backend options meson: consistenlty spell 'CommonCrypto'
2 parents 41c78cf + 6a0ee54 commit e01db87

File tree

2 files changed

+44
-15
lines changed

2 files changed

+44
-15
lines changed

meson.build

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,14 +1326,17 @@ if not meson.is_cross_build() and fs.exists('/dev/tty')
13261326
endif
13271327

13281328
https_backend = get_option('https_backend')
1329+
sha1_backend = get_option('sha1_backend')
1330+
sha1_unsafe_backend = get_option('sha1_unsafe_backend')
1331+
sha256_backend = get_option('sha256_backend')
13291332

1330-
security_framework = dependency('Security', required: https_backend == 'CommonCrypto')
1333+
security_framework = dependency('Security', required: 'CommonCrypto' in [https_backend, sha1_backend, sha1_unsafe_backend])
13311334
core_foundation_framework = dependency('CoreFoundation', required: security_framework.found())
13321335
if https_backend == 'auto' and security_framework.found()
13331336
https_backend = 'CommonCrypto'
13341337
endif
13351338

1336-
openssl_required = https_backend == 'openssl' or get_option('sha1_backend') == 'openssl' or get_option('sha256_backend') == 'openssl'
1339+
openssl_required = 'openssl' in [https_backend, sha1_backend, sha1_unsafe_backend, sha256_backend]
13371340
openssl = dependency('openssl', required: openssl_required, default_options: ['default_library=static'])
13381341
if https_backend == 'auto' and openssl.found()
13391342
https_backend = 'openssl'
@@ -1354,7 +1357,6 @@ if https_backend != 'openssl'
13541357
libgit_c_args += '-DNO_OPENSSL'
13551358
endif
13561359

1357-
sha1_backend = get_option('sha1_backend')
13581360
if sha1_backend == 'sha1dc'
13591361
libgit_c_args += '-DSHA1_DC'
13601362
libgit_c_args += '-DSHA1DC_NO_STANDARD_INCLUDES=1'
@@ -1367,22 +1369,40 @@ if sha1_backend == 'sha1dc'
13671369
'sha1dc/sha1.c',
13681370
'sha1dc/ubc_check.c',
13691371
]
1370-
elif sha1_backend == 'common-crypto'
1372+
endif
1373+
if sha1_backend == 'CommonCrypto' or sha1_unsafe_backend == 'CommonCrypto'
1374+
if sha1_backend == 'CommonCrypto'
1375+
libgit_c_args += '-DSHA1_APPLE'
1376+
endif
1377+
if sha1_unsafe_backend == 'CommonCrypto'
1378+
libgit_c_args += '-DSHA1_APPLE_UNSAFE'
1379+
endif
1380+
13711381
libgit_c_args += '-DCOMMON_DIGEST_FOR_OPENSSL'
1372-
libgit_c_args += '-DSHA1_APPLE'
13731382
# Apple CommonCrypto requires chunking
13741383
libgit_c_args += '-DSHA1_MAX_BLOCK_SIZE=1024L*1024L*1024L'
1375-
elif sha1_backend == 'openssl'
1376-
libgit_c_args += '-DSHA1_OPENSSL'
1384+
endif
1385+
if sha1_backend == 'openssl' or sha1_unsafe_backend == 'openssl'
1386+
if sha1_backend == 'openssl'
1387+
libgit_c_args += '-DSHA1_OPENSSL'
1388+
endif
1389+
if sha1_unsafe_backend == 'openssl'
1390+
libgit_c_args += '-DSHA1_OPENSSL_UNSAFE'
1391+
endif
1392+
13771393
libgit_dependencies += openssl
1378-
elif sha1_backend == 'block'
1379-
libgit_c_args += '-DSHA1_BLK'
1394+
endif
1395+
if sha1_backend == 'block' or sha1_unsafe_backend == 'block'
1396+
if sha1_backend == 'block'
1397+
libgit_c_args += '-DSHA1_BLK'
1398+
endif
1399+
if sha1_unsafe_backend == 'block'
1400+
libgit_c_args += '-DSHA1_BLK_UNSAFE'
1401+
endif
1402+
13801403
libgit_sources += 'block-sha1/sha1.c'
1381-
else
1382-
error('Unhandled SHA1 backend ' + sha1_backend)
13831404
endif
13841405

1385-
sha256_backend = get_option('sha256_backend')
13861406
if sha256_backend == 'openssl'
13871407
libgit_c_args += '-DSHA256_OPENSSL'
13881408
libgit_dependencies += openssl
@@ -1923,3 +1943,10 @@ summary({
19231943
'perl': perl_features_enabled,
19241944
'python': python.found(),
19251945
}, section: 'Auto-detected features')
1946+
1947+
summary({
1948+
'https': https_backend,
1949+
'sha1': sha1_backend,
1950+
'sha1_unsafe': sha1_unsafe_backend,
1951+
'sha256': sha256_backend,
1952+
}, section: 'Backends')

meson_options.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ option('regex', type: 'feature', value: 'auto',
4949
# Backends.
5050
option('https_backend', type: 'combo', value: 'auto', choices: ['auto', 'openssl', 'CommonCrypto', 'none'],
5151
description: 'The HTTPS backend to use when connecting to remotes.')
52-
option('sha1_backend', type: 'combo', choices: ['openssl', 'block', 'sha1dc', 'common-crypto'], value: 'sha1dc',
53-
description: 'The backend used for hashing objects with the SHA1 object format')
52+
option('sha1_backend', type: 'combo', choices: ['openssl', 'block', 'sha1dc', 'CommonCrypto'], value: 'sha1dc',
53+
description: 'The backend used for hashing objects with the SHA1 object format.')
54+
option('sha1_unsafe_backend', type: 'combo', choices: ['openssl', 'block', 'CommonCrypto', 'none'], value: 'none',
55+
description: 'The backend used for hashing data with the SHA1 object format in case no cryptographic security is needed.')
5456
option('sha256_backend', type: 'combo', choices: ['openssl', 'nettle', 'gcrypt', 'block'], value: 'block',
55-
description: 'The backend used for hashing objects with the SHA256 object format')
57+
description: 'The backend used for hashing objects with the SHA256 object format.')
5658

5759
# Build tweaks.
5860
option('macos_use_homebrew_gettext', type: 'boolean', value: true,

0 commit comments

Comments
 (0)