Skip to content

Commit

Permalink
Merge pull request #14 from superna9999/meson-build
Browse files Browse the repository at this point in the history
Introduce meson.build
  • Loading branch information
lumag authored Oct 2, 2023
2 parents c403782 + 4225dc8 commit f09b3e1
Show file tree
Hide file tree
Showing 9 changed files with 165 additions and 88 deletions.
64 changes: 56 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
fail-fast: false
matrix:
arch: [x86-64]
family: [x86-64]
compiler: [gcc, clang]
container:
- archlinux:latest
Expand All @@ -47,34 +48,39 @@ jobs:
- ubuntu:jammy
- ubuntu:focal
- ubuntu:bionic
- ubuntu:xenial
# Meson version on Ubuntu Xenial is really too old
#- ubuntu:xenial
cross_compile: [""]
variant: [""]
include:
# Debian 32-bit builds
- container: "debian:testing"
arch: i386
compiler: gcc -m32
family: x86
compiler: gcc
cross_compile: i686-linux-gnu
pkg_config_path: /usr/lib/i386-linux-gnu/pkgconfig
variant: i386

- container: "debian:stable"
arch: i386
compiler: gcc -m32
family: x86
compiler: gcc
cross_compile: i686-linux-gnu
pkg_config_path: /usr/lib/i386-linux-gnu/pkgconfig
variant: i386

- container: "debian:bookworm"
arch: i386
compiler: gcc -m32
family: x86
compiler: gcc
cross_compile: i686-linux-gnu
pkg_config_path: /usr/lib/i386-linux-gnu/pkgconfig
variant: i386

- container: "debian:buster"
arch: i386
family: x86
compiler: gcc -m32
cross_compile: i686-linux-gnu
pkg_config_path: /usr/lib/i386-linux-gnu/pkgconfig
Expand All @@ -83,55 +89,63 @@ jobs:
# Debian cross compilation builds
- container: "debian:testing"
arch: armhf
family: arm
compiler: arm-linux-gnueabihf-gcc
cross_compile: arm-linux-gnueabihf
pkg_config_path: /usr/lib/arm-linux-gnueabihf/pkgconfig
variant: cross-compile

- container: "debian:testing"
arch: arm64
family: aarch64
compiler: aarch64-linux-gnu-gcc
cross_compile: aarch64-linux-gnu
pkg_config_path: /usr/lib/aarch64-linux-gnu/pkgconfig
variant: cross-compile

- container: "debian:testing"
arch: ppc64el
family: ppc64
compiler: powerpc64le-linux-gnu-gcc
cross_compile: powerpc64le-linux-gnu
pkg_config_path: /usr/lib/powerpc64le-linux-gnu/pkgconfig
variant: cross-compile

- container: "debian:testing"
arch: s390x
family: s390x
compiler: s390x-linux-gnu-gcc
cross_compile: s390x-linux-gnu
pkg_config_path: /usr/lib/s390x-linux-gnu/pkgconfig
variant: cross-compile

- container: "debian:stable"
arch: armhf
family: arm
compiler: arm-linux-gnueabihf-gcc
cross_compile: arm-linux-gnueabihf
pkg_config_path: /usr/lib/arm-linux-gnueabihf/pkgconfig
variant: cross-compile

- container: "debian:stable"
arch: arm64
family: aarch64
compiler: aarch64-linux-gnu-gcc
cross_compile: aarch64-linux-gnu
pkg_config_path: /usr/lib/aarch64-linux-gnu/pkgconfig
variant: cross-compile

- container: "debian:stable"
arch: ppc64el
family: ppc64
compiler: powerpc64le-linux-gnu-gcc
cross_compile: powerpc64le-linux-gnu
pkg_config_path: /usr/lib/powerpc64le-linux-gnu/pkgconfig
variant: cross-compile

- container: "debian:stable"
arch: s390x
family: s390x
compiler: s390x-linux-gnu-gcc
cross_compile: s390x-linux-gnu
pkg_config_path: /usr/lib/s390x-linux-gnu/pkgconfig
Expand All @@ -141,9 +155,9 @@ jobs:
image: ${{ matrix.container }}
env:
ARCH: ${{ matrix.arch }}
FAMILY: ${{ matrix.family }}
CC: ${{ matrix.compiler }}
CROSS_COMPILE: ${{ matrix.cross_compile }}
MODE: ${{ matrix.mode }}
PKG_CONFIG_PATH: ${{ matrix.pkg_config_path }}
VARIANT: ${{ matrix.variant }}

