Skip to content

Commit

Permalink
feat: pkg config management (#164)
Browse files Browse the repository at this point in the history
related: #158

Signed-off-by: shaoting-huang <[email protected]>
  • Loading branch information
shaoting-huang authored Jan 15, 2025
1 parent f4e2393 commit cd5091f
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 4 deletions.
7 changes: 6 additions & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,9 @@ install(TARGETS milvus-storage
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/milvus-storage.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig/")
message( "install cmake install libdir: ${CMAKE_CURRENT_SOURCE_DIR}")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/milvus-storage.pc" DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/build/Release/")

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

set(CMAKE_INCLUDE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/include)
2 changes: 1 addition & 1 deletion cpp/src/milvus-storage.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ Name: Milvus Storage
Description: Milvus Storage
Version: @PROJECT_VERSION@

Libs: -L${libdir} -lstorage
Libs: -L${libdir} -lmilvus-storage
Cflags: -I${includedir}
5 changes: 3 additions & 2 deletions go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ MILVUS_STORAGE_LD_DIR = $(abspath $(MILVUS_STORAGE_ROOT)/cpp/build/Release)
CFLAGS += $(CONAN_CFLAGS)
CXXFLAGS += $(CONAN_CXXFLAGS)
INCLUDE_DIRS = $(CONAN_INCLUDE_DIRS_ARROW) $(MILVUS_STORAGE_INCLUDE_DIR)
CPPFLAGS = $(addprefix -I, $(INCLUDE_DIRS))
CPPFLAGS += $(addprefix -I, $(INCLUDE_DIRS))
LDFLAGS += $(addprefix -L, $(MILVUS_STORAGE_LD_DIR)) -Wl,-rpath,$(MILVUS_STORAGE_LD_DIR)

.EXPORT_ALL_VARIABLES:
Expand All @@ -16,10 +16,11 @@ LDFLAGS += $(addprefix -L, $(MILVUS_STORAGE_LD_DIR)) -Wl,-rpath,$(MI
build:
@echo "CPPFLAGS: $(CPPFLAGS)"
@echo "LDFLAGS: $(LDFLAGS)"
@. $(PWD)/scripts/setenv.sh && \
CGO_CFLAGS="$(CPPFLAGS)" CGO_LDFLAGS="$(LDFLAGS) -lmilvus-storage" go build ./...

test:
LD_LIBRARY_PATH=$(MILVUS_STORAGE_LD_DIR):$$LD_LIBRARY_PATH \
@. $(PWD)/scripts/setenv.sh && LD_LIBRARY_PATH=$(MILVUS_STORAGE_LD_DIR):$$LD_LIBRARY_PATH \
CGO_CFLAGS="$(CPPFLAGS)" \
CGO_LDFLAGS="$(LDFLAGS) -lmilvus-storage" \
go test -count=1 -timeout 30s ./... -gcflags "all=-N -l" -o gdb/
Expand Down
2 changes: 2 additions & 0 deletions go/packed/packed_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package packed

/*
#cgo pkg-config: milvus-storage
#include <stdlib.h>
#include "milvus-storage/packed/reader_c.h"
#include "arrow/c/abi.h"
Expand Down
2 changes: 2 additions & 0 deletions go/packed/packed_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package packed

/*
#cgo pkg-config: milvus-storage
#include <stdlib.h>
#include "milvus-storage/packed/writer_c.h"
#include "arrow/c/abi.h"
Expand Down
10 changes: 10 additions & 0 deletions go/scripts/setenv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set +e

unameOut="$(uname -s)"

ROOT_DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )"

# Update PKG_CONFIG_PATH
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:${ROOT_DIR}/cpp/build/Release/"

0 comments on commit cd5091f

Please sign in to comment.