Skip to content

Commit

Permalink
Merge pull request #71 from vanrein/fix-python-support
Browse files Browse the repository at this point in the history
Fix python support. This applies fixes proposed by Henri Manson.
  • Loading branch information
adriaandegroot authored Feb 28, 2019
2 parents ce2f3b5 + cc3422f commit bf01844
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions cmake/MacroASN1Module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ macro(add_asn1_module _modulename _groupname)
WORKING_DIRECTORY quick-der
COMMENT "Build include file ${_modulename}.h from ASN.1 spec")
add_custom_command (OUTPUT ${CMAKE_BINARY_DIR}/python/testing/${_modulename}.py
COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${CMAKE_SOURCE_DIR}/python:${_ppath} ${PYTHON_EXECUTABLE} ${_qd_asn2quickder} -l python ${asn1module_asn2quickder_options} ${CMAKE_CURRENT_SOURCE_DIR}/${_modulename}.asn1
COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${_ppath} ${PYTHON_EXECUTABLE} ${_qd_asn2quickder} -l python ${asn1module_asn2quickder_options} ${CMAKE_CURRENT_SOURCE_DIR}/${_modulename}.asn1
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_modulename}.asn1
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/python/testing
COMMENT "Build Python script ${_modulename}.py from ASN.1 spec")
Expand All @@ -102,7 +102,7 @@ macro(add_asn1_module _modulename _groupname)
add_dependencies(asn2quickder-done ${_modulename}_asn1_h)

add_test(${_modulename}-test-h ${_modulename}-test-h)
add_test(${_modulename}-test-py ${CMAKE_COMMAND} -E env PYTHONPATH=${CMAKE_SOURCE_DIR}/python:${_ppath} python ${_modulename}-test.py)
add_test(${_modulename}-test-py ${CMAKE_COMMAND} -E env PYTHONPATH=${_ppath} ${PYTHON_EXECUTABLE} ${_modulename}-test.py)
endif()
endmacro()

Expand All @@ -119,7 +119,7 @@ endmacro()

macro(add_asn1_document _docname _groupname)
add_custom_command (OUTPUT doc/${_docname}.md
COMMAND ${CMAKE_SOURCE_DIR}/python/scripts/asn1literate ${CMAKE_CURRENT_SOURCE_DIR}/${_docname}.asn1 ${_docname}.md
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/python/scripts/asn1literate ${CMAKE_CURRENT_SOURCE_DIR}/${_docname}.asn1 ${_docname}.md
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_docname}.asn1
WORKING_DIRECTORY doc
COMMENT "Build markdown text file ${_docname}.md from ASN.1 spec")
Expand Down
7 changes: 6 additions & 1 deletion cmake/PythonSupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
# SPDX-License-Identifier: BSD-2-Clause.degroot
# License-Filename: LICENSES/BSD-2-Clause.degroot

if (WIN32)
# Not using WIN32 here, because that's set when the **target** system
# is Windows. Here, we need it while building, regardless of target,
# on a Windows host.
if (CMAKE_HOST_SYSTEM MATCHES "Windows")
set (PYTHON_PATH_SEPARATOR ";")
else()
set (PYTHON_PATH_SEPARATOR ":")
Expand All @@ -20,6 +23,8 @@ endif()
# Sets @p VARNAME to the value of the environment-variable PYTHONPATH,
# with @p path appended to it with a suitable separator. If more than
# one value is passed in, they are all appended with suitable separators.
#
# This **could** be generalized, to use a different ENV variable.
function (AppendToPythonPath VARNAME path)
set (_ppath $ENV{PYTHONPATH})
# Special-case if the existing environment variable is empty.
Expand Down

0 comments on commit bf01844

Please sign in to comment.