Browse Source

Use proper terminology for macros ("macros", not "tokens")

Alois Mahdal 6 years ago
parent
commit
ea2642d531
4 changed files with 28 additions and 28 deletions
  1. 3
    3
      README.md
  2. 16
    16
      src/include/build.sh
  3. 1
    1
      src/include/vars.sh.skel
  4. 8
    8
      src/stub

+ 3
- 3
README.md View File

42
     If you want to really build "serious" "big" stuff from hundreds of
42
     If you want to really build "serious" "big" stuff from hundreds of
43
     source files, MKit is probably not for you.  Nobody has ever tried
43
     source files, MKit is probably not for you.  Nobody has ever tried
44
     to use it that way.  What MKit understands as "building" is just
44
     to use it that way.  What MKit understands as "building" is just
45
-    replacing tokens in files.  (Some extensibility will  be added in
45
+    replacing macros in files.  (Some extensibility will  be added in
46
     future but scaling to huge things is not a priority for now.)
46
     future but scaling to huge things is not a priority for now.)
47
 
47
 
48
  *  Become a complete solution for building all your RPMs and DEBs.
48
  *  Become a complete solution for building all your RPMs and DEBs.
186
     `make debstuff` under your belt).  You can use `utils/mkit/stub` script
186
     `make debstuff` under your belt).  You can use `utils/mkit/stub` script
187
     for that.
187
     for that.
188
 
188
 
189
- *  Add tokens inside some of your scripts to include stuff known
189
+ *  Add macros inside some of your scripts to include stuff known
190
     only at install time (versions, paths...) so that your application
190
     only at install time (versions, paths...) so that your application
191
     can report --version as accurately as possible.
191
     can report --version as accurately as possible.
192
 
192
 
194
     and see how MKit handles versioning.
194
     and see how MKit handles versioning.
195
 
195
 
196
 MKit uses SemVer so version reflected in tarbal naming, packaging
196
 MKit uses SemVer so version reflected in tarbal naming, packaging
197
-files and tokens contains enough data to track it back to actual commit.
197
+files and macros contains enough data to track it back to actual commit.
198
 This way you can safely distribute packages immediately to your testers
198
 This way you can safely distribute packages immediately to your testers
199
 and/or CI systems.
199
 and/or CI systems.

+ 16
- 16
src/include/build.sh View File

26
     #
26
     #
27
     local ftype=$1      # file/builder type
27
     local ftype=$1      # file/builder type
28
     case $ftype in
28
     case $ftype in
29
-        MKIT_COMMON)    __expand_tokens "tokens" ;;
30
-        rpmstuff)       __expand_tokens "tokens" "rpmstuff:tokens" ;;
31
-        debstuff)       __expand_tokens "tokens" "debstuff:tokens" ;;
29
+        MKIT_COMMON)    __expand_macros "macros" ;;
30
+        rpmstuff)       __expand_macros "macros" "rpmstuff:macros" ;;
31
+        debstuff)       __expand_macros "macros" "debstuff:macros" ;;
32
         *)              die "unknown file type: $ftype" ;;
32
         *)              die "unknown file type: $ftype" ;;
33
     esac
33
     esac
34
 }
34
 }
35
 
35
 
36
-__expand_tokens() {
36
+__expand_macros() {
37
     #
37
     #
38
-    # Read stdin, expanding tokens from sections $@
38
+    # Read stdin, expanding macros from sections $@
39
     #
39
     #
40
     local script        # sed script cache
40
     local script        # sed script cache
41
-    local section       # each section to expand tokens from
42
-    local varname       # each token name
43
-    local varvalue      # each token value
41
+    local section       # each section to expand macros from
42
+    local varname       # each macro name
43
+    local varvalue      # each macro value
44
     script=$(mktemp --tmpdir mkit-tmp.XXXXXXXXXX)
44
     script=$(mktemp --tmpdir mkit-tmp.XXXXXXXXXX)
45
     {
45
     {
46
         for section in "$@"; do
46
         for section in "$@"; do
63
         echo "s|__MKIT_PROJ_VERSION__|$(__cached semver | __qfs)|g;"
63
         echo "s|__MKIT_PROJ_VERSION__|$(__cached semver | __qfs)|g;"
64
         echo "s|__MKIT_SELF_VERSION__|$MKIT_VERSION|g;"
64
         echo "s|__MKIT_SELF_VERSION__|$MKIT_VERSION|g;"
65
     } >> "$script"
65
     } >> "$script"
66
-    sed -f "$script" || die "__expand_tokens failed"
66
+    sed -f "$script" || die "__expand_macros failed"
67
     rm "$script"
67
     rm "$script"
68
 }
68
 }
69
 
69
 
141
 
141
 
