From 28e04342db2865a13750a844249715263e2bdbb3 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Tue, 18 Jan 2022 12:55:20 +0000 Subject: [PATCH 01/37] local: Simplify code iio_device_get_sample_size_mask(dev, dev->mask, dev->words) is the exact same as: iio_device_get_sample_size(dev) Signed-off-by: Paul Cercueil --- local.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/local.c b/local.c index 02088c629..daa39dc90 100644 --- a/local.c +++ b/local.c @@ -848,8 +848,7 @@ static int enable_high_speed(const struct iio_device *dev) req.id = 0; req.type = 0; - req.size = pdata->samples_count * - iio_device_get_sample_size_mask(dev, dev->mask, dev->words); + req.size = pdata->samples_count * iio_device_get_sample_size(dev); req.count = nb_blocks; ret = ioctl_nointr(fd, BLOCK_ALLOC_IOCTL, &req); From 87699e7f2357b9448ad9d7f0b777a110babd3f05 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Mon, 8 Nov 2021 13:54:49 +0000 Subject: [PATCH 02/37] Add option to disable MMAP API Since the high-speed MMAP API is specific to Analog Devices' Linux kernel, add an option to disable it. Signed-off-by: Paul Cercueil --- CMakeLists.txt | 2 ++ iio-config.h.cmakein | 1 + local.c | 12 +++++++----- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b583a4a9..30576c045 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -247,6 +247,7 @@ if(WITH_LOCAL_BACKEND) list(APPEND LIBIIO_CFILES ./libini/libini.c) endif() + option(WITH_LOCAL_MMAP_API "Use the mmap API provided in Analog Devices' kernel (not upstream)" ON) option(WITH_HWMON "Add compatibility with the hardware monitoring (hwmon) subsystem" OFF) endif() @@ -621,6 +622,7 @@ list(APPEND IIO_FEATURES_${HAVE_BONJOUR} bonjour) list(APPEND IIO_FEATURES_${ENABLE_IPV6} ipv6) list(APPEND IIO_FEATURES_${WITH_SERIAL_BACKEND} serial) list(APPEND IIO_FEATURES_${WITH_LOCAL_BACKEND} local) +list(APPEND IIO_FEATURES_${WITH_LOCAL_MMAP_API} local-mmap) list(APPEND IIO_FEATURES_${WITH_HWMON} hwmon) list(APPEND IIO_FEATURES_${WITH_USB_BACKEND} usb) list(APPEND IIO_FEATURES_${WITH_TESTS} utils) diff --git a/iio-config.h.cmakein b/iio-config.h.cmakein index a6cc0160c..ab2687dc2 100644 --- a/iio-config.h.cmakein +++ b/iio-config.h.cmakein @@ -18,6 +18,7 @@ #cmakedefine01 WITH_IIOD_USBD #cmakedefine01 WITH_IIOD_SERIAL #cmakedefine01 WITH_LOCAL_CONFIG +#cmakedefine01 WITH_LOCAL_MMAP_API #cmakedefine01 WITH_HWMON #cmakedefine01 WITH_AIO #cmakedefine01 HAVE_DNS_SD diff --git a/local.c b/local.c index daa39dc90..10a4a993d 100644 --- a/local.c +++ b/local.c @@ -439,7 +439,7 @@ static ssize_t local_get_buffer(const struct iio_device *dev, int f = pdata->fd; ssize_t ret; - if (!pdata->is_high_speed) + if (!WITH_LOCAL_MMAP_API || !pdata->is_high_speed) return -ENOSYS; if (f == -1) return -EBADF; @@ -957,11 +957,13 @@ static int local_open(const struct iio_device *dev, pdata->cyclic_buffer_enqueued = false; pdata->samples_count = samples_count; - ret = enable_high_speed(dev); - if (ret < 0 && ret != -ENOSYS) - goto err_close; + if (WITH_LOCAL_MMAP_API) { + ret = enable_high_speed(dev); + if (ret < 0 && ret != -ENOSYS) + goto err_close; - pdata->is_high_speed = !ret; + pdata->is_high_speed = !ret; + } if (!pdata->is_high_speed) { unsigned long size = samples_count * pdata->max_nb_blocks; From 5b4cd21e86247a81d5ceaec4b4ad8200c4314f38 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Mon, 17 Jan 2022 09:30:30 +0000 Subject: [PATCH 03/37] local: Add support for setting watermark Add support for setting the watermark value, if the driver supports it. The watermark value represents the number of samples that will be read in one burst from the hardware. Since we read data at the granularity of iio_buffer blocks, it makes sense to use the highest watermark value up to the buffer's size. If the value is too high, the driver will automatically adjust it to the maximum watermark value possible. Fixes #780. Signed-off-by: Paul Cercueil --- local.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/local.c b/local.c index 10a4a993d..df85f8133 100644 --- a/local.c +++ b/local.c @@ -104,6 +104,7 @@ static const char * const device_attrs_blacklist[] = { static const char * const buffer_attrs_reserved[] = { "length", "enable", + "watermark", }; static int ioctl_nointr(int fd, unsigned long request, void *data) @@ -923,6 +924,15 @@ static int local_open(const struct iio_device *dev, if (ret < 0) return ret; + /* + * Set watermark to the buffer size; the driver will adjust to its + * maximum if it's too high without issueing an error. + */ + ret = local_write_dev_attr(dev, "buffer/watermark", + buf, strlen(buf) + 1, false); + if (ret < 0 && ret != -ENOENT) + return ret; + pdata->cancel_fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); if (pdata->cancel_fd == -1) return -errno; From 2b9fb23f083fa21e29b1c3c7a5d789d4dcd198b2 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Tue, 1 Feb 2022 11:08:32 +0000 Subject: [PATCH 04/37] Fix hwmon channel type set to unknown if !WITH_HWMON Libiio being compiled without support for hwmon devices means that the local backend won't try to probe hwmon devices; but hwmon devices found by a remote libiio should still be usable across the network or USB, even if WITH_HWMON is disabled locally. Until now if the host libiio was compiled without hwmon support, it could see the target's hwmon devices but their type was wrong. Signed-off-by: Paul Cercueil Reported-by: Adrian Suciu --- channel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/channel.c b/channel.c index b89413481..7a60f6572 100644 --- a/channel.c +++ b/channel.c @@ -177,7 +177,7 @@ void iio_channel_init_finalize(struct iio_channel *chn) char *mod; int type; - if (WITH_HWMON && iio_device_is_hwmon(chn->dev)) { + if (iio_device_is_hwmon(chn->dev)) { type = iio_channel_find_type(chn->id, hwmon_chan_type_name_spec, ARRAY_SIZE(hwmon_chan_type_name_spec)); } else { From bb973958cbbff213de4f133cbb54bc0222319711 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Wed, 2 Feb 2022 13:26:09 +0000 Subject: [PATCH 05/37] local: ignore "permission denied" error on accessing watermark The watermark attribute may be set to read-only by the kernel. In that case, trying to open it for writing will return -EACCES, aka. "permission denied". Therefore, the -EACCES error needs to be ignored. This is a bit annoying, since we cannot know if it happens because the attribute itself was set read-only by the kernel, or because the user simply doesn't have the necesary access rights to write the file. But it is rather safe to assume it is not the latter, as the "buffer/length" attribute was written just a bit before without returning an error. Signed-off-by: Paul Cercueil --- local.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/local.c b/local.c index df85f8133..d14d133f5 100644 --- a/local.c +++ b/local.c @@ -930,7 +930,7 @@ static int local_open(const struct iio_device *dev, */ ret = local_write_dev_attr(dev, "buffer/watermark", buf, strlen(buf) + 1, false); - if (ret < 0 && ret != -ENOENT) + if (ret < 0 && ret != -ENOENT && ret != -EACCES) return ret; pdata->cancel_fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); From 0939f127ca5fa431df6d88758796c0cb1590174f Mon Sep 17 00:00:00 2001 From: Raluca Chis Date: Wed, 9 Feb 2022 14:23:09 +0200 Subject: [PATCH 06/37] CI: drop centOS 8 build Signed-off-by: Raluca Chis --- azure-pipelines.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 39cdca59d..af4b780fd 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -25,11 +25,6 @@ stages: OS_TYPE: 'centos_docker' OS_VERSION: centos7 artifactName: 'Linux-CentOS-7-x86_64' - centos_8_x86_64: - imageName: 'ubuntu-latest' - OS_TYPE: 'centos_docker' - OS_VERSION: centos8 - artifactName: 'Linux-CentOS-8-x86_64' ubuntu_16_04_x86_64: imageName: 'ubuntu-latest' OS_TYPE: 'ubuntu_docker' From 0ed18cd8f6b2fac5204a99e38922bea73f1f778c Mon Sep 17 00:00:00 2001 From: Raluca Chis Date: Thu, 10 Feb 2022 09:24:52 +0200 Subject: [PATCH 07/37] CI: fix PushArtifacts stage Signed-off-by: Raluca Chis --- CI/travis/prepare_assets.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CI/travis/prepare_assets.sh b/CI/travis/prepare_assets.sh index 0fb116a68..efe325b7a 100755 --- a/CI/travis/prepare_assets.sh +++ b/CI/travis/prepare_assets.sh @@ -1,7 +1,7 @@ #!/bin/bash -e release_artifacts() { - local rpm_assets='CentOS-7-x86_64 CentOS-8-x86_64' + local rpm_assets='CentOS-7-x86_64' cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" for i in $rpm_assets; do cd "${i}" @@ -40,7 +40,7 @@ release_artifacts() { } swdownloads_artifacts() { - local linux_dist='CentOS-7-x86_64 CentOS-8-x86_64 Ubuntu-16.04-x86_64 Ubuntu-18.04-x86_64 + local linux_dist='CentOS-7-x86_64 Ubuntu-16.04-x86_64 Ubuntu-18.04-x86_64 Ubuntu-20.04-x86_64 Debian-Buster-ARM Debian-Buster-ARM64' for distribution in $linux_dist; do cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" From e9c801112c28e27ada054bae5ed260d4618f5f21 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Wed, 9 Feb 2022 11:03:54 +0000 Subject: [PATCH 08/37] iio-backend: Remove unused callback .get_description This callback was introduced in commit d61f6296 ("iio: backend: add get_description() backend op") but was never called anywhere, as the backend's description string is also present in the XML directly. Signed-off-by: Paul Cercueil --- iio-backend.h | 2 -- local.c | 1 - network.c | 12 ++---------- serial.c | 12 ++---------- 4 files changed, 4 insertions(+), 23 deletions(-) diff --git a/iio-backend.h b/iio-backend.h index 582132456..0a05c5a22 100644 --- a/iio-backend.h +++ b/iio-backend.h @@ -60,8 +60,6 @@ struct iio_backend_ops { void (*shutdown)(struct iio_context *ctx); - char * (*get_description)(const struct iio_context *ctx); - int (*get_version)(const struct iio_context *ctx, unsigned int *major, unsigned int *minor, char git_tag[8]); diff --git a/local.c b/local.c index d14d133f5..a038b223d 100644 --- a/local.c +++ b/local.c @@ -1976,7 +1976,6 @@ static const struct iio_backend_ops local_ops = { .get_trigger = local_get_trigger, .set_trigger = local_set_trigger, .shutdown = local_shutdown, - .get_description = local_get_description, .set_timeout = local_set_timeout, .cancel = local_cancel, }; diff --git a/network.c b/network.c index 3b39c89ec..c1b64e72c 100644 --- a/network.c +++ b/network.c @@ -282,7 +282,7 @@ int create_socket(const struct addrinfo *addrinfo) return fd; } -static char * __network_get_description(struct addrinfo *res) +static char * network_get_description(struct addrinfo *res) { char *description; unsigned int len; @@ -334,13 +334,6 @@ static char * __network_get_description(struct addrinfo *res) return description; } -static char *network_get_description(const struct iio_context *ctx) -{ - struct iio_context_pdata *pdata = iio_context_get_pdata(ctx); - - return __network_get_description(pdata->addrinfo); -} - static int network_open(const struct iio_device *dev, size_t samples_count, bool cyclic) { @@ -926,7 +919,6 @@ static const struct iio_backend_ops network_ops = { .get_trigger = network_get_trigger, .set_trigger = network_set_trigger, .shutdown = network_shutdown, - .get_description = network_get_description, .get_version = network_get_version, .set_timeout = network_set_timeout, .set_kernel_buffers_count = network_set_kernel_buffers_count, @@ -1144,7 +1136,7 @@ struct iio_context * network_create_context(const char *host) goto err_close_socket; } - description = __network_get_description(res); + description = network_get_description(res); if (!description) goto err_free_pdata; diff --git a/serial.c b/serial.c index 6fe4a11eb..adf2b3c49 100644 --- a/serial.c +++ b/serial.c @@ -105,7 +105,7 @@ static int serial_get_version(const struct iio_context *ctx, major, minor, git_tag); } -static char * __serial_get_description(struct sp_port *port) +static char * serial_get_description(struct sp_port *port) { char *description, *name, *desc; size_t desc_len; @@ -125,13 +125,6 @@ static char * __serial_get_description(struct sp_port *port) return description; } -static char * serial_get_description(const struct iio_context *ctx) -{ - struct iio_context_pdata *pdata = iio_context_get_pdata(ctx); - - return __serial_get_description(pdata->port); -} - static int serial_open(const struct iio_device *dev, size_t samples_count, bool cyclic) { @@ -385,7 +378,6 @@ static const struct iio_backend_ops serial_ops = { .write_channel_attr = serial_write_chn_attr, .set_kernel_buffers_count = serial_set_kernel_buffers_count, .shutdown = serial_shutdown, - .get_description = serial_get_description, .set_timeout = serial_set_timeout, .get_trigger = serial_get_trigger, .set_trigger = serial_set_trigger, @@ -463,7 +455,7 @@ static struct iio_context * serial_create_context(const char *port_name, /* Empty the buffers */ sp_flush(port, SP_BUF_BOTH); - description = __serial_get_description(port); + description = serial_get_description(port); if (!description) goto err_close_port; From 60c33c4c27c6ca0affa5403c006e7b3ec53d7200 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Wed, 16 Feb 2022 13:23:34 +0000 Subject: [PATCH 09/37] iio_info: Remove -s option iio_info had two possible options to scan for contexts: -S (aka. --scan) and -s, which did more or less the same thing, but -s didn't take an argument and scanned all possible contexts. Remove the -s option in the help text to reduce the confusion, while still handling it for backwards-compatibility. Signed-off-by: Paul Cercueil --- man/iio_info.1.in | 2 +- tests/iio_info.c | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/man/iio_info.1.in b/man/iio_info.1.in index 9fcd5be24..1d5a88aed 100644 --- a/man/iio_info.1.in +++ b/man/iio_info.1.in @@ -78,7 +78,7 @@ normally returned from with no address part .RE .TP -.B \-s, \-\-scan +.B \-S, \-\-scan Scan for available backends .TP .B \-a, \-\-auto diff --git a/tests/iio_info.c b/tests/iio_info.c index 6e98fe2da..f7ba27577 100644 --- a/tests/iio_info.c +++ b/tests/iio_info.c @@ -35,14 +35,12 @@ #endif static const struct option options[] = { - {"scan", no_argument, 0, 's'}, {0, 0, 0, 0}, }; static const char *options_descriptions[] = { "[-x ]\n" "\t\t\t\t[-u ]", - "Scan for available backends.", }; static int dev_is_buffer_capable(const struct iio_device *dev) @@ -59,7 +57,7 @@ static int dev_is_buffer_capable(const struct iio_device *dev) return false; } -#define MY_OPTS "s" +#define MY_OPTS "" int main(int argc, char **argv) { @@ -87,7 +85,7 @@ int main(int argc, char **argv) fprintf(stderr, "Failed to add common options\n"); return EXIT_FAILURE; } - while ((c = getopt_long(argc, argw, "+" COMMON_OPTIONS MY_OPTS, /* Flawfinder: ignore */ + while ((c = getopt_long(argc, argw, "+" COMMON_OPTIONS MY_OPTS "s", /* Flawfinder: ignore */ opts, NULL)) != -1) { switch (c) { /* All these are handled in the common */ From 77a3f61687f2347b36fb8bf95d5118b1bf0ffb45 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Thu, 18 Nov 2021 16:57:01 -0500 Subject: [PATCH 10/37] Altough strndup is POSIX.1-2008; Windows does not provide it Add a backup function for Windows machines. Signed-off-by: Robin Getz --- iio-private.h | 1 + utilities.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/iio-private.h b/iio-private.h index 41872d154..6938a9e9c 100644 --- a/iio-private.h +++ b/iio-private.h @@ -260,6 +260,7 @@ void iio_channel_init_finalize(struct iio_channel *chn); unsigned int find_channel_modifier(const char *s, size_t *len_p); char *iio_strdup(const char *str); +char *iio_strndup(const char *str, size_t n); size_t iio_strlcpy(char * __restrict dst, const char * __restrict src, size_t dsize); char * iio_getenv (char * envvar); diff --git a/utilities.c b/utilities.c index 579555d50..132c75845 100644 --- a/utilities.c +++ b/utilities.c @@ -229,6 +229,24 @@ char *iio_strdup(const char *str) #endif } +/* strndup conforms to POSIX.1-2008; but Windows does not provided it + */ +char *iio_strndup(const char *str, size_t n) +{ +#ifdef HAS_STRNDUP + return strndup(str, n); +#else + size_t len = strnlen(str, n + 1); + char *buf = malloc(len + 1); + if (buf) { + /* len = size of buf, so memcpy is OK */ + memcpy(buf, str, len); /* Flawfinder: ignore */ + buf[len] = 0; + } + return buf; +#endif +} + /* strlcpy is designed to be safer, more consistent, and less error prone * replacements for strncpy, since it guarantees to NUL-terminate the result. * From 84ad761e7d44b1f1cbde58a9fc1d834849b074ad Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Mon, 22 Nov 2021 18:25:49 -0500 Subject: [PATCH 11/37] Windows doesn't provide strtok_r, it uses strtok_s so wrap it to make sure we can find it. Signed-off-by: Robin Getz --- CMakeLists.txt | 1 + iio-config.h.cmakein | 1 + iio-private.h | 1 + utilities.c | 11 +++++++++++ 4 files changed, 14 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 30576c045..698676f6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,6 +130,7 @@ include(CheckSymbolExists) check_symbol_exists(strdup "string.h" HAS_STRDUP) check_symbol_exists(strndup "string.h" HAS_STRNDUP) check_symbol_exists(strerror_r "string.h" HAS_STRERROR_R) +check_symbol_exists(strtok_r "string.h" HAS_STRTOK_R) check_symbol_exists(newlocale "locale.h" HAS_NEWLOCALE) option(ENABLE_IPV6 "Define if you want to enable IPv6 support" ON) diff --git a/iio-config.h.cmakein b/iio-config.h.cmakein index ab2687dc2..6f8932536 100644 --- a/iio-config.h.cmakein +++ b/iio-config.h.cmakein @@ -28,6 +28,7 @@ #cmakedefine HAS_PIPE2 #cmakedefine HAS_STRDUP #cmakedefine HAS_STRNDUP +#cmakedefine HAS_STRTOK_R #cmakedefine HAS_STRERROR_R #cmakedefine HAS_NEWLOCALE #cmakedefine HAS_PTHREAD_SETNAME_NP diff --git a/iio-private.h b/iio-private.h index 6938a9e9c..71a46afef 100644 --- a/iio-private.h +++ b/iio-private.h @@ -261,6 +261,7 @@ unsigned int find_channel_modifier(const char *s, size_t *len_p); char *iio_strdup(const char *str); char *iio_strndup(const char *str, size_t n); +char *iio_strtok_r(char *str, const char *delim, char **saveptr); size_t iio_strlcpy(char * __restrict dst, const char * __restrict src, size_t dsize); char * iio_getenv (char * envvar); diff --git a/utilities.c b/utilities.c index 132c75845..87b7f516e 100644 --- a/utilities.c +++ b/utilities.c @@ -213,6 +213,17 @@ void iio_strerror(int err, char *buf, size_t len) } } +char *iio_strtok_r(char *str, const char *delim, char **saveptr) +{ +#if defined(_WIN32) + return strtok_s(str, delim, saveptr); +#elif defined(HAS_STRTOK_R) + return strtok_r(str, delim, saveptr); +#else +#error Need a implentation of strtok_r for this platform +#endif +} + char *iio_strdup(const char *str) { #if defined(_WIN32) From b058c6977d9f132128335586be29104aa9e6e3cc Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Thu, 17 Feb 2022 09:46:29 +0000 Subject: [PATCH 12/37] scan: Rework scanning Instead of going through the list of enabled backends and checking for each one whether or not we were asked to scan from it, we now go through the user-supplied backends list, find the corresponding backend, and call its scan function. This change will make it possible to support scanning from the same backend multiple times, for instance with different USB devices. Signed-off-by: Paul Cercueil --- scan.c | 66 ++++++++++++++++++++++++++-------------------------------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/scan.c b/scan.c index 4e3515801..bee16f591 100644 --- a/scan.c +++ b/scan.c @@ -14,9 +14,7 @@ #include struct iio_scan_context { - bool scan_usb; - bool scan_network; - bool scan_local; + char *backendopts; }; const char * iio_context_info_get_description( @@ -35,37 +33,34 @@ ssize_t iio_scan_context_get_info_list(struct iio_scan_context *ctx, struct iio_context_info ***info) { struct iio_scan_result scan_result = { 0, NULL }; - - if (WITH_LOCAL_BACKEND && ctx->scan_local) { - int ret = local_context_scan(&scan_result); - if (ret < 0) { - if (scan_result.info) - iio_context_info_list_free(scan_result.info); - return ret; - } - } - - if (WITH_USB_BACKEND && ctx->scan_usb) { - int ret = usb_context_scan(&scan_result); - if (ret < 0) { - if (scan_result.info) - iio_context_info_list_free(scan_result.info); - return ret; - } - } - - if (HAVE_DNS_SD && ctx->scan_network) { - int ret = dnssd_context_scan(&scan_result); - if (ret < 0) { - if (scan_result.info) - iio_context_info_list_free(scan_result.info); - return ret; + char *token, *rest=NULL; + ssize_t ret; + + for (token = iio_strtok_r(ctx->backendopts, ":", &rest); + token; token = iio_strtok_r(NULL, ":", &rest)) { + + /* Since tokens are all null terminated, it's safe to use strcmp on them */ + if (WITH_LOCAL_BACKEND && !strcmp(token, "local")) { + ret = local_context_scan(&scan_result); + } else if (WITH_USB_BACKEND && !strcmp(token, "usb")) { + ret = usb_context_scan(&scan_result); + } else if (HAVE_DNS_SD && !strcmp(token, "ip")) { + ret = dnssd_context_scan(&scan_result); + } else { + ret = -ENODEV; } + if (ret < 0) + goto err_free_scan_result_info; } *info = scan_result.info; return (ssize_t) scan_result.size; + +err_free_scan_result_info: + if (scan_result.info) + iio_context_info_list_free(scan_result.info); + return ret; } void iio_context_info_list_free(struct iio_context_info **list) @@ -126,20 +121,19 @@ struct iio_scan_context * iio_create_scan_context( return NULL; } - if (!backend || strstr(backend, "local")) - ctx->scan_local = true; - - if (!backend || strstr(backend, "usb")) - ctx->scan_usb = true; - - if (!backend || strstr(backend, "ip")) - ctx->scan_network = true; + ctx->backendopts = iio_strndup(backend ? backend : "local:usb:ip", PATH_MAX); + if (!ctx->backendopts) { + free(ctx); + errno = ENOMEM; + return NULL; + } return ctx; } void iio_scan_context_destroy(struct iio_scan_context *ctx) { + free(ctx->backendopts); free(ctx); } From f2728864be119b4dea4304fb52ff904e1655263d Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Thu, 17 Feb 2022 09:47:25 +0000 Subject: [PATCH 13/37] scan: Prefer comma instead of colon for backends separator Libiio 1.x (in the dev branch) uses a comma instead of a colon as the backends separator in the scan list string. This makes it possible to use the colon as the VID/PID separator in the USB backend parameters. Update the code and documentation to specify that commas should be used, while still allowing colons as separators to be backwards-compatible. Signed-off-by: Paul Cercueil --- iio.h | 15 ++++++++++----- scan.c | 15 ++++++++++++--- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/iio.h b/iio.h index 2f6a44321..07a1a8004 100644 --- a/iio.h +++ b/iio.h @@ -236,13 +236,18 @@ enum iio_event_direction { /** @brief Create a scan context - * @param backend A NULL-terminated string containing the backend(s) to use for - * scanning (example: pre version 0.20 : "local", "ip", or "usb"; post version - * 0.20 can handle multiple, including "local:usb:", "ip:usb:", "local:usb:ip:"). - * If NULL, all the available backends are used. + * @param backend A NULL-terminated string containing a comma-separated + * list of the backend(s) to use for scanning. * @param flags Unused for now. Set to 0. * @return on success, a pointer to a iio_scan_context structure - * @return On failure, NULL is returned and errno is set appropriately */ + * @return On failure, NULL is returned and errno is set appropriately + * + * NOTE: Libiio version 0.20 and above can handle multiple + * strings, for instance "local:usb:", "ip:usb:", "local:usb:ip:", and + * require a colon as the delimiter. If NULL, the local, USB and IP + * backends will be scanned. + * Libiio version 0.24 and above prefer a comma instead of colon as the + * delimiter. */ __api __check_ret struct iio_scan_context * iio_create_scan_context( const char *backend, unsigned int flags); diff --git a/scan.c b/scan.c index bee16f591..4e9e72ebc 100644 --- a/scan.c +++ b/scan.c @@ -36,8 +36,8 @@ ssize_t iio_scan_context_get_info_list(struct iio_scan_context *ctx, char *token, *rest=NULL; ssize_t ret; - for (token = iio_strtok_r(ctx->backendopts, ":", &rest); - token; token = iio_strtok_r(NULL, ":", &rest)) { + for (token = iio_strtok_r(ctx->backendopts, ",", &rest); + token; token = iio_strtok_r(NULL, ",", &rest)) { /* Since tokens are all null terminated, it's safe to use strcmp on them */ if (WITH_LOCAL_BACKEND && !strcmp(token, "local")) { @@ -108,6 +108,7 @@ struct iio_scan_context * iio_create_scan_context( const char *backend, unsigned int flags) { struct iio_scan_context *ctx; + unsigned int i, len; /* "flags" must be zero for now */ if (flags != 0) { @@ -121,13 +122,21 @@ struct iio_scan_context * iio_create_scan_context( return NULL; } - ctx->backendopts = iio_strndup(backend ? backend : "local:usb:ip", PATH_MAX); + ctx->backendopts = iio_strndup(backend ? backend : "local,usb,ip", PATH_MAX); if (!ctx->backendopts) { free(ctx); errno = ENOMEM; return NULL; } + if (backend) { + /* Replace the colon separator with a comma. */ + len = strlen(ctx->backendopts); + for (i = 0; i < len; i++) + if (ctx->backendopts[i] == ':') + ctx->backendopts[i] = ','; + } + return ctx; } From d8c87b536af0adb853b277b5c05db66613df5838 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Mon, 15 Nov 2021 10:02:20 -0500 Subject: [PATCH 14/37] usb: when scanning provide option to qualify USB vendor ID or product ID When we do a USB scan, we open each device looking for a string "IIO", and if it is not, then we close the device. The archirecture of libusb is that when we are doing this, other applications are locked out from using that device. This is known to cause some user problems on other devices (not IIO) - most notibly HackRF and USRP. This change adds the ability to restricting scans to certain vendors, or specific product IDs - which is what most purpose build software is looking for. (GNU Radio doesn't want to open every device, only the ones it knows about). This should allow us to play nicer with others. Examples: usb,local local,usb=0456:b673,usb=0456:b672 usb=0456:* VENDOR ID and PRODUCT ID are hexadecimal numbers (no prefix needed), "*" (match any). By default (no vid:pid provided) all devices are opened and checked (which is the previous behavour). Signed-off-by: Robin Getz Signed-off-by: Paul Cercueil --- iio-private.h | 2 +- iio.h | 10 ++++++--- scan.c | 19 ++++++++++++++-- usb.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 85 insertions(+), 7 deletions(-) diff --git a/iio-private.h b/iio-private.h index 71a46afef..9cc50a5c5 100644 --- a/iio-private.h +++ b/iio-private.h @@ -249,7 +249,7 @@ struct iio_context * serial_create_context_from_uri(const char *uri); int local_context_scan(struct iio_scan_result *scan_result); -int usb_context_scan(struct iio_scan_result *scan_result); +int usb_context_scan(struct iio_scan_result *scan_result, const char *args); int dnssd_context_scan(struct iio_scan_result *scan_result); diff --git a/iio.h b/iio.h index 07a1a8004..7442a9f3b 100644 --- a/iio.h +++ b/iio.h @@ -244,10 +244,14 @@ enum iio_event_direction { * * NOTE: Libiio version 0.20 and above can handle multiple * strings, for instance "local:usb:", "ip:usb:", "local:usb:ip:", and - * require a colon as the delimiter. If NULL, the local, USB and IP - * backends will be scanned. + * require a colon as the delimiter. * Libiio version 0.24 and above prefer a comma instead of colon as the - * delimiter. */ + * delimiter, and handle specifying backend-specific information. For + * instance, "local,usb=0456:*" will scan the local backend and limit + * scans on USB to vendor ID 0x0456, and accept all product IDs. The + * "usb=0456:b673" string would limit the scan to the device with this + * particular VID/PID. Both IDs are expected in hexadecimal, no 0x + * prefix needed. */ __api __check_ret struct iio_scan_context * iio_create_scan_context( const char *backend, unsigned int flags); diff --git a/scan.c b/scan.c index 4e9e72ebc..33f2ce2cf 100644 --- a/scan.c +++ b/scan.c @@ -42,8 +42,10 @@ ssize_t iio_scan_context_get_info_list(struct iio_scan_context *ctx, /* Since tokens are all null terminated, it's safe to use strcmp on them */ if (WITH_LOCAL_BACKEND && !strcmp(token, "local")) { ret = local_context_scan(&scan_result); - } else if (WITH_USB_BACKEND && !strcmp(token, "usb")) { - ret = usb_context_scan(&scan_result); + } else if (WITH_USB_BACKEND && (!strcmp(token, "usb") || + !strncmp(token, "usb=", sizeof("usb=") - 1))) { + token = token[3] == '=' ? token + 4 : NULL; + ret = usb_context_scan(&scan_result, token); } else if (HAVE_DNS_SD && !strcmp(token, "ip")) { ret = dnssd_context_scan(&scan_result); } else { @@ -108,6 +110,7 @@ struct iio_scan_context * iio_create_scan_context( const char *backend, unsigned int flags) { struct iio_scan_context *ctx; + char *ptr, *ptr2; unsigned int i, len; /* "flags" must be zero for now */ @@ -135,6 +138,18 @@ struct iio_scan_context * iio_create_scan_context( for (i = 0; i < len; i++) if (ctx->backendopts[i] == ':') ctx->backendopts[i] = ','; + + /* The only place where a colon is accepted is in the usb arguments: + * usb=vid:pid */ + for (ptr = strstr(ctx->backendopts, "usb="); ptr; + ptr = strstr(ptr, "usb=")) { + ptr += sizeof("usb="); + strtoul(ptr, &ptr2, 16); + + /* The USB backend will take care of errors */ + if (ptr2 != ptr && *ptr2 == ',') + *ptr2 = ':'; + } } return ctx; diff --git a/usb.c b/usb.c index 97a4496b9..e12fb332f 100644 --- a/usb.c +++ b/usb.c @@ -1200,14 +1200,58 @@ static int usb_fill_context_info(struct iio_context_info *info, return 0; } -int usb_context_scan(struct iio_scan_result *scan_result) +static int parse_vid_pid(const char *vid_pid, uint16_t *vid, uint16_t *pid) +{ + unsigned long val; + char *ptr; + + /* + * vid_pid string must be either: + * - NULL: scan everything, + * - "vid:*": scan all devices with the given VID, + * - "vid:pid": scan the device with the given VID/PID. + * IDs are given in hexadecimal, and the 0x prefix is not required. + */ + + *vid = 0; + *pid = 0; + + if (!vid_pid) + return 0; + + val = strtoul(vid_pid, &ptr, 16); + if (ptr == vid_pid || val > 0xFFFF || *ptr != ':') + return -EINVAL; + + *vid = (uint16_t) val; + + vid_pid = ptr + 1; + + if (*vid_pid == '*') + return vid_pid[1] == '\0' ? 0 : -EINVAL; + + val = strtoul(vid_pid, &ptr, 16); + if (ptr == vid_pid || val > 0xFFFF || *ptr != '\0') + return -EINVAL; + + *pid = (uint16_t) val; + + return 0; +} + +int usb_context_scan(struct iio_scan_result *scan_result, const char *args) { struct iio_context_info *info; libusb_device **device_list; libusb_context *ctx; + uint16_t vid, pid; unsigned int i; int ret; + ret = parse_vid_pid(args, &vid, &pid); + if (ret) + return ret; + ret = libusb_init(&ctx); if (ret < 0) return -(int) libusb_to_errno(ret); @@ -1222,6 +1266,21 @@ int usb_context_scan(struct iio_scan_result *scan_result) struct libusb_device_handle *hdl; struct libusb_device *dev = device_list[i]; unsigned int intrfc = 0; + struct libusb_device_descriptor device_descriptor; + + /* If we are given a pid or vid, use that to qualify for things, + * this avoids open/closing random devices & potentially locking + * (blocking them) from other applications + */ + if(vid || pid) { + ret = libusb_get_device_descriptor(dev, &device_descriptor); + if (ret) + continue; + if (vid && vid != device_descriptor.idVendor) + continue; + if (pid && pid != device_descriptor.idProduct) + continue; + } ret = libusb_open(dev, &hdl); if (ret) From ac180d1907349bf9363f6c94c7540f78c1f80e44 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Mon, 22 Nov 2021 23:55:59 -0500 Subject: [PATCH 15/37] scan: with the new scan options that we support, handle duplicates With the updated scan options, it's possible to scan usb, or ip multiple times, and get duplicates in the list. This sorts the list, and removes duplicates if found, so users get a minimal list. Signed-off-by: Robin Getz Signed-off-by: Paul Cercueil --- scan.c | 50 ++++++++++++++++++++++++++++++++++++++++---------- sort.c | 17 +++++++++++++++++ sort.h | 1 + 3 files changed, 58 insertions(+), 10 deletions(-) diff --git a/scan.c b/scan.c index 33f2ce2cf..503864e5e 100644 --- a/scan.c +++ b/scan.c @@ -8,6 +8,7 @@ #include "iio-config.h" #include "iio-private.h" +#include "sort.h" #include #include @@ -33,7 +34,9 @@ ssize_t iio_scan_context_get_info_list(struct iio_scan_context *ctx, struct iio_context_info ***info) { struct iio_scan_result scan_result = { 0, NULL }; + struct iio_context_info *out; char *token, *rest=NULL; + size_t i, j = 0; ssize_t ret; for (token = iio_strtok_r(ctx->backendopts, ",", &rest); @@ -57,6 +60,38 @@ ssize_t iio_scan_context_get_info_list(struct iio_scan_context *ctx, *info = scan_result.info; + if (scan_result.size > 1) { + qsort(scan_result.info, scan_result.size, + sizeof(struct iio_context_info *), + iio_context_info_compare); + + /* there might be duplicates */ + for (i = 1; i < scan_result.size; i++) { + /* ipv6 and ipv4 can have the same uri, but have different descriptions, + * so check both if necessary + */ + if ((!strcmp(scan_result.info[i - 1]->uri, + scan_result.info[i]->uri)) && + (!strcmp(scan_result.info[i - 1]->description, + scan_result.info[i]->description))) { + out = scan_result.info[i - 1]; + j++; + free(out->description); + free(out->uri); + out->description = NULL; + out->uri = NULL; + } + } + if (j) { + /* Force all the nulls to the end */ + qsort(scan_result.info, scan_result.size, + sizeof(struct iio_context_info *), + iio_context_info_compare); + return (ssize_t) scan_result.size - j; + } + } + + return (ssize_t) scan_result.size; err_free_scan_result_info: @@ -67,17 +102,12 @@ ssize_t iio_scan_context_get_info_list(struct iio_scan_context *ctx, void iio_context_info_list_free(struct iio_context_info **list) { - struct iio_context_info **it; - - if (!list) - return; - - for (it = list; *it; it++) { - struct iio_context_info *info = *it; + unsigned int i; - free(info->description); - free(info->uri); - free(info); + for (i = 0; list && list[i]; i++) { + free(list[i]->description); + free(list[i]->uri); + free(list[i]); } free(list); diff --git a/sort.c b/sort.c index 04187e102..822cde0f7 100644 --- a/sort.c +++ b/sort.c @@ -81,3 +81,20 @@ int iio_buffer_attr_compare(const void *p1, const void *p2) return strcmp(tmp1, tmp2); } +int iio_context_info_compare(const void *p1, const void *p2) +{ + int ret; + const struct iio_context_info *tmp1 = *(struct iio_context_info **)p1; + const struct iio_context_info *tmp2 = *(struct iio_context_info **)p2; + + if(!tmp1->uri) + return 1; + if (!tmp2->uri) + return 0; + + ret = strcmp(tmp1->uri, tmp2->uri); + if (ret) + return ret; + + return strcmp(tmp1->description, tmp2->description); +} diff --git a/sort.h b/sort.h index 66953518d..670f1dc6a 100644 --- a/sort.h +++ b/sort.h @@ -14,5 +14,6 @@ int iio_channel_attr_compare(const void *p1, const void *p2); int iio_device_compare(const void *p1, const void *p2); int iio_device_attr_compare(const void *p1, const void *p2); int iio_buffer_attr_compare(const void *p1, const void *p2); +int iio_context_info_compare(const void *p1, const void *p2); #endif /* __IIO_QSORT_H__ */ From d397c403d684b786444e2d1b8b5f28155fcc45a8 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Thu, 17 Feb 2022 10:12:03 +0000 Subject: [PATCH 16/37] udev: Only scan the requested USB device Instead of scanning all USB devices everytime a new device is plugged, which might disrupt the functionality of the unrelated devices being scanned, only scan for the USB device we are interested in, since we know its VID/PID. Signed-off-by: Paul Cercueil --- libiio.rules.cmakein | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libiio.rules.cmakein b/libiio.rules.cmakein index 55b7a9d92..298d0a2fd 100644 --- a/libiio.rules.cmakein +++ b/libiio.rules.cmakein @@ -1 +1 @@ -SUBSYSTEM=="usb", PROGRAM=="/bin/sh -c '@CMAKE_INSTALL_FULL_BINDIR@/iio_info -S usb | grep %s{idVendor}:%s{idProduct}'", RESULT!="", MODE="666" +SUBSYSTEM=="usb", PROGRAM=="/bin/sh -c '@CMAKE_INSTALL_FULL_BINDIR@/iio_info -S usb=%s{idVendor}:%s{idProduct} | grep %s{idVendor}:%s{idProduct}'", RESULT!="", MODE="666" From 8268715435434b1bfaef0be52de99861f1551fa9 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Mon, 15 Nov 2021 18:19:48 -0500 Subject: [PATCH 17/37] utils: unify scan across all utilities and update man pages this ensures you can do a "-S" on any utility, and it scans the same way on all different utilities. Signed-off-by: Robin Getz Signed-off-by: Paul Cercueil --- man/iio_attr.1.in | 7 +++++-- man/iio_info.1.in | 5 ++++- man/iio_readdev.1.in | 7 ++++++- man/iio_writedev.1.in | 6 ++++++ tests/iio_adi_xflow_check.c | 6 ++++++ tests/iio_reg.c | 6 ++++++ 6 files changed, 33 insertions(+), 4 deletions(-) diff --git a/man/iio_attr.1.in b/man/iio_attr.1.in index a76feae06..aa4975139 100644 --- a/man/iio_attr.1.in +++ b/man/iio_attr.1.in @@ -83,8 +83,11 @@ Read and Write IIO Context attributes .B \-D \-\-debug-attr Read and Write IIO Debug attributes .TP -.B \-S, \-\-Scan -Scan for available IIO contexts, optional arg of specific backend(s) 'ip', 'usb' or 'ip:usb'. If no argument is given, it checks all that are availble. +.B \-S, \-\-scan +Scan for available IIO contexts, optional arg of specific backend(s) 'ip', 'usb' or 'ip,usb'. +Specific options for USB include Vendor ID, Product ID to limit scanning to specific devices 'usb=0456:b673'. +vid,pid are hexadecimal numbers (no prefix needed), "*" (match any for pid only) +If no argument is given, it checks all that are availble. .TP .B \-h, \-\-help Tells diff --git a/man/iio_info.1.in b/man/iio_info.1.in index 1d5a88aed..9fb15aedc 100644 --- a/man/iio_info.1.in +++ b/man/iio_info.1.in @@ -79,7 +79,10 @@ with no address part .RE .TP .B \-S, \-\-scan -Scan for available backends +Scan for available IIO contexts, optional arg of specific backend(s) 'ip', 'usb' or 'ip,usb'. +Specific options for USB include Vendor ID, Product ID to limit scanning to specific devices 'usb=0456:b673'. +vid,pid are hexadecimal numbers (no prefix needed), "*" (match any for pid only) +If no argument is given, it checks all that are availble. .TP .B \-a, \-\-auto Scan for available contexts and if only one is available use it. diff --git a/man/iio_readdev.1.in b/man/iio_readdev.1.in index 862d7f531..6d0f0c267 100644 --- a/man/iio_readdev.1.in +++ b/man/iio_readdev.1.in @@ -76,7 +76,12 @@ Buffer timeout in milliseconds. 0 = no timeout. Default is 0. .TP .B \-a, \-\-auto Scan for available contexts and if only one is available use it. - +.TP +.B \-S, \-\-scan +Scan for available IIO contexts, optional arg of specific backend(s) 'ip', 'usb' or 'ip,usb'. +Specific options for USB include Vendor ID, Product ID to limit scanning to specific devices 'usb=0456:b673'. +vid,pid are hexadecimal numbers (no prefix needed), "*" (match any for pid only) +If no argument is given, it checks all that are availble. .SH RETURN VALUE If the specified device is not found, a non-zero exit code is returned. diff --git a/man/iio_writedev.1.in b/man/iio_writedev.1.in index 83d8e85b0..723d5b6e0 100644 --- a/man/iio_writedev.1.in +++ b/man/iio_writedev.1.in @@ -60,6 +60,12 @@ normally returned from .IP serial:[port] .IP local with no address part +.TP +.B \-S, \-\-scan +Scan for available IIO contexts, optional arg of specific backend(s) 'ip', 'usb' or 'ip,usb'. +Specific options for USB include Vendor ID, Product ID to limit scanning to specific devices 'usb=0456:b673'. +vid,pid are hexadecimal numbers (no prefix needed), "*" (match any for pid only) +If no argument is given, it checks all that are availble. .RE .TP .B \-t \-\-trigger diff --git a/tests/iio_adi_xflow_check.c b/tests/iio_adi_xflow_check.c index 0b05cb9b1..193f77dc8 100644 --- a/tests/iio_adi_xflow_check.c +++ b/tests/iio_adi_xflow_check.c @@ -168,6 +168,7 @@ int main(int argc, char **argv) char unit; int ret; struct option *opts; + bool do_scan = false; argw = dup_argv(MY_NAME, argc, argv); @@ -188,6 +189,8 @@ int main(int argc, char **argv) case 'T': break; case 'S': + do_scan = true; + /* FALLTHROUGH */ case 'a': if (!optarg && argc > optind && argv[optind] != NULL && argv[optind][0] != '-') @@ -215,6 +218,9 @@ int main(int argc, char **argv) } free(opts); + if (do_scan) + return EXIT_SUCCESS; + if (optind + 1 != argc) { fprintf(stderr, "Incorrect number of arguments.\n\n"); usage(MY_NAME, options, options_descriptions); diff --git a/tests/iio_reg.c b/tests/iio_reg.c index 04bb27e4a..c7e1e3802 100644 --- a/tests/iio_reg.c +++ b/tests/iio_reg.c @@ -82,6 +82,7 @@ int main(int argc, char **argv) int c; char * name; struct option *opts; + bool do_scan = false; argw = dup_argv(MY_NAME, argc, argv); @@ -102,6 +103,8 @@ int main(int argc, char **argv) case 'T': break; case 'S': + do_scan = true; + /* FALLTHRU */ case 'a': if (!optarg && argc > optind && argv[optind] != NULL && argv[optind][0] != '-') @@ -114,6 +117,9 @@ int main(int argc, char **argv) } free(opts); + if (do_scan) + return EXIT_SUCCESS; + if ((argc - optind) < 2 || (argc - optind) > 3) { usage(MY_NAME, options, options_descriptions); return EXIT_SUCCESS; From 8a94f8d828f18f310aa1f17523f4ebb21b510013 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Mon, 15 Nov 2021 18:24:25 -0500 Subject: [PATCH 18/37] iio_readdev/iio_writedev: print out examples based on context If you are given a context, but no device/channel, walk through things and print out examples which you might be able to use, as a hint for people. (so I can stop telling them to do it with iio_attr manually). Signed-off-by: Robin Getz --- tests/iio_readdev.c | 47 +++++++++++++++++++++++++++++++++++++++++--- tests/iio_writedev.c | 47 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 88 insertions(+), 6 deletions(-) diff --git a/tests/iio_readdev.c b/tests/iio_readdev.c index b200fd761..1d250b16f 100644 --- a/tests/iio_readdev.c +++ b/tests/iio_readdev.c @@ -195,7 +195,7 @@ static ssize_t print_sample(const struct iio_channel *chn, int main(int argc, char **argv) { char **argw; - unsigned int i, nb_channels; + unsigned int i, j, nb_channels; unsigned int nb_active_channels = 0; unsigned int buffer_size = SAMPLES_PER_READ; unsigned int refill_per_benchmark = REFILL_PER_BENCHMARK; @@ -263,7 +263,7 @@ int main(int argc, char **argv) } free(opts); - if (argc == optind) { + if (argc < optind || argc > optind + 2) { fprintf(stderr, "Incorrect number of arguments.\n\n"); usage(MY_NAME, options, options_descriptions); return EXIT_FAILURE; @@ -272,6 +272,48 @@ int main(int argc, char **argv) if (!ctx) return EXIT_FAILURE; + if (!argw[optind]) { + unsigned int nb_devices = iio_context_get_devices_count(ctx); + + for (i = 0; i < nb_devices; i++) { + const char *dev_id, *label, *name; + bool hit; + + dev = iio_context_get_device(ctx, i); + nb_channels = iio_device_get_channels_count(dev); + + if (!nb_channels) + continue; + + hit = false; + for (j = 0; j < nb_channels; j++) { + struct iio_channel *ch = iio_device_get_channel(dev, j); + + if (!iio_channel_is_scan_element(ch) || + iio_channel_is_output(ch)) + continue; + + hit = true; + + dev_id = iio_device_get_id(dev); + label = iio_device_get_label(dev); + name = iio_device_get_name(dev); + + printf("Example : " MY_NAME " -u %s -b 256 -s 1024 %s %s\n", + iio_context_get_attr_value(ctx, "uri"), + label ? label : name ? name : dev_id, + iio_channel_get_id(ch)); + } + if (hit) + printf("Example : " MY_NAME " -u %s -b 256 -s 1024 %s\n", + iio_context_get_attr_value(ctx, "uri"), + label ? label : name ? name : dev_id); + } + iio_context_destroy(ctx); + usage(MY_NAME, options, options_descriptions); + return EXIT_FAILURE; + } + setup_sig_handler(); dev = iio_context_find_device(ctx, argw[optind]); @@ -332,7 +374,6 @@ int main(int argc, char **argv) } } else { for (i = 0; i < nb_channels; i++) { - unsigned int j; struct iio_channel *ch = iio_device_get_channel(dev, i); for (j = optind + 1; j < (unsigned int) argc; j++) { const char *n = iio_channel_get_name(ch); diff --git a/tests/iio_writedev.c b/tests/iio_writedev.c index ea74c2ec7..2491e45b1 100644 --- a/tests/iio_writedev.c +++ b/tests/iio_writedev.c @@ -206,7 +206,7 @@ static ssize_t read_sample(const struct iio_channel *chn, int main(int argc, char **argv) { char **argw; - unsigned int i, nb_channels; + unsigned int i, j, nb_channels; unsigned int nb_active_channels = 0; unsigned int buffer_size = SAMPLES_PER_READ; unsigned int refill_per_benchmark = REFILL_PER_BENCHMARK; @@ -276,7 +276,7 @@ int main(int argc, char **argv) } free(opts); - if (argc == optind) { + if (argc < optind || argc > optind + 2) { fprintf(stderr, "Incorrect number of arguments.\n\n"); usage(MY_NAME, options, options_descriptions); return EXIT_FAILURE; @@ -285,6 +285,48 @@ int main(int argc, char **argv) if (!ctx) return EXIT_FAILURE; + if (!argw[optind]) { + unsigned int nb_devices = iio_context_get_devices_count(ctx); + + for (i = 0; i < nb_devices; i++) { + const char *dev_id, *label, *name; + bool hit; + + dev = iio_context_get_device(ctx, i); + nb_channels = iio_device_get_channels_count(dev); + + if (!nb_channels) + continue; + + hit = false; + for (j = 0; j < nb_channels; j++) { + struct iio_channel *ch = iio_device_get_channel(dev, j); + + if (!iio_channel_is_scan_element(ch) || + !iio_channel_is_output(ch)) + continue; + + hit = true; + + dev_id = iio_device_get_id(dev); + label = iio_device_get_label(dev); + name = iio_device_get_name(dev); + + printf("Example : " MY_NAME " -u %s -b 256 -s 1024 %s %s\n", + iio_context_get_attr_value(ctx, "uri"), + label ? label : name ? name : dev_id, + iio_channel_get_id(ch)); + } + if (hit) + printf("Example : " MY_NAME " -u %s -b 256 -s 1024 %s\n", + iio_context_get_attr_value(ctx, "uri"), + label ? label : name ? name : dev_id); + } + iio_context_destroy(ctx); + usage(MY_NAME, options, options_descriptions); + return EXIT_FAILURE; + } + if (benchmark && cyclic_buffer) { fprintf(stderr, "Cannot benchmark in cyclic mode.\n"); iio_context_destroy(ctx); @@ -351,7 +393,6 @@ int main(int argc, char **argv) } } else { for (i = 0; i < nb_channels; i++) { - unsigned int j; struct iio_channel *ch = iio_device_get_channel(dev, i); for (j = optind + 1; j < (unsigned int) argc; j++) { const char *n = iio_channel_get_name(ch); From cad83146837971acdac28beaeb8156b9da33ba6b Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Thu, 17 Feb 2022 09:45:13 -0500 Subject: [PATCH 19/37] iiod: replace sprintf with snprintf This replaces sprintf with snprintf to ensure bounds checking inside iiod. Since iiod is only on Linux, we don't have to use iio_snprintf. Signed-off-by: Robin Getz --- iiod/lexer.l | 2 +- iiod/parser.y | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/iiod/lexer.l b/iiod/lexer.l index 962abccea..dfc9cd277 100644 --- a/iiod/lexer.l +++ b/iiod/lexer.l @@ -143,7 +143,7 @@ WORD (([[:alpha:]]+,)|(iio:))?(-|_|\.|[[:alnum:]])+ errno = 0; yylval->value = strtol(yytext, &end, 10); if (yytext == end || errno == ERANGE) { - sprintf(errstr,"lex : bad long constant: %s",(char*)yytext); + snprintf(errstr, sizeof(errstr), "lex : bad long constant: %s",(char*)yytext); perror(errstr); } return VALUE; diff --git a/iiod/parser.y b/iiod/parser.y index b056856ff..dd9d246dc 100644 --- a/iiod/parser.y +++ b/iiod/parser.y @@ -148,7 +148,7 @@ Line: const char *xml = iio_context_get_xml(pdata->ctx); if (!pdata->verbose) { char buf[128]; - sprintf(buf, "%lu\n", (unsigned long) strlen(xml)); + snprintf(buf, sizeof(buf), "%lu\n", (unsigned long) strlen(xml)); output(pdata, buf); } output(pdata, xml); @@ -160,7 +160,7 @@ Line: if (pdata->xml_zstd) { if (!pdata->verbose) { char buf[128]; - sprintf(buf, "%lu\n", (unsigned long)pdata->xml_zstd_len); + snprintf(buf, sizeof(buf), "%lu\n", (unsigned long)pdata->xml_zstd_len); output(pdata, buf); } if (write_all(pdata, pdata->xml_zstd, pdata->xml_zstd_len) <= 0) @@ -169,7 +169,7 @@ Line: YYACCEPT; } else { char buf[128]; - sprintf(buf, "%d\n", -EINVAL); + snprintf(buf, sizeof(buf), "%d\n", -EINVAL); output(pdata, buf); YYABORT; } @@ -452,7 +452,7 @@ void yyerror(yyscan_t scanner, const char *msg) output(pdata, "\n"); } else { char buf[128]; - sprintf(buf, "%i\n", -EINVAL); + snprintf(buf, sizeof(buf), "%i\n", -EINVAL); output(pdata, buf); } } From 163f9a5f7fa758614a23a3a85b8a35fa0e1c6a6c Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Mon, 21 Feb 2022 09:55:18 +0000 Subject: [PATCH 20/37] scan: Fix default backends list containing disabled backends Use CMake to give us a list of the backends available for scanning. This makes sure that the context scan won't fail by trying to scan from a backend that wasn't enabled. Fixes #794. Signed-off-by: Paul Cercueil --- CMakeLists.txt | 9 +++++++++ iio-config.h.cmakein | 2 ++ scan.c | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 698676f6e..6b866b48e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,6 +150,7 @@ if (WITH_USB_BACKEND) message(SEND_ERROR "Unable to find libusb-1.0 dependency.\n" "If you want to disable the USB backend, set WITH_USB_BACKEND=OFF.") else() + list(APPEND LIBIIO_SCAN_BACKENDS usb) set(IIOD_CLIENT 1) set(NEED_LIBXML2 1) set(NEED_THREADS 1) @@ -250,6 +251,8 @@ if(WITH_LOCAL_BACKEND) option(WITH_LOCAL_MMAP_API "Use the mmap API provided in Analog Devices' kernel (not upstream)" ON) option(WITH_HWMON "Add compatibility with the hardware monitoring (hwmon) subsystem" OFF) + + list(APPEND LIBIIO_SCAN_BACKENDS local) endif() option(WITH_SERIAL_BACKEND "Enable the serial backend" OFF) @@ -358,6 +361,10 @@ if(WITH_NETWORK_BACKEND) list(APPEND LIBS_TO_LINK ${AVAHI_LIBRARIES}) endif() + if (HAVE_DNS_SD) + list(APPEND LIBIIO_SCAN_BACKENDS ip) + endif() + set(NEED_THREADS 1) set(IIOD_CLIENT 1) set(NEED_LIBXML2 1) @@ -612,6 +619,8 @@ if (WITH_USB_BACKEND AND CMAKE_SYSTEM_NAME MATCHES "^Linux") endif() endif() +string(REPLACE ";" "," LIBIIO_SCAN_BACKENDS "${LIBIIO_SCAN_BACKENDS}") + configure_file(iio-config.h.cmakein ${CMAKE_CURRENT_BINARY_DIR}/iio-config.h @ONLY) list(APPEND IIO_FEATURES_${WITH_XML_BACKEND} xml) diff --git a/iio-config.h.cmakein b/iio-config.h.cmakein index 6f8932536..7f1f6cf34 100644 --- a/iio-config.h.cmakein +++ b/iio-config.h.cmakein @@ -7,6 +7,8 @@ #define LOG_LEVEL @LOG_LEVEL@_L +#define LIBIIO_SCAN_BACKENDS "@LIBIIO_SCAN_BACKENDS@" + #cmakedefine01 WITH_LOCAL_BACKEND #cmakedefine01 WITH_XML_BACKEND #cmakedefine01 WITH_NETWORK_BACKEND diff --git a/scan.c b/scan.c index 503864e5e..2a05d3aaf 100644 --- a/scan.c +++ b/scan.c @@ -155,7 +155,7 @@ struct iio_scan_context * iio_create_scan_context( return NULL; } - ctx->backendopts = iio_strndup(backend ? backend : "local,usb,ip", PATH_MAX); + ctx->backendopts = iio_strndup(backend ? backend : LIBIIO_SCAN_BACKENDS, PATH_MAX); if (!ctx->backendopts) { free(ctx); errno = ENOMEM; From b370c4483f1b0e23328a4e55b2066799078c1294 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Wed, 10 Nov 2021 16:44:28 -0500 Subject: [PATCH 21/37] Add Azure Pipelines to CI targets that support -Werror So we find errors potential issues faster. but - on some of the build machines check_symbol causes issues with -Werror, so make sure it's off when we use that. Signed-off-by: Robin Getz --- CI/travis/lib.sh | 2 +- CMakeLists.txt | 15 +++++++++++---- examples/CMakeLists.txt | 3 +++ iiod/CMakeLists.txt | 3 +++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CI/travis/lib.sh b/CI/travis/lib.sh index bfea28e5c..19bcf15b3 100644 --- a/CI/travis/lib.sh +++ b/CI/travis/lib.sh @@ -26,7 +26,7 @@ INSIDE_DOCKER_BUILD_DIR=/docker_build_dir # # If these nothing should be passed, then clear or #'unset INSIDE_DOCKER_TRAVIS_CI_ENV' after this script is included -INSIDE_DOCKER_TRAVIS_CI_ENV="TRAVIS TRAVIS_COMMIT TRAVIS_PULL_REQUEST OS_TYPE OS_VERSION ARTIFACTNAME" +INSIDE_DOCKER_TRAVIS_CI_ENV="TF_BUILD TRAVIS TRAVIS_COMMIT TRAVIS_PULL_REQUEST OS_TYPE OS_VERSION ARTIFACTNAME" COMMON_SCRIPTS="inside_docker.sh" diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b866b48e..a10470485 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,8 +170,12 @@ endif() # make sure all check_symbol_exists are before this point, otherwise they fail # on some versions of compilers if (MSVC) - if(DEFINED ENV{CI} AND DEFINED ENV{APPVEYOR}) - message(STATUS "Running in an AppVeyor environment, setting -Werror") + # why can't different CIs use the same flags? + # Travis CI : CI=True & TRAVIS=True + # Appveyor : CI=True & APPVEYOR=True + # Azure Pipelines: TF_BUILD=True + if(DEFINED ENV{TF_BUILD} OR (DEFINED ENV{CI} AND DEFINED ENV{APPVEYOR})) + message(STATUS "Running in an Azure or AppVeyor environment, setting -Werror") add_compile_options(/WX) endif() elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") @@ -181,10 +185,13 @@ elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs -ftest-coverage") endif() - if(DEFINED ENV{CI} AND (DEFINED ENV{TRAVIS} OR DEFINED ENV{APPVEYOR})) - message(STATUS "Running in CI environment (Travis or AppVeyor), setting -Werror") + if(DEFINED ENV{TF_BUILD} OR (DEFINED ENV{CI} AND (DEFINED ENV{TRAVIS} OR DEFINED ENV{APPVEYOR}))) + message(STATUS "Running in CI environment (Azure, Travis or AppVeyor), setting -Werror") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") endif() +else() + message(STATUS "Unknown compiler ${CMAKE_C_COMPILER_ID}") + message(STATUS "GCC ${CMAKE_COMPILER_IS_GNUCC}") endif() IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 8179905ba..961e26bde 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -69,7 +69,10 @@ if (PTHREAD_LIBRARIES set(TEMP1 ${CMAKE_REQUIRED_INCLUDES}) list(APPEND CMAKE_REQUIRED_LIBRARIES ${CURSES_LIBRARY} ${CDK_LIBRARY}) list(APPEND CMAKE_REQUIRED_INCLUDES ${LIBCKD_INCLUDE_DIR}) + set(TMP_FLAGS "${CMAKE_C_FLAGS}") + set(CMAKE_C_FLAGS "") check_symbol_exists(CDK_CSTRING2 "cdk.h" HAS_CDK_CSTRING2) + set(CMAKE_C_FLAGS "${TMP_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES ${TEMP}) set(CMAKE_REQUIRED_INCLUDES ${TEMP1}) endif() diff --git a/iiod/CMakeLists.txt b/iiod/CMakeLists.txt index b144493ff..3d22ff5c0 100644 --- a/iiod/CMakeLists.txt +++ b/iiod/CMakeLists.txt @@ -15,7 +15,10 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include(CheckSymbolExists) set(CMAKE_REQUIRED_LIBRARIES ${PTHREAD_LIBRARIES}) set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) +set(TMP_FLAGS "${CMAKE_C_FLAGS}") +set(CMAKE_C_FLAGS "") check_symbol_exists(pthread_setname_np "pthread.h" HAS_PTHREAD_SETNAME_NP) +set(CMAKE_C_FLAGS "${TMP_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) set(CMAKE_REQUIRED_DEFINITIONS) From 56910cb6bf726d0a0ff1c8fb719aa25ed007b247 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Thu, 17 Feb 2022 18:14:10 -0500 Subject: [PATCH 22/37] Windows Builds: add $ErrorActionPreference = "Stop" to power shell scripts Windows Power Shell default is to ignore errors, and continue, so we miss things, if there were problems. Change this feature to exit on error. Also check the result of the build, and if it didn't work - throw an error Signed-off-by: Robin Getz --- CI/build_win.ps1 | 9 +++++++++ CI/generate_exe.ps1 | 4 ++++ CI/install_deps_win.ps1 | 3 +++ CI/publish_deps.ps1 | 3 +++ 4 files changed, 19 insertions(+) diff --git a/CI/build_win.ps1 b/CI/build_win.ps1 index 08048e226..061d5de33 100644 --- a/CI/build_win.ps1 +++ b/CI/build_win.ps1 @@ -1,3 +1,6 @@ +# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-7.2#erroractionpreference +$ErrorActionPreference = "Stop" +$ErrorView = "NormalView" $COMPILER=$Env:COMPILER $ARCH=$Env:ARCH @@ -12,6 +15,9 @@ if ($ARCH -eq "Win32") { cmake -G "$COMPILER" -A "$ARCH" -DCMAKE_SYSTEM_PREFIX_PATH="C:" -DENABLE_IPV6=OFF -DWITH_USB_BACKEND=ON -DWITH_SERIAL_BACKEND=ON -DPYTHON_BINDINGS=ON -DCSHARP_BINDINGS:BOOL=ON -DLIBXML2_LIBRARIES="C:\\libs\\32\\libxml2.lib" -DLIBUSB_LIBRARIES="C:\\libs\\32\\libusb-1.0.lib" -DLIBSERIALPORT_LIBRARIES="C:\\libs\\32\\libserialport.dll.a" -DLIBUSB_INCLUDE_DIR="C:\\include\\libusb-1.0" -DLIBXML2_INCLUDE_DIR="C:\\include\\libxml2" .. cmake --build . --config Release + if ( $LASTEXITCODE -ne 0 ) { + throw "[*] cmake build failure" + } cp .\libiio.iss $env:BUILD_ARTIFACTSTAGINGDIRECTORY cd ../bindings/python @@ -27,6 +33,9 @@ if ($ARCH -eq "Win32") { cmake -G "$COMPILER" -A "$ARCH" -DCMAKE_SYSTEM_PREFIX_PATH="C:" -DENABLE_IPV6=OFF -DWITH_USB_BACKEND=ON -DWITH_SERIAL_BACKEND=ON -DPYTHON_BINDINGS=ON -DCSHARP_BINDINGS:BOOL=ON -DLIBXML2_LIBRARIES="C:\\libs\\64\\libxml2.lib" -DLIBUSB_LIBRARIES="C:\\libs\\64\\libusb-1.0.lib" -DLIBSERIALPORT_LIBRARIES="C:\\libs\\64\\libserialport.dll.a" -DLIBUSB_INCLUDE_DIR="C:\\include\\libusb-1.0" -DLIBXML2_INCLUDE_DIR="C:\\include\\libxml2" .. cmake --build . --config Release + if ( $LASTEXITCODE -ne 0 ) { + throw "[*] cmake build failure" + } cp .\libiio.iss $env:BUILD_ARTIFACTSTAGINGDIRECTORY cd ../bindings/python diff --git a/CI/generate_exe.ps1 b/CI/generate_exe.ps1 index c68b2eba6..4340d7519 100644 --- a/CI/generate_exe.ps1 +++ b/CI/generate_exe.ps1 @@ -1,3 +1,7 @@ +# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-7.2#erroractionpreference +$ErrorActionPreference = "Stop" +$ErrorView = "NormalView" + SET PATH=packages\Tools.InnoSetup.5.6.1\tools iscc $env:BUILD_ARTIFACTSTAGINGDIRECTORY\Windows-VS-16-2019-Win32\libiio.iss diff --git a/CI/install_deps_win.ps1 b/CI/install_deps_win.ps1 index 53fd02b46..a9e565b4e 100644 --- a/CI/install_deps_win.ps1 +++ b/CI/install_deps_win.ps1 @@ -1,3 +1,6 @@ +# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-7.2#erroractionpreference +$ErrorActionPreference = "Stop" +$ErrorView = "NormalView" $ARCH=$Env:ARCH diff --git a/CI/publish_deps.ps1 b/CI/publish_deps.ps1 index dc0cd46a2..d19e1ceeb 100644 --- a/CI/publish_deps.ps1 +++ b/CI/publish_deps.ps1 @@ -1,3 +1,6 @@ +# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-7.2#erroractionpreference +$ErrorActionPreference = "Stop" +$ErrorView = "NormalView" $src_dir=$pwd From 773c1fa876dd80701adf0edc902e081639c72fb7 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Fri, 12 Nov 2021 10:23:33 -0500 Subject: [PATCH 23/37] utils: make sure the common utility library gets compiled c99 This will reduce some warnings on older versions of gcc Signed-off-by: Robin Getz --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9b63b693f..f819a2b10 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -59,7 +59,7 @@ if(PTHREAD_LIBRARIES OR ANDROID) target_link_libraries(iio_writedev ${PTHREAD_LIBRARIES}) endif() -set_target_properties(${IIO_TESTS_TARGETS} PROPERTIES +set_target_properties(${IIO_TESTS_TARGETS} iio_tests_helper PROPERTIES C_STANDARD 99 C_STANDARD_REQUIRED ON C_EXTENSIONS OFF From ad1911579a5c6bfee6b285c8b972527a34abe34d Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Fri, 18 Feb 2022 10:52:40 -0500 Subject: [PATCH 24/37] tests: remove warnings on Centos 7 in iio_writedev/iio_readdev We were getting: error: 'name' may be used uninitialized in this function [-Werror=maybe-uninitialized] printf("Example : " MY_NAME " -u %s -b 256 -s 1024 %s\n", because, well - we were using it uninitialized... Initialize it properly Signed-off-by: Robin Getz --- tests/iio_readdev.c | 2 +- tests/iio_writedev.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/iio_readdev.c b/tests/iio_readdev.c index 1d250b16f..756a3090a 100644 --- a/tests/iio_readdev.c +++ b/tests/iio_readdev.c @@ -276,7 +276,7 @@ int main(int argc, char **argv) unsigned int nb_devices = iio_context_get_devices_count(ctx); for (i = 0; i < nb_devices; i++) { - const char *dev_id, *label, *name; + const char *dev_id = NULL, *label = NULL, *name = NULL; bool hit; dev = iio_context_get_device(ctx, i); diff --git a/tests/iio_writedev.c b/tests/iio_writedev.c index 2491e45b1..174c43437 100644 --- a/tests/iio_writedev.c +++ b/tests/iio_writedev.c @@ -289,7 +289,7 @@ int main(int argc, char **argv) unsigned int nb_devices = iio_context_get_devices_count(ctx); for (i = 0; i < nb_devices; i++) { - const char *dev_id, *label, *name; + const char *dev_id = NULL, *label = NULL, *name = NULL; bool hit; dev = iio_context_get_device(ctx, i); From 3a4e0b3591a554cfdd97191e973986724811a001 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Fri, 18 Feb 2022 10:59:04 -0500 Subject: [PATCH 25/37] tests: fix warning about suspicious concatenation of string literals With clang (MacOS 11) We were getting: error: suspicious concatenation of string literals in an array initialization; note: place parentheses around the string literal to silence warning So, do so. Signed-off-by: Robin Getz --- tests/iio_attr.c | 4 ++-- tests/iio_common.c | 16 ++++++++-------- tests/iio_genxml.c | 4 ++-- tests/iio_info.c | 4 ++-- tests/iio_stresstest.c | 4 ++-- tests/iio_writedev.c | 8 ++++---- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/iio_attr.c b/tests/iio_attr.c index 765cf5182..084ce2f8c 100644 --- a/tests/iio_attr.c +++ b/tests/iio_attr.c @@ -321,11 +321,11 @@ static const struct option options[] = { }; static const char *options_descriptions[] = { - "-d [device] [attr] [value]\n" + ("-d [device] [attr] [value]\n" "\t\t\t\t-c [device] [channel] [attr] [value]\n" "\t\t\t\t-B [device] [attr] [value]\n" "\t\t\t\t-D [device] [attr] [value]\n" - "\t\t\t\t-C [attr]", + "\t\t\t\t-C [attr]"), /* help */ "Ignore case distinctions.", "Return result only.", diff --git a/tests/iio_common.c b/tests/iio_common.c index dc8402458..08174860a 100644 --- a/tests/iio_common.c +++ b/tests/iio_common.c @@ -238,19 +238,19 @@ struct option * add_common_options(const struct option * longopts) static const char *common_options_descriptions[] = { "Show this help and quit.", "Use the XML backend with the provided XML file.", - "Use the context at the provided URI." + ("Use the context at the provided URI." "\n\t\t\teg: 'ip:192.168.2.1', 'ip:pluto.local', or 'ip:'" "\n\t\t\t 'usb:1.2.3', or 'usb:'" "\n\t\t\t 'serial:/dev/ttyUSB0,115200,8n1'" - "\n\t\t\t 'local:' (Linux only)", - "Scan for available backends." + "\n\t\t\t 'local:' (Linux only)"), + ("Scan for available backends." "\n\t\t\toptional arg of specific backend(s)" - "\n\t\t\t 'ip', 'usb' or 'ip:usb'", - "Scan for available contexts and if a single context is" + "\n\t\t\t 'ip', 'usb' or 'ip:usb'"), + ("Scan for available contexts and if a single context is" "\n\t\t\tavailable use it. filters backend(s)" - "\n\t\t\t 'ip', 'usb' or 'ip:usb:'", - "Context timeout in milliseconds." - "\n\t\t\t0 = no timeout (wait forever)", + "\n\t\t\t 'ip', 'usb' or 'ip:usb:'"), + ("Context timeout in milliseconds." + "\n\t\t\t0 = no timeout (wait forever)"), }; diff --git a/tests/iio_genxml.c b/tests/iio_genxml.c index 48ee5b984..a3a9923cf 100644 --- a/tests/iio_genxml.c +++ b/tests/iio_genxml.c @@ -33,9 +33,9 @@ static const struct option options[] = { }; static const char *options_descriptions[] = { - "\t[-x ]\n" + ("\t[-x ]\n" "\t\t\t\t[-u ]\n" - "\t\t\t\t[-n ]", + "\t\t\t\t[-n ]"), }; int main(int argc, char **argv) diff --git a/tests/iio_info.c b/tests/iio_info.c index f7ba27577..c0ab999d7 100644 --- a/tests/iio_info.c +++ b/tests/iio_info.c @@ -39,8 +39,8 @@ static const struct option options[] = { }; static const char *options_descriptions[] = { - "[-x ]\n" - "\t\t\t\t[-u ]", + ("[-x ]\n" + "\t\t\t\t[-u ]"), }; static int dev_is_buffer_capable(const struct iio_device *dev) diff --git a/tests/iio_stresstest.c b/tests/iio_stresstest.c index 8ea1938ee..4d5d47a69 100644 --- a/tests/iio_stresstest.c +++ b/tests/iio_stresstest.c @@ -107,8 +107,8 @@ static const struct option options[] = { }; static const char *options_descriptions[] = { - "[-n ] [-u :] [-t ] [-b ] [-s ]" - " [ ...]", + ("[-n ] [-u :] [-t ] [-b ] [-s ]" + " [ ...]"), "Show this help and quit.", "Use the context at the provided URI.", "Size of the capture buffer. Default is 256.", diff --git a/tests/iio_writedev.c b/tests/iio_writedev.c index 174c43437..376e4fd0a 100644 --- a/tests/iio_writedev.c +++ b/tests/iio_writedev.c @@ -56,16 +56,16 @@ static const struct option options[] = { }; static const char *options_descriptions[] = { - "[-t ] " + ("[-t ] " "[-b ] [-s ] " - " [ ...]", + " [ ...]"), "Use the specified trigger.", "Size of the transmit buffer. Default is 256.", "Number of samples to write, 0 = infinite. Default is 0.", "Scan for available contexts and if only one is available use it.", "Use cyclic buffer mode.", - "Benchmark throughput." - "\n\t\t\tStatistics will be printed on the standard input.", + ("Benchmark throughput." + "\n\t\t\tStatistics will be printed on the standard input."), }; static struct iio_context *ctx; From 018189d780ce71da99a36e3c688b04fae24e5b2c Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Fri, 18 Feb 2022 11:04:35 -0500 Subject: [PATCH 26/37] iio-utils: remove warning from VS2019_Win64 scan.c(167,33): warning C4267: '=': conversion from 'size_t' to 'unsigned int', possible loss of data iio_writedev.c(500,65): warning C4244: '=': conversion from 'uint64_t' to 'unsigned int', possible loss of data iio_readdev.c(455,65): warning C4244: '=': conversion from 'uint64_t' to 'unsigned int', possible loss of data so just cast strlen to a (unsigned int); and use uint64_t as default Signed-off-by: Robin Getz --- scan.c | 2 +- tests/iio_readdev.c | 4 ++-- tests/iio_writedev.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scan.c b/scan.c index 2a05d3aaf..74010cc96 100644 --- a/scan.c +++ b/scan.c @@ -164,7 +164,7 @@ struct iio_scan_context * iio_create_scan_context( if (backend) { /* Replace the colon separator with a comma. */ - len = strlen(ctx->backendopts); + len = (unsigned int)strlen(ctx->backendopts); for (i = 0; i < len; i++) if (ctx->backendopts[i] == ':') ctx->backendopts[i] = ','; diff --git a/tests/iio_readdev.c b/tests/iio_readdev.c index 756a3090a..ad7f3d8de 100644 --- a/tests/iio_readdev.c +++ b/tests/iio_readdev.c @@ -198,14 +198,14 @@ int main(int argc, char **argv) unsigned int i, j, nb_channels; unsigned int nb_active_channels = 0; unsigned int buffer_size = SAMPLES_PER_READ; - unsigned int refill_per_benchmark = REFILL_PER_BENCHMARK; + uint64_t refill_per_benchmark = REFILL_PER_BENCHMARK; int c; struct iio_device *dev; ssize_t sample_size; ssize_t ret; struct option *opts; bool mib, benchmark = false; - uint64_t before, after, rate, total; + uint64_t before = 0, after, rate, total; argw = dup_argv(MY_NAME, argc, argv); diff --git a/tests/iio_writedev.c b/tests/iio_writedev.c index 376e4fd0a..704bc2972 100644 --- a/tests/iio_writedev.c +++ b/tests/iio_writedev.c @@ -209,14 +209,14 @@ int main(int argc, char **argv) unsigned int i, j, nb_channels; unsigned int nb_active_channels = 0; unsigned int buffer_size = SAMPLES_PER_READ; - unsigned int refill_per_benchmark = REFILL_PER_BENCHMARK; + uint64_t refill_per_benchmark = REFILL_PER_BENCHMARK; int c; struct iio_device *dev; ssize_t sample_size; bool mib, cyclic_buffer = false, benchmark = false; ssize_t ret; struct option *opts; - uint64_t before, after, rate, total; + uint64_t before = 0, after, rate, total; argw = dup_argv(MY_NAME, argc, argv); From abe0996df6b7d110baf5892c9254ec4706ed94d4 Mon Sep 17 00:00:00 2001 From: Raluca Chis Date: Tue, 11 Jan 2022 13:25:50 +0200 Subject: [PATCH 27/37] CI: switch libiio CI config to more standard yaml - eliminate scripts and use code directly in azure-pipelines.yml - modify builds to use docker images containing all dependencies in order to reduce build time - modify files related to artifacts according with new builds Signed-off-by: Raluca Chis --- CI/azure/ci-ubuntu.sh | 12 ++ CI/build_win.ps1 | 49 ++--- CI/generate_exe.ps1 | 3 +- CI/publish_deps.ps1 | 26 ++- CI/travis/prepare_assets.sh | 92 +++++---- README.md | 21 +- azure-pipelines.yml | 368 ++++++++++++++++++++++-------------- libiio.iss.cmakein | 32 +--- 8 files changed, 342 insertions(+), 261 deletions(-) create mode 100644 CI/azure/ci-ubuntu.sh diff --git a/CI/azure/ci-ubuntu.sh b/CI/azure/ci-ubuntu.sh new file mode 100644 index 000000000..5c322263d --- /dev/null +++ b/CI/azure/ci-ubuntu.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -x +uname -a +DEBIAN_FRONTEND=noninteractive apt update +DEBIAN_FRONTEND=noninteractive apt -y upgrade +DEBIAN_FRONTEND=noninteractive apt install -y bison flex cmake git build-essential libxml2-dev doxygen +DEBIAN_FRONTEND=noninteractive apt install -y python3 python3-sphinx python3-setuptools +echo "$PWD" +mkdir build && cd build +cmake .. -DPYTHON_BINDINGS=ON -DENABLE_PACKAGING=ON -DCPACK_SYSTEM_NAME="{ARTIFACTNAME}" +make +make package diff --git a/CI/build_win.ps1 b/CI/build_win.ps1 index 061d5de33..ddf2b9b39 100644 --- a/CI/build_win.ps1 +++ b/CI/build_win.ps1 @@ -3,44 +3,19 @@ $ErrorActionPreference = "Stop" $ErrorView = "NormalView" $COMPILER=$Env:COMPILER -$ARCH=$Env:ARCH - $src_dir=$pwd -if ($ARCH -eq "Win32") { - echo "Running cmake for $COMPILER on 32 bit..." - mkdir build-win32 - cp .\libiio.iss.cmakein .\build-win32 - cd build-win32 - - cmake -G "$COMPILER" -A "$ARCH" -DCMAKE_SYSTEM_PREFIX_PATH="C:" -DENABLE_IPV6=OFF -DWITH_USB_BACKEND=ON -DWITH_SERIAL_BACKEND=ON -DPYTHON_BINDINGS=ON -DCSHARP_BINDINGS:BOOL=ON -DLIBXML2_LIBRARIES="C:\\libs\\32\\libxml2.lib" -DLIBUSB_LIBRARIES="C:\\libs\\32\\libusb-1.0.lib" -DLIBSERIALPORT_LIBRARIES="C:\\libs\\32\\libserialport.dll.a" -DLIBUSB_INCLUDE_DIR="C:\\include\\libusb-1.0" -DLIBXML2_INCLUDE_DIR="C:\\include\\libxml2" .. - cmake --build . --config Release - if ( $LASTEXITCODE -ne 0 ) { - throw "[*] cmake build failure" - } - cp .\libiio.iss $env:BUILD_ARTIFACTSTAGINGDIRECTORY - - cd ../bindings/python - python.exe setup.py.cmakein sdist - Get-ChildItem dist\pylibiio-*.tar.gz | Rename-Item -NewName "libiio-py39-win32.tar.gz" - mv .\dist\*.gz . - rm .\dist\*.gz -}else { - echo "Running cmake for $COMPILER on 64 bit..." - mkdir build-x64 - cp .\libiio.iss.cmakein .\build-x64 - cd build-x64 +echo "Running cmake for $COMPILER on 64 bit..." +mkdir build-x64 +cp .\libiio.iss.cmakein .\build-x64 +cd build-x64 - cmake -G "$COMPILER" -A "$ARCH" -DCMAKE_SYSTEM_PREFIX_PATH="C:" -DENABLE_IPV6=OFF -DWITH_USB_BACKEND=ON -DWITH_SERIAL_BACKEND=ON -DPYTHON_BINDINGS=ON -DCSHARP_BINDINGS:BOOL=ON -DLIBXML2_LIBRARIES="C:\\libs\\64\\libxml2.lib" -DLIBUSB_LIBRARIES="C:\\libs\\64\\libusb-1.0.lib" -DLIBSERIALPORT_LIBRARIES="C:\\libs\\64\\libserialport.dll.a" -DLIBUSB_INCLUDE_DIR="C:\\include\\libusb-1.0" -DLIBXML2_INCLUDE_DIR="C:\\include\\libxml2" .. - cmake --build . --config Release - if ( $LASTEXITCODE -ne 0 ) { - throw "[*] cmake build failure" - } - cp .\libiio.iss $env:BUILD_ARTIFACTSTAGINGDIRECTORY +cmake -G "$COMPILER" -DCMAKE_SYSTEM_PREFIX_PATH="C:" -DENABLE_IPV6=OFF -DWITH_USB_BACKEND=ON -DWITH_SERIAL_BACKEND=ON -DPYTHON_BINDINGS=ON -DCSHARP_BINDINGS:BOOL=ON -DLIBXML2_LIBRARIES="C:\\libs\\64\\libxml2.lib" -DLIBUSB_LIBRARIES="C:\\libs\\64\\libusb-1.0.lib" -DLIBSERIALPORT_LIBRARIES="C:\\libs\\64\\libserialport.dll.a" -DLIBUSB_INCLUDE_DIR="C:\\include\\libusb-1.0" -DLIBXML2_INCLUDE_DIR="C:\\include\\libxml2" .. +cmake --build . --config Release +cp .\libiio.iss $env:BUILD_ARTIFACTSTAGINGDIRECTORY - cd ../bindings/python - python.exe setup.py.cmakein sdist - Get-ChildItem dist\pylibiio-*.tar.gz | Rename-Item -NewName "libiio-py39-amd64.tar.gz" - mv .\dist\*.gz . - rm .\dist\*.gz -} +cd ../bindings/python +python.exe setup.py.cmakein sdist +Get-ChildItem dist\pylibiio-*.tar.gz | Rename-Item -NewName "libiio-py39-amd64.tar.gz" +mv .\dist\*.gz . +rm .\dist\*.gz \ No newline at end of file diff --git a/CI/generate_exe.ps1 b/CI/generate_exe.ps1 index 4340d7519..f6503f8e0 100644 --- a/CI/generate_exe.ps1 +++ b/CI/generate_exe.ps1 @@ -2,8 +2,7 @@ $ErrorActionPreference = "Stop" $ErrorView = "NormalView" -SET PATH=packages\Tools.InnoSetup.5.6.1\tools -iscc $env:BUILD_ARTIFACTSTAGINGDIRECTORY\Windows-VS-16-2019-Win32\libiio.iss +iscc $env:BUILD_ARTIFACTSTAGINGDIRECTORY\Windows-VS-2019-x64\libiio.iss Get-ChildItem $env:BUILD_ARTIFACTSTAGINGDIRECTORY -Force -Recurse | Remove-Item -Force -Recurse cp C:\libiio-setup.exe $env:BUILD_ARTIFACTSTAGINGDIRECTORY diff --git a/CI/publish_deps.ps1 b/CI/publish_deps.ps1 index d19e1ceeb..76ec7955a 100644 --- a/CI/publish_deps.ps1 +++ b/CI/publish_deps.ps1 @@ -3,14 +3,16 @@ $ErrorActionPreference = "Stop" $ErrorView = "NormalView" $src_dir=$pwd +$COMPILER=$Env:COMPILER -cd 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Redist\MSVC\14.29.30133' -if ($ARCH -eq "Win32") { - echo "$PWD" - mv .\x86\Microsoft.VC142.CRT\msvcp140.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY +if ($COMPILER -eq "Visual Studio 16 2019") { + cd 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Redist\MSVC\14.29.30133\x64\Microsoft.VC142.CRT' + cp .\msvcp140.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY + cp .\vcruntime140.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY }else { - echo "$PWD" - mv .\x64\Microsoft.VC142.CRT\msvcp140.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY + cd 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Redist\MSVC\14.29.30133\x64\Microsoft.VC142.CRT' + cp .\msvcp140.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY + cp .\vcruntime140.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY } cd $src_dir @@ -19,12 +21,6 @@ cd dependencies wget http://swdownloads.analog.com/cse/build/libiio-win-deps-libusb1.0.24.zip -OutFile "libiio-win-deps.zip" 7z x -y "libiio-win-deps.zip" -if ($ARCH -eq "Win32") { - mv .\libs\32\libxml2.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY - mv .\libs\32\libserialport-0.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY - mv .\libs\32\libusb-1.0.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY -}else { - mv .\libs\64\libxml2.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY - mv .\libs\64\libserialport-0.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY - mv .\libs\64\libusb-1.0.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY -} +cp .\libs\64\libxml2.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY +cp .\libs\64\libserialport-0.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY +cp .\libs\64\libusb-1.0.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY diff --git a/CI/travis/prepare_assets.sh b/CI/travis/prepare_assets.sh index efe325b7a..c96c0be7b 100755 --- a/CI/travis/prepare_assets.sh +++ b/CI/travis/prepare_assets.sh @@ -1,69 +1,86 @@ #!/bin/bash -e release_artifacts() { - local rpm_assets='CentOS-7-x86_64' - cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" - for i in $rpm_assets; do - cd "${i}" - find . -name '*.rpm' -exec mv {} ../ ";" - cd ../ - rm -r "${i}" - done - - local deb_assets='Ubuntu-16.04-x86_64 Ubuntu-18.04-x86_64 - Ubuntu-20.04-x86_64 Debian-Buster-ARM - Debian-Buster-ARM64' + local deb_linux_assets='Fedora-34 Ubuntu-18.04 Ubuntu-20.04' cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" - for i in $deb_assets; do - cd "${i}" + for i in $deb_linux_assets; do + cd "Linux-${i}" + if [ "${i}" == "Fedora-34" ]; then + find . -name '*.rpm' -exec mv {} ../ ";" + fi find . -name '*.deb' -exec mv {} ../ ";" cd ../ - rm -r "${i}" + rm -r "Linux-${i}" done local pkg_assets='macOS-10.15 macOS-11' cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" for i in $pkg_assets; do cd "${i}" + + # change artifact name + old_name=$(find . -name '*.pkg' | cut -b 3-26) + name=$(echo "${old_name}" | cut -b 1-20) + new_name="${name}-${i}.pkg" + mv ./"${old_name}" ./"${new_name}" + find . -name '*.pkg' -exec mv {} ../ ";" - find . -name '*.gz' -exec mv {} ../ ";" + find . -name '*.tar.gz' -exec mv {} ../ ";" cd ../ rm -r "${i}" done - local windows_dist='Win32 x64' + local zip_assets='2019 2022' cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" - for distribution in $windows_dist; do - zip -r Windows-VS-16-2019-"${distribution}".zip Windows-VS-16-2019-"${distribution}" - rm -r Windows-VS-16-2019-"${distribution}" + for i in $zip_assets; do + zip -r "Windows-VS-${i}-x64".zip "Windows-VS-${i}-x64" + rm -r "Windows-VS-${i}-x64" + done + + local deb_arm_assets='arm32v7 arm64v8 ppc64le x390x' + cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" + for i in $deb_arm_assets; do + cd "Ubuntu-${i}" + find . -name '*.deb' -exec mv {} ../ ";" + cd ../ + rm -r "Ubuntu-${i}" done + } swdownloads_artifacts() { - local linux_dist='CentOS-7-x86_64 Ubuntu-16.04-x86_64 Ubuntu-18.04-x86_64 - Ubuntu-20.04-x86_64 Debian-Buster-ARM Debian-Buster-ARM64' + local linux_dist='Fedora-34 Ubuntu-18.04 Ubuntu-20.04' for distribution in $linux_dist; do - cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" - cd "Linux-${distribution}" - find . -name '*.rpm' -exec mv {} ../"${distribution}"_latest_master_libiio.rpm ";" - find . -name '*.deb' -exec mv {} ../"${distribution}"_latest_master_libiio.deb ";" + cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}/Linux-${distribution}" + if [ "${distribution}" == "Fedora-34" ]; then + find . -name '*.rpm' -exec mv {} ../"${distribution}_latest_master_libiio.rpm" ";" + fi + find . -name '*.tar.gz' -exec mv {} ../"${distribution}_latest_master_libiio.tar.gz" ";" + find . -name '*.deb' -exec mv {} ../"${distribution}_latest_master_libiio.deb" ";" rm -r ../Linux-"${distribution}" done local macOS_dist='macOS-10.15 macOS-11' for distribution in $macOS_dist; do - cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" - cd "${distribution}" - find . -name '*.pkg' -exec mv {} ../"${distribution}"_latest_master_libiio.pkg ";" - find . -name '*.tar.gz' -exec mv {} ../"${distribution}"_latest_master_libiio.tar.gz ";" + cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}/${distribution}" + find . -name '*.pkg' -exec mv {} ../"${distribution}_latest_master_libiio.pkg" ";" + find . -name '*.tar.gz' -exec mv {} ../"${distribution}_latest_master_libiio.tar.gz" ";" rm -r ../"${distribution}" done - local windows_dist='Win32 x64' + local windows_dist='2019 2022' for distribution in $windows_dist; do cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" - zip -r Windows-VS-16-2019-"${distribution}".zip Windows-VS-16-2019-"${distribution}" - rm -r Windows-VS-16-2019-"${distribution}" + zip -r "Windows-VS-${distribution}-x64-latest_master_libiio".zip "Windows-VS-${distribution}-x64" + rm -r "Windows-VS-${distribution}-x64" + done + + local arm_dist='arm32v7 arm64v8 ppc64le x390x' + for distribution in $arm_dist; do + cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}/Ubuntu-${distribution}" + find . -name '*.tar.gz' -exec mv {} ../"Ubuntu-${distribution}_latest_master_libiio.tar.gz" ";" + find . -name '*.deb' -exec mv {} ../"Ubuntu-${distribution}_latest_master_libiio.deb" ";" + rm -r ../Ubuntu-"${distribution}" done cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}/Libiio-Setup-Exe" @@ -71,4 +88,13 @@ swdownloads_artifacts() { rm -r ../Libiio-Setup-Exe } +check_artifacts() { + cd build + while IFS= read -r line; do + if [ -z "${line}" ]; then continue + fi + test -f ./artifacts/"${line}" && echo "${line} exist." || echo "${line} does not exist." + done < "artifact_manifest.txt" +} + "${1}"_artifacts diff --git a/README.md b/README.md index 0f69ff3be..ae3b5b2d8 100644 --- a/README.md +++ b/README.md @@ -25,17 +25,18 @@ As with many open source packages, we use [GitHub](https://github.com/analogdevi | Operating System | GitHub master status | Version | Primary Installer Package | Alternative Package, tarball or zip | |:-----------------------:|:---------------------:|:-------:|:-------------------:|:--------------:| -| Windows | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=WindowsBuilds&configuration=WindowsBuilds%20VS2019_Win64)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Windows-64 Server 2019 | [![Latest Windows installer](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/win_box.png)](https://swdownloads.analog.com/cse/azure_builds/libiio-setup.exe)
[![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=PushArtifacts&jobName=GenerateSetupExe)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | [![Latest Windows zip](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/win_box.png)](https://swdownloads.analog.com/cse/azure_builds/Windows-VS-16-2019-x64.zip) | -| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=WindowsBuilds&configuration=WindowsBuilds%20VS2019_Win32)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Windows-32 Server 2019 | (libiio-setup.exe file works for both Win64 and Win32) | [![Latest Windows zip](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/win_box.png)](https://swdownloads.analog.com/cse/azure_builds/Windows-VS-16-2019-Win32.zip) | +| Windows | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=WindowsBuilds&configuration=WindowsBuilds%20VS2019_Win64)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Windows-64 Server 2019 | [![Latest Windows installer](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/win_box.png)](https://swdownloads.analog.com/cse/azure_builds/libiio-setup.exe)
[![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=PushArtifacts&jobName=GenerateSetupExe)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | [![Latest Windows zip](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/win_box.png)](https://swdownloads.analog.com/cse/azure_builds/Windows-VS-2019-x64-latest_master_libiio.zip) | +| | | Windows-64 Server 2022 | (libiio-setup.exe works for both Windows Server 2019 and Windows Server 2022) | [![Latest Windows zip](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/win_box.png)](https://swdownloads.analog.com/cse/azure_builds/Windows-VS-2022-x64-latest_master_libiio.zip) | | OS X | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=macOSBuilds&configuration=macOSBuilds%20macOS_11)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | macOS Big Sur
(v 11) | [![OS-X package 11](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/osx_box.png)](https://swdownloads.analog.com/cse/azure_builds/macOS-11_latest_master_libiio.pkg) | [![OS-X tarball 11](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/osx_box.png)](https://swdownloads.analog.com/cse/azure_builds/macOS-11_latest_master_libiio.tar.gz) | -| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=macOSBuilds&configuration=macOSBuilds%20macOS_10_15)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | macOS Catalina
(v 10.15) | [![OS-X package 10.13](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/osx_box.png)](https://swdownloads.analog.com/cse/azure_builds/macOS-10.15_latest_master_libiio.pkg) | [![OS-X tarball 10.13](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/osx_box.png)](https://swdownloads.analog.com/cse/azure_builds/macOS-10.15_latest_master_libiio.tar.gz) | -| Linux | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20ubuntu_20_04_x86_64)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Ubuntu Focal Fossa
(v 20.04)1 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-20.04-x86_64_latest_master_libiio.deb) | [![RPM File](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/rpm.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-20.04-x86_64_latest_master_libiio.rpm) | -| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20ubuntu_18_04_x86_64)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Ubuntu Bionic Beaver
(v 18.04)1 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-18.04-x86_64_latest_master_libiio.deb) | [![RPM File](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/rpm.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-18.04-x86_64_latest_master_libiio.rpm) | -| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20ubuntu_16_04_x86_64)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Ubuntu Xenial Xerus
(v 16.04)1 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-16.04-x86_64_latest_master_libiio.deb) | [![RPM File](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/rpm.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-16.04-x86_64_latest_master_libiio.rpm) | -| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20debian_buster_arm32v7)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Debian Buster ARM | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Debian-Buster-ARM_latest_master_libiio.deb) | [![RPM File](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/rpm.png)](https://swdownloads.analog.com/cse/azure_builds/Debian-Buster-ARM_latest_master_libiio.rpm) | -| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20debian_buster_arm64v8)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Debian Buster ARM64 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Debian-Buster-ARM64_latest_master_libiio.deb) | [![RPM File](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/rpm.png)](https://swdownloads.analog.com/cse/azure_builds/Debian-Buster-ARM64_latest_master_libiio.rpm) | -| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20centos_8_x86_64)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | CentOS 8 | [![RPM File](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/rpm.png)](https://swdownloads.analog.com/cse/azure_builds/CentOS-8-x86_64_latest_master_libiio.rpm) | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/CentOS-8-x86_64_latest_master_libiio.deb) | -| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20centos_7_x86_64)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | CentOS 7 | [![RPM File](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/rpm.png)](https://swdownloads.analog.com/cse/azure_builds/CentOS-7-x86_64_latest_master_libiio.rpm) | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/CentOS-7-x86_64_latest_master_libiio.deb) | +| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=macOSBuilds&configuration=macOSBuilds%20macOS_10_15)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | macOS Catalina
(v 10.15) | [![OS-X package 10.15](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/osx_box.png)](https://swdownloads.analog.com/cse/azure_builds/macOS-10.15_latest_master_libiio.pkg) | [![OS-X tarball 10.15](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/osx_box.png)](https://swdownloads.analog.com/cse/azure_builds/macOS-10.15_latest_master_libiio.tar.gz) | +| Linux | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20ubuntu_20_04_x86_64)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Ubuntu Focal Fossa
(v 20.04)1 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-20.04_latest_master_libiio.deb) | | +| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20ubuntu_18_04_x86_64)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Ubuntu Bionic Beaver
(v 18.04)1 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-18.04_latest_master_libiio.deb) | | +| | | Fedora 34 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Fedora-34_latest_master_libiio.deb) | [![RPM File](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/rpm.png)](https://swdownloads.analog.com/cse/azure_builds/Fedora-34_latest_master_libiio.rpm) | +| ARM | | Ubuntu-ppc64le | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-ppc64le_latest_master_libiio.deb) | | +| | | Ubuntu-x390x | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-x390x_latest_master_libiio.deb) | | +| | | Ubuntu-arm64v8 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-arm64v8_latest_master_libiio.deb) | | +| | | Ubuntu-arm32v7 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-arm32v7_latest_master_libiio.deb) | | + If you use it, and like it - please let us know. If you use it, and hate it - please let us know that too. The goal of the project is to try to make Linux IIO devices easier to use on a variety of platforms. If we aren't doing that - we will try to make it better. diff --git a/azure-pipelines.yml b/azure-pipelines.yml index af4b780fd..338f43173 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,3 +1,6 @@ +# If you make changes to builds or artifacts, please check and update the following files if needed: +# README.md, CI/travis/prepare_assets.sh, artifact_manifest.txt.cmakein, CI/publish_deps.ps1 + trigger: branches: include: @@ -10,104 +13,56 @@ trigger: - v* pr: -- main -- master -- 20* + branches: + include: + - main + - master + - 20* stages: - stage: Builds + ############################################# + # Builds + ############################################# jobs: - job: LinuxBuilds - strategy: - matrix: - centos_7_x86_64: - imageName: 'ubuntu-latest' - OS_TYPE: 'centos_docker' - OS_VERSION: centos7 - artifactName: 'Linux-CentOS-7-x86_64' - ubuntu_16_04_x86_64: - imageName: 'ubuntu-latest' - OS_TYPE: 'ubuntu_docker' - OS_VERSION: xenial - artifactName: 'Linux-Ubuntu-16.04-x86_64' - ubuntu_18_04_x86_64: - imageName: 'ubuntu-latest' - OS_TYPE: 'ubuntu_docker' - OS_VERSION: bionic - artifactName: 'Linux-Ubuntu-18.04-x86_64' - ubuntu_20_04_x86_64: - imageName: 'ubuntu-latest' - OS_TYPE: 'ubuntu_docker' - OS_VERSION: focal - artifactName: 'Linux-Ubuntu-20.04-x86_64' - CHECK_AGAINST_KERNEL_HEADER: 1 - debian_buster_arm32v7: - imageName: 'ubuntu-latest' - OS_TYPE: 'arm32v7/debian_docker' - OS_VERSION: 'buster' - artifactName: 'Linux-Debian-Buster-ARM' - debian_buster_arm64v8: - imageName: 'ubuntu-latest' - OS_TYPE: 'arm64v8/debian_docker' - OS_VERSION: 'buster' - artifactName: 'Linux-Debian-Buster-ARM64' - doxygen: - imageName: 'ubuntu-latest' - OS_TYPE: 'doxygen' - OS_VERSION: focal - artifactName: 'Libiio-documentation' - CI_BUILD_SPHINX_DOCS: 1 + # Host Box pool: - vmImage: $(imageName) - steps: - - checkout: self - fetchDepth: 1 - clean: true - persistCredentials: true - - script: ./CI/travis/before_install_linux - displayName: "Install Dependencies" - - script: ./CI/travis/make_linux - displayName: "Build" - - task: CopyFiles@2 - condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), ne(variables['CI_BUILD_SPHINX_DOCS'], '1')) - inputs: - sourceFolder: '$(Agent.BuildDirectory)/s/build/' - contents: '$(Agent.BuildDirectory)/s/build/?(*.deb|*.rpm)' - targetFolder: '$(Build.ArtifactStagingDirectory)' - - task: PublishPipelineArtifact@1 - condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), ne(variables['CI_BUILD_SPHINX_DOCS'], '1')) - inputs: - targetPath: '$(Build.ArtifactStagingDirectory)' - artifactName: '$(artifactName)' - - - job: macOSBuilds + vmImage: 'ubuntu-latest' + # Docker Images strategy: matrix: - macOS_10_15: - imageName: 'macOS-10.15' - artifactName: 'macOS-10.15' - macOS_11: - imageName: 'macOS-11' - artifactName: 'macOS-11' - pool: - vmImage: $(imageName) + ubuntu_18_04: + image: 'tfcollins/libiio_ubuntu_18_04-ci:latest' + artifactName: 'Linux-Ubuntu-18.04' + ubuntu_20_04: + image: 'tfcollins/libiio_ubuntu_20_04-ci:latest' + artifactName: 'Linux-Ubuntu-20.04' + fedora34: + image: 'tfcollins/libiio_fedora_34-ci:latest' + artifactName: 'Linux-Fedora-34' + container: $[ variables['image'] ] steps: - checkout: self fetchDepth: 1 clean: true - - script: ./CI/travis/before_install_darwin - displayName: "Install Dependencies" - - script: ./CI/travis/make_darwin - displayName: "Build" + persistCredentials: true + - script: | + mkdir build && cd build + cmake .. -DENABLE_PACKAGING=ON -DPYTHON_BINDINGS=ON -DWITH_DOC=ON -DCPACK_SYSTEM_NAME=${ARTIFACTNAME} + make + make package + displayName: 'Build' + - script: | + cd $(Agent.BuildDirectory)/s/build/ + sh generateDocumentationAndDeploy.sh + displayName: 'Documentation' + condition: eq(variables['artifactName'], 'Linux-Fedora-34') - task: CopyFiles@2 + condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) inputs: sourceFolder: '$(Agent.BuildDirectory)/s/build/' - contents: '$(Agent.BuildDirectory)/s/build/?(*.pkg)' - targetFolder: '$(Build.ArtifactStagingDirectory)' - - task: CopyFiles@2 - inputs: - sourceFolder: '$(Agent.BuildDirectory)/s/build_tar/' - contents: '$(Agent.BuildDirectory)/s/build_tar/?(*.gz)' + contents: '$(Agent.BuildDirectory)/s/build/?(*.deb|*.gz|*.rpm)' targetFolder: '$(Build.ArtifactStagingDirectory)' - task: PublishPipelineArtifact@1 condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) @@ -115,21 +70,23 @@ stages: targetPath: '$(Build.ArtifactStagingDirectory)' artifactName: '$(artifactName)' + ############################################# - job: WindowsBuilds + # Host Box strategy: matrix: - VS2019_Win32: - imageName: 'windows-2019' - COMPILER: 'Visual Studio 16 2019' - ARCH: 'Win32' - artifactName: 'Windows-VS-16-2019-Win32' - VS2019_Win64: - imageName: 'windows-2019' + VS2022: + vmImage: 'windows-2022' + COMPILER: 'Visual Studio 17 2022' + ARCH: 'x64' + artifactName: 'Windows-VS-2022-x64' + VS2019: + vmImage: 'windows-2019' COMPILER: 'Visual Studio 16 2019' ARCH: 'x64' - artifactName: 'Windows-VS-16-2019-x64' + artifactName: 'Windows-VS-2019-x64' pool: - vmImage: $[ variables['imageName'] ] + vmImage: $[ variables['vmImage'] ] steps: - checkout: self fetchDepth: 1 @@ -138,15 +95,27 @@ stages: inputs: versionSpec: '3.9' - task: PowerShell@2 + displayName: 'Dependencies' inputs: - targetType: 'filePath' - filePath: .\CI\install_deps_win.ps1 - displayName: Dependencies + targetType: inline + script: | + git submodule update --init + if ( !( Test-Path deps ) ) { + mkdir deps + } + cd deps + mkdir libxml + wget https://www.zlatkovic.com/pub/libxml/64bit/libxml2-2.9.3-win32-x86_64.7z -OutFile "libxml.7z" + 7z x -y libxml.7z + rm libxml.7z + cd C:\ + wget http://swdownloads.analog.com/cse/build/libiio-win-deps-libusb1.0.24.zip -OutFile "libiio-win-deps.zip" + 7z x -y "C:\libiio-win-deps.zip" - task: PowerShell@2 inputs: targetType: 'filePath' filePath: .\CI\build_win.ps1 - displayName: Build + displayName: 'Build' - task: CopyFiles@2 displayName: 'Copy libraries' inputs: @@ -187,66 +156,183 @@ stages: targetPath: '$(Build.ArtifactStagingDirectory)' artifactName: '$(artifactName)' -- stage: PushArtifacts + ############################################# + - job: macOSBuilds + # Host Box + strategy: + matrix: + macOS_10_15: + vmImage: 'macOS-10.15' + artifactName: 'macOS-10.15' + macOS_11: + vmImage: 'macOS-11' + artifactName: 'macOS-11' + pool: + vmImage: $[ variables['vmImage'] ] + steps: + - checkout: self + fetchDepth: 1 + clean: true + - script: | + brew install cmake doxygen libusb libxml2 ncurses cdk libserialport + pip3 install sphinx sphinx-rtd-theme + displayName: 'Dependencies' + - script: | + mkdir build && cd build + cmake .. -DOSX_PACKAGE=ON -DPYTHON_BINDINGS=ON -DWITH_EXAMPLES=ON -DWITH_SERIAL_BACKEND=OFF -DWITH_ZSTD=ON + make + sudo make install + cd .. + displayName: 'Build' + - script: | + mkdir build_tar && cd build_tar + cmake .. -DOSX_PACKAGE=OFF -DENABLE_PACKAGING=ON -DPYTHON_BINDINGS=ON -DWITH_SERIAL_BACKEND=OFF -DWITH_ZSTD=ON -DCPACK_SYSTEM_NAME=${ARTIFACTNAME} + make + make package + cd .. + displayName: 'Build tar' + - script: | + cd build + cmake .. -DPYTHON_BINDINGS=ON -DWITH_DOC=ON + make + cd .. + displayName: 'Build With Doc' + - task: CopyFiles@2 + inputs: + sourceFolder: '$(Agent.BuildDirectory)/s/build/' + contents: '$(Agent.BuildDirectory)/s/build/?(*.pkg)' + targetFolder: '$(Build.ArtifactStagingDirectory)' + - task: CopyFiles@2 + inputs: + sourceFolder: '$(Agent.BuildDirectory)/s/build_tar/' + contents: '$(Agent.BuildDirectory)/s/build_tar/?(*.gz)' + targetFolder: '$(Build.ArtifactStagingDirectory)' + - task: PublishPipelineArtifact@1 + condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) + inputs: + targetPath: '$(Build.ArtifactStagingDirectory)' + artifactName: '$(artifactName)' + + ############################################# + - job: ARMBuilds + # Host Box + pool: + vmImage: "ubuntu-latest" + # Docker Images + strategy: + matrix: + ubuntu-ppc64le: + image: tfcollins/libiio_ubuntu_18_04-ci-arm-ppc:latest + arch: ppc64le + build_script: ci-ubuntu.sh + artifactName: 'Ubuntu-ppc64le' + ubuntu-x390x: + image: tfcollins/libiio_ubuntu_18_04-ci-arm-ppc:latest + arch: s390x + build_script: ci-ubuntu.sh + artifactName: 'Ubuntu-x390x' + ubuntu-arm64v8: + image: tfcollins/libiio_ubuntu_18_04-ci-arm-ppc:latest + arch: aarch64 + build_script: ci-ubuntu.sh + artifactName: 'Ubuntu-arm64v8' + ubuntu-arm32v7: + image: tfcollins/libiio_ubuntu_18_04-ci-arm-ppc:latest + arch: arm + build_script: ci-ubuntu.sh + artifactName: 'Ubuntu-arm32v7' + steps: + - script: | + sudo apt-get install -y gcc-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-arm-static + sudo apt-get install -y g++-arm-linux-gnueabihf libstdc++-4.8-dev-armhf-cross + sudo apt-get install -y g++-aarch64-linux-gnu libstdc++-4.8-dev-arm64-cross + sudo apt-get install -y qemu-system-ppc64 + sudo apt-get install qemu + sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + displayName: 'Setup' + - script: | + sudo docker run --rm -t --privileged -e ARTIFACTNAME=$(artifactName) -v "$(Agent.BuildDirectory)/s":"/ci" -v "/usr/bin/qemu-$(arch)-static":"/usr/bin/qemu-$(arch)-static" "$(image)" /bin/bash -c "cd /ci/ && chmod +x ./CI/azure/$(build_script) && ./CI/azure/$(build_script)" + displayName: 'Build' + - task: CopyFiles@2 + condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) + inputs: + sourceFolder: '$(Agent.BuildDirectory)/s/build/' + contents: '$(Agent.BuildDirectory)/s/build/?(*.deb|*.gz)' + targetFolder: '$(Build.ArtifactStagingDirectory)' + - task: PublishPipelineArtifact@1 + condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) + inputs: + targetPath: '$(Build.ArtifactStagingDirectory)' + artifactName: '$(artifactName)' + + ############################################# +- stage: ManageArtifacts dependsOn: Builds + ############################################# + # Deploy + ############################################# jobs: - job: GenerateSetupExe condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))) pool: vmImage: 'windows-2019' steps: - - task: DownloadPipelineArtifact@2 - inputs: - path: '$(Build.ArtifactStagingDirectory)' - - task: PowerShell@2 - inputs: - targetType: 'filePath' - filePath: .\CI\generate_exe.ps1 - displayName: "Generate libiio-setup.exe" - - task: PublishPipelineArtifact@1 - condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) - inputs: - targetPath: '$(Build.ArtifactStagingDirectory)' - artifactName: 'Libiio-Setup-Exe' + - task: DownloadPipelineArtifact@2 + inputs: + path: '$(Build.ArtifactStagingDirectory)' + - task: PowerShell@2 + inputs: + targetType: 'filePath' + filePath: .\CI\generate_exe.ps1 + displayName: 'Generate libiio-setup.exe' + - task: PublishPipelineArtifact@1 + condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) + inputs: + targetPath: '$(Build.ArtifactStagingDirectory)' + artifactName: 'Libiio-Setup-Exe' + + ############################################# - job: PushToSWDownloads dependsOn: GenerateSetupExe condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) pool: vmImage: 'ubuntu-latest' steps: - - task: DownloadPipelineArtifact@2 - inputs: - path: '$(Build.ArtifactStagingDirectory)' - - bash: ./CI/travis/prepare_assets.sh swdownloads - displayName: "Prepare artifacts for SWDownloads" - - task: DownloadSecureFile@1 - name: key - displayName: 'Download rsa key' - inputs: - secureFile: 'id_rsa' - - bash: chmod 600 $(key.secureFilePath) ; scp -2 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o HostKeyAlgorithms=+ssh-dss -i $(key.secureFilePath) -r /home/vsts/work/1/a/* $MAPPED_VAR - env: - MAPPED_VAR: $(SERVER_ADDRESS) - displayName: "Push artifacts to SW Downloads" + - task: DownloadPipelineArtifact@2 + inputs: + path: '$(Build.ArtifactStagingDirectory)' + - bash: ./CI/travis/prepare_assets.sh swdownloads + displayName: "Prepare artifacts for SWDownloads" + - task: DownloadSecureFile@1 + name: key + displayName: 'Download rsa key' + inputs: + secureFile: 'id_rsa' + - bash: chmod 600 $(key.secureFilePath) ; scp -2 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o HostKeyAlgorithms=+ssh-dss -i $(key.secureFilePath) -r /home/vsts/work/1/a/* $MAPPED_VAR + env: + MAPPED_VAR: $(SERVER_ADDRESS) + displayName: 'Push artifacts to SW Downloads' + + ############################################## - job: PushToGithubRelease condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) pool: vmImage: 'ubuntu-latest' steps: - - task: DownloadPipelineArtifact@2 - inputs: - path: '$(Build.ArtifactStagingDirectory)' - - bash: ./CI/travis/prepare_assets.sh release - displayName: "Prepare assets for release" - - task: GithubRelease@0 - displayName: 'Attach artifacts to GitHub Release' - inputs: - gitHubConnection: libiio-release - repositoryName: $(Build.Repository.Name) - action: create - target: $(Build.SourceVersion) - tag: $(Build.SourceBranchName) - title: "Libiio release $(Build.SourceBranchName)" - assets: $(Build.ArtifactStagingDirectory)/* - addChangeLog: true - isDraft: true + - task: DownloadPipelineArtifact@2 + inputs: + path: '$(Build.ArtifactStagingDirectory)' + - bash: ./CI/travis/prepare_assets.sh release + displayName: 'Prepare assets for release' + - task: GithubRelease@0 + displayName: 'Attach artifacts to GitHub Release' + inputs: + gitHubConnection: libiio-release + repositoryName: $(Build.Repository.Name) + action: create + target: $(Build.SourceVersion) + tag: $(Build.SourceBranchName) + title: "Libiio release $(Build.SourceBranchName)" + assets: $(Build.ArtifactStagingDirectory)/* + addChangeLog: true + isDraft: true diff --git a/libiio.iss.cmakein b/libiio.iss.cmakein index fc8de59a0..621144669 100644 --- a/libiio.iss.cmakein +++ b/libiio.iss.cmakein @@ -39,27 +39,13 @@ Name: "turkish"; MessagesFile: "compiler:Languages\Turkish.isl" Name: "ukrainian"; MessagesFile: "compiler:Languages\Ukrainian.isl" [Files] -Source: "D:\a\1\a\Windows-VS-16-2019-Win32\libiio.dll"; DestDir: "{sys}"; Flags: 32bit replacesameversion -Source: "D:\a\1\a\Windows-VS-16-2019-x64\libiio.dll"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: replacesameversion - -Source: "D:\a\1\a\Windows-VS-16-2019-Win32\*.exe"; DestDir: "{sys}"; Check: not Is64BitInstallMode; Flags: replacesameversion -Source: "D:\a\1\a\Windows-VS-16-2019-x64\*.exe"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: replacesameversion - -Source: "D:\a\1\a\Windows-VS-16-2019-Win32\libiio.lib"; DestDir: "{commonpf32}\Microsoft Visual Studio 12.0\VC\lib"; Check: not Is64BitInstallMode -Source: "D:\a\1\a\Windows-VS-16-2019-x64\libiio.lib"; DestDir: "{commonpf32}\Microsoft Visual Studio 12.0\VC\lib\amd64"; Check: Is64BitInstallMode -Source: "D:\a\1\a\Windows-VS-16-2019-Win32\iio.h"; DestDir: "{commonpf32}\Microsoft Visual Studio 12.0\VC\include" - -Source: "D:\a\1\a\Windows-VS-16-2019-Win32\libxml2.dll"; DestDir: "{sys}"; Flags: onlyifdoesntexist 32bit -Source: "D:\a\1\a\Windows-VS-16-2019-x64\libxml2.dll"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: onlyifdoesntexist - -Source: "D:\a\1\a\Windows-VS-16-2019-Win32\libusb-1.0.dll"; DestDir: "{sys}"; Flags: onlyifdoesntexist 32bit -Source: "D:\a\1\a\Windows-VS-16-2019-x64\libusb-1.0.dll"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: onlyifdoesntexist - -Source: "D:\a\1\a\Windows-VS-16-2019-Win32\libserialport-0.dll"; DestDir: "{sys}"; Flags: onlyifdoesntexist 32bit -Source: "D:\a\1\a\Windows-VS-16-2019-x64\libserialport-0.dll"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: onlyifdoesntexist - -Source: "D:\a\1\a\Windows-VS-16-2019-Win32\libiio-sharp.dll"; DestDir: "{commoncf}\libiio"; Flags: replacesameversion - -Source: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Redist\MSVC\14.29.30133\x86\Microsoft.VC142.CRT\msvcp140.dll"; DestDir: "{sys}"; Flags: onlyifdoesntexist 32bit +Source: "D:\a\1\a\Windows-VS-2019-x64\libiio.dll"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: replacesameversion +Source: "D:\a\1\a\Windows-VS-2019-x64\*.exe"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: replacesameversion +Source: "D:\a\1\a\Windows-VS-2019-x64\libiio.lib"; DestDir: "{commonpf32}\Microsoft Visual Studio 12.0\VC\lib\amd64"; Check: Is64BitInstallMode +Source: "D:\a\1\a\Windows-VS-2019-x64\iio.h"; DestDir: "{commonpf32}\Microsoft Visual Studio 12.0\VC\include" +Source: "D:\a\1\a\Windows-VS-2019-x64\libxml2.dll"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: onlyifdoesntexist +Source: "D:\a\1\a\Windows-VS-2019-x64\libusb-1.0.dll"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: onlyifdoesntexist +Source: "D:\a\1\a\Windows-VS-2019-x64\libserialport-0.dll"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: onlyifdoesntexist +Source: "D:\a\1\a\Windows-VS-2019-x64\libiio-sharp.dll"; DestDir: "{commoncf}\libiio"; Flags: replacesameversion Source: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Redist\MSVC\14.29.30133\x64\Microsoft.VC142.CRT\msvcp140.dll"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: onlyifdoesntexist - +Source: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Redist\MSVC\14.29.30133\x64\Microsoft.VC142.CRT\vcruntime140.dll"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: onlyifdoesntexist From 5b9ef36ebccfc82533c5dd949b19f8180a751952 Mon Sep 17 00:00:00 2001 From: Raluca Chis Date: Mon, 21 Feb 2022 12:54:13 +0200 Subject: [PATCH 28/37] CI: add artifact_manifest file - the purpose of this file is to have on GitHub repository a list with all deployed artifacts - this list will be checked in Azure Pipelines at each master push Signed-off-by: Raluca Chis --- CMakeLists.txt | 1 + artifact_manifest.txt.cmakein | 67 +++++++++++++++++++++++++++++++++++ azure-pipelines.yml | 38 +++++++++++++++++++- 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 artifact_manifest.txt.cmakein diff --git a/CMakeLists.txt b/CMakeLists.txt index a10470485..d84f6235e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -433,6 +433,7 @@ if (WIN32) string(REPLACE "." "," LIBIIO_FILEVERSION ${VERSION}) endif() +configure_file(artifact_manifest.txt.cmakein ${CMAKE_CURRENT_BINARY_DIR}/artifact_manifest.txt @ONLY) configure_file(libiio.iss.cmakein ${CMAKE_CURRENT_BINARY_DIR}/libiio.iss @ONLY) set(LIBIIO_PC ${CMAKE_CURRENT_BINARY_DIR}/libiio.pc) diff --git a/artifact_manifest.txt.cmakein b/artifact_manifest.txt.cmakein new file mode 100644 index 000000000..65d67085b --- /dev/null +++ b/artifact_manifest.txt.cmakein @@ -0,0 +1,67 @@ +Libiio-Setup-Exe/libiio-setup.exe + +Linux-Fedora-34/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Linux-Fedora-34.deb +Linux-Fedora-34/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Linux-Fedora-34.rpm +Linux-Fedora-34/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Linux-Fedora-34.tar.gz + +Linux-Ubuntu-18.04/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Linux-Ubuntu-18.04.deb +Linux-Ubuntu-18.04/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Linux-Ubuntu-18.04.tar.gz + +Linux-Ubuntu-20.04/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Linux-Ubuntu-20.04.deb +Linux-Ubuntu-20.04/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Linux-Ubuntu-20.04.tar.gz + +macOS-10.15/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-macOS-10.15.tar.gz +macOS-10.15/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@.pkg + +macOS-11/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-macOS-11.tar.gz +macOS-11/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@.pkg + +Ubuntu-arm32v7/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Ubuntu-arm32v7.deb +Ubuntu-arm32v7/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Ubuntu-arm32v7.tar.gz + +Ubuntu-arm64v8/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Ubuntu-arm64v8.deb +Ubuntu-arm64v8/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Ubuntu-arm64v8.tar.gz + +Ubuntu-ppc64le/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Ubuntu-ppc64le.deb +Ubuntu-ppc64le/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Ubuntu-ppc64le.tar.gz + +Ubuntu-x390x/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Ubuntu-x390x.deb +Ubuntu-x390x/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Ubuntu-x390x.tar.gz + +Windows-VS-2019-x64/iio.h +Windows-VS-2019-x64/iio_attr.exe +Windows-VS-2019-x64/iio_genxml.exe +Windows-VS-2019-x64/iio_info.exe +Windows-VS-2019-x64/iio_readdev.exe +Windows-VS-2019-x64/iio_reg.exe +Windows-VS-2019-x64/iio_writedev.exe +Windows-VS-2019-x64/libiio-py39-amd64.tar.gz +Windows-VS-2019-x64/libiio-sharp.dll +Windows-VS-2019-x64/libiio.dll +Windows-VS-2019-x64/libiio.exp +Windows-VS-2019-x64/libiio.iss +Windows-VS-2019-x64/libiio.lib +Windows-VS-2019-x64/libserialport-0.dll +Windows-VS-2019-x64/libusb-1.0.dll +Windows-VS-2019-x64/libxml2.dll +Windows-VS-2019-x64/msvcp140.dll +Windows-VS-2019-x64/vcruntime140.dll + +Windows-VS-2022-x64/iio.h +Windows-VS-2022-x64/iio_attr.exe +Windows-VS-2022-x64/iio_genxml.exe +Windows-VS-2022-x64/iio_info.exe +Windows-VS-2022-x64/iio_readdev.exe +Windows-VS-2022-x64/iio_reg.exe +Windows-VS-2022-x64/iio_writedev.exe +Windows-VS-2022-x64/libiio-py39-amd64.tar.gz +Windows-VS-2022-x64/libiio-sharp.dll +Windows-VS-2022-x64/libiio.dll +Windows-VS-2022-x64/libiio.exp +Windows-VS-2022-x64/libiio.iss +Windows-VS-2022-x64/libiio.lib +Windows-VS-2022-x64/libserialport-0.dll +Windows-VS-2022-x64/libusb-1.0.dll +Windows-VS-2022-x64/libxml2.dll +Windows-VS-2022-x64/msvcp140.dll +Windows-VS-2022-x64/vcruntime140.dll diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 338f43173..5c0676ec8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -291,9 +291,44 @@ stages: targetPath: '$(Build.ArtifactStagingDirectory)' artifactName: 'Libiio-Setup-Exe' + ############################################# + - job: CheckArtifacts + dependsOn: GenerateSetupExe + condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))) + # Host Box + pool: + vmImage: 'ubuntu-latest' + # Docker Images + strategy: + matrix: + ubuntu_20_04: + image: 'tfcollins/libiio_ubuntu_20_04-ci:latest' + artifactName: 'Check artifacts' + container: $[ variables['image'] ] + steps: + - script: | + mkdir build && cd build + cmake .. + mkdir artifacts + displayName: 'Build artifact manifest' + - task: DownloadPipelineArtifact@2 + inputs: + path: '$(Agent.BuildDirectory)/s/build/artifacts' + - script: ./CI/travis/prepare_assets.sh check + displayName: 'Check files' + - task: CopyFiles@2 + inputs: + sourceFolder: '$(Agent.BuildDirectory)/s/build/' + contents: 'artifact_manifest.txt' + targetFolder: '$(Build.ArtifactStagingDirectory)' + - task: PublishPipelineArtifact@1 + inputs: + targetPath: '$(Build.ArtifactStagingDirectory)' + artifactName: 'Artifact manifest' + ############################################# - job: PushToSWDownloads - dependsOn: GenerateSetupExe + dependsOn: CheckArtifacts condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) pool: vmImage: 'ubuntu-latest' @@ -315,6 +350,7 @@ stages: ############################################## - job: PushToGithubRelease + dependsOn: CheckArtifacts condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) pool: vmImage: 'ubuntu-latest' From 09c08985ad1205f8ec4e40247e0737ef3b089f5d Mon Sep 17 00:00:00 2001 From: Raluca Chis Date: Mon, 21 Feb 2022 17:23:18 +0200 Subject: [PATCH 29/37] CI: update CI folder structure - remove unused files - move used files to 'azure' folder - update paths to moved files Signed-off-by: Raluca Chis --- .travis.yml | 171 ------ .../generateDocumentationAndDeploy.sh.in | 0 CI/{travis => azure}/prepare_assets.sh | 0 CI/{travis => azure}/zip.txt | 0 CI/install_deps_win.ps1 | 33 - CI/travis/after_deploy | 9 - CI/travis/before_deploy | 179 ------ CI/travis/before_install_darwin | 5 - CI/travis/before_install_linux | 111 ---- CI/travis/check_kernel.sh | 70 --- CI/travis/deploy | 10 - CI/travis/deploy.rsa.enc | Bin 1680 -> 0 bytes CI/travis/inside_docker.sh | 30 - CI/travis/lib.sh | 565 ------------------ CI/travis/make_darwin | 40 -- CI/travis/make_linux | 144 ----- CI/travis/make_linux_qemu | 13 - CI/travis/setup_qemu_for_arm.sh | 87 --- CMakeLists.txt | 2 +- appveyor.yml | 184 ------ azure-pipelines.yml | 6 +- 21 files changed, 4 insertions(+), 1655 deletions(-) delete mode 100644 .travis.yml rename CI/{travis => azure}/generateDocumentationAndDeploy.sh.in (100%) rename CI/{travis => azure}/prepare_assets.sh (100%) rename CI/{travis => azure}/zip.txt (100%) delete mode 100644 CI/install_deps_win.ps1 delete mode 100755 CI/travis/after_deploy delete mode 100755 CI/travis/before_deploy delete mode 100755 CI/travis/before_install_darwin delete mode 100755 CI/travis/before_install_linux delete mode 100755 CI/travis/check_kernel.sh delete mode 100755 CI/travis/deploy delete mode 100644 CI/travis/deploy.rsa.enc delete mode 100755 CI/travis/inside_docker.sh delete mode 100644 CI/travis/lib.sh delete mode 100755 CI/travis/make_darwin delete mode 100755 CI/travis/make_linux delete mode 100755 CI/travis/make_linux_qemu delete mode 100755 CI/travis/setup_qemu_for_arm.sh delete mode 100644 appveyor.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 243f3ddab..000000000 --- a/.travis.yml +++ /dev/null @@ -1,171 +0,0 @@ -language: c -sudo: required -python: "3.6" - -env: - global: - - EXTRA_SSH=-oHostKeyAlgorithms=+ssh-dss - # SSHHOST - - secure: "NEXUEA+ccm/I21ujCPuKYIHFb8Gogunr3nYysCRpTBNT40PsU9VFIy5vbmMxPAkCaMwk8XZ0rMHE3uaNGbBAGfoDL9v0Ban5wG/jA1JkmOAWUpFrUsbQeejXNRA04QcZ/4VeL6TgFegV2T6V0tLB4M6/X316dIPhS9Tat1ZUC8s=" - # SSHUSER - - secure: "bYHqhcYYuSbciQa5mBqMxs3CbJkrxxD7/G4zDW2war1IcMh8AC/KPeoYIuhd/L2Mg9+tP++xCznKUJzX85Hu+8EyrMGkC/6zWpGYgyO27DH7wl+9AJjR191WJKkg+S6OqZmb/5v0rdJMDnGOZHrRVB3Vec9dBT+jDTQbyxrckxE=" - # DEPLOY_TO directory - - secure: "PMp93w9HAYd0pR4aw2LT1sMIVmA06f01Xq2jaGW2iy74n3GrqBYe7H9aMR0WD1S6KH9sFydqFI11bCpwUQXPopl+8MPA34AS7V2gaxDUdE+UZnKKXpKV6KRPRp/txlryuEGspjFJM0bo5g1H5lPBSBFj8PB1Bf6BiloGl8TTuiY=" - -services: - - docker - -matrix: - include: - - stage: "Build & Deploy" - - compiler: "gcc" - dist: xenial - env: - - ARCH=arm - - OS_VERSION=jessie - - compiler: "gcc" - dist: xenial - env: - - ARCH=arm - - OS_VERSION=stretch - - compiler: "gcc" - os: linux - env: - - PLATFORM=linux BITS=64 HOST=x86_64 - # TODO do `check` or `check_hw` here too, not just `check_sw` (as part of `coverage`) - - CHECK_RULE=coverage GCOV=1 - - PKG_RULE=gzip - - PYPI=yes - - COVERITY_SCAN_PROJECT_NAME="$TRAVIS_REPO_SLUG" - - COVERITY_SCAN_BRANCH_PATTERN="master" - - COVERITY_SCAN_NOTIFICATION_EMAIL="robin.getz@analog.com" - - COVERITY_SCAN_BUILD_COMMAND_PREPEND="mkdir build && cd build && cmake -DWITH_EXAMPLES=ON .." - - COVERITY_SCAN_BUILD_COMMAND="make" - # The COVERITY_SCAN_TOKEN - - secure: "QQt2l9IVo0xXWLx7Xqgz/4Iezj7YroY3MKfmG+OhtzkMRx4prhx32/07JMNAcYx6mQrccyZkBNzpYuXlfIZjFL3xDxDj5+iKv5XXpJbRFQGhc5xZtAlzOIqHNMcFc0Aj8J2mZwKfSaDnBdf+nMgKcmn46pYbpJOmPe9iEfeLvvg=" - - compiler: "clang" - os: linux - env: LDIST=DO_NOT_DEPLOY - - compiler: "gcc" - os: linux - dist: xenial - env: - # GH_DOC_TOKEN used to deploy docs - - secure: "OrwnYeUITY2R7pn11WHqsO7c6F9fRY7G5fOh98GGXnw7dAIoSvUhjUE70ehaBzLH0CyO83KgaiyACP8eqRx9BYUd1McrqTFDmYJNVR+Wk01SSjJxaXzU4RMsJPhXH9l5U7BEH5dVk/IFLLaCwYnc35mlADHE2KCGNanvtnRU0gU=" - - os: linux - env: - - OS_TYPE=centos_docker - - OS_VERSION=6 - - os: linux - env: - - OS_TYPE=centos_docker - - OS_VERSION=7 - - os: linux - dist: bionic - - os: linux - env: - - OS_TYPE=centos_docker - - OS_VERSION=8 - - os: linux - env: - - OS_TYPE=ubuntu_docker - - OS_VERSION=focal - - compiler: "gcc" - os: osx - osx_image: xcode10.1 - - compiler: "gcc" - os: osx - osx_image: xcode11 - - compiler: "gcc" - os: osx - osx_image: xcode12 - - - stage: "Trigger Next In Pipeline" - env: - - TRIGGER_NEXT_BUILD=true - -addons: - ssh_known_hosts: - secure: "q0dQ9MrhnOCo031McxSdQIqw4N6tEyAZLq7mdbWkAJcXOh/CX58NjFvcdSfamleDUYRmg7KpCZPPgnbx2JtqVvWJv8aNnr67CE1GIjRP1Fxh2WaKS+VK+I6rro7GwCO2C9d+uffCt63LfZKqddF1T7vMI2IgHcu9irc5LCuw6Wo=" - -before_install: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - if [[ "$ARCH" == "arm" ]] ; then - ./CI/travis/setup_qemu_for_arm.sh ${OS_VERSION} ; - else - ./CI/travis/before_install_linux "$OS_TYPE" ; - fi - fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./CI/travis/before_install_darwin ; fi - - if [[ -n "$COVERITY_SCAN_PROJECT_NAME" ]] ; then echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca- ; fi - - if [ -n "$COVERITY_SCAN_PROJECT_NAME" -a "$TRAVIS_EVENT_TYPE" == "cron" ] ; then curl -s 'https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh' | bash || true ; fi - - - mkdir -p $TRAVIS_BUILD_DIR/build - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir -p $TRAVIS_BUILD_DIR/build_tar ; fi - -script: - - if [[ "$ARCH" == "arm" && "$TRAVIS_OS_NAME" == "linux" ]]; then ${TRAVIS_BUILD_DIR}/CI/travis/make_linux_qemu ; fi - - if [[ -z "$ARCH" && "$TRAVIS_OS_NAME" == "linux" ]]; then ${TRAVIS_BUILD_DIR}/CI/travis/make_linux libiio "$OS_TYPE" ; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ${TRAVIS_BUILD_DIR}/CI/travis/make_darwin; fi - - if [[ "$TRIGGER_NEXT_BUILD" == "true" ]]; then ${TRAVIS_BUILD_DIR}/CI/travis/after_deploy; fi - -notifications: - email: - on_success: change - on_failure: always - -before_deploy: - - . ${TRAVIS_BUILD_DIR}/CI/travis/before_deploy - - openssl aes-256-cbc -K $encrypted_48a720578612_key -iv $encrypted_48a720578612_iv -in ${TRAVIS_BUILD_DIR}/CI/travis/deploy.rsa.enc -out /tmp/deploy.rsa -d - - eval "$(ssh-agent -s)" - - chmod 600 /tmp/deploy.rsa - - ssh-add /tmp/deploy.rsa - - if [[ "$PYPI" == "yes" ]]; then cd "build/bindings/python"; fi -deploy: - - provider: releases - api_key: - secure: Bl7sfWp796+D7cF99+YdmbQjr5stXh4H/4hN2L5FNL0FEHL4XnIscSqySgy2NNmcqWF4Mz5WNXMZ9M8rYSNAiOndcaBYB+xvesAUbIdncwswgTNn2cj6yQbv0yR9qVUdoyczvZMK1vIc6GtKWWkh0AmgR04cAFffU3fr+78JHIw= - file: - - "${RELEASE_PKG_FILE_DEB}" - - "${RELEASE_PKG_FILE_RPM}" - - "${RELEASE_PKG_FILE_TGZ}" - skip_cleanup: true - on: - repo: analogdevicesinc/libiio - tags: true - condition: "($CC = gcc) && ($TRAVIS_OS_NAME = linux)" - - provider: releases - api_key: - secure: Bl7sfWp796+D7cF99+YdmbQjr5stXh4H/4hN2L5FNL0FEHL4XnIscSqySgy2NNmcqWF4Mz5WNXMZ9M8rYSNAiOndcaBYB+xvesAUbIdncwswgTNn2cj6yQbv0yR9qVUdoyczvZMK1vIc6GtKWWkh0AmgR04cAFffU3fr+78JHIw= - file: - - "${RELEASE_PKG_FILE_PKG}" - - "${RELEASE_PKG_FILE_TGZ}" - skip_cleanup: true - on: - repo: analogdevicesinc/libiio - tags: true - condition: "$TRAVIS_OS_NAME = osx" - - provider: script - skip_cleanup: true - script: - - ${TRAVIS_BUILD_DIR}/CI/travis/deploy - on: - condition: "($CC = gcc) && ($TRAVIS_OS_NAME = linux)" - all_branches: true - - provider: script - skip_cleanup: true - script: - - ${TRAVIS_BUILD_DIR}/CI/travis/deploy - on: - condition: "$TRAVIS_OS_NAME = osx" - all_branches: true - - provider: pypi - skip_cleanup: true - on: - tags: true - condition: "$PYPI = yes" - username: __token__ - password: - secure: KfORvnPyLlMANLpcwJjcO44Kt6meP614omJk2GloD+B51SuV64O6N31VDOTi2xqioEk9Cajq7tmNte5YoHVUjL9iWFsBblpzxZoXcy40dn4pFN0kMiE8scszxckbDwuBZhokUVZ2fhfLKf/8xORcwjS3vKqSj5HwQKKvVgukSbQ= - distributions: sdist diff --git a/CI/travis/generateDocumentationAndDeploy.sh.in b/CI/azure/generateDocumentationAndDeploy.sh.in similarity index 100% rename from CI/travis/generateDocumentationAndDeploy.sh.in rename to CI/azure/generateDocumentationAndDeploy.sh.in diff --git a/CI/travis/prepare_assets.sh b/CI/azure/prepare_assets.sh similarity index 100% rename from CI/travis/prepare_assets.sh rename to CI/azure/prepare_assets.sh diff --git a/CI/travis/zip.txt b/CI/azure/zip.txt similarity index 100% rename from CI/travis/zip.txt rename to CI/azure/zip.txt diff --git a/CI/install_deps_win.ps1 b/CI/install_deps_win.ps1 deleted file mode 100644 index a9e565b4e..000000000 --- a/CI/install_deps_win.ps1 +++ /dev/null @@ -1,33 +0,0 @@ -# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-7.2#erroractionpreference -$ErrorActionPreference = "Stop" -$ErrorView = "NormalView" - -$ARCH=$Env:ARCH - -git submodule update --init - -if (!(Test-Path deps)) { - mkdir deps -} -cd deps - -mkdir libxml - -if ( "$ARCH" -eq "x64" ) { - wget https://www.zlatkovic.com/pub/libxml/64bit/libxml2-2.9.3-win32-x86_64.7z -OutFile "libxml.7z" -} else { - wget https://www.zlatkovic.com/pub/libxml/64bit/libxml2-2.9.3-win32-x86.7z -OutFile "libxml.7z" -} -7z x -y libxml.7z -rm libxml.7z - -echo "Downloading deps..." -cd C:\ -wget http://swdownloads.analog.com/cse/build/libiio-win-deps-libusb1.0.24.zip -OutFile "libiio-win-deps.zip" -7z x -y "C:\libiio-win-deps.zip" - -# Note: InnoSetup is already installed on Azure images; so don't run this step -# Running choco seems a bit slow; seems to save about 40-60 seconds here -#choco install InnoSetup - -set PATH=%PATH%;"C:\Program Files (x86)\Inno Setup 6" diff --git a/CI/travis/after_deploy b/CI/travis/after_deploy deleted file mode 100755 index 4acdeb4b9..000000000 --- a/CI/travis/after_deploy +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -e - -TRIGGERING_NEXT_BUILD=true - -. CI/travis/lib.sh - -should_trigger_next_builds "$TRAVIS_BRANCH" || exit 0 - -trigger_adi_build "libad9361-iio" "$TRAVIS_BRANCH" diff --git a/CI/travis/before_deploy b/CI/travis/before_deploy deleted file mode 100755 index 80bf03151..000000000 --- a/CI/travis/before_deploy +++ /dev/null @@ -1,179 +0,0 @@ -#!/bin/sh -e - -. CI/travis/lib.sh - -# Don't prepare a deploy on a Coverity build -if [ "x${COVERITY_SCAN_PROJECT_NAME}" != "x" ] ; then exit 0; fi - -deploy=0 -if [ -z "$TRAVIS_BUILD_DIR" ] ; then - t=$(find ./ -name CMakeCache.txt|head -1) - if [ -n "${t}" ] ; then - cd $(dirname $(dirname ${t})) - TRAVIS_BUILD_DIR=$(pwd) - else - echo "I am confused - can't find CMakeCache.txt" - exit - fi -else - cd $TRAVIS_BUILD_DIR -fi -pwd - -if [ -z "${LDIST}" -a -f "build/.LDIST" ] ; then - export LDIST="-$(cat build/.LDIST)" -fi -if [ -z "${LDIST}" ] ; then - export LDIST="-$(get_ldist)" -fi - -check_file() -{ -temp="" -for i in $(find ./ -name CMakeCache.txt) -do -hit=$(find $(dirname ${i}) -maxdepth 1 -name "libiio*.$1" -a ! -name "*${LDIST}*") -if [ "$(echo ${hit} | wc -w)" -gt "1" ] ; then - echo "I am confused - more than 2 $1 files!" - echo $hit - exit 1 -else - if [ "$(echo ${hit} | wc -w)" -eq "1" ] ; then - if [ -z "${temp}" ] ; then - temp=$hit - else - echo "I am confused - more than 2 $1 files" - echo $temp - echo $hit - exit 1 - fi - fi -fi -done -} - -check_file deb -if [ -n "${temp}" ] ; then - deploy=$(expr ${deploy} + 1) - if [ -z "${TARGET_DEB}" ] ; then - export TARGET_DEB=$(echo ${temp} | \ - sed -e 's:^./.*/::' -e 's:-Linux::' -e 's:.deb$::')${LDIST}.deb - fi - echo "deploying ${temp} to nightly $TARGET_DEB" - if [ -z "${RELEASE_PKG_FILE_DEB}" ] ; then - export RELEASE_PKG_FILE_DEB=$(dirname ${temp})/${TARGET_DEB} - cp ${temp} ${RELEASE_PKG_FILE_DEB} - fi - echo ${TARGET_DEB} - ls -lh ${temp} - echo ${RELEASE_PKG_FILE_DEB} - ls -lh ${RELEASE_PKG_FILE_DEB} -else - echo "Skipping deployment of debian package" -fi - -check_file rpm -if [ -n "${temp}" ] ; then - deploy=$(expr ${deploy} + 1) - if [ -z "${TARGET_RPM}" ] ; then - export TARGET_RPM=$(echo ${temp} | \ - sed -e 's:^./.*/::' -e 's:-Linux::' -e 's:.rpm$::')${LDIST}.rpm - fi - echo "deploying ${temp} to nightly $TARGET_RPM" - if [ -z "${RELEASE_PKG_FILE_RPM}" ] ; then - export RELEASE_PKG_FILE_RPM=$(dirname ${temp})/${TARGET_RPM} - cp ${temp} ${RELEASE_PKG_FILE_RPM} - fi - echo ${TARGET_RPM} - ls -lh ${temp} - echo ${RELEASE_PKG_FILE_RPM} - ls -lh ${RELEASE_PKG_FILE_RPM} -else - echo "Skipping deployment of rpm package" -fi - -check_file tar.gz -if [ -n "${temp}" ] ; then - deploy=$(expr ${deploy} + 1) - if [ -z "${TARGET_TGZ}" ] ; then - echo updating tar file - ( - cd $(dirname ${temp}) - if [ -d tarball_fixup ] ; then - rm -rf tarball_fixup - fi - mkdir tarball_fixup && cd tarball_fixup - - if [ "$TRAVIS_OS_NAME" = "osx" ] ; then - tar --strip-components=1 -xzf ${TRAVIS_BUILD_DIR}/${temp} - else - tar -xzf ${TRAVIS_BUILD_DIR}/${temp} - fi - - if [ "$TRAVIS_OS_NAME" = "osx" ] ; then - cd usr/lib - ln -fs ../../Library/Frameworks/iio.framework/iio libiio.dylib - install_name_tool -change /usr/local/opt/libusb/lib/libusb-1.0.0.dylib @rpath/libusb-1.0.dylib libiio.dylib - install_name_tool -add_rpath @loader_path/../../../../../usr/lib libiio.dylib - install_name_tool -add_rpath /usr/local/opt/libusb/lib libiio.dylib - - cd ../include - ln -s ../../Library/Frameworks/iio.framework/Headers/iio.h iio.h - - # Update references for tools - cd ../.. - TOOLS=Library/Frameworks/iio.framework/Tools/* - for tool in $TOOLS - do - install_name_tool -add_rpath @loader_path/../../ $tool - done - cp /usr/local/lib/libusb-1.0.dylib usr/lib/ - chmod +w usr/lib/libusb-1.0.dylib - install_name_tool -id @rpath/libusb-1.0.dylib usr/lib/libusb-1.0.dylib - - tar -czf ${TRAVIS_BUILD_DIR}/${temp} usr Library - else - tar -czf ${TRAVIS_BUILD_DIR}/${temp} usr lib - fi - ) - - export TARGET_TGZ=$(echo ${temp} | \ - sed -e 's:^./.*/::' -e 's:-Linux::' -e 's:-Darwin::' -e 's:.tar.gz$::')${LDIST}.tar.gz; - fi - echo "deploying ${temp} to $TARGET_TGZ" - if [ -z "${RELEASE_PKG_FILE_TGZ}" ] ; then - export RELEASE_PKG_FILE_TGZ=$(dirname ${temp})/${TARGET_TGZ} - cp ${temp} ${RELEASE_PKG_FILE_TGZ} - fi - echo ${TARGET_TGZ} - ls -lh ${temp} - echo ${RELEASE_PKG_FILE_TGZ} - ls -lh ${RELEASE_PKG_FILE_TGZ} -else - echo "Skipping deployment of tarball" -fi - -check_file pkg -if [ -n "${temp}" ] ; then - deploy=$(expr ${deploy} + 1) - if [ -z "${TARGET_PKG}" ] ; then - export TARGET_PKG=$(echo ${temp} | \ - sed -e 's:^./.*/::' -e 's:.pkg$::')${LDIST}.pkg - fi - echo "deploying ${temp} to nightly $TARGET_PKG" - if [ -z "${RELEASE_PKG_FILE_PKG}" ] ; then - export RELEASE_PKG_FILE_PKG=$(dirname ${temp})/${TARGET_PKG} - cp ${temp} ${RELEASE_PKG_FILE_PKG} - fi - echo ${TARGET_PKG} - ls -lh ${temp} - echo ${RELEASE_PKG_FILE_PKG} - ls -lh ${RELEASE_PKG_FILE_PKG} -else - echo "Skipping deployment of OS X package" -fi - -if [ "${deploy}" -eq "0" ] ; then - echo did not deploy any files - exit 1 -fi diff --git a/CI/travis/before_install_darwin b/CI/travis/before_install_darwin deleted file mode 100755 index bf6cfc25d..000000000 --- a/CI/travis/before_install_darwin +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -e - -. CI/travis/lib.sh - -brew_install_if_not_exists cmake doxygen libusb libxml2 ncurses cdk zstd diff --git a/CI/travis/before_install_linux b/CI/travis/before_install_linux deleted file mode 100755 index f336c320f..000000000 --- a/CI/travis/before_install_linux +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/sh -e - -. CI/travis/lib.sh - -install_sphinx() { - if [ "$CI_BUILD_SPHINX_DOCS" != "1" ] ; then - return - fi - - if ! is_python_at_least_ver "$PYTHON" "3.6" ; then - echo_red "Python version is too old no python interpreter installed" - return 1 - fi - - $PYTHON --version - command -v $PYTHON - $PYTHON -m pip install sphinx - $PYTHON -m pip install sphinx-rtd-theme -} - -handle_centos() { - # needed for man2html and a few other popular tools - yum search epel-release - yum info epel-release - yum -y install epel-release - - # FIXME: see about adding `libserialport-dev` from EPEL ; maybe libusb-1.0.0-devel... - yum -y groupinstall 'Development Tools' - - if [ "$(get_version | head -c 1)" = "7" ] ; then - yum -y install cmake libxml2-devel libusb1-devel libaio-devel \ - bzip2 gzip rpm rpm-build libzstd-devel - - # install Cmake3, and make it the default - yum -y install cmake3 - alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake 10 \ - --slave /usr/local/bin/ctest ctest /usr/bin/ctest \ - --slave /usr/local/bin/cpack cpack /usr/bin/cpack \ - --slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake \ - --family cmake - alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake3 20 \ - --slave /usr/local/bin/ctest ctest /usr/bin/ctest3 \ - --slave /usr/local/bin/cpack cpack /usr/bin/cpack3 \ - --slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake3 \ - --family cmake - fi - - if [ "$(get_version | head -c 1)" = "8" ] ; then - yum -y install wget - wget https://github.com/Kitware/CMake/releases/download/v3.15.2/cmake-3.15.2.tar.gz - tar -zxvf cmake-3.15.2.tar.gz - cd cmake-3.15.2 - ./bootstrap - make - make install - cd .. - yum -y install epel-release - yum -y install libzstd - - yum -y install dnf - dnf -y --enablerepo=powertools install doxygen - - yum -y install libxml2-devel libusb1-devel libaio-devel \ - bzip2 gzip rpm rpm-build libzstd-devel - fi - - if is_centos_at_least_ver "8" ; then - # On CentOS 8, avahi-devel & doxygen are in this repo; enable it - yum -y install yum-utils - yum config-manager --set-enabled powertools - # On CentOS 6 & 7, have issues building or packaging doc - yum -y install python3 doxygen man2html - install_sphinx - else - # On CentOS 8, cdk-devel (Curses Development Kit) does not exist yet - yum -y install ncurses-devel cdk-devel - fi - - yum -y install avahi-devel -} - -handle_generic_docker() { - prepare_docker_image -} - -handle_default() { - sudo apt-get -qq update - sudo DEBIAN_FRONTEND=noninteractive apt-get install -y cmake graphviz \ - libaio-dev libavahi-client-dev libserialport-dev libzstd-dev \ - libavahi-common-dev libusb-1.0-0-dev libxml2-dev rpm tar \ - bzip2 gzip flex bison git libncurses5-dev libcdk5-dev \ - doxygen man2html python3 python3-pip python3-setuptools - - install_sphinx -} - -handle_ubuntu() { - handle_default -} - -handle_debian() { - handle_default -} - -handle_doxygen() { - handle_default -} - -setup_build_type_env_vars - -handle_${BUILD_TYPE} diff --git a/CI/travis/check_kernel.sh b/CI/travis/check_kernel.sh deleted file mode 100755 index ff2e82d8b..000000000 --- a/CI/travis/check_kernel.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -set -e - -KERNEL_TYPES="/tmp/mainline_types.h" -IIOH="./iio.h" -CHANNELC="./channel.c" - -if [ ! -f ${IIOH} ] ; then - echo can not find ${IIOH} - exit 1 -fi - -if [ ! -f ${CHANNELC} ] ; then - echo can not find ${CHANNELC} - exit 1 -fi - -rm -f ${KERNEL_TYPES} -wget -O ${KERNEL_TYPES} https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/include/uapi/linux/iio/types.h - -ret=0 - -for enum in iio_chan_type iio_modifier -do - echo looking for ${enum} - rm -f /tmp/kernel_${enum} /tmp/libiio_${enum} - sed "0,/${enum}/d" ${KERNEL_TYPES} | sed -n '/}/q;p' > /tmp/kernel_${enum} - sed "0,/^enum.*${enum}/d" ${IIOH} | sed -n '/}/q;p' | grep -v IIO_CHAN_TYPE_UNKNOWN > /tmp/libiio_${enum} - echo Differences in ${enum} - # diff exit status of 1 means a difference, not an error - set +e - diff -u /tmp/libiio_${enum} /tmp/kernel_${enum} - count=$(diff -u /tmp/libiio_${enum} /tmp/kernel_${enum} | wc -l) - set -e - if [ "$count" -ne "0" ] ; then - ret=1 - echo difference between upstream kernel types.h and iio.h in ${enum} - else - echo none - fi -done - -for enum in iio_chan_type_name_spec modifier_names -do - sed "0,/^static.*${enum}/d" ${CHANNELC} | sed -n '/}/q;p' | \ - grep -v IIO_CHAN_TYPE_UNKNOWN > /tmp/libiio_${enum} -done - -while IFS="" read -r p ; do - key=$(echo ${p//[[:space:],]/}) - count=$(grep "\[$key\]" /tmp/libiio_iio_chan_type_name_spec | wc -l) - if [ "$count" -eq "0" ] ; then - echo "$key missing from channel.c iio_chan_type_name_spec" - ret=1 - fi -done < /tmp/libiio_iio_chan_type - -echo -sed -i '/IIO_NO_MOD/d' /tmp/libiio_iio_modifier - -while IFS="" read -r p ; do - key=$(echo "${p//[[:space:],]/}") - count=$(grep "\[$key\]" /tmp/libiio_modifier_names | wc -l) - if [ "$count" -eq "0" ] ; then - echo "$key missing from channel.c modifier_names" - ret=1 - fi -done < /tmp/libiio_iio_modifier - -exit $ret diff --git a/CI/travis/deploy b/CI/travis/deploy deleted file mode 100755 index aa4d086ba..000000000 --- a/CI/travis/deploy +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -e - -. CI/travis/lib.sh - -# libname from to suffix -upload_file_to_swdownloads libiio ${RELEASE_PKG_FILE_DEB} ${TARGET_DEB} .deb -upload_file_to_swdownloads libiio ${RELEASE_PKG_FILE_RPM} ${TARGET_RPM} .rpm -upload_file_to_swdownloads libiio ${RELEASE_PKG_FILE_TGZ} ${TARGET_TGZ} .tar.gz -upload_file_to_swdownloads libiio ${RELEASE_PKG_FILE_PKG} ${TARGET_PKG} .pkg -remove_old_pkgs libiio diff --git a/CI/travis/deploy.rsa.enc b/CI/travis/deploy.rsa.enc deleted file mode 100644 index 78fe1ff0542b2a9053072451ec1453566fd4694a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1680 zcmV;B25P)>Aod@z*#hoh2J9ToRT>hfq|y7 zm^0tPWYpYsgo%WRZK3?2?jeoyQ)U3+SGafdWMKX zfgELIg4?5Z1IbT-ne;gvH-NjAgz(;A+M3zrkq`*-Z$GKlXNYEmL}<1*0-$ z3ufV;gi4bg4%h9+mmMCTRYqte;MAK)P=T9)xG-lqF9AUH(-~EVet=sIe5zqEC!#sw zV;EALqO!ijmAMhR2V~Wj5Aiu23EqT#W79|_J$c@BiOhJN%aLO1P@z{-rn=t|%&w8m zT=!x_SjP<;xpUW#F~p*@fxjxF?JM9N%HNJUAr$x;oa6BibR(fW*s0lwz0lA+r>Mf~ z?dLmmVYr-%!Vk-MVhZtc7L&(9S)rtH=o*o0?51-NL$ymPF6-AYN;JH6=6_QK%S_ea z%$L^eGaBlLu)$6m(=X2-Gj9|rX~ryXQ*ULo-GxH!FgG<h|e5iZ<17>^S-f|3Xf$3~a2ZS6+9b8W`-tWAyQUprU+%f5qAf?31@ zzjWFKj0~6hw>-?*K_h%us7=21SRtq{hX#ct`Ip;>yY!z{EOd>vSKL&-D((64_1+fd zP;HxaSH0p%?lIyl5T`0I&S73T95lOw|2bzWCkb=Z0d|n?TZ7Wh7xZf|kSM;~ZV8hG zQcetdz>MhF$5*u`AP7JE`z?c~|9gja>MkbU&&dm>-%ehekeH5Q+w1`XgAqmHv z@Y7pTPDKmR$_^)XUEifO#c4P_%KG&JFqE_Clg4Adu()*I4c! zQPyz!EX2KSu3y`gNE47&3~MPDli6uNl>~S!iTD-CM606Y4K4H(s0x1Rzr1y$>L58Q zd1odg6gtk_G`pEC@I`7=cbdi}&D_ieKJ1_XIbDx!3I#Px!TXZ{iWD$qG%!b8kM?3YJc613ucw9?@vMSryeG`l)hUUKb~*+SY!fs>%ON`7rP^ zrNP;+9)8e{C=T6EgK7614*`X<4bHrS6&*HQJmM^kS7=F_29GdzER@7`JiUX$VS7=I z?1DvVYnL?iRF53zUnb7K8Sk6P3+J|~YI&+vTb2o@w7yk?>7s=zJK35$8AO-Tv~nr% zJzp@Fw%36`H${kPX3HbZJMFSnE9@ui{HG>IK%h}(&at6*-%MEd3SfM7wT?_mIEq2g zUq1qb1kZk`MK^U}$ZW_ueixvo$LD%8!nUXXTqSC2#%;mez$QRQI!WY{9!1*%kh91q$B}Ya z(!GW$i|J8CpHd6uRlHH8UwaT4JcDIZcnu>4gp z>O_M6X;4ggdq$@j*qUVO9y9J)Y15VKPZ7oq8<2NoPF4g84C)V|^VY$=vt>2It6vc+ zmvHW~?;01I@5D_YtDRq<2Nc6EIQh6uBj%ew=a)$|@8dkTKYFcyr!){y9duVG239O= a3nge5@iB%dC7puVgnUHGonnhs>Xsm@xHrQ9 diff --git a/CI/travis/inside_docker.sh b/CI/travis/inside_docker.sh deleted file mode 100755 index afa013fba..000000000 --- a/CI/travis/inside_docker.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -e - -export INSIDE_DOCKER="1" - -INSIDE_DOCKER_BUILD_DIR=/docker_build_dir - -export TRAVIS_BUILD_DIR="$INSIDE_DOCKER_BUILD_DIR" - -cd "$INSIDE_DOCKER_BUILD_DIR" - -if [ -d "/$INSIDE_DOCKER_BUILD_DIR/CI" ] ; then - CI="/$INSIDE_DOCKER_BUILD_DIR/CI" -elif [ -d "/$INSIDE_DOCKER_BUILD_DIR/ci" ] ; then - CI="/$INSIDE_DOCKER_BUILD_DIR/ci" -else - echo "No CI/ci directory present" - exit 1 -fi - -if [ -f "$INSIDE_DOCKER_BUILD_DIR/inside-travis-ci-docker-env" ] ; then - . "$INSIDE_DOCKER_BUILD_DIR/inside-travis-ci-docker-env" -fi - -"$CI/travis/before_install_linux" - -"$CI/travis/make_linux" - -# need to find this out inside the container -. "$CI/travis/lib.sh" -echo "$(get_ldist)" > "${INSIDE_DOCKER_BUILD_DIR}/build/.LDIST" diff --git a/CI/travis/lib.sh b/CI/travis/lib.sh deleted file mode 100644 index 19bcf15b3..000000000 --- a/CI/travis/lib.sh +++ /dev/null @@ -1,565 +0,0 @@ -#!/bin/sh -e - -if [ "$TRIGGER_NEXT_BUILD" = "true" ] && [ "$TRIGGERING_NEXT_BUILD" != "true" ] ; then - exit 0 -fi - -export TRAVIS_API_URL="https://api.travis-ci.com" -LOCAL_BUILD_DIR=${LOCAL_BUILD_DIR:-build} - -HOMEBREW_NO_INSTALL_CLEANUP=1 -export HOMEBREW_NO_INSTALL_CLEANUP - -PYTHON=python3 -export PYTHON - -# This needs to be duplicated inside 'inside_docker.sh' -# It's the common convention between host & container -INSIDE_DOCKER_BUILD_DIR=/docker_build_dir - -# Add here all the common env-vars that should be propagated -# to the docker image, simply by referencing the env-var name. -# The values will be evaluated. -# -# Make sure to not pass certain stuff that are specific to the host -# and not specific to inside-the-docker (like TRAVIS_BUILD_DIR) -# -# If these nothing should be passed, then clear or -#'unset INSIDE_DOCKER_TRAVIS_CI_ENV' after this script is included -INSIDE_DOCKER_TRAVIS_CI_ENV="TF_BUILD TRAVIS TRAVIS_COMMIT TRAVIS_PULL_REQUEST OS_TYPE OS_VERSION ARTIFACTNAME" - -COMMON_SCRIPTS="inside_docker.sh" - -echo_red() { printf "\033[1;31m$*\033[m\n"; } -echo_green() { printf "\033[1;32m$*\033[m\n"; } -echo_blue() { printf "\033[1;34m$*\033[m\n"; } - -backtrace() { - # shell backtraces only work on bash - if [ ! -z "${BASH}" ] ; then - local i= - i=${#FUNCNAME[@]} - ((--i)) - - while (( i >= 0 )) - do - echo "${BASH_SOURCE[$i]}:${BASH_LINENO[$i]}.${FUNCNAME[$i]}()" - i=$((i - 1)) - done - fi -} - -get_script_path() { - local script="$1" - - [ -n "$script" ] || return 1 - - if [ -f "CI/travis/$script" ] ; then - echo "CI/travis/$script" - elif [ -f "ci/travis/$script" ] ; then - echo "ci/travis/$script" - elif [ -f "${LOCAL_BUILD_DIR}/$script" ] ; then - echo "${LOCAL_BUILD_DIR}/$script" - else - return 1 - fi -} - -pipeline_branch() { - local branch=$1 - - [ -n "$branch" ] || return 1 - - # master is a always a pipeline branch - [ "$branch" = "master" ] && return 0 - - set +x - # Check if branch name is 20XX_RY where: - # XX - 14 to 99 /* wooh, that's a lot of years */ - # Y - 1 to 9 /* wooh, that's a lot of releases per year */ - for year in $(seq 2014 2099) ; do - for rel_num in $(seq 1 9) ; do - [ "$branch" = "${year}_R${rel_num}" ] && \ - return 0 - done - done - - return 1 -} - -should_trigger_next_builds() { - local branch="$1" - - [ -z "${COVERITY_SCAN_PROJECT_NAME}" ] || return 1 - - # These Travis-CI vars have to be non-empty - [ -n "$TRAVIS_PULL_REQUEST" ] || return 1 - [ -n "$branch" ] || return 1 - set +x - [ -n "$TRAVIS_API_TOKEN" ] || return 1 - - # Has to be a non-pull-request - [ "$TRAVIS_PULL_REQUEST" = "false" ] || return 1 - - pipeline_branch "$branch" || return 1 -} - -trigger_build() { - local repo_slug="$1" - local branch="$2" - - [ -n "$repo_slug" ] || return 1 - [ -n "$branch" ] || return 1 - - local body="{ - \"request\": { - \"branch\":\"$branch\" - } - }" - - # Turn off tracing here (shortly) - set +x - curl -s -X POST \ - -H "Content-Type: application/json" \ - -H "Accept: application/json" \ - -H "Travis-API-Version: 3" \ - -H "Authorization: token $TRAVIS_API_TOKEN" \ - -d "$body" \ - "${TRAVIS_API_URL}/repo/$repo_slug/requests" -} - -trigger_adi_build() { - local adi_repo="$1" - local branch="$2" - - [ -n "$adi_repo" ] || return 1 - trigger_build "analogdevicesinc%2F$adi_repo" "$branch" -} - -command_exists() { - local cmd=$1 - [ -n "$cmd" ] || return 1 - type "$cmd" >/dev/null 2>&1 -} - -get_ldist() { - case "$(uname)" in - Linux*) - if [ ! -f /etc/os-release ] ; then - if [ -f /etc/centos-release ] ; then - echo "centos-$(sed -e 's/CentOS release //' -e 's/(.*)$//' \ - -e 's/ //g' /etc/centos-release)-$(uname -m)" - return 0 - fi - ls /etc/*elease - [ -z "${OSTYPE}" ] || { - echo "${OSTYPE}-unknown" - return 0 - } - echo "linux-unknown" - return 0 - fi - . /etc/os-release - if ! command_exists dpkg ; then - echo $ID-$VERSION_ID-$(uname -m) - else - echo $ID-$VERSION_ID-$(dpkg --print-architecture) - fi - ;; - Darwin*) - echo "darwin-$(sw_vers -productVersion)" - ;; - *) - echo "$(uname)-unknown" - ;; - esac - return 0 -} - -__brew_install_or_upgrade() { - brew install "$1" || \ - brew upgrade "$1" || \ - brew ls --versions "$1" -} - -brew_install_or_upgrade() { - while [ -n "$1" ] ; do - __brew_install_or_upgrade "$1" || return 1 - shift - done -} - -__brew_install_if_not_exists() { - brew ls --versions "$1" || \ - brew install "$1" -} - -brew_install_if_not_exists() { - while [ -n "$1" ] ; do - __brew_install_if_not_exists "$1" || return 1 - shift - done -} - -sftp_cmd_pipe() { - sftp -o "StrictHostKeyChecking no" "${EXTRA_SSH}" "${SSHUSER}@${SSHHOST}" -} - -sftp_run_cmds() { - local x=5 - while [ "${x}" -gt "0" ] ; do - sftp -o "StrictHostKeyChecking no" "${EXTRA_SSH}" "${SSHUSER}@${SSHHOST}" 0< "$1" && break; - echo_red "failed to ssh, trying again" - x=$((x - 1)) - sleep 10 - done - if [ "${x}" -eq "0" ] ; then - echo_red "failed to upload files" - return 1; - fi - return 0 -} - -sftp_rm_artifact() { - local artifact="$1" - sftp_cmd_pipe <<-EOF - cd ${DEPLOY_TO} - rm ${artifact} - bye - EOF -} - -sftp_upload() { - local FROM="$1" - local TO="$2" - local LATE="$3" - - if [ -n "${LATE}" ] ; then - sftp_cmd_pipe <<-EOF - cd ${DEPLOY_TO} - - put ${FROM} ${TO} - ls -l ${TO} - - symlink ${TO} ${LATE} - ls -l ${LATE} - bye - EOF - else - sftp_cmd_pipe <<-EOF - cd ${DEPLOY_TO} - - put ${FROM} ${TO} - ls -l ${TO} - bye - EOF - fi -} - -upload_file_to_swdownloads() { - - if [ "$#" -ne 4 ] ; then - echo "skipping deployment of something" - echo "send called with $@" - return 0 - fi - - local LIBNAME=$1 - local FROM=$2 - local FNAME=$3 - local EXT=$4 - - if [ -z "$FROM" ] ; then - echo no file to send - return 1 - fi - - if [ ! -r "$FROM" ] ; then - echo "file $FROM is not readable" - return 1 - fi - - if [ -n "$TRAVIS_PULL_REQUEST_BRANCH" ] ; then - local branch="$TRAVIS_PULL_REQUEST_BRANCH" - else - local branch="$TRAVIS_BRANCH" - fi - - local TO=${branch}_${FNAME} - local LATE=${branch}_latest_${LIBNAME}${LDIST}${EXT} - local GLOB=${DEPLOY_TO}/${branch}_${LIBNAME}-* - - echo attempting to deploy "$FROM" to "$TO" - echo and "${branch}_${LIBNAME}${LDIST}${EXT}" - ssh -V - - local tmpfl=$(mktemp) - echo "cd ${DEPLOY_TO}" > "${tmpfl}" - echo "rm ${TO}" >> "${tmpfl}" - echo "rm ${LATE}" >> "${tmpfl}" - echo "put ${FROM} ${TO}" >> "${tmpfl}" - echo "symlink ${TO} ${LATE}" >> "${tmpfl}" - echo "ls -l ${TO}" >> "${tmpfl}" - echo "ls -l ${LATE}" >> "${tmpfl}" - echo "bye" >> "${tmpfl}" - - sftp_run_cmds "${tmpfl}" - rm "${tmpfl}" - - return 0 -} - -remove_old_pkgs() { - # limit things to a few files, so things don't grow forever - # we only do this on one build so simultaneous builds don't clobber each other - if [ -z "${GH_DOC_TOKEN}" ] ; then - return 0 - fi - - if [ -z "${TRAVIS_BUILD_DIR}" ] ; then - echo "TRAVIS_BUILD_DIR not set" - return 0 - fi - - if [ ! -d "${TRAVIS_BUILD_DIR}/.git" ] ; then - echo "No ${TRAVIS_BUILD_DIR}/.git to operate git on" - return 0 - fi - - local LIBNAME=$1 - local old= - - echo "Remove old packages from ${LIBNAME}" - - if [ -n "$TRAVIS_PULL_REQUEST_BRANCH" ] ; then - local branch="$TRAVIS_PULL_REQUEST_BRANCH" - else - local branch="$TRAVIS_BRANCH" - fi - - local GLOB=${DEPLOY_TO}/${branch}_${LIBNAME}-* - - # putting everything into a file, and connecting once decreases the chances - # for ssh issues, connections happen once, not every single file - local tmpfl=$(mktemp) - echo "cd ${DEPLOY_TO}" > "${tmpfl}" - for files in $(ssh -o "StrictHostKeyChecking no" "${EXTRA_SSH}" "${SSHUSER}@${SSHHOST}" \ - "ls -lt ${GLOB}" | tail -n +100 | awk '{print $NF}') - do - echo "rm ${files}" >> "${tmpfl}" - done - echo "bye" >> "${tmpfl}" - # if it is only cd & bye, skip it - if [ "$(wc -l "${tmpfl}" | awk '{print $1}')" -gt "2" ] ; then - sftp_run_cmds "${tmpfl}" - fi - rm "${tmpfl}" - # provide an index so people can find files. - ssh -o "StrictHostKeyChecking no" "${EXTRA_SSH}" "${SSHUSER}@${SSHHOST}" \ - "ls -lt ${DEPLOY_TO}" | grep "${LIBNAME}" > "${LIBNAME}_index.html" - echo "ls captured" - - echo "cd ${DEPLOY_TO}" > "${tmpfl}" - # prune old / removed branches, leave things are are tags/branches - for old in $(sed 's/-> .*$//' libiio_index.html | \ - awk '{print $NF}' | grep -v master | sort | \ - sed "s/_libiio-0.[0-9][0-9].g[a-z0-9]*-/ %% /" | \ - grep "%%" | awk '{print $1}' | sort -u) - do - if [ "$(git --git-dir "${TRAVIS_BUILD_DIR}/.git" ls-remote --heads origin "${old}" | wc -l)" -ne "0" ] ; then - echo "${old} is a branch" - else - if [ "$(git --git-dir "${TRAVIS_BUILD_DIR}/.git" ls-remote --tags origin "${old}" | wc -l)" -ne "0" ] ; then - echo "${old} is a tag" - else - echo "${old} can be removed" - echo "rm ${old}_${LIBNAME}-*" >> "${tmpfl}" - echo "rm ${old}_latest_${LIBNAME}-*" >> "${tmpfl}" - echo "rm ${old}_lastest_${LIBNAME}-*" >> "${tmpfl}" - fi - fi - done - # cap things at 15, so we don't exceed the time - sed -i 16q "${tmpfl}" - echo "bye" >> "${tmpfl}" - # if it is only cd & bye, skip it - if [ "$(wc -l "${tmpfl}" | awk '{print $1}')" -gt "2" ] ; then - sftp_run_cmds "${tmpfl}" - fi - rm "${tmpfl}" - - #Now that we removed things, do it again - rm "${LIBNAME}_index.html" - ssh -o "StrictHostKeyChecking no" "${EXTRA_SSH}" "${SSHUSER}@${SSHHOST}" \ - "ls -lt ${DEPLOY_TO}" | grep "${LIBNAME}" > "${LIBNAME}_index.html" - sftp_upload "${LIBNAME}_index.html" "${LIBNAME}_index.html" - - return 0 -} - -prepare_docker_image() { - local DOCKER_IMAGE="${OS_TYPE}:${OS_VERSION}" - # If arch is specified, setup multiarch support - if [ -n "$OS_ARCH" ] ; then - sudo apt-get -qq update - sudo DEBIAN_FRONTEND=noninteractive apt-get install -y qemu \ - qemu binfmt-support qemu-user-static - sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - DOCKER_IMAGE="${OS_ARCH}/${DOCKER_IMAGE}" - fi - echo 'DOCKER_OPTS="-H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock -s devicemapper"' | sudo tee /etc/default/docker > /dev/null - sudo service docker restart - sudo docker pull "$DOCKER_IMAGE" -} - -__save_env_for_docker() { - local env_file="$1/inside-travis-ci-docker-env" - for env in $INSIDE_DOCKER_TRAVIS_CI_ENV ; do - val="$(eval echo "\$${env}")" - if [ -n "$val" ] ; then - echo "export ${env}=\"${val}\"" >> "${env_file}" - fi - done -} - -run_docker_script() { - local DOCKER_SCRIPT="$(get_script_path $1)" - local MOUNTPOINT="${INSIDE_DOCKER_BUILD_DIR}" - local DOCKER_IMAGE="${OS_TYPE}:${OS_VERSION}" - - if [ -n "$OS_ARCH" ] ; then - DOCKER_IMAGE="${OS_ARCH}/${DOCKER_IMAGE}" - fi - - __save_env_for_docker "$(pwd)" - - sudo docker run --rm=true \ - -v "$(pwd):/${MOUNTPOINT}:rw" \ - "$DOCKER_IMAGE" \ - /bin/bash -e "/${MOUNTPOINT}/${DOCKER_SCRIPT}" "${MOUNTPOINT}" "${OS_TYPE}" -} - -ensure_command_exists() { - local cmd="$1" - local package="$2" - local yes_confirm - [ -n "$cmd" ] || return 1 - [ -n "$package" ] || package="$cmd" - ! command_exists "$cmd" || return 0 - # go through known package managers - for pacman in apt-get brew yum ; do - command_exists $pacman || continue - if [ "$pacman" = "brew" ] ; then - yes_confirm= - else - yes_confirm="-y" - fi - "$pacman" install $yes_confirm "$package" || { - # Try an update if install doesn't work the first time - "$pacman" $yes_confirm update && \ - "$pacman" install $yes_confirm "$package" - } - return $? - done - return 1 -} - -version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"; } -version_le() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" = "$1"; } -version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" != "$1"; } -version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" = "$1"; } - -get_codename() { - local VERSION_CODENAME - eval $(grep -w VERSION_CODENAME /etc/os-release) - echo "$VERSION_CODENAME" -} - -get_dist_id() { - local ID - eval $(grep -w ID /etc/os-release) - echo "$ID" -} - -get_version() { - local VERSION_ID - eval $(grep -w VERSION_ID /etc/os-release) - echo "$VERSION_ID" -} - -is_ubuntu_at_least_ver() { - [ "$(get_dist_id)" = "ubuntu" ] || return 1 - version_ge "$(get_version)" "$1" -} - -is_centos_at_least_ver() { - [ "$(get_dist_id)" = "centos" ] || return 1 - version_ge "$(get_version)" "$1" -} - -is_python_at_least_ver() { - local out python_exec - - python_exec="$1" - command_exists "$python_exec" || return 1 - out=$($python_exec --version) - version_ge "${out#* }" "$2" -} - -is_arm() { - [ "$(dpkg --print-architecture)" = "armhf" ] || return 1 -} - -is_arm64() { - [ "$(dpkg --print-architecture)" = "arm64" ] || return 1 -} - -print_github_api_rate_limits() { - # See https://developer.github.com/v3/rate_limit/ - # Note: Accessing this endpoint does not count against your REST API rate limit. - echo_green '-----------------------------------------' - echo_green 'Github API Rate limits' - echo_green '-----------------------------------------' - wget -q -O- https://api.github.com/rate_limit - echo_green '-----------------------------------------' -} - -setup_build_type_env_vars() { - OS_TYPE=${OS_TYPE:-default} - - # For a 'arm32_v7/debian_docker' string, OS TYPE becomes 'debian' - # This also works for just 'debian_docker' - # And we're extracting OS_ARCH if present - if [ "${OS_TYPE#*_}" = "docker" ] ; then - BUILD_TYPE=generic_docker - OS_TYPE=${OS_TYPE%_*} - OS_ARCH=${OS_TYPE%/*} - OS_TYPE=${OS_TYPE#*/} - if [ "$OS_ARCH" = "$OS_TYPE" ] ; then - OS_ARCH= - fi - else - BUILD_TYPE="$OS_TYPE" - fi - - export OS_TYPE - export OS_ARCH - export BUILD_TYPE -} - -ensure_command_exists sudo -ensure_command_exists wget - -# Other scripts will download lib.sh [this script] and lib.sh will -# in turn download the other scripts it needs. -# This gives way more flexibility when changing things, as they propagate -for script in $COMMON_SCRIPTS ; do - [ ! -f "CI/travis/$script" ] || continue - [ ! -f "ci/travis/$script" ] || continue - [ ! -f "${LOCAL_BUILD_DIR}/$script" ] || continue - mkdir -p "${LOCAL_BUILD_DIR}" - wget https://raw.githubusercontent.com/analogdevicesinc/libiio/master/CI/travis/$script \ - -O "$LOCAL_BUILD_DIR/$script" -done - -print_github_api_rate_limits diff --git a/CI/travis/make_darwin b/CI/travis/make_darwin deleted file mode 100755 index c27fd505e..000000000 --- a/CI/travis/make_darwin +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -e - -LIBIIO_BUILD_CONF="-DWITH_SERIAL_BACKEND=OFF -DWITH_ZSTD=ON" - -if [ "x${COVERITY_SCAN_PROJECT_NAME}" != "x" ] ; then exit 0; fi - -build_osx() { - FLAGS=$1 - echo "### cmake ${FLAGS}" - cmake ${FLAGS} .. - - echo "### make" - make - - echo "### files are" - ls -} - -change_artefact_name() { - old_name=`find . -name '*.pkg' | cut -b 3-26` - name=`echo ${old_name} | cut -b 1-20` - new_name="${name}-${ARTIFACTNAME}.pkg" - mv ./${old_name} ./${new_name} -} - -mkdir -p build - -cd build -build_osx "-DOSX_PACKAGE=ON -DPYTHON_BINDINGS=ON -DWITH_EXAMPLES=ON ${LIBIIO_BUILD_CONF}" -change_artefact_name - -cd .. - -mkdir -p build_tar -cd build_tar -build_osx "-DOSX_PACKAGE=OFF -DENABLE_PACKAGING=ON -DPYTHON_BINDINGS=ON -DCPACK_SYSTEM_NAME=${ARTIFACTNAME} ${LIBIIO_BUILD_CONF}" -echo "### make package" -make package -echo "### files are" -ls diff --git a/CI/travis/make_linux b/CI/travis/make_linux deleted file mode 100755 index f5e89374a..000000000 --- a/CI/travis/make_linux +++ /dev/null @@ -1,144 +0,0 @@ -#!/bin/sh -e - -if [ "x${COVERITY_SCAN_PROJECT_NAME}" != "x" ] ; then exit 0; fi - -. CI/travis/lib.sh - -INSIDE_DOCKER_TRAVIS_CI_ENV="$INSIDE_DOCKER_TRAVIS_CI_ENV CHECK_AGAINST_KERNEL_HEADER CI_BUILD_SPHINX_DOCS" -CPACK_HELP="-DCPACK_SYSTEM_NAME=${ARTIFACTNAME}" - -handle_default() { - echo "### making build dir" - mkdir -p build - cd build - - if command_exists $PYTHON ; then - command -v $PYTHON - $PYTHON --version - - PYTHON_HELP="-DPYTHON_BINDINGS=ON \ - -DPYTHON_INCLUDE_DIR=$($PYTHON -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \ - -DPYTHON_LIBRARY=$($PYTHON -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))") \ - -DPYTHON_EXECUTABLE=$(command -v $PYTHON)" - - # Add ~/.local dir to paths; this is where pip installs things (if no sudo) - export PATH="$PATH:$(readlink -f ~/.local/bin/)" - export PYTHONPATH="$(readlink -f ~/.local/lib/python*/site-packages/)" - - if command_exists sphinx-build ; then - DOC_HELP="-DWITH_DOC=ON" - fi - else - echo No Python - if command_exists doxygen ; then - DOC_HELP="-DWITH_DOC=ON" - fi - fi - if [ ! -n "${DOC_HELP}" ] ; then - if command_exists man2html ; then - echo doc and man - MAN_HELP="-DWITH_MAN=ON" - fi - else - MAN_HELP="-DWITH_MAN=ON" - fi - - FLAGS="-DENABLE_PACKAGING=ON -DDEB_DETECT_DEPENDENCIES=ON -DWITH_EXAMPLES=ON ${PYTHON_HELP} ${DOC_HELP} ${MAN_HELP} ${CPACK_HELP}" - - # Ubuntu Xenial's libserialport and libzstd are too old - if [ "${OS_VERSION}" = xenial ] ; then - FLAGS="${FLAGS} -DWITH_SERIAL_BACKEND=OFF" - else - FLAGS="${FLAGS} -DWITH_SERIAL_BACKEND=ON -DWITH_ZSTD=ON" - fi - - echo "### cmake ${FLAGS}" - cmake ${FLAGS} .. - - if [ -f CMakeFiles/CMakeError.log ] ; then - echo "### CMakeError.log" - cat CMakeFiles/CMakeError.log - exit 1 - fi - - echo "### make" - make - - # check the error output if either file is not empty - if [ -s ./Dox_output_libiio -o -s ./Dox_output_csharp -o -s ./Spx_output_python ] ; then - if [ -s ./Dox_output_libiio ] ; then - echo "### ERRORs in Dox_output_libiio" - cat ./Dox_output_libiio - fi - if [ -s ./Dox_output_csharp ] ; then - echo "### ERRORs in Dox_output_csharp" - cat ./Dox_output_csharp - fi - if [ -s ./Spx_output_python ] ; then - echo "### ERRRORs in Spx_output_python" - cat ./Spx_output_python - fi - exit 1 - else - echo "### No errors in Doc" - if [ -f Dox_output_csharp ] ; then - ls -l Dox_output_csharp - fi - if [ -f Dox_output_libiio ] ; then - ls -l Dox_output_libiio - fi - if [ -f Spx_output_python ] ; then - ls -l Spx_output_python - fi - fi - - echo "### make package" - make package - - if [ -f "./generateDocumentationAndDeploy.sh" ] ; then - sh generateDocumentationAndDeploy.sh - fi - cd .. - - # make sure we are up to date (once) - if [ "$CHECK_AGAINST_KERNEL_HEADER" = "1" ] ; then - ./CI/travis/check_kernel.sh - fi - echo "### All done building" -} - -handle_centos() { - echo "handle centos" - mkdir -p build - cd build - - FLAGS="-DENABLE_PACKAGING=ON -DPYTHON_BINDINGS=ON -DWITH_SERIAL_BACKEND=OFF -DWITH_ZSTD=ON ${CPACK_HELP}" - - # CentOS 7's kernel headers are too old for USB support in IIOD - [ "${OS_VERSION}" = centos7 ] && FLAGS="${FLAGS} -DWITH_IIOD_USBD=OFF" - - cmake ${FLAGS} .. - make - make package - cd .. -} - -handle_ubuntu() { - handle_default -} - -handle_debian() { - handle_default -} - -handle_generic_docker() { - run_docker_script inside_docker.sh -} - -handle_doxygen() { - handle_default -} - -setup_build_type_env_vars - -handle_${BUILD_TYPE} diff --git a/CI/travis/make_linux_qemu b/CI/travis/make_linux_qemu deleted file mode 100755 index b1d101db7..000000000 --- a/CI/travis/make_linux_qemu +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -set -ex - -CHROOT_DIR=/tmp/arm-chroot - -sudo chroot ${CHROOT_DIR} bash -c "cd ${TRAVIS_BUILD_DIR} && ./CI/travis/make_linux libiio" -sudo chroot ${CHROOT_DIR} bash -c ". ${TRAVIS_BUILD_DIR}/CI/travis/lib.sh && get_ldist > ${TRAVIS_BUILD_DIR}/build/.LDIST" - -#move the artifacts back to the non-qemu place -sudo rsync -av ${CHROOT_DIR}/${TRAVIS_BUILD_DIR}/ ${TRAVIS_BUILD_DIR}/ -#make sure the normal travis user can read them -sudo chown -R ${USER} ${TRAVIS_BUILD_DIR} - diff --git a/CI/travis/setup_qemu_for_arm.sh b/CI/travis/setup_qemu_for_arm.sh deleted file mode 100755 index ab8b39d6f..000000000 --- a/CI/travis/setup_qemu_for_arm.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash -# Based on a test script from avsm/ocaml repo https://github.com/avsm/ocaml -set -ex - -if [ $# -ne 1 ] ; then - echo Must include debian distribution ie wheezy, jessie, stretch, or buster - exit -1 -fi -if [[ ! $1 =~ ^wheezy|jessie|stretch|buster$ ]] ; then - echo Must include debian distribution ie wheezy, jessie, stretch, or buster - exit -1 -fi - -CHROOT_DIR=/tmp/arm-chroot -MIRROR=http://archive.raspbian.org/raspbian -# wheezy = 7 (2013-05-04); jessie = 8 (2015-04-26); stretch = 9 (2017-06-17); buster = 10 (2019-03-12) -VERSION=$1 -echo building for "${VERSION}" -CHROOT_ARCH=armhf - -# Host dependencies -sudo apt-get update -sudo apt-get install -qq -y qemu-user-static binfmt-support sbuild wget debian-archive-keyring ubuntu-keyring gnupg libudev1 libudev-dev liblzma-dev libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev -# need a newer version of qemu :( -QEMU_DIR=/tmp/qemu -sudo mkdir -p ${QEMU_DIR} -sudo chown "${USER}" /tmp/qemu -cd ${QEMU_DIR} -wget https://download.qemu.org/qemu-3.1.0.tar.xz -tar xf qemu-3.1.0.tar.xz -cd qemu-3.1.0 -mkdir build -mkdir install -cd build -../configure --prefix=${QEMU_DIR}/install --disable-bsd-user --disable-guest-agent --disable-strip --disable-werror --disable-gcrypt --disable-debug-info --disable-debug-tcg --disable-docs --disable-tcg-interpreter --enable-attr --disable-brlapi --disable-linux-aio --disable-bzip2 --disable-bluez --disable-cap-ng --disable-curl --disable-fdt --disable-glusterfs --disable-gnutls --disable-nettle --disable-gtk --disable-rdma --disable-libiscsi --disable-vnc-jpeg --disable-kvm --disable-lzo --disable-curses --disable-libnfs --disable-numa --disable-opengl --disable-vnc-png --disable-rbd --disable-vnc-sasl --disable-sdl --disable-seccomp --disable-smartcard --disable-snappy --disable-spice --disable-libssh2 --disable-libusb --disable-usb-redir --disable-vde --disable-vhost-net --disable-virglrenderer --disable-virtfs --disable-vnc --disable-vte --disable-xen --disable-xen-pci-passthrough --disable-xfsctl --enable-linux-user --disable-system --disable-blobs --disable-tools --target-list=arm-linux-user --static --disable-pie -make -j $(nproc) -make install -ls -lR ${QEMU_DIR}/install -cd /tmp - -# per https://wiki.ubuntu.com/DebootstrapChroot -if [[ "$VERSION" =~ ^wheezy|jessie$ ]] ; then - sudo apt-get install -qq -y debootstrap - -elif [[ "$VERSION" =~ ^stretch$ ]] ; then - sudo add-apt-repository -r "deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-updates main restricted universe multiverse " - sudo apt-get install -qq -y -t $(lsb_release -cs)-updates debootstrap -elif [[ "$VERSION" =~ ^buster$ ]] ; then - wget http://http.us.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.111_all.deb -O /tmp/debootstrap_1.0.111_all.deb - sudo dpkg --install /tmp/debootstrap_1.0.111_all.deb -fi - -# Create chrooted environment -sudo mkdir ${CHROOT_DIR} -sudo debootstrap --foreign --no-check-gpg --include=fakeroot,build-essential --arch="${CHROOT_ARCH}" "${VERSION}" "${CHROOT_DIR}" "${MIRROR}" -sudo cp ${QEMU_DIR}/install/bin/qemu-arm ${CHROOT_DIR}/usr/bin/qemu-arm-static -${CHROOT_DIR}/usr/bin/qemu-arm-static -version -sudo chroot ${CHROOT_DIR} ./debootstrap/debootstrap --second-stage -sudo sbuild-createchroot --arch="${CHROOT_ARCH}" --foreign --setup-only "${VERSION}" "${CHROOT_DIR}" "${MIRROR}" - -# Create file with environment variables which will be used inside chrooted -# environment -echo "export ARCH=${ARCH}" > envvars.sh -echo "export TRAVIS_BUILD_DIR=${TRAVIS_BUILD_DIR}" >> envvars.sh -chmod a+x envvars.sh - -# Install dependencies inside chroot -sudo chroot ${CHROOT_DIR} dpkg --add-architecture ${CHROOT_ARCH} -sudo chroot ${CHROOT_DIR} dpkg --remove-architecture amd64 -sudo chroot ${CHROOT_DIR} apt-get update -sudo chroot ${CHROOT_DIR} apt-get --allow-unauthenticated install -qq -y locales -sudo chroot ${CHROOT_DIR} locale -sudo chroot ${CHROOT_DIR} bash -c "echo en_US.UTF-8 UTF-8 > /etc/locale.gen" -sudo chroot ${CHROOT_DIR} locale-gen -#sudo chroot ${CHROOT_DIR} bash -c "echo -e 'LANG=\"en_US.UTF-8\"\\nLANGUAGE=\"en_US:en\"\\n' > /etc/default/locale" -sudo chroot ${CHROOT_DIR} apt-get --allow-unauthenticated install -qq -y build-essential git m4 sudo python cmake - -# Create build dir and copy travis build files to our chroot environment -sudo mkdir -p "${CHROOT_DIR}/${TRAVIS_BUILD_DIR}" -sudo rsync -av "${TRAVIS_BUILD_DIR}/" "${CHROOT_DIR}/${TRAVIS_BUILD_DIR}/" - -# Indicate chroot environment has been set up -sudo touch ${CHROOT_DIR}/.chroot_is_done - -# Call standard before_install_linux in chroot environment -sudo chroot ${CHROOT_DIR} bash -c "cd ${TRAVIS_BUILD_DIR} && pwd && ./CI/travis/before_install_linux" - diff --git a/CMakeLists.txt b/CMakeLists.txt index d84f6235e..4b5380f24 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -505,7 +505,7 @@ if(WITH_DOC) ${CMAKE_CURRENT_SOURCE_DIR}/bindings/csharp/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_csharp @ONLY) configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/CI/travis/generateDocumentationAndDeploy.sh.in + ${CMAKE_CURRENT_SOURCE_DIR}/CI/azure/generateDocumentationAndDeploy.sh.in ${CMAKE_CURRENT_BINARY_DIR}/generateDocumentationAndDeploy.sh @ONLY) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/doc DESTINATION ${CMAKE_HTML_DEST_DIR}/${CMAKE_API_DEST_DIR} diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index bd8144253..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,184 +0,0 @@ -version: '{branch}.{build}' -clone_depth: 1 - -skip_commits: - message: /(iiod|IIOD):.*/ - -environment: - # Tell msys2 to add mingw64 to the path - MSYSTEM: MINGW64 - # Tell msys2 to inherit the current directory when starting the shell - CHERE_INVOKING: 1 - -configuration: - - Release - -install: - - echo "Checking out sub-modules..." - - git submodule update --init - - echo "Downloading deps..." - - cd C:\ - - appveyor DownloadFile http://swdownloads.analog.com/cse/build/libiio-win-deps.zip - - 7z x -y "C:\libiio-win-deps.zip" - #Install Inno Setup - - choco install InnoSetup - - set PATH=%PATH%;"C:\Program Files (x86)\Inno Setup 5" - -build_script: - - set OLD_PATH=%PATH% - - set OPT_PATH=C:\msys64\mingw32\bin;C:\msys64\mingw64\bin; - - set PATH=%OPT_PATH%%PATH% - - set GENERATOR=Unix Makefiles - - set MINGW_TOOLCHAIN_VERSION=10.0.0-3 - - set DOXYGEN_VERSION=1.8.18-1 - - set GRAPHVIZ_VERSION=2.40.1-13 - - cd C:\projects\libiio - - set folder-path=C:\projects\libiio\build-mingw-win32\%configuration% - # MinGW 32 bit - - echo "Running cmake for MinGW 32 bit... " - - mkdir C:\projects\libiio\build-mingw-win32 - - cd C:\projects\libiio\build-mingw-win32 - - C:\msys64\usr\bin\bash -lc "pwd" - - mkdir C:\projects\libiio\build-mingw-win32\"%configuration%"& cd C:\projects\libiio\build-mingw-win32\"%configuration%" - - C:\msys64\usr\bin\bash -lc "pwd" - # TODO: Revert this after appveyor supports the latest installer. - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -U http://repo.msys2.org/msys/x86_64/pacman-5.2.2-1-x86_64.pkg.tar.xz" - - C:\msys64\usr\bin\bash -lc "curl -O http://repo.msys2.org/msys/x86_64/msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz" - - C:\msys64\usr\bin\bash -lc "curl -O http://repo.msys2.org/msys/x86_64/msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz.sig" - - C:\msys64\usr\bin\bash -lc "pacman-key --verify msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz{.sig,}" - - C:\msys64\usr\bin\bash -lc "pacman-key --populate" - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -U msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz" - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Syu" - - C:\msys64\usr\bin\bash -lc "pacman -Rs --noconfirm mingw-w64-i686-gcc-ada mingw-w64-i686-gcc-fortran mingw-w64-i686-gcc-libgfortran mingw-w64-i686-gcc-objc" - - C:\msys64\usr\bin\bash -lc "rm /mingw32/etc/gdbinit" - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Sy mingw-w64-i686-gcc mingw-w64-i686-libusb mingw-w64-i686-curl mingw-w64-i686-cmake mingw-w64-i686-libxml2 mingw-w64-i686-pkg-config mingw-w64-i686-libzip" - # Newer llvm breaks doxygen, use old version for now - - C:\msys64\usr\bin\bash -lc "pacman -U --noconfirm http://repo.msys2.org/mingw/i686/mingw-w64-i686-llvm-%MINGW_TOOLCHAIN_VERSION%-any.pkg.tar.zst http://repo.msys2.org/mingw/i686/mingw-w64-i686-clang-%MINGW_TOOLCHAIN_VERSION%-any.pkg.tar.zst" - # set the specific version of doxygen (06-Jun-2018), need to look at this later. - - C:\msys64\usr\bin\bash -lc "pacman -U --noconfirm http://repo.msys2.org/mingw/i686/mingw-w64-i686-doxygen-%DOXYGEN_VERSION%-any.pkg.tar.zst" - - C:\msys64\usr\bin\bash -lc "pacman -U --noconfirm http://repo.msys2.org/mingw/i686/mingw-w64-i686-graphviz-%GRAPHVIZ_VERSION%-any.pkg.tar.zst" - # Download a 32-bit version of windres.exe - - appveyor DownloadFile http://swdownloads.analog.com/cse/build/windres.exe.gz -FileName C:\windres.exe.gz - - C:\msys64\usr\bin\bash -lc "cd /c ; gunzip windres.exe.gz" - - C:\msys64\usr\bin\bash -lc "cmake -G '%GENERATOR%' -DCMAKE_RC_COMPILER=/c/windres.exe -DGIT_EXECUTABLE=C:/Program\ Files/Git/cmd/git.exe -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_INSTALL_PREFIX=/mingw32 -DCMAKE_C_COMPILER:FILEPATH=/mingw32/bin/i686-w64-mingw32-gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=/mingw32/bin/i686-w64-mingw32-g++.exe -DPKG_CONFIG_EXECUTABLE:FILEPATH=/mingw32/bin/pkg-config.exe -DENABLE_IPV6:BOOL=OFF -DLIBSERIALPORT_LIBRARIES=/c/libs/32/libserialport.dll.a -DLIBSERIALPORT_INCLUDE_DIR=/c/include -DLIBLZMA_LIBRARY=c:/msys64/mingw32/lib/liblzma.dll.a /c/projects/libiio && make -j3" - - # MinGW 64 bit - - cd c:\projects\libiio - - echo "Running cmake for MinGW 64 bit... " - - mkdir c:\projects\libiio\build-mingw-win64 - - cd c:\projects\libiio\build-mingw-win64 - - mkdir c:\projects\libiio\build-mingw-win64\"%configuration%"& cd c:\projects\libiio\build-mingw-win64\"%configuration%" - - C:\msys64\usr\bin\bash -lc "pwd" - - C:\msys64\usr\bin\bash -lc "pacman -Rs --noconfirm mingw-w64-x86_64-gcc-ada mingw-w64-x86_64-gcc-fortran mingw-w64-x86_64-gcc-libgfortran mingw-w64-x86_64-gcc-objc" - - C:\msys64\usr\bin\bash -lc "rm /mingw64/etc/gdbinit" - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Sy mingw-w64-x86_64-gcc mingw-w64-x86_64-libusb mingw-w64-x86_64-curl mingw-w64-x86_64-cmake mingw-w64-x86_64-libxml2 mingw-w64-x86_64-pkg-config mingw-w64-x86_64-libzip" - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Sy pacman" - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Su" - # Newer llvm breaks doxygen, use old version for now - - C:\msys64\usr\bin\bash -lc "pacman -U --noconfirm http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-llvm-%MINGW_TOOLCHAIN_VERSION%-any.pkg.tar.zst http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-clang-%MINGW_TOOLCHAIN_VERSION%-any.pkg.tar.zst" - # set the specific version of doxygen, need to look at this later. - - C:\msys64\usr\bin\bash -lc "pacman -U --noconfirm http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-doxygen-%DOXYGEN_VERSION%-any.pkg.tar.zst" - - C:\msys64\usr\bin\bash -lc "pacman -U --noconfirm http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-graphviz-%GRAPHVIZ_VERSION%-any.pkg.tar.zst" - - C:\msys64\usr\bin\bash -lc "cmake -G '%GENERATOR%' -DCMAKE_RC_COMPILER=/c/msys64/mingw64/bin/windres.exe -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_INSTALL_PREFIX=/mingw64 -DCMAKE_C_COMPILER:FILEPATH=/mingw64/bin/x86_64-w64-mingw32-gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=/mingw64/bin/x86_64-w64-mingw32-g++.exe -DPKG_CONFIG_EXECUTABLE:FILEPATH=/mingw64/bin/pkg-config.exe -DENABLE_IPV6:BOOL=OFF -DLIBSERIALPORT_LIBRARIES=/c/libs/64/libserialport.dll.a -DLIBSERIALPORT_INCLUDE_DIR=/c/include /c/projects/libiio && make -j3" - - # Move the tests folder - - cd c:\projects\libiio - - mkdir build-mingw-win32\tests\ build-mingw-win32\tests\"%configuration%"& copy build-mingw-win32\Release\tests\*.exe build-mingw-win32\tests\"%configuration%"\ - - mkdir build-mingw-win64\tests\ build-mingw-win64\tests\"%configuration%"& copy build-mingw-win64\Release\tests\*.exe build-mingw-win64\tests\"%configuration%"\ - - - set PATH=%OLD_PATH% - - set GENERATOR=Visual Studio 12 - - cd c:\projects\libiio - - set folder-path=c:\projects\libiio\build-win32 - - #MSVC 32 bit - - set PATH=C:\\Python37;C:\\Python37\\libs;%PATH% - - echo "Running cmake for Visual Studio 32 bit... " - - mkdir build-win32 - - cd build-win32 - - set MCS_EXECUTABLE_PATH="C:\Windows\Microsoft.NET\Framework\v4.0.30319" - - cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE:STRING="%configuration%" -DENABLE_IPV6:BOOL=OFF -DCMAKE_SYSTEM_PREFIX_PATH="C:" -DCSHARP_BINDINGS:BOOL=ON -DPYTHON_BINDINGS:BOOL=ON -DLIBXML2_LIBRARIES="C:\\libs\\32\\libxml2.lib" -DLIBUSB_LIBRARIES="C:\\libs\\32\\libusb-1.0.lib" -DLIBSERIALPORT_LIBRARIES="C:\\libs\\32\\libserialport.dll.a" .. - - cmake --build . --config %configuration% - - - cd bindings/python - - python.exe setup.py sdist - - ps: Get-ChildItem dist\libiio-*.tar.gz | Rename-Item -NewName "libiio-py37-win32.tar.gz" - - ps: cp dist\*.tar.gz . - - ps: rm dist\*.tar.gz - - set PATH=C:\\Python36;C:\\Python36\\libs;%PATH% - - python.exe setup.py sdist - - ps: Get-ChildItem dist\libiio-*.tar.gz | Rename-Item -NewName "libiio-py36-win32.tar.gz" - - ps: cp dist\*.tar.gz . - - ps: rm dist\*.tar.gz - - #MSVC 64 bit - - set PATH=C:\Python37-x64;C:\\Python37-x64\\libs;%PATH% - - cd c:\projects\libiio - - echo "Running cmake for Visual Studio 64 bit... " - - mkdir build-win64 - - cd build-win64 - - cmake -G "%GENERATOR% Win64" -DCMAKE_BUILD_TYPE:STRING="%configuration%" -DENABLE_IPV6:BOOL=OFF -DCMAKE_SYSTEM_PREFIX_PATH="C:" -DCSHARP_BINDINGS:BOOL=ON -DPYTHON_BINDINGS:BOOL=ON -DLIBXML2_LIBRARIES="C:\\libs\\64\\libxml2.lib" -DLIBUSB_LIBRARIES="C:\\libs\\64\\libusb-1.0.lib" -DLIBSERIALPORT_LIBRARIES="C:\\libs\\64\\libserialport.dll.a" .. - - cmake --build . --config %configuration% - - - cd bindings/python - - python.exe setup.py sdist - - ps: Get-ChildItem dist\libiio-*.tar.gz | Rename-Item -NewName "libiio-py37-amd64.tar.gz" - - ps: cp dist\*.tar.gz . - - ps: rm dist\*.tar.gz - - set PATH=C:\Python36-x64;C:\\Python36-x64\\libs;%PATH% - - python.exe setup.py sdist - - ps: Get-ChildItem dist\libiio-*.tar.gz | Rename-Item -NewName "libiio-py36-amd64.tar.gz" - - ps: cp dist\*.tar.gz . - - ps: rm dist\*.tar.gz - - cd c:\projects\libiio\build-win64 - - #Create the installer - - ISCC %folder-path%\libiio.iss - - appveyor PushArtifact C:\libiio-setup.exe - - # Create ZIP package - # set LIBIIO_VERSION to current project version determined by cmake - - ps: >- - Set-AppveyorBuildVariable -Name LIBIIO_VERSION -Value (get-content .version) - - set ARCHIVE_NAME=libiio-%LIBIIO_VERSION% - - cd c:\projects\libiio - - mkdir c:\%ARCHIVE_NAME% c:\%ARCHIVE_NAME%\include c:\%ARCHIVE_NAME%\MS32 c:\%ARCHIVE_NAME%\MS64 c:\%ARCHIVE_NAME%\MinGW32 c:\%ARCHIVE_NAME%\MinGW64 - - copy iio.h c:\%ARCHIVE_NAME%\include - - copy build-win32\Release\libiio.* c:\%ARCHIVE_NAME%\MS32 - - copy build-win64\Release\libiio.* c:\%ARCHIVE_NAME%\MS64 - - copy build-win32\bindings\csharp\libiio-sharp.dll c:\%ARCHIVE_NAME%\MS32 - - copy build-win64\bindings\csharp\libiio-sharp.dll c:\%ARCHIVE_NAME%\MS64 - - copy build-win32\bindings\python\*.tar.gz c:\%ARCHIVE_NAME%\MS32 - - copy build-win64\bindings\python\*.tar.gz c:\%ARCHIVE_NAME%\MS64 - - copy build-mingw-win32\Release\libiio.* c:\%ARCHIVE_NAME%\MinGW32 - - copy build-mingw-win64\Release\libiio.* c:\%ARCHIVE_NAME%\MinGW64 - - del c:\%ARCHIVE_NAME%\MinGW32\libiio.iss - - del c:\%ARCHIVE_NAME%\MinGW64\libiio.iss - - del c:\%ARCHIVE_NAME%\MinGW32\libiio.pc - - del c:\%ARCHIVE_NAME%\MinGW64\libiio.pc - - - copy build-win32\tests\Release\*.exe c:\%ARCHIVE_NAME%\MS32 - - copy build-win64\tests\Release\*.exe c:\%ARCHIVE_NAME%\MS64 - - copy build-mingw-win32\tests\Release\*.exe c:\%ARCHIVE_NAME%\MinGW32 - - copy build-mingw-win64\tests\Release\*.exe c:\%ARCHIVE_NAME%\MinGW64 - - #Copy dependencies for MSVC - - copy c:\libs\32\libxml2.dll c:\%ARCHIVE_NAME%\MS32 - - copy c:\libs\64\libxml2.dll c:\%ARCHIVE_NAME%\MS64 - - copy c:\libs\32\libusb-1.0.dll c:\%ARCHIVE_NAME%\MS32 - - copy c:\libs\64\libusb-1.0.dll c:\%ARCHIVE_NAME%\MS64 - - copy c:\libs\32\libserialport-0.dll c:\%ARCHIVE_NAME%\MS32 - - copy c:\libs\64\libserialport-0.dll c:\%ARCHIVE_NAME%\MS64 - - #Copy dependencies for MinGW - - C:\msys64\usr\bin\bash -lc "cd c:/msys64/mingw32/bin ; cp -r libwinpthread-*.dll libgcc_*.dll libstdc++-*.dll libiconv-*.dll zlib*.dll libxml2-*.dll liblzma-*.dll libzip*.dll libusb-*.dll /c/%ARCHIVE_NAME%/MinGW32" - - C:\msys64\usr\bin\bash -lc "cd c:/msys64/mingw64/bin ; cp -r libwinpthread-*.dll libgcc_*.dll libstdc++-*.dll libiconv-*.dll zlib*.dll libxml2-*.dll liblzma-*.dll libzip*.dll libusb-*.dll /c/%ARCHIVE_NAME%/MinGW64" - - C:\msys64\usr\bin\bash -lc "cd c:/libs/32 ; cp libserialport-*.dll /c/%ARCHIVE_NAME%/MinGW32" - - C:\msys64\usr\bin\bash -lc "cd c:/libs/64 ; cp libserialport-*.dll /c/%ARCHIVE_NAME%/MinGW64" - - - copy "c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\redist\x86\Microsoft.VC120.CRT\msvcr120.dll" c:\%ARCHIVE_NAME%\MS32 - - copy "c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\redist\x64\Microsoft.VC120.CRT\msvcr120.dll" c:\%ARCHIVE_NAME%\MS64 - - - copy c:\projects\libiio\CI\travis\zip.txt c:\%ARCHIVE_NAME%\README.txt - - 7z a "c:\libiio.zip" c:\%ARCHIVE_NAME% - - appveyor PushArtifact c:\libiio.zip diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5c0676ec8..fe37dff24 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -314,7 +314,7 @@ stages: - task: DownloadPipelineArtifact@2 inputs: path: '$(Agent.BuildDirectory)/s/build/artifacts' - - script: ./CI/travis/prepare_assets.sh check + - script: ./CI/azure/prepare_assets.sh check displayName: 'Check files' - task: CopyFiles@2 inputs: @@ -336,7 +336,7 @@ stages: - task: DownloadPipelineArtifact@2 inputs: path: '$(Build.ArtifactStagingDirectory)' - - bash: ./CI/travis/prepare_assets.sh swdownloads + - bash: ./CI/azure/prepare_assets.sh swdownloads displayName: "Prepare artifacts for SWDownloads" - task: DownloadSecureFile@1 name: key @@ -358,7 +358,7 @@ stages: - task: DownloadPipelineArtifact@2 inputs: path: '$(Build.ArtifactStagingDirectory)' - - bash: ./CI/travis/prepare_assets.sh release + - bash: ./CI/azure/prepare_assets.sh release displayName: 'Prepare assets for release' - task: GithubRelease@0 displayName: 'Attach artifacts to GitHub Release' From d85b1b3f83c21645131d40c4e17ab8f8cad5a343 Mon Sep 17 00:00:00 2001 From: Raluca Chis Date: Tue, 22 Feb 2022 13:29:52 +0200 Subject: [PATCH 30/37] CI: update badges in README.md Signed-off-by: Raluca Chis --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ae3b5b2d8..2f3582307 100644 --- a/README.md +++ b/README.md @@ -25,17 +25,17 @@ As with many open source packages, we use [GitHub](https://github.com/analogdevi | Operating System | GitHub master status | Version | Primary Installer Package | Alternative Package, tarball or zip | |:-----------------------:|:---------------------:|:-------:|:-------------------:|:--------------:| -| Windows | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=WindowsBuilds&configuration=WindowsBuilds%20VS2019_Win64)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Windows-64 Server 2019 | [![Latest Windows installer](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/win_box.png)](https://swdownloads.analog.com/cse/azure_builds/libiio-setup.exe)
[![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=PushArtifacts&jobName=GenerateSetupExe)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | [![Latest Windows zip](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/win_box.png)](https://swdownloads.analog.com/cse/azure_builds/Windows-VS-2019-x64-latest_master_libiio.zip) | -| | | Windows-64 Server 2022 | (libiio-setup.exe works for both Windows Server 2019 and Windows Server 2022) | [![Latest Windows zip](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/win_box.png)](https://swdownloads.analog.com/cse/azure_builds/Windows-VS-2022-x64-latest_master_libiio.zip) | +| Windows | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=WindowsBuilds&configuration=WindowsBuilds%20VS2019)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Windows-64 Server 2019 | [![Latest Windows installer](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/win_box.png)](https://swdownloads.analog.com/cse/azure_builds/libiio-setup.exe)
[![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=ManageArtifacts&jobName=GenerateSetupExe)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | [![Latest Windows zip](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/win_box.png)](https://swdownloads.analog.com/cse/azure_builds/Windows-VS-2019-x64-latest_master_libiio.zip) | +| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=WindowsBuilds&configuration=WindowsBuilds%20VS2022)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Windows-64 Server 2022 | (libiio-setup.exe works for both Windows Server 2019 and Windows Server 2022) | [![Latest Windows zip](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/win_box.png)](https://swdownloads.analog.com/cse/azure_builds/Windows-VS-2022-x64-latest_master_libiio.zip) | | OS X | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=macOSBuilds&configuration=macOSBuilds%20macOS_11)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | macOS Big Sur
(v 11) | [![OS-X package 11](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/osx_box.png)](https://swdownloads.analog.com/cse/azure_builds/macOS-11_latest_master_libiio.pkg) | [![OS-X tarball 11](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/osx_box.png)](https://swdownloads.analog.com/cse/azure_builds/macOS-11_latest_master_libiio.tar.gz) | | | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=macOSBuilds&configuration=macOSBuilds%20macOS_10_15)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | macOS Catalina
(v 10.15) | [![OS-X package 10.15](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/osx_box.png)](https://swdownloads.analog.com/cse/azure_builds/macOS-10.15_latest_master_libiio.pkg) | [![OS-X tarball 10.15](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/osx_box.png)](https://swdownloads.analog.com/cse/azure_builds/macOS-10.15_latest_master_libiio.tar.gz) | -| Linux | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20ubuntu_20_04_x86_64)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Ubuntu Focal Fossa
(v 20.04)1 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-20.04_latest_master_libiio.deb) | | -| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20ubuntu_18_04_x86_64)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Ubuntu Bionic Beaver
(v 18.04)1 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-18.04_latest_master_libiio.deb) | | -| | | Fedora 34 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Fedora-34_latest_master_libiio.deb) | [![RPM File](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/rpm.png)](https://swdownloads.analog.com/cse/azure_builds/Fedora-34_latest_master_libiio.rpm) | -| ARM | | Ubuntu-ppc64le | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-ppc64le_latest_master_libiio.deb) | | -| | | Ubuntu-x390x | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-x390x_latest_master_libiio.deb) | | -| | | Ubuntu-arm64v8 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-arm64v8_latest_master_libiio.deb) | | -| | | Ubuntu-arm32v7 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-arm32v7_latest_master_libiio.deb) | | +| Linux | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20ubuntu_20_04)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Ubuntu Focal Fossa
(v 20.04)1 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-20.04_latest_master_libiio.deb) | | +| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20ubuntu_18_04)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Ubuntu Bionic Beaver
(v 18.04)1 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-18.04_latest_master_libiio.deb) | | +| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20fedora34)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Fedora 34 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Fedora-34_latest_master_libiio.deb) | [![RPM File](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/rpm.png)](https://swdownloads.analog.com/cse/azure_builds/Fedora-34_latest_master_libiio.rpm) | +| ARM | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=ARMBuilds&configuration=ARMBuilds%20ubuntu-ppc64le)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Ubuntu-ppc64le | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-ppc64le_latest_master_libiio.deb) | | +| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=ARMBuilds&configuration=ARMBuilds%20ubuntu-x390x)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Ubuntu-x390x | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-x390x_latest_master_libiio.deb) | | +| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=ARMBuilds&configuration=ARMBuilds%20ubuntu-arm64v8)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Ubuntu-arm64v8 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-arm64v8_latest_master_libiio.deb) | | +| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=ARMBuilds&configuration=ARMBuilds%20ubuntu-arm32v7)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Ubuntu-arm32v7 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-arm32v7_latest_master_libiio.deb) | | If you use it, and like it - please let us know. If you use it, and hate it - please let us know that too. The goal of the project is to try to make Linux IIO devices easier to use on a variety of platforms. If we aren't doing that - we will try to make it better. From 70a5839e5b3edebc91bf0569c872db1120df7db5 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Mon, 21 Feb 2022 15:22:36 -0500 Subject: [PATCH 31/37] README_BUILD.md : update Add the list of missing features/and note about MSVC. Signed-off-by: Robin Getz --- README_BUILD.md | 77 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 17 deletions(-) diff --git a/README_BUILD.md b/README_BUILD.md index d92ccfde2..1c69ace2e 100644 --- a/README_BUILD.md +++ b/README_BUILD.md @@ -11,7 +11,7 @@ Install Prerequisites ```shell analog@precision:~$ sudo apt-get install libxml2-dev bison flex libcdk5-dev cmake ``` -Install Backends +Install libraries for Backends ```shell analog@precision:~$ sudo apt-get install libaio-dev libusb-1.0-0-dev analog@precision:~$ sudo apt-get install libserialport-dev libavahi-client-dev @@ -24,12 +24,7 @@ Install to build python backends ```shell analog@precision:~$ sudo apt-get install python3 python3-pip python3-setuptools ``` -Install to Read local context attributes from `/etc/libiio.ini` -```shell -analog@precision:~$ git clone https://github.com/pcercuei/libini.git -analog@precision:~$ cd libini -analog@precision:~/libini$ mkdir build && cd build && cmake ../ && make && sudo make install -``` + ## Clone ```shell analog@precision:~$ git clone https://github.com/analogdevicesinc/libiio.git @@ -42,26 +37,61 @@ when configuring libiio with cmake, there are a few optional settings that you c Cmake Options | Default | Description | ------------------- | ------- | ---------------------------------------------- | +`BUILD_SHARED_LIBS` | ON | Build shared libraries | +`CMAKE_INSTALL_PREFIX` | `/usr` | default install path | +`ENABLE_PACKAGING` | OFF | Create .deb/.rpm or .tar.gz packages via 'make package' | `CSHARP_BINDINGS` | OFF | Install C# bindings | `PYTHON_BINDINGS` | OFF | Install PYTHON bindings | `WITH_DOC` | OFF | Generate documentation with Doxygen and Sphinx | `WITH_MAN` | OFF | Generate and install man pages | -`WITH_TESTS` | ON | Build the test programs | +`WITH_TESTS` | ON | Build the test programs (iio-utils) | +`INSTALL_UDEV_RULE` | ON | Install a Linux udev rule for detection of USB devices | +`UDEV_RULES_INSTALL_DIR` | /lib/udev/rules.d | default install path for udev rules | +`WITH_EXAMPLES` | OFF | Build the example programs | `WITH_LOCAL_CONFIG` | ON | Read local context attributes from /etc/libiio.ini | `WITH_HWMON` | OFF | Add compatibility with the hwmon subsystem | -`ENABLE_PACKAGING` | OFF | Create .deb/.rpm/.tar.gz via 'make package' | -`INSTALL_UDEV_RULE` | ON | Install a udev rule for detection of USB devices | +`NO_THREADS` | OFF | Disable multi-threading support | +`WITH_GCOV` | OFF | Build with gcov profiling flags | Which backends the library supports is dependent on the build system, but can be overridden. (If cmake finds libusb, it will use it, unless turned off manually) -Cmake Options | Depends on | Description | ----------------------- | ------------- | ------------------------------- | -`WITH_XML_BACKEND` | libxml2 | Enable the XML backend | -`WITH_USB_BACKEND` | libusb | Enable the libusb backend | -`WITH_SERIAL_BACKEND` | libserialport | Enable the Serial backend | -`WITH_NETWORK_BACKEND` | | Supports TCP/IP | -`WITH_LOCAL_BACKEND` | Linux | Enables local support with iiod | +Cmake Options | Default | Depends on | Description | +---------------------- | ------- | ------------- | ------------------------------- | +`WITH_XML_BACKEND` | ON | libxml2 | Enable the XML backend, required when using network, serial, or USB backend | +`WITH_USB_BACKEND` | ON | libusb | Enable the libusb backend | +`WITH_SERIAL_BACKEND` | OFF | libserialport | Enable the Serial backend | +`WITH_NETWORK_BACKEND` | ON | | Supports TCP/IP | +`HAVE_DNS_SD` | ON | Networking | Enable DNS-SD (ZeroConf) support | +`ENABLE_IPV6` | ON | Networking | Define if you want to enable IPv6 support | +`WITH_LOCAL_BACKEND` | ON | Linux | Enables local support with iiod | +`WITH_LOCAL_CONFIG` | ON | Local backend | Read local context attributes from /etc/libiio.ini | + + +There are a few options, which are experimental, which should be left to their default settings: + +Cmake Options | Default | Description | +------------------- | ------- | ---------------------------------------------- | +`WITH_LOCAL_MMAP_API` | ON | Use the mmap API provided in Analog Devices' kernel (not upstream) | +`WITH_NETWORK_GET_BUFFER` | OFF | Enable experimental zero-copy transfers | +`WITH_ZSTD` | OFF | Support for ZSTD compressed metadata | + + +Options which effect iiod only. These are only avalible on Linux. + +Cmake Options | Default | Description | +------------------- | ------- | ---------------------------------------------- | +`WITH_IIOD` | ON | Build the IIO Daemon | +`WITH_IIOD_SERIAL` | ON | Add serial (UART) support | +`WITH_IIOD_USBD` | ON | Add support for USB through FunctionFS within IIOD | +`WITH_AIO` | ON | Build IIOD with async. I/O support | +`WITH_SYSTEMD` | OFF | Enable installation of systemd service file for iiod | +`SYSTEMD_UNIT_INSTALL_DIR` | /lib/systemd/system | default install path for systemd unit files | +`WITH_SYSVINIT` | OFF | Enable installation of SysVinit script for iiod | +`SYSVINIT_INSTALL_DIR` | /etc/init.d | default install path for SysVinit scripts | +`WITH_UPSTART` | OFF | Enable installation of upstart config file for iiod | +`UPSTART_CONF_INSTALL_DIR`: | /etc/init | default install path for upstart conf files | + ```shell @@ -80,3 +110,16 @@ Note: Some things (specifically building doc) need to find libiio or the bindin That means that you configure (with -DWITH_DOC=OFF), build, install, configure (with -DWITH_DOC=ON), build again to get the doc. If you have issues, please ask. + +## Notes + +Special Note on Microsoft Visual Compiler (MSVC): + +MSVC in debug mode is just very stupid. If it sees this code: +```c +if (0) + call_function(); +``` +It will try to link against the `call_function` symbol even though it's clearly dead code. + +For this reason, when building with MSVC, please build in `RelWithDebInfo` mode. If you try to build in `Debug` mode, it will error. From cfb7286421ccdb9839f41121a5027c162227e10c Mon Sep 17 00:00:00 2001 From: Raluca Chis Date: Wed, 23 Feb 2022 09:16:09 +0200 Subject: [PATCH 32/37] CI: fix Fedora build Signed-off-by: Raluca Chis --- azure-pipelines.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fe37dff24..343a8f5c7 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -53,17 +53,17 @@ stages: make make package displayName: 'Build' - - script: | - cd $(Agent.BuildDirectory)/s/build/ - sh generateDocumentationAndDeploy.sh - displayName: 'Documentation' - condition: eq(variables['artifactName'], 'Linux-Fedora-34') - task: CopyFiles@2 condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) inputs: sourceFolder: '$(Agent.BuildDirectory)/s/build/' contents: '$(Agent.BuildDirectory)/s/build/?(*.deb|*.gz|*.rpm)' targetFolder: '$(Build.ArtifactStagingDirectory)' + - script: | + cd $(Agent.BuildDirectory)/s/build/ + sh generateDocumentationAndDeploy.sh + displayName: 'Documentation' + condition: eq(variables['artifactName'], 'Linux-Fedora-34') - task: PublishPipelineArtifact@1 condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) inputs: From 8687f240f3cd9d49ab30b3de3eee9ba1027f1b5c Mon Sep 17 00:00:00 2001 From: Raluca Chis Date: Wed, 23 Feb 2022 09:41:40 +0200 Subject: [PATCH 33/37] CI: temporary add files to fix linux repo builds Signed-off-by: Raluca Chis --- CI/travis/inside_docker.sh | 30 ++ CI/travis/lib.sh | 562 +++++++++++++++++++++++++++++++++++++ 2 files changed, 592 insertions(+) create mode 100644 CI/travis/inside_docker.sh create mode 100644 CI/travis/lib.sh diff --git a/CI/travis/inside_docker.sh b/CI/travis/inside_docker.sh new file mode 100644 index 000000000..afa013fba --- /dev/null +++ b/CI/travis/inside_docker.sh @@ -0,0 +1,30 @@ +#!/bin/sh -e + +export INSIDE_DOCKER="1" + +INSIDE_DOCKER_BUILD_DIR=/docker_build_dir + +export TRAVIS_BUILD_DIR="$INSIDE_DOCKER_BUILD_DIR" + +cd "$INSIDE_DOCKER_BUILD_DIR" + +if [ -d "/$INSIDE_DOCKER_BUILD_DIR/CI" ] ; then + CI="/$INSIDE_DOCKER_BUILD_DIR/CI" +elif [ -d "/$INSIDE_DOCKER_BUILD_DIR/ci" ] ; then + CI="/$INSIDE_DOCKER_BUILD_DIR/ci" +else + echo "No CI/ci directory present" + exit 1 +fi + +if [ -f "$INSIDE_DOCKER_BUILD_DIR/inside-travis-ci-docker-env" ] ; then + . "$INSIDE_DOCKER_BUILD_DIR/inside-travis-ci-docker-env" +fi + +"$CI/travis/before_install_linux" + +"$CI/travis/make_linux" + +# need to find this out inside the container +. "$CI/travis/lib.sh" +echo "$(get_ldist)" > "${INSIDE_DOCKER_BUILD_DIR}/build/.LDIST" diff --git a/CI/travis/lib.sh b/CI/travis/lib.sh new file mode 100644 index 000000000..b605f6512 --- /dev/null +++ b/CI/travis/lib.sh @@ -0,0 +1,562 @@ +#!/bin/sh -e + +if [ "$TRIGGER_NEXT_BUILD" = "true" ] && [ "$TRIGGERING_NEXT_BUILD" != "true" ] ; then + exit 0 +fi + +export TRAVIS_API_URL="https://api.travis-ci.com" +LOCAL_BUILD_DIR=${LOCAL_BUILD_DIR:-build} + +HOMEBREW_NO_INSTALL_CLEANUP=1 +export HOMEBREW_NO_INSTALL_CLEANUP + +PYTHON=python3 +export PYTHON + +# This needs to be duplicated inside 'inside_docker.sh' +# It's the common convention between host & container +INSIDE_DOCKER_BUILD_DIR=/docker_build_dir + +# Add here all the common env-vars that should be propagated +# to the docker image, simply by referencing the env-var name. +# The values will be evaluated. +# +# Make sure to not pass certain stuff that are specific to the host +# and not specific to inside-the-docker (like TRAVIS_BUILD_DIR) +# +# If these nothing should be passed, then clear or +#'unset INSIDE_DOCKER_TRAVIS_CI_ENV' after this script is included +INSIDE_DOCKER_TRAVIS_CI_ENV="TRAVIS TRAVIS_COMMIT TRAVIS_PULL_REQUEST OS_TYPE OS_VERSION ARTIFACTNAME" + +COMMON_SCRIPTS="inside_docker.sh" + +echo_red() { printf "\033[1;31m$*\033[m\n"; } +echo_green() { printf "\033[1;32m$*\033[m\n"; } +echo_blue() { printf "\033[1;34m$*\033[m\n"; } + +backtrace() { + # shell backtraces only work on bash + if [ ! -z "${BASH}" ] ; then + local i= + i=${#FUNCNAME[@]} + ((--i)) + + while (( i >= 0 )) + do + echo "${BASH_SOURCE[$i]}:${BASH_LINENO[$i]}.${FUNCNAME[$i]}()" + i=$((i - 1)) + done + fi +} + +get_script_path() { + local script="$1" + + [ -n "$script" ] || return 1 + + if [ -f "CI/travis/$script" ] ; then + echo "CI/travis/$script" + elif [ -f "ci/travis/$script" ] ; then + echo "ci/travis/$script" + elif [ -f "${LOCAL_BUILD_DIR}/$script" ] ; then + echo "${LOCAL_BUILD_DIR}/$script" + else + return 1 + fi +} + +pipeline_branch() { + local branch=$1 + + [ -n "$branch" ] || return 1 + + # master is a always a pipeline branch + [ "$branch" = "master" ] && return 0 + + set +x + # Check if branch name is 20XX_RY where: + # XX - 14 to 99 /* wooh, that's a lot of years */ + # Y - 1 to 9 /* wooh, that's a lot of releases per year */ + for year in $(seq 2014 2099) ; do + for rel_num in $(seq 1 9) ; do + [ "$branch" = "${year}_R${rel_num}" ] && \ + return 0 + done + done + + return 1 +} + +should_trigger_next_builds() { + local branch="$1" + + [ -z "${COVERITY_SCAN_PROJECT_NAME}" ] || return 1 + + # These Travis-CI vars have to be non-empty + [ -n "$TRAVIS_PULL_REQUEST" ] || return 1 + [ -n "$branch" ] || return 1 + set +x + [ -n "$TRAVIS_API_TOKEN" ] || return 1 + + # Has to be a non-pull-request + [ "$TRAVIS_PULL_REQUEST" = "false" ] || return 1 + + pipeline_branch "$branch" || return 1 +} + +trigger_build() { + local repo_slug="$1" + local branch="$2" + + [ -n "$repo_slug" ] || return 1 + [ -n "$branch" ] || return 1 + + local body="{ + \"request\": { + \"branch\":\"$branch\" + } + }" + + # Turn off tracing here (shortly) + set +x + curl -s -X POST \ + -H "Content-Type: application/json" \ + -H "Accept: application/json" \ + -H "Travis-API-Version: 3" \ + -H "Authorization: token $TRAVIS_API_TOKEN" \ + -d "$body" \ + "${TRAVIS_API_URL}/repo/$repo_slug/requests" +} + +trigger_adi_build() { + local adi_repo="$1" + local branch="$2" + + [ -n "$adi_repo" ] || return 1 + trigger_build "analogdevicesinc%2F$adi_repo" "$branch" +} + +command_exists() { + local cmd=$1 + [ -n "$cmd" ] || return 1 + type "$cmd" >/dev/null 2>&1 +} + +get_ldist() { + case "$(uname)" in + Linux*) + if [ ! -f /etc/os-release ] ; then + if [ -f /etc/centos-release ] ; then + echo "centos-$(sed -e 's/CentOS release //' -e 's/(.*)$//' \ + -e 's/ //g' /etc/centos-release)-$(uname -m)" + return 0 + fi + ls /etc/*elease + [ -z "${OSTYPE}" ] || { + echo "${OSTYPE}-unknown" + return 0 + } + echo "linux-unknown" + return 0 + fi + . /etc/os-release + if ! command_exists dpkg ; then + echo $ID-$VERSION_ID-$(uname -m) + else + echo $ID-$VERSION_ID-$(dpkg --print-architecture) + fi + ;; + Darwin*) + echo "darwin-$(sw_vers -productVersion)" + ;; + *) + echo "$(uname)-unknown" + ;; + esac + return 0 +} + +__brew_install_or_upgrade() { + brew install "$1" || \ + brew upgrade "$1" || \ + brew ls --versions "$1" +} + +brew_install_or_upgrade() { + while [ -n "$1" ] ; do + __brew_install_or_upgrade "$1" || return 1 + shift + done +} + +__brew_install_if_not_exists() { + brew ls --versions "$1" || \ + brew install "$1" +} + +brew_install_if_not_exists() { + while [ -n "$1" ] ; do + __brew_install_if_not_exists "$1" || return 1 + shift + done +} + +sftp_cmd_pipe() { + sftp -o "StrictHostKeyChecking no" "${EXTRA_SSH}" "${SSHUSER}@${SSHHOST}" +} + +sftp_run_cmds() { + local x=5 + while [ "${x}" -gt "0" ] ; do + sftp -o "StrictHostKeyChecking no" "${EXTRA_SSH}" "${SSHUSER}@${SSHHOST}" 0< "$1" && break; + echo_red "failed to ssh, trying again" + x=$((x - 1)) + sleep 10 + done + if [ "${x}" -eq "0" ] ; then + echo_red "failed to upload files" + return 1; + fi + return 0 +} + +sftp_rm_artifact() { + local artifact="$1" + sftp_cmd_pipe <<-EOF + cd ${DEPLOY_TO} + rm ${artifact} + bye + EOF +} + +sftp_upload() { + local FROM="$1" + local TO="$2" + local LATE="$3" + + if [ -n "${LATE}" ] ; then + sftp_cmd_pipe <<-EOF + cd ${DEPLOY_TO} + put ${FROM} ${TO} + ls -l ${TO} + symlink ${TO} ${LATE} + ls -l ${LATE} + bye + EOF + else + sftp_cmd_pipe <<-EOF + cd ${DEPLOY_TO} + put ${FROM} ${TO} + ls -l ${TO} + bye + EOF + fi +} + +upload_file_to_swdownloads() { + + if [ "$#" -ne 4 ] ; then + echo "skipping deployment of something" + echo "send called with $@" + return 0 + fi + + local LIBNAME=$1 + local FROM=$2 + local FNAME=$3 + local EXT=$4 + + if [ -z "$FROM" ] ; then + echo no file to send + return 1 + fi + + if [ ! -r "$FROM" ] ; then + echo "file $FROM is not readable" + return 1 + fi + + if [ -n "$TRAVIS_PULL_REQUEST_BRANCH" ] ; then + local branch="$TRAVIS_PULL_REQUEST_BRANCH" + else + local branch="$TRAVIS_BRANCH" + fi + + local TO=${branch}_${FNAME} + local LATE=${branch}_latest_${LIBNAME}${LDIST}${EXT} + local GLOB=${DEPLOY_TO}/${branch}_${LIBNAME}-* + + echo attempting to deploy "$FROM" to "$TO" + echo and "${branch}_${LIBNAME}${LDIST}${EXT}" + ssh -V + + local tmpfl=$(mktemp) + echo "cd ${DEPLOY_TO}" > "${tmpfl}" + echo "rm ${TO}" >> "${tmpfl}" + echo "rm ${LATE}" >> "${tmpfl}" + echo "put ${FROM} ${TO}" >> "${tmpfl}" + echo "symlink ${TO} ${LATE}" >> "${tmpfl}" + echo "ls -l ${TO}" >> "${tmpfl}" + echo "ls -l ${LATE}" >> "${tmpfl}" + echo "bye" >> "${tmpfl}" + + sftp_run_cmds "${tmpfl}" + rm "${tmpfl}" + + return 0 +} + +remove_old_pkgs() { + # limit things to a few files, so things don't grow forever + # we only do this on one build so simultaneous builds don't clobber each other + if [ -z "${GH_DOC_TOKEN}" ] ; then + return 0 + fi + + if [ -z "${TRAVIS_BUILD_DIR}" ] ; then + echo "TRAVIS_BUILD_DIR not set" + return 0 + fi + + if [ ! -d "${TRAVIS_BUILD_DIR}/.git" ] ; then + echo "No ${TRAVIS_BUILD_DIR}/.git to operate git on" + return 0 + fi + + local LIBNAME=$1 + local old= + + echo "Remove old packages from ${LIBNAME}" + + if [ -n "$TRAVIS_PULL_REQUEST_BRANCH" ] ; then + local branch="$TRAVIS_PULL_REQUEST_BRANCH" + else + local branch="$TRAVIS_BRANCH" + fi + + local GLOB=${DEPLOY_TO}/${branch}_${LIBNAME}-* + + # putting everything into a file, and connecting once decreases the chances + # for ssh issues, connections happen once, not every single file + local tmpfl=$(mktemp) + echo "cd ${DEPLOY_TO}" > "${tmpfl}" + for files in $(ssh -o "StrictHostKeyChecking no" "${EXTRA_SSH}" "${SSHUSER}@${SSHHOST}" \ + "ls -lt ${GLOB}" | tail -n +100 | awk '{print $NF}') + do + echo "rm ${files}" >> "${tmpfl}" + done + echo "bye" >> "${tmpfl}" + # if it is only cd & bye, skip it + if [ "$(wc -l "${tmpfl}" | awk '{print $1}')" -gt "2" ] ; then + sftp_run_cmds "${tmpfl}" + fi + rm "${tmpfl}" + # provide an index so people can find files. + ssh -o "StrictHostKeyChecking no" "${EXTRA_SSH}" "${SSHUSER}@${SSHHOST}" \ + "ls -lt ${DEPLOY_TO}" | grep "${LIBNAME}" > "${LIBNAME}_index.html" + echo "ls captured" + + echo "cd ${DEPLOY_TO}" > "${tmpfl}" + # prune old / removed branches, leave things are are tags/branches + for old in $(sed 's/-> .*$//' libiio_index.html | \ + awk '{print $NF}' | grep -v master | sort | \ + sed "s/_libiio-0.[0-9][0-9].g[a-z0-9]*-/ %% /" | \ + grep "%%" | awk '{print $1}' | sort -u) + do + if [ "$(git --git-dir "${TRAVIS_BUILD_DIR}/.git" ls-remote --heads origin "${old}" | wc -l)" -ne "0" ] ; then + echo "${old} is a branch" + else + if [ "$(git --git-dir "${TRAVIS_BUILD_DIR}/.git" ls-remote --tags origin "${old}" | wc -l)" -ne "0" ] ; then + echo "${old} is a tag" + else + echo "${old} can be removed" + echo "rm ${old}_${LIBNAME}-*" >> "${tmpfl}" + echo "rm ${old}_latest_${LIBNAME}-*" >> "${tmpfl}" + echo "rm ${old}_lastest_${LIBNAME}-*" >> "${tmpfl}" + fi + fi + done + # cap things at 15, so we don't exceed the time + sed -i 16q "${tmpfl}" + echo "bye" >> "${tmpfl}" + # if it is only cd & bye, skip it + if [ "$(wc -l "${tmpfl}" | awk '{print $1}')" -gt "2" ] ; then + sftp_run_cmds "${tmpfl}" + fi + rm "${tmpfl}" + + #Now that we removed things, do it again + rm "${LIBNAME}_index.html" + ssh -o "StrictHostKeyChecking no" "${EXTRA_SSH}" "${SSHUSER}@${SSHHOST}" \ + "ls -lt ${DEPLOY_TO}" | grep "${LIBNAME}" > "${LIBNAME}_index.html" + sftp_upload "${LIBNAME}_index.html" "${LIBNAME}_index.html" + + return 0 +} + +prepare_docker_image() { + local DOCKER_IMAGE="${OS_TYPE}:${OS_VERSION}" + # If arch is specified, setup multiarch support + if [ -n "$OS_ARCH" ] ; then + sudo apt-get -qq update + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y qemu \ + qemu binfmt-support qemu-user-static + sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + DOCKER_IMAGE="${OS_ARCH}/${DOCKER_IMAGE}" + fi + echo 'DOCKER_OPTS="-H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock -s devicemapper"' | sudo tee /etc/default/docker > /dev/null + sudo service docker restart + sudo docker pull "$DOCKER_IMAGE" +} + +__save_env_for_docker() { + local env_file="$1/inside-travis-ci-docker-env" + for env in $INSIDE_DOCKER_TRAVIS_CI_ENV ; do + val="$(eval echo "\$${env}")" + if [ -n "$val" ] ; then + echo "export ${env}=\"${val}\"" >> "${env_file}" + fi + done +} + +run_docker_script() { + local DOCKER_SCRIPT="$(get_script_path "$1")" + local MOUNTPOINT="${INSIDE_DOCKER_BUILD_DIR}" + local DOCKER_IMAGE="${OS_TYPE}:${OS_VERSION}" + + if [ -n "$OS_ARCH" ] ; then + DOCKER_IMAGE="${OS_ARCH}/${DOCKER_IMAGE}" + fi + + __save_env_for_docker "$(pwd)" + + sudo docker run --rm=true \ + -v "$(pwd):/${MOUNTPOINT}:rw" \ + "$DOCKER_IMAGE" \ + /bin/bash -e "/${MOUNTPOINT}/${DOCKER_SCRIPT}" "${MOUNTPOINT}" "${OS_TYPE}" +} + +ensure_command_exists() { + local cmd="$1" + local package="$2" + local yes_confirm + [ -n "$cmd" ] || return 1 + [ -n "$package" ] || package="$cmd" + ! command_exists "$cmd" || return 0 + # go through known package managers + for pacman in apt-get brew yum ; do + command_exists $pacman || continue + if [ "$pacman" = "brew" ] ; then + yes_confirm= + else + yes_confirm="-y" + fi + "$pacman" install $yes_confirm "$package" || { + # Try an update if install doesn't work the first time + "$pacman" $yes_confirm update && \ + "$pacman" install $yes_confirm "$package" + } + return $? + done + return 1 +} + +version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"; } +version_le() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" = "$1"; } +version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" != "$1"; } +version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" = "$1"; } + +get_codename() { + local VERSION_CODENAME + eval $(grep -w VERSION_CODENAME /etc/os-release) + echo "$VERSION_CODENAME" +} + +get_dist_id() { + local ID + eval $(grep -w ID /etc/os-release) + echo "$ID" +} + +get_version() { + local VERSION_ID + eval $(grep -w VERSION_ID /etc/os-release) + echo "$VERSION_ID" +} + +is_ubuntu_at_least_ver() { + [ "$(get_dist_id)" = "ubuntu" ] || return 1 + version_ge "$(get_version)" "$1" +} + +is_centos_at_least_ver() { + [ "$(get_dist_id)" = "centos" ] || return 1 + version_ge "$(get_version)" "$1" +} + +is_python_at_least_ver() { + local out python_exec + + python_exec="$1" + command_exists "$python_exec" || return 1 + out=$($python_exec --version) + version_ge "${out#* }" "$2" +} + +is_arm() { + [ "$(dpkg --print-architecture)" = "armhf" ] || return 1 +} + +is_arm64() { + [ "$(dpkg --print-architecture)" = "arm64" ] || return 1 +} + +print_github_api_rate_limits() { + # See https://developer.github.com/v3/rate_limit/ + # Note: Accessing this endpoint does not count against your REST API rate limit. + echo_green '-----------------------------------------' + echo_green 'Github API Rate limits' + echo_green '-----------------------------------------' + wget -q -O- https://api.github.com/rate_limit + echo_green '-----------------------------------------' +} + +setup_build_type_env_vars() { + OS_TYPE=${OS_TYPE:-default} + + # For a 'arm32_v7/debian_docker' string, OS TYPE becomes 'debian' + # This also works for just 'debian_docker' + # And we're extracting OS_ARCH if present + if [ "${OS_TYPE#*_}" = "docker" ] ; then + BUILD_TYPE=generic_docker + OS_TYPE=${OS_TYPE%_*} + OS_ARCH=${OS_TYPE%/*} + OS_TYPE=${OS_TYPE#*/} + if [ "$OS_ARCH" = "$OS_TYPE" ] ; then + OS_ARCH= + fi + else + BUILD_TYPE="$OS_TYPE" + fi + + export OS_TYPE + export OS_ARCH + export BUILD_TYPE +} + +ensure_command_exists sudo +ensure_command_exists wget + +# Other scripts will download lib.sh [this script] and lib.sh will +# in turn download the other scripts it needs. +# This gives way more flexibility when changing things, as they propagate +for script in $COMMON_SCRIPTS ; do + [ ! -f "CI/travis/$script" ] || continue + [ ! -f "ci/travis/$script" ] || continue + [ ! -f "${LOCAL_BUILD_DIR}/$script" ] || continue + mkdir -p "${LOCAL_BUILD_DIR}" + wget https://raw.githubusercontent.com/analogdevicesinc/libiio/master/CI/travis/$script \ + -O "$LOCAL_BUILD_DIR/$script" +done + +print_github_api_rate_limits From 9d80346ae95fe9410defe4e58b356fa969faf291 Mon Sep 17 00:00:00 2001 From: Raluca Chis Date: Wed, 23 Feb 2022 15:39:05 +0200 Subject: [PATCH 34/37] CI: fix the path in a comment Signed-off-by: Raluca Chis --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 343a8f5c7..e13fe2b21 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,5 +1,5 @@ # If you make changes to builds or artifacts, please check and update the following files if needed: -# README.md, CI/travis/prepare_assets.sh, artifact_manifest.txt.cmakein, CI/publish_deps.ps1 +# README.md, CI/azure/prepare_assets.sh, artifact_manifest.txt.cmakein, CI/publish_deps.ps1 trigger: branches: From e5f8ece279f831b4894967c262a99360a0b7faec Mon Sep 17 00:00:00 2001 From: Raluca Chis Date: Wed, 23 Feb 2022 15:45:42 +0200 Subject: [PATCH 35/37] CI: run setup.py on python bindings Signed-off-by: Raluca Chis --- CI/build_win.ps1 | 6 +++--- azure-pipelines.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CI/build_win.ps1 b/CI/build_win.ps1 index ddf2b9b39..d301b7a68 100644 --- a/CI/build_win.ps1 +++ b/CI/build_win.ps1 @@ -14,8 +14,8 @@ cmake -G "$COMPILER" -DCMAKE_SYSTEM_PREFIX_PATH="C:" -DENABLE_IPV6=OFF -DWITH_US cmake --build . --config Release cp .\libiio.iss $env:BUILD_ARTIFACTSTAGINGDIRECTORY -cd ../bindings/python -python.exe setup.py.cmakein sdist +cd bindings/python +python.exe setup.py sdist Get-ChildItem dist\pylibiio-*.tar.gz | Rename-Item -NewName "libiio-py39-amd64.tar.gz" mv .\dist\*.gz . -rm .\dist\*.gz \ No newline at end of file +rm .\dist\*.gz diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e13fe2b21..07bd878a3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -136,7 +136,7 @@ stages: - task: CopyFiles@2 displayName: 'Copy .tar.gz files' inputs: - sourceFolder: '$(Agent.BuildDirectory)/s/bindings/python' + sourceFolder: '$(Agent.BuildDirectory)/s/build-x64/bindings/python' contents: '*.gz' targetFolder: '$(Build.ArtifactStagingDirectory)' - task: CopyFiles@2 From c17813bb50c99a1d4679d2585b99f0aacd1fa7c3 Mon Sep 17 00:00:00 2001 From: Raluca Chis Date: Thu, 24 Feb 2022 09:09:54 +0200 Subject: [PATCH 36/37] CI: add checks to make sure the windows build completed properly Signed-off-by: Raluca Chis --- CI/build_win.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CI/build_win.ps1 b/CI/build_win.ps1 index d301b7a68..97f7d1e1e 100644 --- a/CI/build_win.ps1 +++ b/CI/build_win.ps1 @@ -12,6 +12,9 @@ cd build-x64 cmake -G "$COMPILER" -DCMAKE_SYSTEM_PREFIX_PATH="C:" -DENABLE_IPV6=OFF -DWITH_USB_BACKEND=ON -DWITH_SERIAL_BACKEND=ON -DPYTHON_BINDINGS=ON -DCSHARP_BINDINGS:BOOL=ON -DLIBXML2_LIBRARIES="C:\\libs\\64\\libxml2.lib" -DLIBUSB_LIBRARIES="C:\\libs\\64\\libusb-1.0.lib" -DLIBSERIALPORT_LIBRARIES="C:\\libs\\64\\libserialport.dll.a" -DLIBUSB_INCLUDE_DIR="C:\\include\\libusb-1.0" -DLIBXML2_INCLUDE_DIR="C:\\include\\libxml2" .. cmake --build . --config Release +if ( $LASTEXITCODE -ne 0 ) { + throw "[*] cmake build failure" + } cp .\libiio.iss $env:BUILD_ARTIFACTSTAGINGDIRECTORY cd bindings/python From 9e1efe0063313134218603da2df6044cf34f5e96 Mon Sep 17 00:00:00 2001 From: Raluca Chis Date: Thu, 24 Feb 2022 09:31:18 +0200 Subject: [PATCH 37/37] CI: update bindings/python/README.md Signed-off-by: Raluca Chis --- bindings/python/README.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/bindings/python/README.md b/bindings/python/README.md index 66db5fc4e..0a7b84828 100644 --- a/bindings/python/README.md +++ b/bindings/python/README.md @@ -4,13 +4,18 @@ This package contains the python bindings for libiio, a library for interfacing libiio is used to interface to the Linux Industrial Input/Output (IIO) Subsystem. The Linux IIO subsystem is intended to provide support for devices that in some sense are analog to digital or digital to analog converters (ADCs, DACs). This includes, but is not limited to ADCs, Accelerometers, Gyros, IMUs, Capacitance to Digital Converters (CDCs), Pressure Sensors, Color, Light and Proximity Sensors, Temperature Sensors, Magnetometers, DACs, DDS (Direct Digital Synthesis), PLLs (Phase Locked Loops), Variable/Programmable Gain Amplifiers (VGA, PGA), and RF transceivers. You can use libiio natively on an embedded Linux target (local mode), or use libiio to communicate remotely to that same target from a host Linux, Windows or MAC over USB or Ethernet or Serial. -[![Build Status](https://travis-ci.com/analogdevicesinc/libiio.svg?branch=master)](https://travis-ci.com/analogdevicesinc/libiio) -[![PyPI version](https://badge.fury.io/py/pylibiio.svg)](https://badge.fury.io/py/pylibiio) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/4bd027bfc5774029a30a9e1cedf5a434)](https://www.codacy.com/app/rgetz/libiio?utm_source=github.com&utm_medium=referral&utm_content=analogdevicesinc/libiio&utm_campaign=Badge_Grade) -![open bugs](https://img.shields.io/github/issues/analogdevicesinc/libiio.svg) - -[[Docs](https://analogdevicesinc.github.io/libiio/v0.19/python/index.html)] -[[Support](http://ez.analog.com)] -[[Wiki](https://wiki.analog.com/resources/tools-software/linux-software/libiio)] +Library License : [![Library License](https://img.shields.io/badge/license-LGPL2+-blue.svg)](https://github.com/analogdevicesinc/libiio/blob/master/COPYING.txt) +Tests/Examples License : [![Application License](https://img.shields.io/badge/license-GPL2+-blue.svg)](https://github.com/analogdevicesinc/libiio/blob/master/COPYING_GPL.txt) +Latest Release : [![GitHub release](https://img.shields.io/github/release/analogdevicesinc/libiio.svg)](https://github.com/analogdevicesinc/libiio/releases/latest) +Downloads : [![Github All Releases](https://img.shields.io/github/downloads/analogdevicesinc/libiio/total.svg)](https://github.com/analogdevicesinc/libiio/releases/latest) + +Scans : [![Coverity Scan Build Status](https://img.shields.io/coverity/scan/4796.svg)](https://scan.coverity.com/projects/analogdevicesinc-libiio) +Release docs: [![Documentation](https://codedocs.xyz/analogdevicesinc/libiio.svg)](http://analogdevicesinc.github.io/libiio/) +Issues : [![open bugs](https://img.shields.io/github/issues/analogdevicesinc/libiio.svg)](https://github.com/analogdevicesinc/libiio/issues) +[![closed bugs](https://img.shields.io/github/issues-closed/analogdevicesinc/libiio.svg)](https://github.com/analogdevicesinc/libiio/issues?q=is%3Aissue+is%3Aclosed) + +Support:
+If you have a question about libiio and an Analog Devices IIO kernel driver please ask on : [![EngineerZone](https://img.shields.io/badge/chat-on%20EngineerZone-blue.svg)](https://ez.analog.com/linux-device-drivers/linux-software-drivers). If you have a question about a non-ADI devices, please ask it on [github](https://github.com/analogdevicesinc/libiio/issues). ## Requirements To use these bindings naturally you need the core library they depend upon, libiio. This is not packaged with the pypi release but there are a number of options: