From 7c6abf861e10fff07311f64375b2f6c0d595d593 Mon Sep 17 00:00:00 2001 From: Alistair Delva Date: Thu, 24 Oct 2019 16:44:50 -0700 Subject: Add target build for libkmod This library will be used by igt-gpu-tools on the target. Build it as a static library so it can be linked directly into the igt-gpu-tools binaries. This will not be shipped with the platform; the igt-gpu-tools binaries will be part of VTS. Bug: 110963635 Change-Id: Ibaeb8749c05f9a81185cbc732f5fb14e85967fd8 --- Android.bp | 56 +++++++++++++++++++++++++++++++++++++------------------ port-gnu/config.h | 11 ++++++++++- 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/Android.bp b/Android.bp index 9ef1efb..2ebdd16 100644 --- a/Android.bp +++ b/Android.bp @@ -1,4 +1,32 @@ -cc_binary_host { +cc_defaults { + name: "libkmod_cflags_common", + local_include_dirs: ["port-gnu"], + cflags: [ + "-include config.h", + "-ffunction-sections", + "-fdata-sections", + "-Wall", + "-Werror", + "-Wno-format", + "-Wno-unused-parameter", + "-Wno-unused-variable", + "-Dsecure_getenv=getenv", + "-DHAVE_CONFIG_H", + "-DANOTHER_BRICK_IN_THE", + "-DSYSCONFDIR=\"/tmp\"", + ], + target: { + linux_glibc: { + cflags: ["-DHAVE_DECL_STRNDUPA"] + } + } +} + +cc_library_static { + defaults: ["libkmod_cflags_common"], + export_include_dirs: ["libkmod"], + host_supported: true, + name: "libkmod", srcs: [ "libkmod/libkmod.c", "libkmod/libkmod-file.c", @@ -13,6 +41,14 @@ cc_binary_host { "shared/util.c", "shared/hash.c", "shared/strbuf.c", + ], + visibility: ["//external/igt-gpu-tools"], +} + +cc_binary_host { + defaults: ["libkmod_cflags_common"], + name: "depmod", + srcs: [ "tools/port.c", "tools/depmod.c", "tools/kmod.c", @@ -26,21 +62,5 @@ cc_binary_host { "tools/lsmod.c", "tools/remove.c", ], - - name: "depmod", - local_include_dirs: ["port-gnu"], - cflags: [ - "-include config.h", - "-ffunction-sections", - "-fdata-sections", - "-Wall", - "-Werror", - "-Wno-format", - "-Wno-unused-parameter", - "-Wno-unused-variable", - "-Dsecure_getenv=getenv", - "-DHAVE_CONFIG_H", - "-DANOTHER_BRICK_IN_THE", - "-DSYSCONFDIR=\"/tmp\"", - ], + static_libs: ["libkmod"], } diff --git a/port-gnu/config.h b/port-gnu/config.h index 8f527cb..eb4ce84 100644 --- a/port-gnu/config.h +++ b/port-gnu/config.h @@ -22,7 +22,7 @@ /* Define to 1 if you have the declaration of `strndupa', and to 0 if you don't. */ -#define HAVE_DECL_STRNDUPA 1 +/* #define HAVE_DECL_STRNDUPA */ /* Define to 1 if you have the header file. */ #define HAVE_DLFCN_H 1 @@ -181,3 +181,12 @@ char* basename(const char*); #include #endif + +#if defined(__ANDROID__) +#include +#include +static inline char *get_current_dir_name(void) +{ + return getcwd(malloc(PATH_MAX), PATH_MAX); +} +#endif -- cgit v1.2.3 From a322503d3a4313818201411786abbefec5438ef8 Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Tue, 5 Nov 2019 12:48:55 -0800 Subject: kmod: update missing.h to work on Apple kmod's build system already has a special accommodation for providing the strndupa macro on Apple. As a result, we don't need to provide our own variant on Apple builders. Test: presubmit, `m gem_blt` on Apple Fixes: 143962371 Change-Id: I83eefb86f3711df666c1e27b479ea36c7dffd507 --- shared/missing.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/missing.h b/shared/missing.h index 4c0d136..72aaa95 100644 --- a/shared/missing.h +++ b/shared/missing.h @@ -33,7 +33,7 @@ static inline int finit_module(int fd, const char *uargs, int flags) } #endif -#if !HAVE_DECL_STRNDUPA +#if (!HAVE_DECL_STRNDUPA && !defined(__APPLE__)) #define strndupa(s, n) \ ({ \ const char *__old = (s); \ -- cgit v1.2.3