142
 _mkit_data() {
142
 _mkit_data() {
143
     #
143
     #
144
-    # Build sampler showing all token values
144
+    # Build sampler showing all macro values
145
     #
145
     #
146
-    local token
146
+    local macro
147
     local section
147
     local section
148
     local sections
148
     local sections
149
     sections=()
149
     sections=()
150
-    ini lskeys tokens | grep -q . && sections=(tokens)
151
-    sections+=( $(ini lssect | grep ':tokens$') )
150
+    ini lskeys macros | grep -q . && sections=(macros)
151
+    sections+=( $(ini lssect | grep ':macros$') )
152
     {
152
     {
153
         echo "(builtin):"
153
         echo "(builtin):"
154
         echo "  x_MKIT_PROJ_NAME__ => '__MKIT_PROJ_NAME__'"
154
         echo "  x_MKIT_PROJ_NAME__ => '__MKIT_PROJ_NAME__'"
163
         echo "  x_MKIT_SELF_VERSION__ => '__MKIT_SELF_VERSION__'"
163
         echo "  x_MKIT_SELF_VERSION__ => '__MKIT_SELF_VERSION__'"
164
         for section in "${sections[@]}"; do
164
         for section in "${sections[@]}"; do
165
             echo "$section:"
165
             echo "$section:"
166
-            for token in $(ini lskeys "$section"); do
167
-                echo "  x${token:1} => '$token'"
166
+            for macro in $(ini lskeys "$section"); do
167
+                echo "  x${macro:1} => '$macro'"
168
             done
168
             done
169
         done
169
         done
170
     } \
170
     } \
171
-      | __expand_tokens "MKIT_BUILTIN" "${sections[@]}" \
171
+      | __expand_macros "MKIT_BUILTIN" "${sections[@]}" \
172
       | sed '/^  x/ s|x|_|'
172
       | sed '/^  x/ s|x|_|'
173
 }
173
 }
174
 
174
 

+ 1
- 1
src/include/vars.sh.skel View File

51
 #
51
 #
52
 # Package name
52
 # Package name
53
 #
53
 #
54
-# Used as base for tarball and in some default tokens.
54
+# Used as base for tarball and in some default macros.
55
 #
55
 #
56
 MKIT_PROJ_PKGNAME=""
56
 MKIT_PROJ_PKGNAME=""
57
 
57
 

+ 8
- 8
src/stub View File

82
                 remake_section dist
82
                 remake_section dist
83
                 remake_section ENV
83
                 remake_section ENV
84
                 remake_section roots
84
                 remake_section roots
85
-                remake_section tokens
85
+                remake_section macros
86
                 remake_section modes
86
                 remake_section modes
87
                 remake_section files
87
                 remake_section files
88
             else
88
             else
112
                     echo "doc = [ENV:PREFIX]/share/doc/$PackageName"
112
                     echo "doc = [ENV:PREFIX]/share/doc/$PackageName"
113
                 } | reformat_section
113
                 } | reformat_section
114
                 echo ""
114
                 echo ""
115
-                echo "[tokens]"
115
+                echo "[macros]"
116
                 {
116
                 {
117
                     echo "__${PackageName^^}_FOO__ = Barr.."
117
                     echo "__${PackageName^^}_FOO__ = Barr.."
118
                 } | reformat_section
118
                 } | reformat_section
258
             echo "    machine should be uder 'src'."
258
             echo "    machine should be uder 'src'."
259
             echo ""
259
             echo ""
260
             echo "    Note that during build time, files named ending with"
260
             echo "    Note that during build time, files named ending with"
261
-            echo "    '.skel' are subject to token expansion, see mkit.ini"
261
+            echo "    '.skel' are subject to macro expansion, see mkit.ini"
262
             echo "    section below for details."
262
             echo "    section below for details."
263
             echo ""
263
             echo ""
264
             echo " *  *notes* directory - here you shall store notes"
264
             echo " *  *notes* directory - here you shall store notes"
279
             echo " *  *packaging* directory contains templates that enable"
279
             echo " *  *packaging* directory contains templates that enable"
280
             echo "    MKit create raw stuffs used to create DEB or RPM"
280
             echo "    MKit create raw stuffs used to create DEB or RPM"
281
             echo "    packages.  Similar to '.skel' files in 'src', all files"
281
             echo "    packages.  Similar to '.skel' files in 'src', all files"
282
-            echo "    here are automatically considered for token expansion,"
282
+            echo "    here are automatically considered for macro expansion,"
283
             echo "    no matter how they are named (see mkit.ini section"
283
             echo "    no matter how they are named (see mkit.ini section"
284
             echo "    below)."
284
             echo "    below)."
285
             echo ""
285
             echo ""
382
             echo "    \`[modes]\` section is your friend.  Permissions here"
382
             echo "    \`[modes]\` section is your friend.  Permissions here"
383
             echo "    should be in UNIX octal format."
383
             echo "    should be in UNIX octal format."
384
             echo ""
384
             echo ""
385
-            echo " 5. Next, \`[tokens]\` section allows you to define own"
385
+            echo " 5. Next, \`[macros]\` section allows you to define own"
386
             echo "    placeholders that will be replaced when your scripts are"
386
             echo "    placeholders that will be replaced when your scripts are"
387
             echo "    built.  Each file in 'src' directory that is named with"
387
             echo "    built.  Each file in 'src' directory that is named with"
388
             echo "    '.skel' suffix, and each file from 'packaging' directory"
388
             echo "    '.skel' suffix, and each file from 'packaging' directory"
389
-            echo "    (no matter its name), can contain one or more of tokens"
390
-            echo "    defined here, plus range of tokens automatically defined"
391
-            echo "    by MKit.  During build, these tokens are replaced with"
389
+            echo "    (no matter its name), can contain one or more of macros"
390
+            echo "    defined here, plus range of macros automatically defined"
391
+            echo "    by MKit.  During build, these macros are replaced with"
392
             echo "    their actual values."
392
             echo "    their actual values."
393
             echo ""
393
             echo ""
394
             echo " 6. Less interesting, but important section is \`[dist]\`,"
394
             echo " 6. Less interesting, but important section is \`[dist]\`,"