Skip to content

scripts/build: improve whitespace / empty parameter handling in syscall scripts #87633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions scripts/build/gen_syscalls.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ class SyscallParseException(Exception):


def typename_split(item):
item = item.strip().replace("\n", " ")
if "[" in item:
raise SyscallParseException(
"Please pass arrays to syscalls as pointers, unable to process '%s'" %
Expand Down Expand Up @@ -414,7 +413,7 @@ def analyze_fn(match_group, fn, userspace_only):
if args == "void":
args = []
else:
args = [typename_split(a) for a in args.split(",")]
args = [typename_split(a.strip()) for a in args.split(",")]

func_type, func_name = typename_split(func)
except SyscallParseException:
Expand Down
7 changes: 5 additions & 2 deletions scripts/build/parse_syscalls.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,11 @@ def analyze_headers(include_dir, scan_dir, file_list):
try:
to_emit = syscall_files[one_file]["emit"] | args.emit_all_syscalls

syscall_result = [(mo.groups(), fn, to_emit)
for mo in syscall_regex.finditer(contents)]
syscall_result = []
for mo in syscall_regex.finditer(contents):
groups = mo.groups()
groups = [re.sub(r'\s+', ' ', group) for group in groups]
syscall_result.append((groups, fn, to_emit,))
for tag in struct_tags:
tagged_struct_update(tagged_ret[tag], tag, contents)
except Exception:
Expand Down
6 changes: 6 additions & 0 deletions tests/cmake/syscalls/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (c) 2025 Renesas Electronics Corporation
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.28)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(app C)
target_sources(app PRIVATE main.c)
8 changes: 8 additions & 0 deletions tests/cmake/syscalls/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright (c) 2025 Renesas Electronics Corporation
* SPDX-License-Identifier: Apache-2.0
*/

#include "main.h"

int main(void) { return 0; }
16 changes: 16 additions & 0 deletions tests/cmake/syscalls/main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

/*
* Copyright (c) 2025 Renesas Electronics Corporation
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/syscall.h>

/* Newline between return type and function name */
/* clang-format off */
__syscall void
test_wrapped(int foo);
/* clang-format on */

#include <zephyr/syscalls/main.h>
3 changes: 3 additions & 0 deletions tests/cmake/syscalls/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (c) 2025 Renesas Electronics Corporation
# SPDX-License-Identifier: Apache-2.0
CONFIG_APPLICATION_DEFINED_SYSCALL=y
6 changes: 6 additions & 0 deletions tests/cmake/syscalls/testcase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (c) 2025 Renesas Electronics Corporation
# SPDX-License-Identifier: Apache-2.0
tests:
buildsystem.syscalls:
build_only: true
platform_allow: native_sim
Loading