Skip to content

Commit 97cffa4

Browse files
authored
added cross compile setup (#153)
1 parent d883539 commit 97cffa4

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

.github/workflows/install-dependencies

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
#!/bin/sh -ex
22

33
case "${DISTRO}" in
4+
ubuntu:focal)
5+
export DEBIAN_FRONTEND=noninteractive
6+
apt clean
7+
apt update
8+
apt -y install gcc pkg-config libjose-dev jose libhttp-parser-dev \
9+
systemd gcovr curl socat iproute2 asciidoc git python3-pip ninja-build
10+
apt remove -y meson
11+
pip3 install --upgrade meson
12+
;;
13+
414
debian:*|ubuntu:*)
515
export DEBIAN_FRONTEND=noninteractive
616
apt clean

meson.build

+29-5
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,45 @@ add_project_arguments('-DVERSION="'+meson.project_version() + '"', language : 'c
5454

5555
jose = dependency('jose', version: '>=8')
5656
a2x = find_program('a2x', required: false)
57-
compiler = meson.get_compiler('c')
57+
compiler = meson.get_compiler('c', native : true)
58+
59+
if meson.is_cross_build()
60+
compiler = meson.get_compiler('c', native : false)
61+
endif
62+
63+
message(compiler.version())
64+
message(compiler.get_id())
5865

5966
http_lib = []
60-
if compiler.has_header('llhttp.h', args: '-I/usr/local/include')
67+
68+
inc_dir = meson.get_external_property('inc_dir', '-I/usr/local/include')
69+
lib_dir = meson.get_external_property('lib_dir','/usr/local/lib')
70+
71+
if meson.is_cross_build()
72+
message('----------------')
73+
message('*** THIS IS A CROSS BUILD ***')
74+
message('Compiler version :'+ compiler.version())
75+
message('Compiler ID :' + compiler.get_id())
76+
message('Library search directory :'+ lib_dir)
77+
message('Include directory :' + inc_dir)
78+
message('----------------')
79+
endif
80+
81+
if compiler.has_header('llhttp.h', args: inc_dir)
6182
http_lib = 'llhttp'
6283
add_project_arguments('-DUSE_LLHTTP', language: 'c')
6384
else
64-
if not compiler.has_header('http_parser.h', args: '-I/usr/local/include')
85+
if not compiler.has_header('http_parser.h', args: inc_dir)
6586
error('neither llhttp nor http-parser devel files found.')
6687
endif
88+
6789
http_lib = 'http_parser'
6890
endif
6991

7092
if host_machine.system() == 'freebsd'
7193
http_parser = compiler.find_library(http_lib, dirs : '/usr/local/lib')
7294
else
73-
http_parser = compiler.find_library(http_lib)
95+
http_parser = compiler.find_library(http_lib, dirs: [lib_dir])
7496
endif
7597

7698
licenses = ['COPYING']
@@ -82,7 +104,9 @@ units = []
82104
subdir('doc')
83105
subdir('src')
84106
subdir('units')
85-
subdir('tests')
107+
if not meson.is_cross_build()
108+
subdir('tests')
109+
endif
86110

87111
install_data(libexecbins, install_dir: libexecdir)
88112
install_data(bins, install_dir: bindir)

0 commit comments

Comments
 (0)