Skip to content

Commit ef99cc8

Browse files
committed
Tools: Testbench: Avoid need linux kernel headers in build
This patch adds simplified linux/types.h into testbench headers to enable include of ALSA asoc.h to build without other difficult kernel headers content. The CMakeLists.txt files are updated to make a build time copy of asoc.h to subdirectory include of the build directories. The new directory is added to headers path. This change avoids build fail with xcc toolchain that can't use the gcc toolchain headers from the system where the ALSA headers are located. Suggested-by: Marc Herbert <marc.herbert@intel.com> Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent 56abcad commit ef99cc8

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

tools/testbench/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ project(SOF_TESTBENCH C)
77
include(../../scripts/cmake/misc.cmake)
88
include(CheckCCompilerFlag)
99

10+
set(default_asoc_h "/usr/include/alsa/sound/uapi/asoc.h")
11+
1012
add_executable(testbench
1113
testbench.c
1214
common_test.c
@@ -31,6 +33,12 @@ target_include_directories(testbench PRIVATE
3133
)
3234
endif()
3335

36+
# Configuration time, make copy
37+
configure_file(${default_asoc_h} ${CMAKE_CURRENT_BINARY_DIR}/include/alsa/sound/asoc.h)
38+
39+
# Build time
40+
target_include_directories(testbench PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/include")
41+
3442
# -Wimplicit-fallthrough is preferred, check if it's supported
3543
check_c_compiler_flag(-Wimplicit-fallthrough supports_implicit_fallthrough)
3644
if (supports_implicit_fallthrough)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* SPDX-License-Identifier: BSD-3-Clause */
2+
3+
#ifndef __TESTBENCH_LINUX_TYPES_H__
4+
#define __TESTBENCH_LINUX_TYPES_H__
5+
6+
#include <stdint.h>
7+
8+
/*
9+
* This header files allows to include asoc.h for topology parsing to
10+
* non-gcc builds with other C library, e.g. the one that is used by
11+
* xt-xcc compiler. The kernel linux/types.h cannot be used because
12+
* the other definitions there are not compatible with the toolchain.
13+
*/
14+
15+
/* There are minimum types needed for alsa/sound/uapi/asoc.h */
16+
17+
typedef int64_t __le64;
18+
typedef int32_t __le32;
19+
typedef int16_t __le16;
20+
typedef uint8_t __u8;
21+
22+
#endif /* __TESTBENCH_LINUX_TYPES_H__ */

tools/tplg_parser/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ project(SOF_TPLG_PARSER C)
77
include(../../scripts/cmake/misc.cmake)
88
include(CheckCCompilerFlag)
99

10+
set(default_asoc_h "/usr/include/alsa/sound/uapi/asoc.h")
11+
1012
set(sof_source_directory "${PROJECT_SOURCE_DIR}/../..")
1113

1214
if (CONFIG_LIBRARY_STATIC)
@@ -40,6 +42,12 @@ target_include_directories(sof_tplg_parser PRIVATE ${sof_source_directory}/src/p
4042
# TODO: The topology parser should NOT need to include RTOS header. FIX.
4143
target_include_directories(sof_tplg_parser PRIVATE ${sof_source_directory}/xtos/include)
4244

45+
# Configuration time, make copy
46+
configure_file(${default_asoc_h} ${CMAKE_CURRENT_BINARY_DIR}/include/alsa/sound/asoc.h)
47+
48+
# Build time
49+
target_include_directories(sof_tplg_parser PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/include")
50+
4351
# -Wimplicit-fallthrough is preferred, check if it's supported
4452
check_c_compiler_flag(-Wimplicit-fallthrough supports_implicit_fallthrough)
4553
if (supports_implicit_fallthrough)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* SPDX-License-Identifier: BSD-3-Clause */
2+
3+
#ifndef __TPLG_PARSER_LINUX_TYPES_H__
4+
#define __TPLG_PARSER_LINUX_TYPES_H__
5+
6+
#include <stdint.h>
7+
8+
/*
9+
* This header files allows to include asoc.h for topology parsing to
10+
* non-gcc builds with other C library, e.g. the one that is used by
11+
* xt-xcc compiler. The kernel linux/types.h cannot be used because
12+
* the other definitions there are not compatible with the toolchain.
13+
*/
14+
15+
/* There are minimum types needed for alsa/sound/uapi/asoc.h */
16+
17+
typedef int64_t __le64;
18+
typedef int32_t __le32;
19+
typedef int16_t __le16;
20+
typedef uint8_t __u8;
21+
22+
#endif /* __TPLG_PARSER_LINUX_TYPES_H__ */

0 commit comments

Comments
 (0)