Skip to content
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
15 changes: 15 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
build --action_env=CMAKE_PREFIX_PATH
build --action_env=CMAKE_LIBRARY_PATH
build --action_env=CMAKE_INCLUDE_PATH
build --action_env=NIX_CFLAGS_COMPILE
build --action_env=NIX_LDFLAGS
build --action_env=PKG_CONFIG_PATH
build --action_env=NIX_CC_WRAPPER_x86_64_unknown_linux_gnu_TARGET_HOST
# for Python
build --action_env=PYTHONPATH

# get more ccache hits
build --action_env=CCACHE_NOHASHDIR=true
build --action_env=CCACHE_SLOPPINESS=file_macro,time_macros

try-import %workspace%/user.bazelrc
77 changes: 77 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
on: [push, pull_request]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build_upstream:
name: CentOS 7 upstream (Bazel)
runs-on: ubuntu-latest
container: 'quay.io/jdanek/cli-cpp_centos7_upstream'
steps:
- uses: actions/checkout@v2

- name: Prepare ccache timestamp
id: ccache_cache_timestamp
shell: cmake -P {0}
run: |
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
message("::set-output name=timestamp::${current_date}")

- uses: actions/cache@v2
with:
path: "/.cache"
key: bazel-${{ steps.ccache_cache_timestamp.outputs.timestamp }}
restore-keys: bazel

- run: mkdir -p /.cache
- run: echo "build --disk_cache=/.cache" >> .bazelrc
shell: bash

- run: bazelisk build //:cli-cpp --//:deps=upstream

build_bazel:
name: CentOS 7 EPEL (Bazel)
runs-on: ubuntu-latest
container: 'quay.io/jdanek/cli-cpp_centos7_epel'
steps:
- uses: actions/checkout@v2

- run: bazelisk build //:cli-cpp --//:deps=rpms

build_cmake:
name: ${{ matrix.container }} (CMake)
runs-on: ubuntu-latest
container: ${{ matrix.container }}
strategy:
fail-fast: false
matrix:
# checkout action node is broken on 'quay.io/jdanek/cli-cpp_centos6x_epel'
container: ['quay.io/jdanek/cli-cpp_centos7_epel', 'quay.io/jdanek/cli-cpp_fedora31_epel']
steps:
- uses: actions/checkout@v2

- name: Create Build Environment
working-directory: ${{runner.workspace}}
run: cmake -E make_directory build

- name: Configure CMake
shell: bash
working-directory: ${{runner.workspace}}/build
# 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.
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE

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

