Skip to content

Commit

Permalink
Added CMake install command for dwarfs and wrapper library (#40)
Browse files Browse the repository at this point in the history
Closed #39
  • Loading branch information
maxirmx authored Oct 23, 2021
1 parent 05ca314 commit 374e204
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 17 deletions.
45 changes: 31 additions & 14 deletions .github/workflows/ubuntu-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Ubuntu build

on:
push:
branches: [ master, issue-1 ]
branches: [ master, issue-39 ]
paths-ignore:
- 'docs/**'
- '**.adoc'
Expand Down Expand Up @@ -59,26 +59,43 @@ jobs:
libunwind-dev libdwarf-dev libelf-dev libfmt-dev libgoogle-glog-dev libgtest-dev
- name: Configure
run: cmake -B ${{github.workspace}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
run: cmake -B ${{github.workspace}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
run: cmake --build ${{github.workspace}} --config ${{env.BUILD_TYPE}}

- name: Unit tests
run: make test

- name: Running pure "C" program, calling all C API redefines
run: ./wr-bin
- name: Check "C" interface bindings in statically linked program, check that tmp directory is cleaned upon shutdown
run: |
mkdir ${{github.workspace}}/t_dir
ls /tmp >> ${{github.workspace}}/t_dir/before
ls -l /tmp
./wr-bin
ls /tmp >> ${{github.workspace}}/t_dir/after
ls -l /tmp
diff ${{github.workspace}}/t_dir/before ${{github.workspace}}/t_dir/after
- name: Running ldd to check that wr-bin has been linked statically
- name: Run ldd to check that wr-bin has been linked statically
run: ldd wr-bin 2>&1 >/dev/null | grep -i 'not a dynamic executable'

# [TODO]
# - name: Checking that tmp dir has been cleaned
# run: |
# shopt -s nullglob
# numfiles=(/tmp/*)
# numfiles=${#numfiles[@]}
# echo $numfiles


- name: Install and verify installation folders
run: |
sudo cmake --install ${{github.workspace}} --prefix ${{github.workspace}}/install
test -f ${{github.workspace}}/install/bin/dwarfs || (echo "File ${{github.workspace}}/install/bin/dwarfs does not exist" && false)
test -f ${{github.workspace}}/install/bin/dwarfsck || (echo "File ${{github.workspace}}/install/bin/dwarfsck does not exist" && false)
test -f ${{github.workspace}}/install/bin/dwarfsextract || (echo "File ${{github.workspace}}/install/bin/dwarfsextract does not exist" && false)
test -f ${{github.workspace}}/install/bin/mkdwarfs || (echo "File ${{github.workspace}}/install/bin/mkdwarfs does not exist" && false)
test -f ${{github.workspace}}/install/lib/libdwarfs-wr.a || (echo "File ${{github.workspace}}/install/lib/libdwarfs-wr.a does not exist" && false)
test -f ${{github.workspace}}/install/lib/libdwarfs.a || (echo "File ${{github.workspace}}/install/lib/libdwarfs.a does not exist" && false)
test -f ${{github.workspace}}/install/lib/libfsst.a || (echo "File ${{github.workspace}}/install/lib/libfsst.a does not exist" && false)
test -f ${{github.workspace}}/install/lib/libfolly.a || (echo "File ${{github.workspace}}/install/lib/libfolly.a does not exist" && false)
test -f ${{github.workspace}}/install/lib/libmetadata_thrift.a || (echo "File ${{github.workspace}}/install/lib/libmetadata_thrift.a does not exist" && false)
test -f ${{github.workspace}}/install/lib/libthrift_light.a || (echo "File ${{github.workspace}}/install/lib/libthrift_light.a does not exist" && false)
test -f ${{github.workspace}}/install/lib/libxxhash.a || (echo "File ${{github.workspace}}/install/lib/libxxhash.a does not exist" && false)
test -f ${{github.workspace}}/install/lib/libzstd.a || (echo "File ${{github.workspace}}/install/lib/libzstd.a does not exist" && false)
test -f ${{github.workspace}}/install/lib/libarchive.a || (echo "File ${{github.workspace}}/install/lib/libarchive.a does not exist" && false)
test -f ${{github.workspace}}/install/include/tebako/tebako-defines.h || (echo "File ${{github.workspace}}/install/include/tebako/tebako-defines.h does not exist" && false)
test -f ${{github.workspace}}/install/include/tebako/tebako-io.h || (echo "File ${{github.workspace}}/install/include/tebako/tebako-io.h does not exist" && false)
32 changes: 31 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ include(ExternalProject)
include(FetchContent)
include(GoogleTest)
include(CTest)
include(GNUInstallDirs)
include(${CMAKE_SOURCE_DIR}/cmake/def_ext_prj.cmake)


enable_testing()

set(Boost_USE_STATIC_LIBS ON)
Expand Down Expand Up @@ -270,6 +272,10 @@ function(ADD_DWARFS_LIBRARY NAME PRJ APP_NM)
set_target_properties(${NAME} PROPERTIES IMPORTED_LOCATION ${_${NAME}})
add_dependencies(${NAME} ${PRJ})
target_link_libraries(${APP_NM} ${NAME})
install(FILES ${_${NAME}}
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

endfunction()


Expand Down Expand Up @@ -311,6 +317,9 @@ endfunction()
# (2) it is statically linked

add_executable(wr-bin
"include/tebako-pch.h"
"include/tebako-defines.h"
"include/tebako-io.h"
"tests/tests-defines-static.c"
"tests/tebako-fs.cpp"
"tests/tebako-fs.h"
Expand Down Expand Up @@ -352,6 +361,8 @@ add_dwarfs_library(_LIBARCHIVE ${DWARFS_PRJ} wr-bin)
# Google test

add_executable(wr-tests
"include/tebako-pch.h"
"include/tebako-io.h"
"tests/tests-fs-load.cpp"
"tests/tests-file-ctl.cpp"
"tests/tests-file-io.cpp"
Expand Down Expand Up @@ -387,6 +398,7 @@ target_link_libraries(wr-tests _LIBARCHIVE)
# IMPORTANT !!!
# MUST be in this order otherwise link may fail
# -static-libgcc and gcc_eh below is all together an ugly trick to enforce static linking
# [??? this also looked like a requirement but not tests pass withoot libc ] ${_LIBC}

target_link_libraries(wr-tests
${_LIBFMT} ${Boost_LIBRARIES} ${_LIBDC}
Expand All @@ -397,5 +409,23 @@ target_link_libraries(wr-tests _LIBARCHIVE)
${_LIBUNWIND} ${_LIBLZMA}
)

# ${_LIBC}
install(TARGETS
dwarfs-wr
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

install(FILES
"include/tebako-defines.h"
"include/tebako-io.h"
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tebako
)

install(FILES
${DEPS_BIN_DIR}/dwarfs
${DEPS_BIN_DIR}/dwarfsck
${DEPS_BIN_DIR}/dwarfsextract
${DEPS_BIN_DIR}/mkdwarfs
DESTINATION ${CMAKE_INSTALL_BINDIR}
)


4 changes: 2 additions & 2 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeExecutable": "cmake",
"cmakeCommandArgs": "-DWITH_LINK_TESTS:BOOL=OFF -DUSE_TEMP_FS:BOOL=OFF",
"cmakeCommandArgs": "-DWITH_LINK_TESTS:BOOL=ON -DUSE_TEMP_FS:BOOL=OFF",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "linux_x64" ],
"wslPath": "C:\\Users\\maxirmx\\AppData\\Local\\Microsoft\\WindowsApps\\ubuntu2004.exe"
"wslPath": "C:\\Users\\Maxim\\AppData\\Local\\Microsoft\\WindowsApps\\ubuntu2004.exe"
}
]
}

0 comments on commit 374e204

Please sign in to comment.