155
155
# These machine files can be passed to `meson setup` via the `--native-file`
156
156
# option.
157
157
#
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
+ #
158
189
# Subproject wrappers
159
190
# ===================
160
191
#
@@ -173,7 +204,7 @@ project('git', 'c',
173
204
# The version is only of cosmetic nature, so if we cannot find a shell yet we
174
205
# simply don't set up a version at all. This may be the case for example on
175
206
# 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 (
177
208
' GIT-VERSION-GEN' , meson .current_source_dir(), ' --format=@GIT_VERSION@' ,
178
209
capture : true ,
179
210
check : true ,
@@ -198,16 +229,18 @@ elif host_machine.system() == 'windows'
198
229
program_path = [ ' C:/Program Files/Git/bin' , ' C:/Program Files/Git/usr/bin' ]
199
230
endif
200
231
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 )
207
240
208
241
# Sanity-check that programs required for the build exist.
209
242
foreach tool : [' cat' , ' cut' , ' grep' , ' sort' , ' tr' , ' uname' ]
210
- find_program (tool, dirs : program_path)
243
+ find_program (tool, dirs : program_path, native : true )
211
244
endforeach
212
245
213
246
script_environment = environment ()
@@ -706,7 +739,7 @@ libgit_c_args = [
706
739
' -DGIT_LOCALE_PATH="' + get_option (' localedir' ) + ' "' ,
707
740
' -DGIT_MAN_PATH="' + get_option (' mandir' ) + ' "' ,
708
741
' -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()) + ' "' ,
710
743
]
711
744
libgit_include_directories = [ ' .' ]
712
745
libgit_dependencies = [ ]
@@ -770,6 +803,7 @@ endif
770
803
build_options_config.set_quoted(' X' , executable_suffix)
771
804
772
805
python = import (' python' ).find_installation(' python3' , required : get_option (' python' ))
806
+ target_python = find_program (' python3' , native : false , required : python.found())
773
807
if python.found()
774
808
build_options_config.set(' NO_PYTHON' , '' )
775
809
else
@@ -799,9 +833,11 @@ endif
799
833
# which we can do starting with Meson 1.5.0 and newer, or we have to
800
834
# match against the minor version.
801
835
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' )
803
838
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' )
805
841
endif
806
842
perl_features_enabled = perl.found() and get_option (' perl' ).allowed()
807
843
if perl_features_enabled
852
888
build_options_config.set(' NO_PTHREADS' , ' 1' )
853
889
endif
854
890
855
- msgfmt = find_program (' msgfmt' , dirs : program_path, required : false )
891
+ msgfmt = find_program (' msgfmt' , dirs : program_path, native : true , required : false )
856
892
gettext_option = get_option (' gettext' ).disable_auto_if(not msgfmt.found())
857
893
if not msgfmt.found() and gettext_option.enabled()
858
894
error (' Internationalization via libintl requires msgfmt' )
@@ -1697,7 +1733,7 @@ bin_wrappers += executable('scalar',
1697
1733
install_dir : get_option (' libexecdir' ) / ' git-core' ,
1698
1734
)
1699
1735
1700
- if get_option ( ' curl' ).enabled ()
1736
+ if curl.found ()
1701
1737
libgit_curl = declare_dependency (
1702
1738
sources : [
1703
1739
' http.c' ,
@@ -1985,9 +2021,9 @@ foreach key, value : {
1985
2021
' GIT_TEST_TEMPLATE_DIR' : meson .project_build_root() / ' templates' ,
1986
2022
' GIT_TEST_TEXTDOMAINDIR' : meson .project_build_root() / ' po' ,
1987
2023
' 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(),
1991
2027
' TAR' : tar.full_path(),
1992
2028
' TEST_OUTPUT_DIRECTORY' : test_output_directory,
1993
2029
' TEST_SHELL_PATH' : shell.full_path(),
0 commit comments