Expand All @@ -154,10 +168,11 @@ jobs:
- name: Show env (matrix settings)
run: |
echo "ARCH: $ARCH"
echo "FAMILY: $FAMILY"
echo "CC: $CC"
echo "CROSS_COMPILE: $CROSS_COMPILE"
echo "MODE: $MODE"
echo "VARIANT: $VARIANT"
echo "PKG_CONFIG_PATH: $PKG_CONFIG_PATH"
- name: Git checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -187,8 +202,41 @@ jobs:
echo "############################################"
printenv
# i386 build on x86_64 only requires passing -m32 to CFLAGS & LDFLAGS
- name: Meson init for i386
if: ${{ matrix.variant == 'i386' }}
run: |
mkdir build
CFLAGS="-m32" LDFLAGS="-m32" meson setup . build
- name: Meson init with cross compile
if: ${{ matrix.variant == 'cross-compile' }}
run: |
# Generate cross compile file (see https://mesonbuild.com/Cross-compilation.html#cross-compilation)
echo "[binaries]" > cross.txt
echo "c = '${CROSS_COMPILE}-gcc'" >> cross.txt
echo "strip = '${CROSS_COMPILE}-strip'" >> cross.txt
# Forcing pkgconfig binary to 'pkg-config' is required for cross build to work
echo "pkgconfig = 'pkg-config'" >> cross.txt
echo "[host_machine]" >> cross.txt
echo "system = 'linux'" >> cross.txt
echo "cpu_family = '${FAMILY}'" >> cross.txt
echo "cpu = '${ARCH}'" >> cross.txt
echo "endian = 'little'" >> cross.txt
echo "[properties]" >> cross.txt
echo "pkg_config_libdir = '${PKG_CONFIG_PATH}'" >> cross.txt
cat cross.txt
mkdir build
meson setup --cross-file cross.txt . build
- name: Meson init
if: ${{ matrix.variant == '' }}
run: |
mkdir build
meson setup . build
- name: Compile
run: make -j$(nproc)
run: ninja -C build

- name: Install
run: make install
run: ninja -C build install
5 changes: 2 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ jobs:
- name: Install additional packages
run: sudo ./ci/ubuntu.sh

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

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
51 changes: 0 additions & 51 deletions Makefile

This file was deleted.

9 changes: 7 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ The CDBA control tool is used for remotely booting images on development boards
attached using a CDB Assist [https://github.com/sonyxperiadev/CDB-Assist] or Conmux.

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

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

= Build instructions

# meson . build
# ninja -C build

= Client side
The client is invoked as:

Expand Down
2 changes: 1 addition & 1 deletion ci/archlinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ pacman -Syu --noconfirm \
libftdi-compat \
libyaml \
systemd-libs \
make \
pkgconf \
meson \
$PKGS_CC

echo "Install finished: $0"
2 changes: 1 addition & 1 deletion ci/debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ apt install -y --no-install-recommends \
libftdi-dev \
libudev-dev \
libyaml-dev \
make \
meson \
$PKGS_CC

echo "Install finished: $0"
2 changes: 1 addition & 1 deletion ci/fedora.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dnf -y install \
libftdi-devel \
libudev-devel \
libyaml-devel \
make \
meson \
$PKGS_CC

echo "Install finished: $0"
45 changes: 24 additions & 21 deletions conmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct conmux {

struct conmux_lookup {
char *host;
int port;
char *port;
};

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

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

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

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

void *conmux_open(struct device *dev)
{
struct addrinfo hints = {0}, *addrs, *addr;
struct conmux_response resp = {};
struct conmux_lookup lookup;
struct sockaddr_in saddr;
struct conmux *conmux;
struct hostent *hent;
const char *service = dev->control_dev;
const char *user;
ssize_t n;
char req[256];
int ret;
int fd;
int fd = -1;

user = getenv("USER");
if (!user)
Expand All @@ -246,27 +245,31 @@ void *conmux_open(struct device *dev)
if (ret)
exit(1);

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

fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0)
err(1, "failed to create registry socket");
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;

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

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

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

ret = connect(fd, (struct sockaddr *)&saddr, sizeof(saddr));
if (ret < 0)
err(1, "failed to connect to conmux instance");
if (fd == -1)
errx(1, "failed to connect to conmux instance");

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

0 comments on commit f09b3e1

Please sign in to comment.