Skip to content
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

More conventional syntax of -I command line argument in tool cpp_to_pybind #351

Open
wants to merge 4 commits into
base: master
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
4 changes: 2 additions & 2 deletions doc/userguide/bindings/generating-pybind11-bindings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ the module.
To generate a C++ header file for a new SMTK class, use
``[smtk-root-directory]/utilities/python/cpp_to_pybind11.py`` with the
appropriate arguments for the header file, project root directory,
include directories (e.g. ``-I "[smtk-build-directory]
[smtk-root-directory]/thirdparty/cJSON path/to/vtk/include"``) and
include directories (e.g. ``-I [smtk-build-directory]
-I [smtk-root-directory]/thirdparty/cJSON path/to/vtk/include``) and
generated file prefix; the module's binding source file (also located
in the ``pybind`` subdirectory of the module) must then be updated to
call the functions defined in the generated header file. To generate
Expand Down
12 changes: 7 additions & 5 deletions utilities/python/cpp_to_pybind11.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import os
import sys
from typing import List

# Find out the file location within the sources tree
this_module_dir_path = os.path.abspath(
Expand Down Expand Up @@ -231,7 +232,7 @@ def flatten(list_, separator):
return sorted(includes)


def parse_file(filename, project_source_directory, include_directories,
def parse_file(filename, project_source_directory, include_directories: List[str],
declaration_names, stream):
"""
Entry point for parsing a file
Expand All @@ -242,7 +243,7 @@ def parse_file(filename, project_source_directory, include_directories,
# Configure the xml generator
config = parser.xml_generator_configuration_t(
start_with_declarations=declaration_names.split(" "),
include_paths=include_directories.split(" "),
include_paths=include_directories,
xml_generator_path=generator_path,
xml_generator=generator_name,
cflags='-std=c++11 -Wc++11-extensions')
Expand Down Expand Up @@ -567,7 +568,8 @@ def uncapitalize(s):
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('-I', '--include-dirs',
help='Add an include directory to the parser',
default="")
action='append',
default=[])

arg_parser.add_argument('-d', '--declaration-name',
help='names of C++ classes and functions',
Expand All @@ -591,8 +593,8 @@ def uncapitalize(s):

args = arg_parser.parse_args()

if not args.include_dirs:
args.include_dirs = args.input_directory
if len(args.include_dirs) == 0:
args.include_dirs.append(os.path.getdirname(args.input))

def stream_with_line_breaks(stream):
def write(string):
Expand Down
7 changes: 4 additions & 3 deletions utilities/python/generate_pybind11_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@

arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('-I', '--include-dirs',
action='append',
help='Add an include directory to the parser',
default="")
default=[])

arg_parser.add_argument('-i', '--input-directory',
help='<Required> Input directory',
Expand Down Expand Up @@ -57,8 +58,8 @@
if not os.path.exists(args.input_directory):
raise IOError("No directory \"%s\"" % args.input_directory)

if not args.include_dirs:
args.include_dirs = args.input_directory
if len(args.include_dirs) == 0:
args.include_dirs.append(args.input_directory)

def stream_with_line_breaks(stream):
def write(string):
Expand Down