Skip to content

Commit f09b3e1

Browse files
authored
Merge pull request #14 from superna9999/meson-build
Introduce meson.build
2 parents c403782 + 4225dc8 commit f09b3e1

File tree

9 files changed

+165
-88
lines changed

9 files changed

+165
-88
lines changed

.github/workflows/ci.yml

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
fail-fast: false
3030
matrix:
3131
arch: [x86-64]
32+
family: [x86-64]
3233
compiler: [gcc, clang]
3334
container:
3435
- archlinux:latest
@@ -47,34 +48,39 @@ jobs:
4748
- ubuntu:jammy
4849
- ubuntu:focal
4950
- ubuntu:bionic
50-
- ubuntu:xenial
51+
# Meson version on Ubuntu Xenial is really too old
52+
#- ubuntu:xenial
5153
cross_compile: [""]
5254
variant: [""]
5355
include:
5456
# Debian 32-bit builds
5557
- container: "debian:testing"
5658
arch: i386
57-
compiler: gcc -m32
59+
family: x86
60+
compiler: gcc
5861
cross_compile: i686-linux-gnu
5962
pkg_config_path: /usr/lib/i386-linux-gnu/pkgconfig
6063
variant: i386
6164

6265
- container: "debian:stable"
6366
arch: i386
64-
compiler: gcc -m32
67+
family: x86
68+
compiler: gcc
6569
cross_compile: i686-linux-gnu
6670
pkg_config_path: /usr/lib/i386-linux-gnu/pkgconfig
6771
variant: i386
6872

6973
- container: "debian:bookworm"
7074
arch: i386
71-
compiler: gcc -m32
75+
family: x86
76+
compiler: gcc
7277
cross_compile: i686-linux-gnu
7378
pkg_config_path: /usr/lib/i386-linux-gnu/pkgconfig
7479
variant: i386
7580

7681
- container: "debian:buster"
7782
arch: i386
83+
family: x86
7884
compiler: gcc -m32
7985
cross_compile: i686-linux-gnu
8086
pkg_config_path: /usr/lib/i386-linux-gnu/pkgconfig
@@ -83,55 +89,63 @@ jobs:
8389
# Debian cross compilation builds
8490
- container: "debian:testing"
8591
arch: armhf
92+
family: arm
8693
compiler: arm-linux-gnueabihf-gcc
8794
cross_compile: arm-linux-gnueabihf
8895
pkg_config_path: /usr/lib/arm-linux-gnueabihf/pkgconfig
8996
variant: cross-compile
9097

9198
- container: "debian:testing"
9299
arch: arm64
100+
family: aarch64
93101
compiler: aarch64-linux-gnu-gcc
94102
cross_compile: aarch64-linux-gnu
95103
pkg_config_path: /usr/lib/aarch64-linux-gnu/pkgconfig
96104
variant: cross-compile
97105

98106
- container: "debian:testing"
99107
arch: ppc64el
108+
family: ppc64
100109
compiler: powerpc64le-linux-gnu-gcc
101110
cross_compile: powerpc64le-linux-gnu
102111
pkg_config_path: /usr/lib/powerpc64le-linux-gnu/pkgconfig
103112
variant: cross-compile
104113

105114
- container: "debian:testing"
106115
arch: s390x
116+
family: s390x
107117
compiler: s390x-linux-gnu-gcc
108118
cross_compile: s390x-linux-gnu
109119
pkg_config_path: /usr/lib/s390x-linux-gnu/pkgconfig
110120
variant: cross-compile
111121

112122
- container: "debian:stable"
113123
arch: armhf
124+
family: arm
114125
compiler: arm-linux-gnueabihf-gcc
115126
cross_compile: arm-linux-gnueabihf
116127
pkg_config_path: /usr/lib/arm-linux-gnueabihf/pkgconfig
117128
variant: cross-compile
118129

119130
- container: "debian:stable"
120131
arch: arm64
132+
family: aarch64
121133
compiler: aarch64-linux-gnu-gcc
122134
cross_compile: aarch64-linux-gnu
123135
pkg_config_path: /usr/lib/aarch64-linux-gnu/pkgconfig
124136
variant: cross-compile
125137

126138
- container: "debian:stable"
127139
arch: ppc64el
140+
family: ppc64
128141
compiler: powerpc64le-linux-gnu-gcc
129142
cross_compile: powerpc64le-linux-gnu
130143
pkg_config_path: /usr/lib/powerpc64le-linux-gnu/pkgconfig
131144
variant: cross-compile
132145

