Commit bbca8c1a035abb8788e27c802a50609c41807c39

Authored by Peter M. Groen
1 parent b0085648

Added comments to the script.

.gitignore
@@ -3,3 +3,4 @@ build/* @@ -3,3 +3,4 @@ build/*
3 CMakeLists.txt.user* 3 CMakeLists.txt.user*
4 cmake/ 4 cmake/
5 versioning/ 5 versioning/
  6 +/.gitmodules
CMakeLists.txt
1 cmake_minimum_required(VERSION 3.0) 1 cmake_minimum_required(VERSION 3.0)
  2 +project(osdev_mqtt)
2 # ============================================================================== 3 # ==============================================================================
3 # Check to see if we're a submodule or top-repo. 4 # Check to see if we're a submodule or top-repo.
4 if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cmake) 5 if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
@@ -32,6 +33,5 @@ add_subdirectory(src) @@ -32,6 +33,5 @@ add_subdirectory(src)
32 add_subdirectory(examples/pub) 33 add_subdirectory(examples/pub)
33 add_subdirectory(examples/sub) 34 add_subdirectory(examples/sub)
34 35
35 -  
36 -# include(packaging)  
37 -# package_component() 36 +include(packaging)
  37 +package_component()
scripts/setup_submodules
1 #!/bin/bash 1 #!/bin/bash
2 -# =================  
3 -# = Do not change.  
4 -# ================= 2 +
  3 +# ===============================================
  4 +# == Setting some environment variables
  5 +# ===============================================
5 GIT_URL_SUBS="http://gitlab.osdev.nl/open_source" 6 GIT_URL_SUBS="http://gitlab.osdev.nl/open_source"
6 -FUNC_RESULT="" 7 +FUNC_RESULT="-1"
7 8
  9 +# Name : print_usage_exit()
  10 +# Description : Print the way this script is intended to be used and exit.
  11 +# Parameters : None.
  12 +# Returns : err_code 1 to the Operating System
  13 +# --------------------------------------------------------------------------------------
8 function print_usage_exit() 14 function print_usage_exit()
9 { 15 {
10 echo "Usage $0 -i|--install|-u|--update" 16 echo "Usage $0 -i|--install|-u|--update"
@@ -14,6 +20,15 @@ function print_usage_exit() @@ -14,6 +20,15 @@ function print_usage_exit()
14 exit 1 20 exit 1
15 } 21 }
16 22
  23 +# Name : check_top_or_sub
  24 +# Description : Determine if we're running in a "single" lib-build or part of a
  25 +# "meta"-repository ( submodule ).
  26 +# Parameters : None
  27 +# Returns : Updates the value FUNC_RESULT.
  28 +# -1 - We're neither a git-repo or submodule.
  29 +# 0 - We're a submodule
  30 +# 1 - We're a top-repo ( Single library )
  31 +# --------------------------------------------------------------------------------------
17 function check_top_or_sub() 32 function check_top_or_sub()
18 { 33 {
19 # This function checks if we're the top-repository. 34 # This function checks if we're the top-repository.
@@ -29,12 +44,21 @@ function check_top_or_sub() @@ -29,12 +44,21 @@ function check_top_or_sub()
29 return 44 return
30 fi 45 fi
31 fi 46 fi
32 - FUNC_RESULT="0" 47 + FUNC_RESULT="-1"
33 return 48 return
34 } 49 }
35 50
  51 +# Name : check_working_dir
  52 +# Description : If we're in the top of our repo, we can run this script further.
  53 +# Parameters : None.
  54 +# Returns : Updates the value FUNC_RESULT.
  55 +# -1 - Not used.
  56 +# 0 - We're not on the top-level
  57 +# 1 - We're at the top-level. Good to go.
  58 +# --------------------------------------------------------------------------------------
36 function check_working_dir() 59 function check_working_dir()
37 { 60 {
  61 + FUNC_RESULT="-1"
38 # Check if we're in the top-level directory of our repository. 62 # Check if we're in the top-level directory of our repository.
39 if [ -f ./scripts/submodules.list ]; then 63 if [ -f ./scripts/submodules.list ]; then
40 # We're good to go 64 # We're good to go
@@ -45,27 +69,58 @@ function check_working_dir() @@ -45,27 +69,58 @@ function check_working_dir()
45 return 69 return
46 } 70 }
47 71
  72 +# Name : read_submodules
  73 +# Description : Read the list of submodules needed for this project
  74 +# Parameters : None
  75 +# Returns : Updates the value FUNC_RESULT
  76 +# 0 - Module list was not found
  77 +# 1 - Module list was found and read.
  78 +# --------------------------------------------------------------------------------------
48 function read_submodules() 79 function read_submodules()
49 { 80 {
  81 + FUNC_RESULT="-1"
50 if [ -e ./scripts/submodules.list ]; then 82 if [ -e ./scripts/submodules.list ]; then
51 source ./scripts/submodules.list 83 source ./scripts/submodules.list
  84 + FUNC_RESULT="1"
  85 + return
52 fi 86 fi
  87 +
  88 + echo "Submodules list not found...."
  89 + FUNC_RESULT="0"
  90 + return
53 } 91 }
54 92
  93 +# Name : add_submodules
  94 +# Description : Configure the repo to add the submodules.
  95 +# Parameters : None.
  96 +# Returns : None.
  97 +# --------------------------------------------------------------------------------------
55 function add_submodules() 98 function add_submodules()
56 { 99 {
  100 + echo -e "Adding SubModule(s)."
57 for SUB_MODULE in ${SUB_MODULES} 101 for SUB_MODULE in ${SUB_MODULES}
58 do 102 do
  103 + echo -e "< ${SUB_MODULE} >"
59 git submodule add -f ${GIT_URL_SUBS}/${SUB_MODULE}.git ${SUB_MODULE} 104 git submodule add -f ${GIT_URL_SUBS}/${SUB_MODULE}.git ${SUB_MODULE}
60 git config submodule.${SUB_MODULE}.url ${GIT_URL_SUBS}/${SUB_MODULE}.git 105 git config submodule.${SUB_MODULE}.url ${GIT_URL_SUBS}/${SUB_MODULE}.git
61 done 106 done
62 } 107 }
63 108
  109 +# Name : get_submodules
  110 +# Description : Actually get the submodules from gitlab and add them.
  111 +# Parameters : None
  112 +# Returns : None
  113 +# --------------------------------------------------------------------------------------
64 function get_submodules() 114 function get_submodules()
65 { 115 {
66 git submodule update --init --recursive 116 git submodule update --init --recursive
67 } 117 }
68 118
  119 +# Name : update_submodules
  120 +# Description : Update the submodules already added.
  121 +# Parameters : None
  122 +# Returns : None
  123 +# --------------------------------------------------------------------------------------
69 function update_submodules() 124 function update_submodules()
70 { 125 {
71 git submodule update --recursive 126 git submodule update --recursive