cisco

Home Shitty cloud provider
Log | Files | Refs | Submodules | git clone https://git.ne02ptzero.me/git/cisco

commit 54e7de1cdc80ef68d03be5518ed627162d05336a
parent 808ef09d926fa46d2fdbfee7acbd4808bab44733
Author: Louis Solofrizzo <louis@ne02ptzero.me>
Date:   Sat, 30 Mar 2019 15:16:31 +0100

CMake: Add definitions and main CMake

Signed-off-by: Louis Solofrizzo <louis@ne02ptzero.me>

Diffstat:
A.gitmodules | 3+++
MCMakeLists.txt | 17+++++++++++++++++
Acontrib/lxc/src | 1+
Adefs/ansible/CMakeLists.txt | 45+++++++++++++++++++++++++++++++++++++++++++++
Mdefs/go/CMakeLists.txt | 42++++++++++++++++++++++++++++++++++++++++--
5 files changed, 106 insertions(+), 2 deletions(-)

diff --git a/.gitmodules b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "contrib/lxc/src"] + path = contrib/lxc/src + url = https://github.com/lxc/lxc.git diff --git a/CMakeLists.txt b/CMakeLists.txt @@ -23,8 +23,25 @@ endif () # Compilation Settings #### add_subdirectory(defs/go) +add_subdirectory(defs/ansible) + +#### +# External contributions +#### +add_subdirectory(contrib) #### # Software #### add_subdirectory(api) +add_subdirectory(slave) + +#### +# Deployment +#### +add_subdirectory(deploy) + +add_custom_target( + cisco + DEPENDS lf-cloud-api lf-slave lf-slave-arm +) diff --git a/contrib/lxc/src b/contrib/lxc/src @@ -0,0 +1 @@ +Subproject commit ae6497d0c0c3e8fcb44e473352be4554cce457bb diff --git a/defs/ansible/CMakeLists.txt b/defs/ansible/CMakeLists.txt @@ -0,0 +1,45 @@ +macro(generate_deploy_targets_ansible NAME TYPE) + if (DEPLOY_TYPE STREQUAL ${TYPE}) + add_custom_target( + deploy-${NAME} + DEPENDS deploy-${NAME}-${TYPE} + ) + add_custom_target( + deploy-${NAME}-hosts + DEPENDS deploy-${NAME}-${TYPE}-hosts + ) + endif() + + add_custom_target( + deploy-${NAME}-${TYPE} + COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --cyan "Deploying ${NAME} to ${TYPE} cluster..." && + cd ${CMAKE_CURRENT_SOURCE_DIR}/${TYPE} && + BIN_DIR=${CMAKE_BINARY_DIR} ANSIBLE_NOCOWS=1 ANSIBLE_HOST_KEY_CHECKING=False SRC_DIR=${CMAKE_SOURCE_DIR} + ansible-playbook deploy.yml -i ${CMAKE_SOURCE_DIR}/scripts/dyn.py + DEPENDS ${NAME} + ) + + add_custom_target( + deploy-${NAME}-${TYPE}-hosts + COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR}/${TYPE} && + SRC_DIR=${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/scripts/dyn.py --hosts >> /etc/hosts + ) + + add_test( + NAME deploy-${NAME}-${TYPE}-test + COMMAND /bin/bash -c "BIN_DIR=${CMAKE_BINARY_DIR} ANSIBLE_NOCOWS=1 ANSIBLE_HOST_KEY_CHECKING=False SRC_DIR=${CMAKE_SOURCE_DIR} ansible-playbook deploy.yml -i ${CMAKE_SOURCE_DIR}/scripts/dyn.py --check" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${TYPE} + ) +endmacro(generate_deploy_targets_ansible) + +macro(generate_deploy_playbook_ansible NAME TYPE PLAYBOOK) + add_custom_target( + deploy-${NAME}-${TYPE}-${PLAYBOOK} + COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --cyan "Deploying ${NAME} to ${TYPE} cluster..." && + cd ${CMAKE_CURRENT_SOURCE_DIR}/${TYPE} && + BIN_DIR=${CMAKE_BINARY_DIR} ANSIBLE_NOCOWS=1 ANSIBLE_HOST_KEY_CHECKING=False SRC_DIR=${CMAKE_SOURCE_DIR} + ansible-playbook ../${PLAYBOOK}.yml -i ${CMAKE_SOURCE_DIR}/scripts/dyn.py + DEPENDS ${NAME} + ) + +endmacro(generate_deploy_playbook_ansible) diff --git a/defs/go/CMakeLists.txt b/defs/go/CMakeLists.txt @@ -17,13 +17,51 @@ function(add_go_component NAME) ${GO_SRC} COMMAND export GOPATH=${GOPATH} && export GO111MODULE=on && - export GOMOD=${CMAKE_SOURCE_DIR}/.go.mod && + export GOARCH=amd64 && /usr/bin/env bash -c - "go build -o ${CMAKE_CURRENT_BINARY_DIR}/${NAME} ${CMAKE_GO_FLAGS} ${GO_SRC}" + "go build --tags \"libsqlite3\" -o ${CMAKE_CURRENT_BINARY_DIR}/${NAME} ${CMAKE_GO_FLAGS} ${GO_SRC}" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) endfunction(add_go_component) +function(add_arm_go_component NAME) + add_custom_target(${NAME} ALL) + + # GoPath settings + set(GOPATH "${CMAKE_BINARY_DIR}/go") + file(MAKE_DIRECTORY ${GOPATH}) + + # Add sources + foreach(DEP ${ARGN}) + set(GO_SRC "${GO_SRC} ${CMAKE_CURRENT_LIST_DIR}/${DEP}") + endforeach() + + add_custom_command( + TARGET ${NAME} + DEPENDS + ${GO_SRC} + COMMAND + export GOPATH=${GOPATH}-arm && export GO111MODULE=on && + export CGO_ENABLED=1 && + export CC=${_armgcc_bin} && + export CXX=${_armgcc_cxx_bin} && + export PKG_CONFIG_PATH=${PKG_CONFIG_PATH} && + export CGO_LDFLAGS="${CGO_LDFLAGS};-static" && + export CGO_CFLAGS_ALLOW=${CGO_CFLAGS_ALLOW} && + export CGO_CFLAGS="${CGO_CFLAGS};" && + export GOARCH=arm && + export GOOS=linux && + /usr/bin/env bash -c + "go build --tags \"libsqlite3\" -ldflags '-linkmode external -extldflags \"-static\"' -o ${CMAKE_CURRENT_BINARY_DIR}/${NAME} ${CMAKE_GO_FLAGS} ${GO_SRC}" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + + add_dependencies( + ${NAME} + armgcc + ) +endfunction(add_arm_go_component) + function(add_go_test NAME) if (WITH_TESTS STREQUAL "ON") add_test(NAME ${NAME} COMMAND go test -v WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})