133146
- container: "debian:stable"
134147
arch: s390x
148+
family: s390x
135149
compiler: s390x-linux-gnu-gcc
136150
cross_compile: s390x-linux-gnu
137151
pkg_config_path: /usr/lib/s390x-linux-gnu/pkgconfig
@@ -141,9 +155,9 @@ jobs:
141155
image: ${{ matrix.container }}
142156
env:
143157
ARCH: ${{ matrix.arch }}
158+
FAMILY: ${{ matrix.family }}
144159
CC: ${{ matrix.compiler }}
145160
CROSS_COMPILE: ${{ matrix.cross_compile }}
146-
MODE: ${{ matrix.mode }}
147161
PKG_CONFIG_PATH: ${{ matrix.pkg_config_path }}
148162
VARIANT: ${{ matrix.variant }}
149163

@@ -154,10 +168,11 @@ jobs:
154168
- name: Show env (matrix settings)
155169
run: |
156170
echo "ARCH: $ARCH"
171+
echo "FAMILY: $FAMILY"
157172
echo "CC: $CC"
158173
echo "CROSS_COMPILE: $CROSS_COMPILE"
159-
echo "MODE: $MODE"
160174
echo "VARIANT: $VARIANT"
175+
echo "PKG_CONFIG_PATH: $PKG_CONFIG_PATH"
161176
162177
- name: Git checkout
163178
uses: actions/checkout@v3
@@ -187,8 +202,41 @@ jobs:
187202
echo "############################################"
188203
printenv
189204
205+
# i386 build on x86_64 only requires passing -m32 to CFLAGS & LDFLAGS
206+
- name: Meson init for i386
207+
if: ${{ matrix.variant == 'i386' }}
208+
run: |
209+
mkdir build
210+
CFLAGS="-m32" LDFLAGS="-m32" meson setup . build
211+
212+
- name: Meson init with cross compile
213+
if: ${{ matrix.variant == 'cross-compile' }}
214+
run: |
215+
# Generate cross compile file (see https://mesonbuild.com/Cross-compilation.html#cross-compilation)
216+
echo "[binaries]" > cross.txt
217+
echo "c = '${CROSS_COMPILE}-gcc'" >> cross.txt
218+
echo "strip = '${CROSS_COMPILE}-strip'" >> cross.txt
219+
# Forcing pkgconfig binary to 'pkg-config' is required for cross build to work
220+
echo "pkgconfig = 'pkg-config'" >> cross.txt
221+
echo "[host_machine]" >> cross.txt
222+
echo "system = 'linux'" >> cross.txt
223+
echo "cpu_family = '${FAMILY}'" >> cross.txt
224+
echo "cpu = '${ARCH}'" >> cross.txt
225+
echo "endian = 'little'" >> cross.txt
226+
echo "[properties]" >> cross.txt
227+
echo "pkg_config_libdir = '${PKG_CONFIG_PATH}'" >> cross.txt
228+
cat cross.txt
229+
mkdir build
230+
meson setup --cross-file cross.txt . build
231+
232+
- name: Meson init
233+
if: ${{ matrix.variant == '' }}
234+
run: |
235+
mkdir build
236+
meson setup . build
237+
190238
- name: Compile
191-
run: make -j$(nproc)
239+
run: ninja -C build
192240

193241
- name: Install
194-
run: make install
242+
run: ninja -C build install

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ jobs:
3434
- name: Install additional packages
3535
run: sudo ./ci/ubuntu.sh
3636

37-
- name: Compile
38-
run: |
39-
make -j$(nproc)
37+
- name: Autobuild
38+
uses: github/codeql-action/autobuild@v2
4039

4140
- name: Perform CodeQL Analysis
4241
uses: github/codeql-action/analyze@v2

Makefile

Lines changed: 0 additions & 51 deletions
This file was deleted.

