Skip to content

Commit 7cfdb0a

Browse files
committed
Merge branch 'ps/misc-build-fixes'
Random build fixes. * ps/misc-build-fixes: ci: use Visual Studio for win+meson job on GitHub Workflows meson: distinguish build and target host binaries meson: respect 'tests' build option in contrib gitweb: fix generation of "gitweb.js" meson: fix handling of '-Dcurl=auto'
2 parents 779534d + 85e1d68 commit 7cfdb0a

File tree

9 files changed

+87
-47
lines changed

9 files changed

+87
-47
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ jobs:
265265
run: pip install meson ninja
266266
- name: Setup
267267
shell: pwsh
268-
run: meson setup build -Dperl=disabled -Dcredential_helpers=wincred
268+
run: meson setup build --vsenv -Dperl=disabled -Dcredential_helpers=wincred
269269
- name: Compile
270270
shell: pwsh
271271
run: meson compile -C build

.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 -Dcredential_helpers=wincred
167+
- meson setup build --vsenv -Dperl=disabled -Dbackend_max_links=1 -Dcredential_helpers=wincred
168168
- meson compile -C build
169169
artifacts:
170170
paths:

Documentation/meson.build

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,17 +215,17 @@ endif
215215

216216
docs_backend = get_option('docs_backend')
217217
if docs_backend == 'auto'
218-
if find_program('asciidoc', dirs: program_path, required: false).found()
218+
if find_program('asciidoc', dirs: program_path, native: true, required: false).found()
219219
docs_backend = 'asciidoc'
220-
elif find_program('asciidoctor', dirs: program_path, required: false).found()
220+
elif find_program('asciidoctor', dirs: program_path, native: true, required: false).found()
221221
docs_backend = 'asciidoctor'
222222
else
223223
error('Neither asciidoc nor asciidoctor were found.')
224224
endif
225225
endif
226226

