Skip to content

Commit

Permalink
events: pass relative paths plus base path to source parser script (P…
Browse files Browse the repository at this point in the history
…X4#22551)

* events: pass relative paths plus base path to source parser script

to work around maximum Makefile command lenght limits.

* events: correct cmake comment typo

Co-authored-by: Beat Küng <[email protected]>

---------

Co-authored-by: Beat Küng <[email protected]>
  • Loading branch information
MaEtUgR and bkueng authored Dec 18, 2023
1 parent f38fe24 commit 6ffc5a9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ define_property(GLOBAL PROPERTY PX4_MODULE_PATHS
BRIEF_DOCS "PX4 module paths"
FULL_DOCS "List of paths to all PX4 modules"
)

define_property(GLOBAL PROPERTY PX4_SRC_FILES
BRIEF_DOCS "src files from all PX4 modules & libs"
FULL_DOCS "SRC files from px4_add_{module,library}"
Expand Down
6 changes: 5 additions & 1 deletion Tools/px_process_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def main():
metavar="PATH",
nargs='*',
help="one or more paths/files to source files to scan for events")
parser.add_argument("-b", "--base-path",
default=[""],
metavar="PATH",
help="path prefix for everything passed with --src-path")
parser.add_argument("-j", "--json",
nargs='?',
const="events.json",
Expand Down Expand Up @@ -84,7 +88,7 @@ def main():
# canonicalize + remove duplicates
src_paths = set()
for path in args.src_path:
src_paths.add(os.path.realpath(path))
src_paths.add(os.path.realpath(os.path.join(args.base_path, path)))

if not scanner.ScanDir(src_paths, parser):
sys.exit(1)
Expand Down
10 changes: 9 additions & 1 deletion src/lib/events/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,21 @@ px4_add_git_submodule(TARGET git_libevents PATH "libevents")

get_property(all_px4_src_files GLOBAL PROPERTY PX4_SRC_FILES)

# Use relative path list to work around Makefile command character limit
set(all_px4_src_files_relative "")
foreach(f ${all_px4_src_files})
file(RELATIVE_PATH relative_path ${PX4_SOURCE_DIR}/src ${f})
list(APPEND all_px4_src_files_relative "${relative_path}")
endforeach(f)

set(generated_events_dir ${PX4_BINARY_DIR}/events)
set(generated_events_px4_file ${generated_events_dir}/px4.json)
set(generated_events_common_enums_file ${generated_events_dir}/common_with_enums.json)
add_custom_command(OUTPUT ${generated_events_px4_file}
COMMAND ${CMAKE_COMMAND} -E make_directory ${generated_events_dir}
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_process_events.py
--src-path ${all_px4_src_files}
--base-path ${PX4_SOURCE_DIR}/src
--src-path ${all_px4_src_files_relative}
--json ${generated_events_px4_file} #--verbose
DEPENDS
${all_px4_src_files}
Expand Down

0 comments on commit 6ffc5a9

Please sign in to comment.