README

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@ The CDBA control tool is used for remotely booting images on development boards
33
attached using a CDB Assist [https://github.com/sonyxperiadev/CDB-Assist] or Conmux.
44

55
= Dependencies
6-
sudo apt-get install libudev-dev libyaml-dev for debian systems
7-
dnf install systemd-devel libyaml-devel for fedora systems
6+
sudo apt-get install libudev-dev libyaml-dev libftdi1-dev pkg-config meson for debian systems
7+
dnf install systemd-devel libyaml-devel libftdi1-devel pkg-config meson for fedora systems
88

99
= Device side
1010
On the host with the CDB Assist or Conmux attached the "cdba-server" executable is run
1111
from sandbox/cdba/cdba-server. Available devices are read from $HOME/.cdba
1212

13+
= Build instructions
14+
15+
# meson . build
16+
# ninja -C build
17+
1318
= Client side
1419
The client is invoked as:
1520

ci/archlinux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ pacman -Syu --noconfirm \
2020
libftdi-compat \
2121
libyaml \
2222
systemd-libs \
23-
make \
2423
pkgconf \
24+
meson \
2525
$PKGS_CC
2626

2727
echo "Install finished: $0"

ci/debian.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ apt install -y --no-install-recommends \
3232
libftdi-dev \
3333
libudev-dev \
3434
libyaml-dev \
35-
make \
35+
meson \
3636
$PKGS_CC
3737

3838
echo "Install finished: $0"

ci/fedora.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dnf -y install \
2020
libftdi-devel \
2121
libudev-devel \
2222
libyaml-devel \
23-
make \
23+
meson \
2424
$PKGS_CC
2525

2626
echo "Install finished: $0"

conmux.c

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ struct conmux {
5151

5252
struct conmux_lookup {
5353
char *host;
54-
int port;
54+
char *port;
5555
};
5656

5757
struct conmux_response {
@@ -193,7 +193,7 @@ static int registry_lookup(const char *service, struct conmux_lookup *result)
193193
*p++ = '\0';
194194

195195
result->host = strdup(resp.result);
196-
result->port = strtol(p, NULL, 10);
196+
result->port = strdup(p);
197197

198198
ret = strcmp(resp.status, "OK") ? -1 : 0;
199199

@@ -226,17 +226,16 @@ static int conmux_data(int fd, void *data)
226226

227227
void *conmux_open(struct device *dev)
228228
{
229+
struct addrinfo hints = {0}, *addrs, *addr;
229230
struct conmux_response resp = {};
230231
struct conmux_lookup lookup;
231-
struct sockaddr_in saddr;
232232
struct conmux *conmux;
233-
struct hostent *hent;
234233
const char *service = dev->control_dev;
235234
const char *user;
236235
ssize_t n;
237236
char req[256];
238237
int ret;
239-
int fd;
238+
int fd = -1;
240239

241240
user = getenv("USER");
242241
if (!user)
@@ -246,27 +245,31 @@ void *conmux_open(struct device *dev)
246245
if (ret)
247246
exit(1);
248247

249-
fprintf(stderr, "conmux device at %s:%d\n", lookup.host, lookup.port);
248+
fprintf(stderr, "conmux device at %s:%s\n", lookup.host, lookup.port);
250249

251-
fd = socket(AF_INET, SOCK_STREAM, 0);
252-
if (fd < 0)
253-
err(1, "failed to create registry socket");
250+
hints.ai_family = AF_UNSPEC;
251+
hints.ai_socktype = SOCK_STREAM;
252+
hints.ai_protocol = IPPROTO_TCP;
254253

255-
memset(&saddr, 0, sizeof(saddr));
256-
saddr.sin_family = AF_INET;
257-
saddr.sin_port = htons(lookup.port);
254+
ret = getaddrinfo(lookup.host, lookup.port, &hints, &addrs);
255+
if (ret != 0)
256+
errx(1, "failed resolve \"%s\": %s", lookup.host, gai_strerror(ret));
258257

259-
hent = gethostbyname(lookup.host);
260-
if (!hent) {
261-
errno = h_errno;
262-
err(1, "failed resolve \"%s\"", lookup.host);
263-
}
258+
for (addr = addrs; addr; addr = addr->ai_next) {
259+
fd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
260+
if (fd < 0)
261+
err(1, "failed to create registry socket");
264262

265-
saddr.sin_addr = *(struct in_addr *)hent->h_addr_list[0];
263+
ret = connect(fd, addr->ai_addr, addr->ai_addrlen);
264+
if (ret < 0) {
265+
warn("failed to connect to conmux instance");
266+
close(fd);
267+
fd = -1;
268+
}
269+
}
266270

267-
ret = connect(fd, (struct sockaddr *)&saddr, sizeof(saddr));
268-
if (ret < 0)
269-
err(1, "failed to connect to conmux instance");
271+
if (fd == -1)
272+
errx(1, "failed to connect to conmux instance");
270273

271274
ret = snprintf(req, sizeof(req), "CONNECT id=cdba:%s to=console\n", user);
272275
if (ret >= (int)sizeof(req))

0 commit comments

Comments
 (0)