Skip to content

Commit

Permalink
Update liblcd:
Browse files Browse the repository at this point in the history
- fix run on Lunux;
- add runs tests;
  • Loading branch information
rozhuk-im committed Apr 26, 2024
1 parent 90dbcc1 commit 0143aaa
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 10 deletions.
23 changes: 20 additions & 3 deletions .github/workflows/build-macos-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ jobs:
with:
submodules: 'recursive'

- name: Install libraries
run: |
checkPkgAndInstall()
{
while [ $# -ne 0 ]
do
rm -f '/usr/local/bin/2to3'
if brew ls --versions $1 ; then
brew upgrade $1
else
brew install $1
fi
shift
done
}
checkPkgAndInstall cunit
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
Expand All @@ -42,17 +59,17 @@ jobs:
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DENABLE_TESTS=1

- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE
run: cmake --build . --config $BUILD_TYPE -j 16

- name: Test
working-directory: ${{github.workspace}}/build
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C $BUILD_TYPE
run: ctest -C $BUILD_TYPE -j 16 --output-on-failure
11 changes: 8 additions & 3 deletions .github/workflows/build-ubuntu-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ jobs:
with:
submodules: 'recursive'

- name: Install libraries
run: |
sudo apt-get update
sudo apt-get install cmake libcunit1 libcunit1-doc libcunit1-dev
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
Expand All @@ -42,17 +47,17 @@ jobs:
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DENABLE_TESTS=1

- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE
run: cmake --build . --config $BUILD_TYPE -j 16

- name: Test
working-directory: ${{github.workspace}}/build
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C $BUILD_TYPE
run: ctest -C $BUILD_TYPE -j 16 --output-on-failure
14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}")

############################# OPTIONS SECTION ##########################

option(ENABLE_TESTS "Enable tests [default: OFF]" OFF)
if (ENABLE_TESTS)
# Enable testing functionality.
enable_testing()
set(ENABLE_LIBLCB_TESTS TRUE)
endif()

# Now CMAKE_INSTALL_PREFIX is a base prefix for everything.
if (NOT CONFDIR)
set(CONFDIR "${CMAKE_INSTALL_PREFIX}/etc/msd_lite")
Expand Down Expand Up @@ -234,12 +241,13 @@ add_definitions(-DHAVE_CONFIG_H)

################################ SUBDIRS SECTION #######################

add_definitions(-DHTTP_SRV_XML_CONFIG)
add_definitions(-DSOCKET_XML_CONFIG)
add_definitions(-DTHREAD_POOL_SETTINGS_XML)
include(src/liblcb/CMakeLists.txt)
add_subdirectory(src)

if (ENABLE_TESTS)
#add_subdirectory(tests)
endif()

############################ TARGETS SECTION ###########################

add_custom_target(dist ${CMAKE_CURRENT_SOURCE_DIR}/dist.sh
Expand Down
4 changes: 4 additions & 0 deletions msd_lite.project
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<CodeLite_Project Name="msd_lite" InternalType="" Version="11000">
<VirtualDirectory Name="workflows">
<File Name=".github/workflows/build-ubuntu-latest.yml"/>
<File Name=".github/workflows/build-macos-latest.yml"/>
</VirtualDirectory>
<Plugins>
<Plugin Name="CppCheck"/>
<Plugin Name="CMakePlugin">
Expand Down
10 changes: 10 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ make -j 8
```


## Run tests
```
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=1 ..
cmake --build . --config Release -j 16
ctest -C Release --output-on-failure -j 16
```


## Usage
```
msd_lite [-d] [-v] [-c file]
Expand Down
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ set(MSD_LITE_BIN msd_lite.c
liblcb/src/utils/xml.c)

add_executable(msd_lite ${MSD_LITE_BIN})
target_compile_definitions(msd_lite PRIVATE -DHTTP_SRV_XML_CONFIG)
target_compile_definitions(msd_lite PRIVATE -DSOCKET_XML_CONFIG)
target_compile_definitions(msd_lite PRIVATE -DTHREAD_POOL_SETTINGS_XML)
set_target_properties(msd_lite PROPERTIES LINKER_LANGUAGE C)
target_link_libraries(msd_lite ${CMAKE_REQUIRED_LIBRARIES} ${CMAKE_EXE_LINKER_FLAGS})

Expand Down

0 comments on commit 0143aaa

Please sign in to comment.