Skip to content

Commit d18a279

Browse files
authored
Merge pull request #1120 from milroy/lib-updates
Build reapi_cli as a shared library
2 parents af5f62b + bf373e8 commit d18a279

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

cmake/GolangSimple.cmake

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@ function(BUILD_GO_PROGRAM NAME MAIN_SRC CGO_CFLAGS CGO_LIBRARY_FLAGS)
1111
get_filename_component(MAIN_SRC_ABS ${MAIN_SRC} ABSOLUTE)
1212
add_custom_target(${NAME})
1313

14-
# IMPORTANT: the trick to getting *spaces* to render in COMMAND is to convert them to ";"
15-
# string(REPLACE <match-string> <replace-string> <out-var> <input>...)
16-
STRING(REPLACE " " ";" CGO_LIBRARY_FLAGS ${CGO_LIBRARY_FLAGS})
1714
add_custom_command(TARGET ${NAME}
18-
COMMAND GOPATH=${GOPATH}:${CUSTOM_GO_PATH} GOOS=linux G0111MODULE=off CGO_CFLAGS="${CGO_CFLAGS}" CGO_LDFLAGS='${CGO_LIBRARY_FLAGS}' go build -ldflags '-w'
15+
COMMAND GOPATH=${GOPATH}:${CUSTOM_GO_PATH} GOOS=linux G0111MODULE=off CGO_CFLAGS="${CGO_CFLAGS}" CGO_LDFLAGS="${CGO_LIBRARY_FLAGS}" go build -ldflags '-w'
1916
-o "${CMAKE_CURRENT_SOURCE_DIR}/${NAME}"
2017
${CMAKE_GO_FLAGS} ${MAIN_SRC}
2118
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}

resource/reapi/bindings/CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1-
add_library ( reapi_cli STATIC
1+
add_library ( reapi_cli SHARED
22
c++/reapi.hpp
33
c++/reapi_cli.hpp
44
c++/reapi_cli_impl.hpp
55
c/reapi_cli.cpp
66
c/reapi_cli.h
77
)
8-
target_link_libraries(reapi_cli PRIVATE
8+
target_link_libraries( reapi_cli PRIVATE
9+
resource
10+
jobspec_conv
911
flux::core
1012
)
11-
add_library ( reapi_module STATIC
13+
install(TARGETS reapi_cli LIBRARY DESTINATION "${FLUX_LIB_DIR}")
14+
15+
add_library (reapi_module STATIC
1216
c++/reapi.hpp
1317
c++/reapi_module.hpp
1418
c++/reapi_module_impl.hpp
1519
c/reapi_module.cpp
1620
c/reapi_module.h
1721
)
18-
target_link_libraries(reapi_module PRIVATE
22+
target_link_libraries( reapi_module PRIVATE
1923
flux::core
2024
)
2125

resource/reapi/bindings/go/src/test/CMakeLists.txt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,24 @@ set(SRCS main.go)
33
set(CGO_CFLAGS "-I${CMAKE_BINARY_DIR}/resource/reapi/bindings/c")
44

55
# This is currently passed but not used because when passed into add_custom_command the spaces are escaped
6-
set(CGO_LIBRARY_FLAGS "-Wl,-R ${CMAKE_BINARY_DIR}/resource -L${CMAKE_BINARY_DIR}/resource/reapi/bindings -L${CMAKE_BINARY_DIR}/resource/libjobspec -ljobspec_conv -lreapi_cli -L${CMAKE_BINARY_DIR}/resource -lresource -L${CMAKE_BINARY_DIR}/resource/planner/c -lplanner -L${CMAKE_BINARY_DIR}/resource/planner/c++ -lplanner_cxx -lflux-idset -lstdc++ -lczmq -ljansson -lhwloc -lboost_system -lflux-hostlist -lboost_graph -lyaml-cpp")
6+
set(CGO_LIBRARY_FLAGS -Wl,-R
7+
-lflux-idset
8+
-lstdc++
9+
-lczmq
10+
-ljansson
11+
-lhwloc
12+
-lboost_system
13+
-lflux-hostlist
14+
-lboost_graph
15+
-lyaml-cpp
16+
-L${CMAKE_BINARY_DIR}/resource/reapi/bindings -lreapi_cli
17+
)
718

819
# This ensures the main binary is cleaned up
920
set_directory_properties(
1021
PROPERTIES
11-
ADDITIONAL_CLEAN_FILES "${CMAKE_CURRENT_BINARY_DIR}/main"
22+
ADDITIONAL_CLEAN_FILES "${CMAKE_CURRENT_BINARY_DIR}/main"
1223
)
1324

14-
# GO_GET(go_redis github.com/hoisie/redis)
15-
# main main.go
1625
# We add the dependencies at the end so the build can run in parallel and we don't try to build this before they are ready!
17-
BUILD_GO_PROGRAM(${TARGET} ${SRCS} "${CGO_CFLAGS}" "${CGO_LIBRARY_FLAGS}" jobspec_conv reapi_module reapi_cli resource flux::core)
26+
BUILD_GO_PROGRAM(${TARGET} ${SRCS} "${CGO_CFLAGS}" "${CGO_LIBRARY_FLAGS}" reapi_cli)

t/t9001-golang-basic.t

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ if ! which go >/dev/null; then
1414
test_done
1515
fi
1616

17+
export LD_LIBRARY_PATH=../../resource/reapi/bindings
18+
1719
exp_dir="${SHARNESS_TEST_SRCDIR}/data/resource/expected/golang"
1820
jgf="${SHARNESS_TEST_SRCDIR}/data/resource/jgfs/tiny.json"
1921
jobspec1="${SHARNESS_TEST_SRCDIR}/data/resource/jobspecs/basics/test001.yaml"

0 commit comments

Comments
 (0)