- name: Test
working-directory: ${{runner.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
139 changes: 139 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
load("@rules_foreign_cc//tools/build_defs:cmake.bzl", "cmake_external")

# TODO

# configuration: source of packages either download github, local checkout (can modify source), or rpms (present in standard paths)
# ccache on or off
# smart setting of CCACHE_BASEDIR is needed
# lib64

#build ints
# python2 -m pip install --user setuptools
# sudo swupd bundle-add devpkg-nspr

# switch to ninja

cmake_external(
name = "qpid-proton",
cache_entries = {
"CMAKE_C_COMPILER_LAUNCHER": "ccache",
"CMAKE_CXX_COMPILER_LAUNCHER": "ccache",
"CMAKE_CXX_COMPILER": "g++",

#"BUILD_BINDINGS": "OFF",
"BUILD_BINDINGS": "cpp",
"BUILD_TESTING": "OFF",
# these are optional by default, CMake would skip them if not found
"SASL_IMPL": "cyrus",
"SSL_IMPL": "openssl",
"PROACTOR": "epoll",
# normalize expectations (cmake_external expects ubuntu)
#"LIB_INSTALL_DIR": "lib",
#"LIB_SUFFIX": "",
},
lib_source = "@qpid-proton//:all",
out_lib_dir = "lib64",

make_commands = [
"make -j8",
"make install"
],

shared_libraries = ["libqpid-proton-core.so", "libqpid-proton.so"],
#shared_libraries = ["libqpid-proton-core.so", "libqpid-proton.so", "libqpid-proton-cpp.so"],
)


cmake_external(
name = "qpid-cpp",
cache_entries = {
"CMAKE_C_COMPILER_LAUNCHER": "ccache",
"CMAKE_CXX_COMPILER_LAUNCHER": "ccache",
"CMAKE_CXX_COMPILER": "g++",

"BUILD_AMQP": "ON",
"BUILD_SASL": "ON",
"BUILD_SSL": "ON",
# disable as much as we can
"BUILD_BINDING_PERL": "OFF",
"BUILD_BINDING_PYTHON": "OFF",
"BUILD_BINDING_DOTNET": "OFF",
"BUILD_BINDING_RUBY": "OFF",
"BUILD_TESTING": "OFF",
"BUILD_XML": "OFF",
"BUILD_DOCS": "OFF",
"BUILD_PROBES": "OFF",
"BUILD_LEGACYSTORE": "OFF",
"BUILD_LINEARSTORE": "OFF",
"BUILD_HA": "OFF",
"BUILD_RDMA": "OFF",
"BUILD_MSSQL": "OFF",
"BUILD_MSCLFS": "OFF",
"INSTALL_QMFGEN": "OFF",

"EXT_BUILD_DEPS": "$EXT_BUILD_DEPS",
"Proton_DIR": "$EXT_BUILD_DEPS/qpid-proton/lib64/cmake/Proton",
},
lib_source = "@qpid-cpp//:all",
make_commands = [
"make -j8",
"make install"
],

out_lib_dir = "lib64",
shared_libraries = ["libqpidclient.so", "libqpidcommon.so", "libqpidtypes.so", "libqpidmessaging.so"],

deps = [":qpid-proton"],
)

#filegroup(name = "sources", srcs = glob(["othersrc/**"]), visibility = ["//visibility:public"])
filegroup(name = "sources", srcs = glob(["CMakeLists.txt", "src/**", "dist/**", "*.cmake"]), visibility = ["//visibility:public"])
#filegroup(name = "sources", srcs = glob(["**"], exclude=["bazel-*", "bazel-*/**", ".bazelrc"]), visibility = ["//visibility:public"])

cmake_external(
name = "cli-cpp",
cache_entries = {
"CMAKE_CXX_COMPILER": "g++",

"EXT_BUILD_DEPS": "$EXT_BUILD_DEPS",
"Qpid_DIR": "$EXT_BUILD_DEPS/qpid-cpp/lib64/cmake/Qpid",
"Proton_DIR": "$EXT_BUILD_DEPS/qpid-proton/lib64/cmake/Proton",
"ProtonCpp_DIR": "$EXT_BUILD_DEPS/qpid-proton/lib64/cmake/ProtonCpp",
},
lib_source = "sources",

make_commands = [
"make -j8",
"make install"
],

binaries = ["aac3_receiver"],
working_directory = "..",

deps = select({
":deps_upstream": [":qpid-cpp", ":qpid-proton"],
":deps_rpms": [],
}),
)

# This file uses the above definitions to define two custom build settings.
load("//:build_settings.bzl", "string_flag")

string_flag(
name = "deps",
build_setting_default = "upstream",
)

config_setting(
name = "deps_upstream",
flag_values = {
"//:deps": "upstream"
}
)

config_setting(
name = "deps_rpms",
flag_values = {
"//:deps": "rpms"
}
)
44 changes: 44 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Build instructions

## Two ways to build

This project can be built either with CMake, or with CMake executed by Bazel.

### Bazel command line

Bazel is used to also build the dependencies, qpid-cpp and qpid-proton.

bazelisk build //:cli-cpp --//:deps=upstream

You can tell Bazel not to build these dependencies, and they will be then picked by CMake from system location.

bazelisk build //:cli-cpp --//:deps=rpms

When building with ccache, add the following

--sandbox_writable_path=$HOME/.ccache

### CMake build

If you want to use the dependencies built by Bazel in your CMake build, do this.

mkdir ext_build_deps
ln -s `pwd`/bazel-bin/copy_*/*/lib64/cmake/*/*.cmake ext_build_deps/
ln -s `pwd`/bazel-bin/copy_*/* ext_build_deps/
cmake -DCMAKE_PREFIX_PATH=`pwd`/cmake_module_path -DEXT_BUILD_DEPS=`pwd`/cmake_module_path

### Flags for libraries

See `BUILD.bazel` for qpid-cpp and qpid-proton flags.
The idea is to build as little as possible.

## Design considerations

It makes sense to build cli-cpp with libs from RPM, libs from upstream, or local checkout.

Further, it makes sense to mix and match tools such as ninja, make, ccache.

Next, the Debug/Release build should be selected as needed.

Bazel can provide caching of build actions, and it can be used both in CI or locally.

Loading