Browse Source

Update MKit to v0.0.40

Alois Mahdal 2 months ago
parent
commit
a1e7491aab
5 changed files with 55 additions and 12 deletions
  1. 1
    1
      mkit.ini
  2. 28
    7
      utils/mkit/include/build.sh
  3. 22
    1
      utils/mkit/include/facts.sh
  4. 3
    2
      utils/mkit/include/release.sh
  5. 1
    1
      utils/mkit/include/vars.sh

+ 1
- 1
mkit.ini View File

@@ -30,4 +30,4 @@
30 30
 [files]
31 31
     bin = src/app dummy
32 32
 
33
-#mkit version=0.0.37
33
+#mkit version=0.0.40

+ 28
- 7
utils/mkit/include/build.sh View File

@@ -80,6 +80,7 @@ __expand_macros() {
80 80
     MacroMap[__MKIT_PROJ_MAINTAINER__]=$(ini 1value project:maintainer)
81 81
     MacroMap[__MKIT_PROJ_VCS_BROWSER__]=$(ini 1value project:vcs_browser)
82 82
     MacroMap[__MKIT_PROJ_GIT_LASTHASH__]=$(__cached git_lasthash)
83
+    MacroMap[__MKIT_PROJ_GIT_LASTSUMMARY__]=$(__cached git_lastsummary)
83 84
     MacroMap[__MKIT_PROJ_VERSION__]=$(__cached semver)
84 85
     for section in "$@"; do
85 86
         for mname in $(ini lskeys "$section"); do
@@ -161,7 +162,7 @@ __rec_built() {
161 162
     #
162 163
     local file=$1
163 164
     mkdir -p "$MKIT_LOCAL"
164
-    echo "$file" >> "$MKIT_LOCAL/built.lst"
165
+    echo "1:$file" >> "$MKIT_LOCAL/built.lst"
165 166
 }
166 167
 
167 168
 _mkit_data() {
@@ -185,6 +186,7 @@ _mkit_data() {
185 186
         echo "  x_MKIT_PROJ_MAINTAINER__ => '__MKIT_PROJ_MAINTAINER__'"
186 187
         echo "  x_MKIT_PROJ_VCS_BROWSER__ => '__MKIT_PROJ_VCS_BROWSER__'"
187 188
         echo "  x_MKIT_PROJ_GIT_LASTHASH__ => '__MKIT_PROJ_GIT_LASTHASH__'"
189
+        echo "  x_MKIT_PROJ_GIT_LASTSUMMARY__ => '__MKIT_PROJ_GIT_LASTSUMMARY__'"
188 190
         echo "  x_MKIT_PROJ_VERSION__ => '__MKIT_PROJ_VERSION__'"
189 191
         for section in "${sections[@]}"; do
190 192
             echo "$section:"
@@ -212,12 +214,31 @@ clean() {
212 214
     #
213 215
     # Clean up tree after building
214 216
     #
215
-    test -f "$MKIT_LOCAL/built.lst" && {
216
-        <"$MKIT_LOCAL/built.lst" grep -v -e '\.\.' -e ^/ \
217
-          | xargs -r rm -rf
218
-        rm -f "$MKIT_LOCAL/built.lst"
219
-        rmdir --ignore-fail-on-non-empty "$MKIT_LOCAL"
220
-    }
217
+    local path
218
+    local line
219
+    local depth
220
+    test -f "$MKIT_LOCAL/built.lst" || return 0
221
+    {
222
+        cat "$MKIT_LOCAL/built.lst"
223
+        echo "1:$MKIT_LOCAL/built.lst"
224
+        echo "1:$MKIT_LOCAL"
225
+    } \
226
+      | grep -v -e '\.\.' -e ^/ -e '^~' \
227
+      | while IFS=: read -r depth path; do
228
+            test -e "$path" || continue
229
+            case $depth in
230
+                1)  warn "removing: $path"
231
+                    test -d "$path" \
232
+                     && rmdir -p --ignore-fail-on-non-empty "$path"
233
+                    test -f "$path" && rm "$path"
234
+                    ;;
235
+                r)  warn "removing recursively: $path"
236
+                    rm -r "$path"
237
+                    ;;
238
+                *)  warn "invalid built.lst format!"
239
+                    ;;
240
+            esac
241
+        done
221 242
     true
222 243
 }
223 244
 

+ 22
- 1
utils/mkit/include/facts.sh View File

@@ -103,6 +103,27 @@ git_lasthash() {
103 103
     git_bool dirty && echo -n ".dirty"
104 104
 }
105 105
 
106
+git_lastsummary() {
107
+    #
108
+    # Show last commit summary
109
+    #
110
+    # We can't do it outside git repo (or without git) but we should
111
+    # not be asked to; targets that don't require git should make use
112
+    # of cache built by dist target.
113
+    #
114
+    git_present || {
115
+        echo UNKNOWN_SUMMARY
116
+        warn "no git present; could not determine last summary"
117
+        return 3
118
+    }
119
+    git_bool dirty && {
120
+        echo "(index is dirty)"
121
+        return
122
+    }
123
+    git log -1 --format=oneline HEAD \
124
+      | cut -d' ' -f2-
125
+}
126
+
106 127
 semver() {
107 128
     #
108 129
     # Build proper SemVer version string
@@ -171,7 +192,7 @@ semver() {
171 192
     if ! git describe --tags --exact-match HEAD >&/dev/null;
172 193
     then    # we are at a later commit than the last tag
173 194
         is_tagged=F
174
-        brname=$(git_fact current_branch)
195
+        brname=$(git_fact current_branch | sed 's/[^[:alnum:]]/_/g')
175 196
         ghash=$(git_fact latest_sha)
176 197
     fi
177 198
     git_bool dirty && is_dirty=T

+ 3
- 2
utils/mkit/include/release.sh View File

@@ -154,7 +154,7 @@ __vbump() {
154 154
     git add mkit.ini \
155 155
       || die "failed to add mkit.ini to the index"
156 156
     cache=$(mktemp -t "mkit._vbump_gitmsg.XXXXXXXX")
157
-    _vbump_gitmsg > "$cache"
157
+    _vbump_gitmsg "$nextver" > "$cache"
158 158
     git commit -e -F "$cache"   # note: reading from stdin will break vim
159 159
     rm "$cache"
160 160
 }
@@ -163,7 +163,8 @@ _vbump_gitmsg() {
163 163
     #
164 164
     # Compose git message template for 'Bump version' commit
165 165
     #
166
-    echo "Bump version"
166
+    local nextver=$1
167
+    echo "Bump version to $nextver"
167 168
     echo ""
168 169
     echo "Overview of changes:"
169 170
     echo ""

+ 1
- 1
utils/mkit/include/vars.sh View File

@@ -86,4 +86,4 @@ MKIT_TSTAMP=${MKIT_TSTAMP:-ctime}
86 86
 #
87 87
 # This MKit version
88 88
 #
89
-MKIT_VERSION=0.0.37
89
+MKIT_VERSION=0.0.40