Skip to content
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
12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ if(POLICY CMP0167)
cmake_policy(SET CMP0167 NEW)
endif()

find_package(Boost REQUIRED COMPONENTS system)
find_package(Boost REQUIRED)

# Define the shared library for the native component.
add_library(nrepl_server_native SHARED src/cpp/nrepl_server/nrepl_server.cpp)
target_include_directories(nrepl_server_native PUBLIC src/cpp)
target_link_libraries(nrepl_server_native PRIVATE Boost::system)

set_target_properties(nrepl_server_native PROPERTIES
PREFIX "" # removes the "lib"
OUTPUT_NAME "nrepl_server_native" # makes sure the name matches exactly
)

target_include_directories(nrepl_server_native PUBLIC src/cpp ${Boost_INCLUDE_DIRS})
target_link_libraries(nrepl_server_native)

# Define a dummy interface target for the jank script which we will use to
# collect include directories, link directories, and link libraries to be passed
Expand Down
9 changes: 8 additions & 1 deletion src/jank/nrepl_server/handler/eval.jank
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
[nrepl-server.capture :as capture]
[nrepl-server.inspect :refer [inspect-str]]))

(cpp/raw "#include <cstdio>")
(cpp/raw "
static FILE* get_stdout() {
return stdout;
}
")

(def default-ns
"The namespace in which evaluation will occur when an invalid or no ns
parameter is specified."
Expand All @@ -21,7 +28,7 @@
;; output during a long eval.
(let [target-ns (or (some-> ns symbol find-ns) default-ns)
;; do the eval, capturing anything on stdout
capture-handle (capture/start (cpp/box cpp/stdout))
capture-handle (capture/start (cpp/box (cpp/get_stdout)))
[success res-ns] (binding [*ns* target-ns]
;; the evaluation may change the namespace
[(safe-eval code) *ns*])
Expand Down