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

feat: add server example #5

Merged
merged 2 commits into from
May 2, 2024
Merged
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
69 changes: 58 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,18 @@ jobs:
vulkan-components: Vulkan-Headers, Vulkan-Loader
vulkan-use-cache: true

- name: Build
- name: Build library
run: |
./configure.sh
make build CMAKE_EXTRA_FLAGS="${{ matrix.defines }}"

- name: Build server example
run: |
mkdir -p examples/server/build
cd examples/server/build
cmake .. ${{ matrix.defines }}
cmake --build . --config Release

ubuntu-amd64-cuda-build:
runs-on: ubuntu-18-04-cuda-${{ matrix.cuda }}
timeout-minutes: 40
Expand All @@ -57,10 +64,17 @@ jobs:
with:
submodules: recursive

- name: Build
- name: Build library
run: |
./configure.sh
make build CMAKE_EXTRA_FLAGS="-DLLAMA_NATIVE=OFF -DLLAMA_CUDA=ON"

- name: Build server example
run: |
mkdir -p examples/server/build
cd examples/server/build
cmake .. -DLLAMA_NATIVE=OFF -DLLAMA_CUDA=ON
cmake --build . --config Release


macOS-silicon-build:
Expand All @@ -73,11 +87,17 @@ jobs:
with:
submodules: recursive

- name: Build
- name: Build library
run: |
./configure.sh
make build
ls -la

- name: Build server example
run: |
mkdir -p examples/server/build
cd examples/server/build
cmake ..
cmake --build . --config Release

macOS-amd64-build:
runs-on: macos-13
Expand All @@ -89,12 +109,18 @@ jobs:
with:
submodules: recursive

- name: Build
- name: Build library
id: cmake_build
run: |
./configure.sh
make build
ls -la

- name: Build server example
run: |
mkdir -p examples/server/build
cd examples/server/build
cmake ..
cmake --build . --config Release

windows-amd64-build:
runs-on: windows-latest
Expand Down Expand Up @@ -131,11 +157,23 @@ jobs:
vulkan-components: Vulkan-Headers, Vulkan-Loader
vulkan-use-cache: true

- name: Build
- name: Build library
shell: cmd
run: |
./configure.bat
make build CMAKE_EXTRA_FLAGS="${{ matrix.defines }}"
cmake -S ./third-party -B ./build_deps/third-party
cmake --build ./build_deps/third-party --config Release -j %NUMBER_OF_PROCESSORS%
mkdir -p build
cd build
cmake .. ${{ matrix.defines }}
cmake --build . --config Release

- name: Build server example
shell: cmd
run: |
mkdir .\examples\server\build
cd .\examples\server\build
cmake .. ${{ matrix.defines }}
cmake --build . --config Release

windows-amd64-cuda-build:
runs-on: windows-cuda-${{ matrix.cuda }}
Expand Down Expand Up @@ -170,12 +208,21 @@ jobs:
with:
submodules: recursive

- name: Build
- name: Build library
shell: cmd
run: |
./configure.bat
cmake -S ./third-party -B ./build_deps/third-party
cmake --build ./build_deps/third-party --config Release -j %NUMBER_OF_PROCESSORS%
mkdir -p build
cd build
cmake .. ${{ matrix.instructions }} ${{ matrix.flags }}
cmake --build . --config Release

- name: Build server example
shell: cmd
run: |
mkdir .\examples\server\build
cd .\examples\server\build
cmake .. ${{ matrix.instructions }} ${{ matrix.flags }}
cmake --build . --config Release

5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 3.5)
project(cortex.llamacpp)
SET(TARGET engine)

if(UNIX AND NOT APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
add_compile_options(-fPIC)
endif()

set(THIRD_PARTY_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build_deps/_install)
set(CORTEX_COMMON_PATH ${CMAKE_CURRENT_SOURCE_DIR}/base/)

Expand Down
52 changes: 52 additions & 0 deletions examples/server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
cmake_minimum_required(VERSION 3.5)
project(server)

find_package(Threads REQUIRED)

if(UNIX AND NOT APPLE)
set(LINKER_FLAGS -ldl)
endif()

include(CheckIncludeFileCXX)
# CPP version
check_include_file_cxx(any HAS_ANY)
check_include_file_cxx(string_view HAS_STRING_VIEW)
check_include_file_cxx(coroutine HAS_COROUTINE)
if(HAS_ANY
AND HAS_STRING_VIEW
AND HAS_COROUTINE)
set(CMAKE_CXX_STANDARD 20)
elseif(HAS_ANY AND HAS_STRING_VIEW)
set(CMAKE_CXX_STANDARD 17)
else()
set(CMAKE_CXX_STANDARD 14)
endif()

set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

add_executable(${PROJECT_NAME}
server.cc
dylib.h
httplib.h
)

set(THIRD_PARTY_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../build_deps/_install)
set(CORTEX_COMMON_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../base/)

find_library(JSONCPP
NAMES jsoncpp
HINTS "${THIRD_PARTY_PATH}/lib"
)

find_library(TRANTOR
NAMES trantor
HINTS "${THIRD_PARTY_PATH}/lib"
)

target_link_libraries(${PROJECT_NAME} PRIVATE ${JSONCPP} ${TRANTOR} ${LINKER_FLAGS}
${CMAKE_THREAD_LIBS_INIT})

target_include_directories(${PROJECT_NAME} PRIVATE
${CORTEX_COMMON_PATH}
${THIRD_PARTY_PATH}/include)
Loading
Loading