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

Initial merge with xeus-clang-repl #14

Draft
wants to merge 69 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
39b1b13
Initial merge with xeus-clang-repl
alexander-penev Oct 2, 2023
10d02c4
Source cleanup
alexander-penev Oct 2, 2023
30db5ce
Add python magic
alexander-penev Oct 3, 2023
959eb07
Fix rich results display
alexander-penev Oct 5, 2023
a2ac8c2
Move docker container to port 9999 and some other minor fixes
alexander-penev Oct 29, 2023
61e1a8e
Fix build paths. Fix inspect to work with CppInterOp
alexander-penev Nov 19, 2023
365a6f6
Add mamba install of CppInterOp
alexander-penev Feb 12, 2024
d493445
Remove clang-dev dep
alexander-penev Feb 12, 2024
ba87e69
Fix CppInterOp package find
alexander-penev Feb 12, 2024
39eddea
Fix CppInterOp package find
alexander-penev Feb 12, 2024
286687f
Fix CppInterOp package find
alexander-penev Feb 12, 2024
66b9b4b
Fix CppInterOp package find
alexander-penev Feb 12, 2024
ed8dc76
Fix CppInterOp package find
alexander-penev Feb 12, 2024
6963241
Fix CppInterOp package find
alexander-penev Feb 12, 2024
2996647
Fix CppInterOp package find
alexander-penev Feb 12, 2024
82f94ba
Fix CppInterOp package find
alexander-penev Feb 12, 2024
cac2f64
Fix CppInterOp package find
alexander-penev Feb 12, 2024
9eaf1a7
Fix CppInterOp package find
alexander-penev Feb 12, 2024
8431daf
Fix CppInterOp package find
alexander-penev Feb 12, 2024
4a99c80
Fix CppInterOp package find
alexander-penev Feb 13, 2024
f4da8bc
Fix CppInterOp package find
alexander-penev Feb 13, 2024
27bd9c1
Fix CppInterOp package find
alexander-penev Feb 13, 2024
182b0d7
Fix CppInterOp package find
alexander-penev Feb 13, 2024
b0f2b80
Fix CppInterOp package find
alexander-penev Feb 13, 2024
0aa3d4a
Fix CppInterOp package find
alexander-penev Feb 13, 2024
bca9949
Fix CppInterOp package find
alexander-penev Feb 13, 2024
d0f9af0
Update main.yml
alexander-penev Mar 5, 2024
4297c1b
Update main.yml
alexander-penev Mar 5, 2024
dc1c374
Update main.yml
alexander-penev Mar 5, 2024
d8a4b4c
Update main.yml
alexander-penev Mar 5, 2024
395c95a
Update main.yml
vgvassilev Mar 5, 2024
31f7f36
Fix argpars
alexander-penev Mar 5, 2024
1a933f4
Update main.yml
alexander-penev Mar 5, 2024
eae4c10
Fix 1
alexander-penev Mar 6, 2024
9d5e285
Fix '?std::vector' error
alexander-penev Mar 9, 2024
7f9ffb9
Debug 1
alexander-penev Mar 10, 2024
76e6180
Fix xcpp crash
alexander-penev Mar 10, 2024
0ef7b75
Fix argv crash 2
alexander-penev Mar 10, 2024
5abd0ee
Cleanup debuging commands
alexander-penev Mar 10, 2024
3fb19d9
Try fix pytest run
alexander-penev Mar 10, 2024
4718304
Try fix
alexander-penev Mar 11, 2024
af0d85a
Try to fix 2
alexander-penev Mar 11, 2024
04f3663
Try to fix 3
alexander-penev Mar 11, 2024
8ea9692
Try to fix 4
alexander-penev Mar 11, 2024
424b479
Try to fix 5
alexander-penev Mar 11, 2024
c6c0de4
Try to fix 6
alexander-penev Mar 11, 2024
76ad13c
Update CMakeLists.txt
vgvassilev Mar 11, 2024
bf96863
Allow debugging wasm
vgvassilev Mar 11, 2024
d300c95
Emscripten finds Development.Embed and not Python::Python
vgvassilev Mar 11, 2024
0859ed0
Don't build the pythonexec just yet
vgvassilev Mar 11, 2024
eae9650
More wasm fixes
vgvassilev Mar 11, 2024
8bda4fe
Try setting the lib suffix
vgvassilev Mar 11, 2024
eb55cd6
Fix pytest
alexander-penev Mar 11, 2024
dba64ea
Fix pytest 1
alexander-penev Mar 11, 2024
36b3e72
Fix
alexander-penev Mar 11, 2024
c17f736
Try 1
alexander-penev Mar 12, 2024
cc90a16
Fix
alexander-penev Mar 12, 2024
1e3a995
Extend debug time
alexander-penev Mar 13, 2024
7bf6909
Debug 90
alexander-penev Mar 13, 2024
3990230
Debug 60
alexander-penev Mar 13, 2024
f65cd08
Debug 30
alexander-penev Mar 13, 2024
4ad7dc0
Update main.yml
alexander-penev Mar 5, 2024
7ccb228
Update main.yml
alexander-penev Mar 5, 2024
483e047
Update main.yml
vgvassilev Mar 5, 2024
040d307
Allow debugging wasm
vgvassilev Mar 11, 2024
02e7981
Emscripten finds Development.Embed and not Python::Python
vgvassilev Mar 11, 2024
8a334e5
Try setting the so->a
vgvassilev Mar 11, 2024
8049756
Add back the GNUInstallDirs
vgvassilev Mar 14, 2024
0e655ef
Remove unused set
vgvassilev Mar 14, 2024
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
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/**/*
build
15 changes: 8 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ concurrency:

