diff --git a/README.md b/README.md index 9680f54a..5afeba4f 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,15 @@ #### Dependencies -`sudo apt install libatspi2.0-dev` +`sudo apt install cmake libatspi2.0-dev` -For swig: -* `sudo apt install swig` +For Python3 bindings (optional): +* `sudo apt install swig python3-dev` For NodeJS module (optional): +* `sudo apt install swig node-gyp` -* `sudo apt install node-gyp` +These bindings dependencies are on my default. See *Feature Flags* section below for how to disable them. #### Build steps ``` @@ -38,7 +39,7 @@ As well as a python module. 'Google Chrome' ``` -An optionally a NodeJS module `atspi_inspect.node`. +And a NodeJS module `atspi_inspect.node`. ``` % cd build/lib/atspi/ % nodejs @@ -52,6 +53,7 @@ An optionally a NodeJS module `atspi_inspect.node`. #### Feature flags +* Python3 bindings: `-DATSPI_PYTHON_MODULE=<ON/OFF>`, ON by default. * NodeJS bindings: `-DATSPI_NODEJS_MODULE=<ON/OFF>`, ON by default. ### On Mac diff --git a/lib/atspi/CMakeLists.txt b/lib/atspi/CMakeLists.txt index ba5c7dff..e0e2c751 100644 --- a/lib/atspi/CMakeLists.txt +++ b/lib/atspi/CMakeLists.txt @@ -1,4 +1,11 @@ -# Feature flag for NodeJS bindings +# Feature flag for Python bindings, ON by default +option( + ATSPI_PYTHON_MODULE + "Build Python bindings (requires swig and python3)" + ON +) + +# Feature flag for NodeJS bindings, ON by default option( ATSPI_NODEJS_MODULE "Build NodeJS bindings (requires swig and node-gyp)" @@ -67,36 +74,44 @@ target_link_libraries( atspi_inspect ) -# SWIG Instructions to build a python module called "atspi_inspect" +# SWIG Instructions to build library bindings to different languages +# (only required if at least one binding is ON). -FIND_PACKAGE(SWIG REQUIRED) -INCLUDE(${SWIG_USE_FILE}) +if (ATSPI_PYTHON_MODULE OR ATSPI_NODEJS_MODULE) + FIND_PACKAGE(SWIG REQUIRED) + INCLUDE(${SWIG_USE_FILE}) +endif() -FIND_PACKAGE(PythonLibs) -INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) +# Generate Python bindings using swig + python3 -SET_SOURCE_FILES_PROPERTIES(atspi_inspect.i PROPERTIES CPLUSPLUS ON) +if (ATSPI_PYTHON_MODULE) + FIND_PACKAGE(PythonLibs) + INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) -SWIG_ADD_LIBRARY( - # The name of the c++ library used by python module - atspi_python_inspect - TYPE SHARED - LANGUAGE python - SOURCES atspi_inspect.i -) + SET_SOURCE_FILES_PROPERTIES(atspi_inspect.i PROPERTIES CPLUSPLUS ON) -TARGET_LINK_LIBRARIES( - atspi_python_inspect - atspi_inspect - ${PYTHON_LIBRARIES} -) + SWIG_ADD_LIBRARY( + # The name of the c++ library used by python module + atspi_python_inspect + TYPE SHARED + LANGUAGE python + SOURCES atspi_inspect.i + ) + + TARGET_LINK_LIBRARIES( + atspi_python_inspect + atspi_inspect + ${PYTHON_LIBRARIES} + ) + + set_property( + TARGET atspi_python_inspect + PROPERTY + SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE + ) +endif() -set_property( - TARGET atspi_python_inspect - PROPERTY - SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE -) # Generate a NodeJS Module using swig + node-gyp diff --git a/lib/atspi/linux_utils.cc b/lib/atspi/linux_utils.cc index 631b7278..c7a11c1c 100644 --- a/lib/atspi/linux_utils.cc +++ b/lib/atspi/linux_utils.cc @@ -23,7 +23,7 @@ AtspiNodePtr find_root_accessible_from_pid(const int pid) { atspi_accessible_get_child_at_index(desktop, i, &error); CHECK_ATSPI_ERROR_NULLPTR(error); - uint application_pid = atspi_accessible_get_process_id(child, &error); + pid_t application_pid = atspi_accessible_get_process_id(child, &error); CHECK_ATSPI_ERROR_NULLPTR(error) if (pid == application_pid) { return std::make_unique<AtspiNode>(AtspiNode(child));