227227
if docs_backend == 'asciidoc'
228-
asciidoc = find_program('asciidoc', dirs: program_path)
228+
asciidoc = find_program('asciidoc', dirs: program_path, native: true)
229229
asciidoc_html = 'xhtml11'
230230
asciidoc_docbook = 'docbook'
231231
xmlto_extra = [ ]
@@ -254,7 +254,7 @@ if docs_backend == 'asciidoc'
254254
asciidoc_conf,
255255
]
256256
elif docs_backend == 'asciidoctor'
257-
asciidoctor = find_program('asciidoctor', dirs: program_path)
257+
asciidoctor = find_program('asciidoctor', dirs: program_path, native: true)
258258
asciidoc_html = 'xhtml5'
259259
asciidoc_docbook = 'docbook5'
260260
xmlto_extra = [
@@ -296,7 +296,7 @@ if get_option('breaking_changes')
296296
asciidoc_common_options += ['--attribute', 'with-breaking-changes']
297297
endif
298298

299-
xmlto = find_program('xmlto', dirs: program_path)
299+
xmlto = find_program('xmlto', dirs: program_path, native: true)
300300

301301
cmd_lists = [
302302
'cmds-ancillaryinterrogators.adoc',
@@ -417,7 +417,7 @@ if get_option('docs').contains('html')
417417
pointing_to: 'git.html',
418418
)
419419

420-
xsltproc = find_program('xsltproc', dirs: program_path)
420+
xsltproc = find_program('xsltproc', dirs: program_path, native: true)
421421

422422
user_manual_xml = custom_target(
423423
command: asciidoc_common_options + [

contrib/credential/netrc/meson.build

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ credential_netrc = custom_target(
77
install_dir: get_option('libexecdir') / 'git-core',
88
)
99

10-
credential_netrc_testenv = test_environment
11-
credential_netrc_testenv.set('CREDENTIAL_NETRC_PATH', credential_netrc.full_path())
10+
if get_option('tests')
11+
credential_netrc_testenv = test_environment
12+
credential_netrc_testenv.set('CREDENTIAL_NETRC_PATH', credential_netrc.full_path())
1213

13-
test('t-git-credential-netrc',
14-
shell,
15-
args: [ meson.current_source_dir() / 't-git-credential-netrc.sh' ],
16-
workdir: meson.current_source_dir(),
17-
env: credential_netrc_testenv,
18-
depends: test_dependencies + bin_wrappers + [credential_netrc],
19-
timeout: 0,
20-
)
14+
test('t-git-credential-netrc',
15+
shell,
16+
args: [ meson.current_source_dir() / 't-git-credential-netrc.sh' ],
17+
workdir: meson.current_source_dir(),
18+
env: credential_netrc_testenv,
19+
depends: test_dependencies + bin_wrappers + [credential_netrc],
20+
timeout: 0,
21+
)
22+
endif

contrib/subtree/meson.build

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@ git_subtree = custom_target(
1212
install_dir: get_option('libexecdir') / 'git-core',
1313
)
1414

15-
subtree_test_environment = test_environment
16-
subtree_test_environment.prepend('PATH', meson.current_build_dir())
15+
if get_option('tests')
16+
subtree_test_environment = test_environment
17+
subtree_test_environment.prepend('PATH', meson.current_build_dir())
1718

18-
test('t7900-subtree', shell,
19-
args: [ 't7900-subtree.sh' ],
20-
env: subtree_test_environment,
21-
workdir: meson.current_source_dir() / 't',
22-
depends: test_dependencies + bin_wrappers + [ git_subtree ],
23-
timeout: 0,
24-
)
19+
test('t7900-subtree', shell,
20+
args: [ 't7900-subtree.sh' ],
21+
env: subtree_test_environment,
22+
workdir: meson.current_source_dir() / 't',
23+
depends: test_dependencies + bin_wrappers + [ git_subtree ],
24+
timeout: 0,
25+
)
26+
endif
2527

2628
if get_option('docs').contains('man')
2729
subtree_xml = custom_target(

gitweb/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ $(MAK_DIR_GITWEB)gitweb.cgi: $(MAK_DIR_GITWEB)gitweb.perl
118118
$(MAK_DIR_GITWEB)static/gitweb.js: $(MAK_DIR_GITWEB)generate-gitweb-js.sh
119119
$(MAK_DIR_GITWEB)static/gitweb.js: $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_JSLIB_FILES))
120120
$(QUIET_GEN)$(RM) $@ $@+ && \
121-
$(MAK_DIR_GITWEB)generate-gitweb-js.sh $@+ $^ && \
121+
$(MAK_DIR_GITWEB)generate-gitweb-js.sh $@+ $(filter %.js,$^) && \
122122
mv $@+ $@
123123

124124
### Installation rules

gitweb/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
gitweb_config = configuration_data()
2-
gitweb_config.set_quoted('PERL_PATH', perl.full_path())
2+
gitweb_config.set_quoted('PERL_PATH', target_perl.full_path())
33
gitweb_config.set_quoted('CSSMIN', '')
44
gitweb_config.set_quoted('JSMIN', '')
55
gitweb_config.set_quoted('GIT_BINDIR', get_option('prefix') / get_option('bindir'))

meson.build

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,37 @@
155155
# These machine files can be passed to `meson setup` via the `--native-file`
156156
# option.
157157
#
158+
# Cross compilation
159+
# =================
160+
#
161+
# Machine files can also be used in the context of cross-compilation to
162+
# describe the target machine as well as the cross-compiler toolchain that
163+
# shall be used. An example machine file could look like the following:
164+
#
165+
# [binaries]
166+
# c = 'x86_64-w64-mingw32-gcc'
167+
# cpp = 'x86_64-w64-mingw32-g++'
168+
# ar = 'x86_64-w64-mingw32-ar'
169+
# windres = 'x86_64-w64-mingw32-windres'
170+
# strip = 'x86_64-w64-mingw32-strip'
171+
# exe_wrapper = 'wine64'
172+
# sh = 'C:/Program Files/Git for Windows/usr/bin/sh.exe'
173+
#
174+
# [host_machine]
175+
# system = 'windows'
176+
# cpu_family = 'x86_64'
177+
# cpu = 'x86_64'
178+
# endian = 'little'
179+
#
180+
# These machine files can be passed to `meson setup` via the `--cross-file`
181+
# option.
182+
#
183+
# Note that next to the cross-compiler toolchain, the `[binaries]` section is
184+
# also used to locate a couple of binaries that will be built into Git. This
185+
# includes `sh`, `python` and `perl`, so when cross-compiling Git you likely
186+
# want to set these binary paths in addition to the cross-compiler toolchain
187+
# binaries.
188+
#
158189
# Subproject wrappers
159190
# ===================
160191
#
@@ -173,7 +204,7 @@ project('git', 'c',
173204
# The version is only of cosmetic nature, so if we cannot find a shell yet we
174205
# simply don't set up a version at all. This may be the case for example on
175206
# Windows systems, where we first have to bootstrap the host environment.
176-
version: find_program('sh', required: false).found() ? run_command(
207+
version: find_program('sh', native: true, required: false).found() ? run_command(
177208
'GIT-VERSION-GEN', meson.current_source_dir(), '--format=@GIT_VERSION@',
178209
capture: true,
179210
check: true,
@@ -198,16 +229,18 @@ elif host_machine.system() == 'windows'
198229
program_path = [ 'C:/Program Files/Git/bin', 'C:/Program Files/Git/usr/bin' ]
199230
endif
200231

201-
cygpath = find_program('cygpath', dirs: program_path, required: false)
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)
205-
shell = find_program('sh', dirs: program_path)
206-
tar = find_program('tar', dirs: program_path)
232+
cygpath = find_program('cygpath', dirs: program_path, native: true, required: false)
233+
diff = find_program('diff', dirs: program_path, native: true)
234+
git = find_program('git', dirs: program_path, native: true, required: false)
235+
sed = find_program('sed', dirs: program_path, native: true)
236+
shell = find_program('sh', dirs: program_path, native: true)
237+
tar = find_program('tar', dirs: program_path, native: true)
238+
239+
target_shell = find_program('sh', dirs: program_path, native: false)
207240

208241
# Sanity-check that programs required for the build exist.
209242
foreach tool : ['cat', 'cut', 'grep', 'sort', 'tr', 'uname']
210-
find_program(tool, dirs: program_path)
243+
find_program(tool, dirs: program_path, native: true)
211244
endforeach
212245

213246
script_environment = environment()
@@ -706,7 +739,7 @@ libgit_c_args = [
706739
'-DGIT_LOCALE_PATH="' + get_option('localedir') + '"',
707740
'-DGIT_MAN_PATH="' + get_option('mandir') + '"',
708741
'-DPAGER_ENV="' + get_option('pager_environment') + '"',
709-
'-DSHELL_PATH="' + fs.as_posix(shell.full_path()) + '"',
742+
'-DSHELL_PATH="' + fs.as_posix(target_shell.full_path()) + '"',
710743
]
711744
libgit_include_directories = [ '.' ]
712745
libgit_dependencies = [ ]
@@ -770,6 +803,7 @@ endif
770803
build_options_config.set_quoted('X', executable_suffix)
771804

772805
python = import('python').find_installation('python3', required: get_option('python'))
806+
target_python = find_program('python3', native: false, required: python.found())
773807
if python.found()
774808
build_options_config.set('NO_PYTHON', '')
775809
else
@@ -799,9 +833,11 @@ endif
799833
# which we can do starting with Meson 1.5.0 and newer, or we have to
800834
# match against the minor version.
801835
if meson.version().version_compare('>=1.5.0')
802-
perl = find_program('perl', dirs: program_path, required: perl_required, version: '>=5.26.0', version_argument: '-V:version')
836+
perl = find_program('perl', dirs: program_path, native: true, required: perl_required, version: '>=5.26.0', version_argument: '-V:version')
837+
target_perl = find_program('perl', dirs: program_path, native: false, required: perl.found(), version: '>=5.26.0', version_argument: '-V:version')
803838
else
804-
perl = find_program('perl', dirs: program_path, required: perl_required, version: '>=26')
839+
perl = find_program('perl', dirs: program_path, native: true, required: perl_required, version: '>=26')
840+
target_perl = find_program('perl', dirs: program_path, native: false, required: perl.found(), version: '>=26')
805841
endif
806842
perl_features_enabled = perl.found() and get_option('perl').allowed()
807843
if perl_features_enabled
@@ -852,7 +888,7 @@ else
852888
build_options_config.set('NO_PTHREADS', '1')
853889
endif
854890

855-
msgfmt = find_program('msgfmt', dirs: program_path, required: false)
891+
msgfmt = find_program('msgfmt', dirs: program_path, native: true, required: false)
856892
gettext_option = get_option('gettext').disable_auto_if(not msgfmt.found())
857893
if not msgfmt.found() and gettext_option.enabled()
858894
error('Internationalization via libintl requires msgfmt')
@@ -1697,7 +1733,7 @@ bin_wrappers += executable('scalar',
16971733
install_dir: get_option('libexecdir') / 'git-core',
16981734
)
16991735

1700-
if get_option('curl').enabled()
1736+
if curl.found()
17011737
libgit_curl = declare_dependency(
17021738
sources: [
17031739
'http.c',
@@ -1985,9 +2021,9 @@ foreach key, value : {
19852021
'GIT_TEST_TEMPLATE_DIR': meson.project_build_root() / 'templates',
19862022
'GIT_TEST_TEXTDOMAINDIR': meson.project_build_root() / 'po',
19872023
'PAGER_ENV': get_option('pager_environment'),
1988-
'PERL_PATH': perl.found() ? perl.full_path() : '',
1989-
'PYTHON_PATH': python.found () ? python.full_path() : '',
1990-
'SHELL_PATH': shell.full_path(),
2024+
'PERL_PATH': target_perl.found() ? target_perl.full_path() : '',
2025+
'PYTHON_PATH': target_python.found () ? target_python.full_path() : '',
2026+
'SHELL_PATH': target_shell.full_path(),
19912027
'TAR': tar.full_path(),
19922028
'TEST_OUTPUT_DIRECTORY': test_output_directory,
19932029
'TEST_SHELL_PATH': shell.full_path(),

templates/meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
template_config = configuration_data()
2-
template_config.set('PERL_PATH', perl.found() ? fs.as_posix(perl.full_path()) : '')
3-
template_config.set('SHELL_PATH', fs.as_posix(shell.full_path()))
2+
template_config.set('PERL_PATH', target_perl.found() ? fs.as_posix(target_perl.full_path()) : '')
3+
template_config.set('SHELL_PATH', fs.as_posix(target_shell.full_path()))
44
template_config.set('GITWEBDIR', fs.as_posix(get_option('prefix') / get_option('datadir') / 'gitweb'))
55

66
configure_file(

0 commit comments

Comments
 (0)