Commit 59367614038e300c56608403028a448eba2c4de3

Authored by Peter M. Groen
1 parent b5d9e433

Install script..

.gitignore
1 1 ./build/
  2 +./build/*
... ...
CMakeLists.txt
1 1 cmake_minimum_required(VERSION 3.0)
2 2 # ==============================================================================
3 3 # Check to see if we're a submodule or top-repo.
4   -message( STATUS "Current Directory : ${CMAKE_CURRENT_SOURCE_DIR}" )
5   -
6 4 if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
  5 + message( STATUS "Looks like we're a single module" )
7 6 LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
8 7 elseif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
  8 + message( STATUS "Looks like we're a submodule" )
9 9 LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
10 10 else()
11 11 message( FATAL_ERROR "No cmake directory found. Did you run the submodules script?" )
12 12 endif()
13 13  
14   -
  14 +# ==============================================================================
15 15 # Check to see if there is versioning information available
16 16 if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/osdev_versioning/cmake)
17 17 LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/osdev_versioning/cmake)
18   - include(osdevversion)
  18 +elseif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../osdev_versioning/cmake)
  19 + LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../osdev_versioning/cmake)
  20 +else()
  21 + message( FATAL_ERROR "No ${CURRENT_SOURCE_DIR}/osdev_versioning directory found. Did you run the submodules script?" )
19 22 endif()
20 23  
  24 +# ==============================================================================
  25 +# = Include build information
  26 +include(osdevversion)
21 27 include(projectheader)
  28 +
22 29 project_header(osdev_mqtt)
23 30  
24 31 add_subdirectory(src)
... ...
scripts/setup_submodules
1 1 #!/bin/bash
  2 +# =================
  3 +# = Do not chenge.
  4 +# =================
  5 +GIT_URL_SUBS="http://gitlab.osdev.nl/open_source"
  6 +TOP_REPO="-1"
2 7  
3 8 function print_usage_exit() {
4 9 echo "Usage $0 -i|--install|-u|--update"
... ... @@ -8,17 +13,41 @@ function print_usage_exit() {
8 13 exit 1
9 14 }
10 15  
  16 +function check_top_or_sub() {
  17 + # This function checks if we're the top-repository.
  18 + # In that case we need the submodules.. If we're already a submodule,
  19 + # we simply exit this script with a message
  20 + if [ -d ./.git ]; then
  21 + return 1
  22 + elif [ -d ../.git ]; then
  23 + if [ -f ../.submodules ]; then
  24 + echo "Seems like we're already a submodule. Nothing to do here."
  25 + return 0
  26 + fi
  27 + fi
  28 + return 0
  29 +}
  30 +
  31 +function check_working_dir() {
  32 + # Check if we're in the top-level directory of our repository.
  33 + if [ -f ./scripts/submodules.list ]; then
  34 + # We're good to go
  35 + return 1
  36 + fi
  37 + return 0
  38 +}
  39 +
11 40 function read_submodules() {
12   - if [ -e ./submodules.list ]; then
13   - source ./submodules.list
  41 + if [ -e ./scripts/submodules.list ]; then
  42 + source ./scripts/submodules.list
14 43 fi
15 44 }
16 45  
17 46 function add_submodules() {
18 47 for SUB_MODULE in ${SUB_MODULES}
19 48 do
20   - git submodule add -f git@gitlab.osdev.nl:OpenSystemsDevelopment/${SUB_MODULE} ${SUB_MODULE}
21   - git config submodule.${SUB_MODULE}.url git@gitlab.osdev.nl:OpenSystemsDevelopment/${SUB_MODULE}
  49 + git submodule add -f ${GIT_URL_SUBS}/${SUB_MODULE} ${SUB_MODULE}
  50 + git config submodule.${SUB_MODULE}.url ${GIT_URL_SUBS}/${SUB_MODULE}
22 51 done
23 52 }
24 53  
... ... @@ -33,6 +62,18 @@ function update_submodules() {
33 62 # =============================================================================
34 63 # == T H E M A I N E N T R Y O F T H I S S C R I P T ==
35 64 # =============================================================================
  65 +RESULT=check_top_or_sub()
  66 +if [ $RESULT -eq 0 ]; then
  67 + echo "Seems like we're a submodule already or not part of a repository."
  68 + exit 0
  69 +fi
  70 +
  71 +RESULT=check_working_dir()
  72 +if [ $RESULT -eq 0 ]; then
  73 + echo "Go to the top of this repository and type : scripts/setup_submodules [-i|--install]"
  74 + exit 0
  75 +fi
  76 +
36 77 read_submodules
37 78  
38 79 case "$1" in
... ...