jobs:
unix:

runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -74,14 +74,14 @@ jobs:
shell: bash -l {0}
run: |
cd build/test
export CPLUS_INCLUDE_PATH=$CONDA_PREFIX/include:$CONDA_BUILD_SYSROOT:$CONDA_BUILD_SYSROOT/..:$CONDA_BUILD_SYSROOT/../x86_64-conda-linux-gnu/include/c++/12.3.0:$CONDA_BUILD_SYSROOT/../x86_64-conda-linux-gnu/include/c++/12.3.0/include:$CONDA_BUILD_SYSROOT/../include:$CONDA_BUILD_SYSROOT/usr/include:/home/runner/micromamba-root/envs/xeus-cpp/bin/../lib/gcc/x86_64-conda-linux-gnu/12.3.0/include:/home/runner/micromamba-root/envs/xeus-cpp/bin/../lib/gcc/x86_64-conda-linux-gnu/12.3.0/include-fixed:/home/runner/micromamba-root/envs/xeus-cpp/bin/../lib/gcc/x86_64-conda-linux-gnu/12.3.0/../../../../x86_64-conda-linux-gnu/include:/home/runner/micromamba-root/envs/xeus-cpp/bin/../x86_64-conda-linux-gnu/sysroot/usr/include
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious to know what is this export being used for !

./test_xeus_cpp
timeout-minutes: 4

- name: test
shell: bash -l {0}
run: |
cd test
pytest . --reruns 5
$CONDA_PREFIX/bin/pytest test --reruns 5

- name: Prepare code coverage report
if: ${{ success() && (matrix.coverage == true) }}
Expand Down Expand Up @@ -109,10 +109,11 @@ jobs:
uses: mxschmitt/action-tmate@v3
# When debugging increase to a suitable value!
timeout-minutes: 30

win:

runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -177,7 +178,7 @@ jobs:
emsdk activate ${{matrix.emsdk_ver}}
source $CONDA_EMSDK_DIR/emsdk_env.sh
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32

mkdir build
pushd build

Expand Down
144 changes: 119 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")

set(XEUS_CPP_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)

enable_language(CXX)
set(CMAKE_CXX_EXTENSIONS NO)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Versionning
# ===========

Expand All @@ -40,12 +44,52 @@ include(GNUInstallDirs)

if (NOT DEFINED XEUS_CPP_KERNELSPEC_PATH)
set(XEUS_CPP_KERNELSPEC_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/")
set(XEUS_CPP_RESOURCE_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/clang/17)
endif ()

configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/xcpp/kernel.json.in"
"${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels/xcpp/kernel.json"
)
function(configure_kernel kernel)
set(CMAKE_CPLUS_INCLUDE_PATH "$ENV{CPLUS_INCLUDE_PATH}")
set(CMAKE_PATH "$ENV{PATH}")
set(CMAKE_LD_LIBRARY_PATH "$ENV{LD_LIBRARY_PATH}")
set(CMAKE_PYTHONPATH "$ENV{PYTHONPATH}")
set(CMAKE_VENV_PATH "$ENV{VENV}")

message(STATUS "Debug: Replace in kernels")
message(STATUS "Debug: CMAKE_CPLUS_INCLUDE_PATH=${CMAKE_CPLUS_INCLUDE_PATH}")
message(STATUS "Debug: CMAKE_PATH=${CMAKE_PATH}")
message(STATUS "Debug: CMAKE_LD_LIBRARY_PATH=${CMAKE_LD_LIBRARY_PATH}")
message(STATUS "Debug: CMAKE_PYTHONPATH=${CMAKE_PYTHONPATH}")
message(STATUS "Debug: CMAKE_VENV_PATH=${CMAKE_VENV_PATH}")
message(STATUS "Debug: CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}")
message(STATUS "Debug: CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}")

configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/${kernel}/kernel.json.in"
"${CMAKE_CURRENT_BINARY_DIR}/${kernel}/kernel.json"
)
file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/${kernel}/*.png")
foreach(file ${files})
configure_file(
"${file}"
"${CMAKE_CURRENT_BINARY_DIR}/${kernel}/"
COPYONLY
)
endforeach()
file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/${kernel}/*.svg")
foreach(file ${files})
configure_file(
"${file}"
"${CMAKE_CURRENT_BINARY_DIR}/${kernel}/"
COPYONLY
)
endforeach()
endfunction()

file(GLOB _kernels LIST_DIRECTORIES true RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "share/jupyter/kernels/*")
foreach(_kernel IN LISTS _kernels)
message("Configure kernel: ${_kernel}")
configure_kernel("${_kernel}")
endforeach()

# Build options
# =============
Expand All @@ -54,8 +98,8 @@ option(XEUS_CPP_BUILD_STATIC "Build xeus-cpp static library" ON)
OPTION(XEUS_CPP_BUILD_SHARED "Split xcpp build into executable and library" ON)
OPTION(XEUS_CPP_BUILD_EXECUTABLE "Build the xcpp executable" ON)

OPTION(XEUS_CPP_USE_SHARED_XEUS "Link xcpp with the xeus shared library (instead of the static library)" ON)
OPTION(XEUS_CPP_USE_SHARED_XEUS_CPP "Link xcpp with the xeus shared library (instead of the static library)" ON)
OPTION(XEUS_CPP_USE_SHARED_XEUS "Link xcpp with the xeus shared library (instead of the static library)" ON)
OPTION(XEUS_CPP_USE_SHARED_XEUS_CPP "Link xcpp with the xeus shared library (instead of the static library)" ON)

# Test options
OPTION(XEUS_CPP_BUILD_TESTS "xeus-cpp test suite" ON)
Expand Down Expand Up @@ -110,8 +154,11 @@ else()
add_compile_options(-fexceptions)
endif ()

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
if(NOT EMSCRIPTEN)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
CMAKE_CXX_COMPILER_ID MATCHES "Intel")

if(NOT XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
add_compile_options(-Wunused-parameter -Wextra -Wreorder)
endif()
endif ()
Expand All @@ -121,12 +168,15 @@ if(EMSCRIPTEN)
set(EMSCRIPTEN_FEATURES "${EMSCRIPTEN_FEATURES} -s \"EXTRA_EXPORTED_RUNTIME_METHODS=[ENV']\"")
endif()

find_package(Clang REQUIRED)
include(AddLLVM)
include(HandleLLVMOptions)
add_definitions(${LLVM_DEFINITIONS})
find_package(CppInterOp REQUIRED CONFIG PATHS "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CPPINTEROP_DIR}" "${CPPINTEROP_DIR}/lib")
if(CppInterOp_FOUND)
message(STATUS "Found CppInterOp: config=${CppInterOp_CONFIG} dir=${CppInterOp_DIR} (found version=${CppInterOp_VERSION})")
endif()

find_package(argparse REQUIRED)
find_package(pugixml REQUIRED)
set(Python_FIND_VIRTUALENV ONLY)
find_package(Python COMPONENTS Interpreter Development)

# Source files
# ============
Expand Down Expand Up @@ -155,10 +205,18 @@ set(XEUS_CPP_SRC
src/xoptions.cpp
src/xparser.cpp
src/xutils.cpp
src/xdemangle.hpp
src/xinspect.hpp
src/xsystem.hpp
src/xparser.hpp
src/xmagics/os.hpp
src/xmagics/os.cpp
)

if(EMSCRIPTEN)
list(APPEND XEUS_CPP_SRC src/xinterpreter_wasm.cpp)
else()
list(APPEND XEUS_CPP_SRC src/xmagics/pythonexec.hpp src/xmagics/pythonexec.cpp)
endif()

set(XEUS_CPP_MAIN_SRC
Expand All @@ -172,7 +230,8 @@ include(CheckCXXCompilerFlag)

string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE)

set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib; ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
list(REMOVE_DUPLICATES CMAKE_INSTALL_RPATH)

macro(xeus_cpp_set_common_options target_name)
if (MSVC)
Expand Down Expand Up @@ -226,7 +285,6 @@ macro(xeus_cpp_set_kernel_options target_name)
find_package(Threads)
target_link_libraries(${target_name} PRIVATE ${CMAKE_THREAD_LIBS_INIT})
endif()

endmacro()

# Common macro for shared and static library
Expand Down Expand Up @@ -262,7 +320,14 @@ macro(xeus_cpp_create_target target_name linkage output_name)
set(XEUS_CPP_XEUS_TARGET xeus-static)
endif ()

target_link_libraries(${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangInterpreter pugixml argparse::argparse xtl)
target_link_libraries(${target_name} PUBLIC ${XEUS_CPP_XEUS_TARGET} clangCppInterOp pugixml argparse::argparse xtl)
if (EMSCRIPTEN)
# For some reason emscripten cannot find Python::Python.
target_link_libraries(${target_name} PUBLIC Development.Embed)
else()
target_link_libraries(${target_name} PUBLIC Python::Python)
endif()

if (WIN32 OR CYGWIN)
#
elseif (APPLE)
Expand All @@ -272,7 +337,7 @@ macro(xeus_cpp_create_target target_name linkage output_name)
find_package(Threads) # TODO: add Threads as a dependence of xeus-static?
target_link_libraries(${target_name} PRIVATE ${CMAKE_THREAD_LIBS_INIT})
endif()

endmacro()

# xeus-cpp-headers
Expand Down Expand Up @@ -319,6 +384,30 @@ if (XEUS_CPP_BUILD_EXECUTABLE)
xeus_cpp_set_common_options(xcpp)
xeus_cpp_set_kernel_options(xcpp)
target_link_libraries(xcpp PRIVATE xeus-zmq)
set_target_properties(xcpp PROPERTIES
ENABLE_EXPORTS 1
CXX_STANDARD ${CMAKE_CXX_STANDARD})
target_link_libraries(xcpp PUBLIC xeus-cpp pthread Python::Python)

##TODO: We may be need sse RPATH
set_target_properties(xcpp clangCppInterOp PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
if(APPLE)
target_link_libraries(xcpp PUBLIC -Wl,-w -Wl,-bind_at_load -Wl,-undefined,dynamic_lookup)
elseif(NOT MSVC)
target_link_libraries(xcpp PUBLIC -Wl,--unresolved-symbols=ignore-in-object-files)
endif()

target_include_directories(xeus-cpp PUBLIC ${Python_INCLUDE_DIRS})
target_link_libraries(xeus-cpp PUBLIC ${PYTHON_LIBRARIES})
target_link_libraries(xeus-cpp ${PYTHON_LIBRARIES_Development_Main})
set_target_properties(xeus-cpp PROPERTIES
PUBLIC_HEADER "${XEUS_CPP_HEADERS}"
COMPILE_DEFINITIONS "XEUS_CPP_EXPORTS"
PREFIX ""
VERSION ${${PROJECT_NAME}_VERSION}
SOVERSION ${XEUS_CPP_VERSION_MAJOR}
OUTPUT_NAME "libxeus-cpp"
CXX_STANDARD ${CMAKE_CXX_STANDARD})
endif()

if(EMSCRIPTEN)
Expand Down Expand Up @@ -348,33 +437,34 @@ set(XEUS_CPP_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NA
if (XEUS_CPP_BUILD_SHARED)
install(TARGETS ${XEUS_CPP_TARGETS}
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/xeus-cpp)
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/xeus-cpp)

# Makes the project importable from the build directory
export(EXPORT ${PROJECT_NAME}-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")
endif ()

# Install xcpp
if ("${CMAKE_VENV_PATH}" STREQUAL "")
set(CMAKE_VENV_PATH "${CMAKE_INSTALL_PREFIX}")
endif()
if (XEUS_CPP_BUILD_EXECUTABLE)
install(TARGETS xcpp
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
RUNTIME DESTINATION ${CMAKE_VENV_PATH}/bin)
endif(XEUS_CPP_BUILD_EXECUTABLE)

if(XEUS_CPP_BUILD_EXECUTABLE OR EMSCRIPTEN)
# Configuration and data directories for jupyter and xeus-cpp
set(XJUPYTER_DATA_DIR "share/jupyter" CACHE STRING "Jupyter data directory")

# Install xcpp Jupyter kernelspec
set(KERNELSPEC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/share/jupyter/kernels)
set(KERNELSPEC_DIR ${CMAKE_CURRENT_BINARY_DIR}/share/jupyter/kernels)
install(DIRECTORY ${KERNELSPEC_DIR}
DESTINATION ${XJUPYTER_DATA_DIR}
PATTERN "*.in" EXCLUDE)


# Extra path for installing Jupyter kernelspec
if (XEXTRA_JUPYTER_DATA_DIR)
install(DIRECTORY ${KERNELSPEC_DIR}
Expand Down Expand Up @@ -439,3 +529,7 @@ if(EMSCRIPTEN)
"$<TARGET_FILE_DIR:xcpp>/xcpp.wasm"
DESTINATION ${CMAKE_INSTALL_BINDIR})
endif ()

if(XEUS_CPP_INCLUDE_DOCS)
add_subdirectory(docs)
endif()
Loading
Loading