cargo-make 0.37.16

Rust task runner and build tool.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
# cargo-make

[![crates.io](https://img.shields.io/crates/v/cargo-make.svg)](https://crates.io/crates/cargo-make)
[![CI](https://github.com/sagiegurari/cargo-make/workflows/CI/badge.svg?branch=master)](https://github.com/sagiegurari/cargo-make/actions)
[![codecov](https://codecov.io/gh/sagiegurari/cargo-make/branch/master/graph/badge.svg)](https://codecov.io/gh/sagiegurari/cargo-make)
[![license](https://img.shields.io/crates/l/cargo-make.svg)](https://github.com/sagiegurari/cargo-make/blob/master/LICENSE)
[![Crates.io](https://img.shields.io/crates/d/cargo-make?label=cargo%20installs)](https://crates.io/crates/cargo-make)
[![GitHub All Releases](https://img.shields.io/github/downloads/sagiegurari/cargo-make/total?label=binary%20downloads)](https://github.com/sagiegurari/cargo-make/releases)
[![Built with cargo-make](https://sagiegurari.github.io/cargo-make/assets/badges/cargo-make.svg)](https://sagiegurari.github.io/cargo-make)

> [Rust]https://www.rust-lang.org/ task runner and build tool.

* [Overview]#overview
* [Installation]#installation
    * [Arch Linux]#installation-arch-linux
    * [Binary Release]#installation-binary-release
* [Usage]#usage
    * [Simple Example]#usage-simple
    * [Tasks, Dependencies, and Aliases]#usage-task-dependencies-alias
    * [Commands, Scripts, and Sub Tasks]#usage-task-command-script-task
        * [Sub Task]#usage-task-command-script-task-examplesubtask
        * [Command]#usage-task-command-script-task-examplecommand
        * [Script]#usage-task-command-script-task-examplescript
        * [Duckscript]#usage-task-command-script-task-exampleduckscript
        * [Rust Code]#usage-task-command-script-task-examplerust
        * [Cross Platform Shell]#usage-task-command-script-task-exampleshell2batch
        * [Other Programming Languages]#usage-task-command-script-task-examplegeneric
        * [Shebang Support]#usage-task-command-script-task-exampleshebang
    * [Default Tasks and Extending]#usage-default-tasks
        * [Extending External Makefiles]#usage-workspace-extending-external-makefile
        * [Automatically Extend Workspace Makefile]#usage-workspace-extend
        * [Load Scripts]#usage-load-scripts
        * [Predefined Makefiles]#usage-predefined-makefiles
        * [The Default Task]#usage-default-task
    * [Extending Tasks]#usage-extending-tasks
        * [Task Override]#usage-task-override
        * [Platform Override]#usage-platform-override
        * [Extend Attribute]#usage-task-extend-attribute
    * [Environment Variables]#usage-env
        * [Declaration]#env-declaration
        * [Global Configuration]#usage-env-config
        * [Task]#usage-env-task
        * [Command Line]#usage-env-cli
        * [Env File]#usage-env-file
        * [Env Setup Scripts]#usage-env-setup-scripts
        * [Loading Order]#usage-env-vars-loading-order
        * [Note about Ordering]#env-note-about-ordering
        * [Global]#usage-env-global
    * [Setting Up Working Directory]#usage-setting-up-working-directory
    * [Ignoring Errors]#usage-ignoring-errors
    * [Conditions]#usage-conditions
        * [Criteria]#usage-conditions-structure
        * [Scripts]#usage-conditions-script
        * [And/Or/Group Or]#usage-conditions-and-or
        * [Combining Conditions and Sub Tasks]#usage-conditions-and-subtasks
        * [Running Tasks Only If Sources Changed]#usage-running-tasks-only-if-sources-changed
    * [Installing Dependencies]#usage-installing-dependencies
        * [Cargo Plugins]#usage-installing-cargo-plugins
        * [Crates]#usage-installing-crates
        * [Rustup Components]#usage-installing-rustup-components
        * [Native Dependencies]#usage-installing-native-dependencies
        * [Defining Version]#usage-installing-version
        * [Global Lock Of Versions]#usage-installing-locked
        * [Alternate Cargo Install Commands]#usage-installing-alternate-cargo-install-commands
        * [Installation Priorities]#usage-installing-dependencies-priorities
        * [Multiple Installations]#usage-installing-dependencies-multiple
    * [Workspace Support]#usage-workspace-support
        * [Disabling Workspace Support]#usage-workspace-disabling-workspace-support
        * [Composite Flow]#usage-workspace-composite-flow
        * [Profiles]#usage-workspace-profiles
        * [Skipping/Including Specific Members]#usage-workspace-support-skip-include-members
        * [Workspace Emulation]#usage-workspace-emulation
    * [Toolchain]#usage-toolchain
    * [Init and End tasks]#usage-init-end-tasks
    * [Catching Errors]#usage-catching-errors
    * [Cargo Alias Tasks]#usage-cargo-alias-tasks
    * [Profiles]#usage-profiles
        * [Environment Variables]#usage-profiles-env
        * [Conditions]#usage-profiles-conditions
        * [Built In Profiles]#usage-profiles-built-in
    * [Private Tasks]#usage-private-tasks
    * [Deprecated Tasks]#usage-deprecated-tasks
    * [Watch]#usage-watch
        * [Running Multiple Blocking Watches]#usage-watch-running-multiple-blocking-watches
    * [Functions]#usage-functions
        * [Split]#usage-functions-split
        * [GetAt]#usage-functions-getat
        * [Remove Empty]#usage-functions-remove-empty
        * [Trim]#usage-functions-trim
        * [Decode]#usage-functions-decode
    * [Continuous Integration]#usage-ci
        * [Github Actions]#usage-ci-github-actions
        * [Travis]#usage-ci-travis
        * [AppVeyor]#usage-ci-appveyor
        * [GitLab]#usage-ci-gitlab
        * [CircleCI]#usage-ci-circleci
        * [Azure Pipelines]#usage-ci-azure-pipelines
        * [drone.io]#usage-ci-drone-io
        * [Cirrus CI]#usage-ci-cirrus
    * [Predefined Flows]#usage-predefined-flows
        * [Coverage]#usage-predefined-flows-coverage
        * [Full List]https://github.com/sagiegurari/cargo-make/blob/master/docs/cargo_make_task_list.md
        * [Disabling Predefined Tasks/Flows]#usage-predefined-flows-disable
        * [Modifying Predefined Tasks/Flows]#usage-predefined-flows-modify
    * [Minimal Version]#usage-min-version
    * [Performance Tuning]#usage-performance-tuning
    * [Command Groups (Subcommands)]#usage-command-groups
    * [Diff Changes]#usage-diff-changes
    * [Unstable Features]#usage-unstable-features
    * [CLI Options]#usage-cli
    * [Plugins]#usage-plugins
        * [Defining Plugins]#usage-plugins-defining-plugins
        * [Plugin SDK]#usage-plugins-plugin-sdk
        * [Plugin Example - Docker Integration]#usage-plugins-plugin-example-dockerize
        * [Plugin Example - Run workspace members in parallel]#usage-plugins-plugin-example-parallel-workspace-members
        * [Plugin Example - load Env From Rust Script]#usage-plugins-plugin-example-rustenv
        * [Plugin Example - Adding Simpler Windows Powershell Support]#usage-plugins-plugin-example-powershell
    * [Shell Completion]#usage-shell-completion
        * [Bash]#usage-shell-completion-bash
        * [zsh]#usage-shell-completion-zsh
        * [Fig / Amazon CodeWhisperer for command line]#usage-shell-completion-fig
    * [Global Configuration]#cargo-make-global-config
* [Makefile Definition]#descriptor-definition
* [Task Naming Conventions]#task-name-conventions
* [Articles]#articles
    * [Introduction and Basics]https://medium.com/@sagiegurari/automating-your-rust-workflows-with-cargo-make-part-1-of-5-introduction-and-basics-b19ced7e7057
    * [Extending Tasks, Platform Overrides, and Aliases]https://medium.com/@sagiegurari/automating-your-rust-workflows-with-cargo-make-part-2-of-5-extending-tasks-platform-overrides-1527386dcf87
    * [Environment Variables, Conditions, Sub Tasks, and Mixing]https://medium.com/@sagiegurari/automating-your-rust-workflows-with-cargo-make-part-3-of-5-environment-variables-conditions-3c740a837a01
    * [Workspace Support, Init/End Tasks, and Makefiles]https://medium.com/@sagiegurari/automating-your-rust-workflows-with-cargo-make-part-4-of-5-workspace-support-init-end-tasks-c3e738699421
    * [Predefined Tasks, CI Support, and Conventions]https://medium.com/@sagiegurari/automating-your-rust-workflows-with-cargo-make-part-5-final-predefined-tasks-ci-support-and-4594812e57da
* [Badge]#badge
* [Roadmap]#roadmap
* [Editor Support]#editor-support
    * [vim]#editor-support-vim
    * [vs-code]#editor-support-vs-code
* [Contributing].github/CONTRIBUTING.md
* [Release History]https://github.com/sagiegurari/cargo-make/blob/master/CHANGELOG.md
* [License]#license

<a name="overview"></a>
## Overview
The cargo-make task runner enables to define and configure sets of tasks and run them as a flow.<br>
A task is a command, script, rust code, or other sub tasks to execute.<br>
Tasks can have dependencies which are also tasks that will be executed before the task itself.<br>
With a simple toml based configuration file, you can define a multi platform build script that can run build, test, generate documentation, run bench tests, run security validations and more, executed by running a single command.

<a name="installation"></a>
## Installation
In order to install, just run the following command

```sh
cargo install --force cargo-make
```

This will install cargo-make in your `~/.cargo/bin`.<br>
Make sure to add `~/.cargo/bin` directory to your `PATH` variable.<br>
<br>
You will have two executables available: *`cargo-make`* and *`makers`*<br>

* **cargo-make** - This is a cargo plugin invoked using **cargo make ...**
* **makers** - A standalone executable which provides same features and cli arguments as cargo-make, but is invoked directly and not as a cargo plugin.

See [Cli Options](#usage-cli) section for full CLI instructions.

In order to install with minimal features (for example, no TLS support), run the following:

```sh
cargo install --no-default-features --force cargo-make
```

<a name="installation-arch-linux"></a>
### Arch Linux

```sh
sudo pacman -S cargo-make
```

<a name="installation-binary-release"></a>
### Binary Release
Binary releases are available in the [github releases page](https://github.com/sagiegurari/cargo-make/releases).<br>
The following binaries are available for each release:

* x86_64-unknown-linux-gnu
* x86_64-unknown-linux-musl
* x86_64-apple-darwin
* x86_64-pc-windows-msvc
* aarch64-apple-darwin

<a name="usage"></a>
## Usage
When using cargo-make, all tasks are defined and configured via toml files.<br>
Below are simple instructions to get you started off quickly.

<a name="usage-simple"></a>
### Simple Example
In order to run a set of tasks, you first must define them in a toml file.<br>
For example, if we would like to have a script which:

* Formats the code
* Cleans old target directory
* Runs build
* Runs tests

By default, cargo-make reads tasks from `Makefile.toml` if it exists.

We will create a `Makefile.toml` file as follows:

```toml
[tasks.format]
install_crate = "rustfmt"
command = "cargo"
args = ["fmt", "--", "--emit=files"]

[tasks.clean]
command = "cargo"
args = ["clean"]

[tasks.build]
command = "cargo"
args = ["build"]
dependencies = ["clean"]

[tasks.test]
command = "cargo"
args = ["test"]
dependencies = ["clean"]

[tasks.my-flow]
dependencies = [
    "format",
    "build",
    "test"
]
```

We would execute the flow with the following command:

```sh
cargo make my-flow
```

The output would look something like this:

```console
[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: my-flow
[cargo-make] INFO - Setting Up Env.
[cargo-make] INFO - Running Task: format
[cargo-make] INFO - Execute Command: "cargo" "fmt" "--" "--emit=files"
[cargo-make] INFO - Running Task: clean
[cargo-make] INFO - Execute Command: "cargo" "clean"
[cargo-make] INFO - Running Task: build
[cargo-make] INFO - Execute Command: "cargo" "build"
   Compiling bitflags v0.9.1
   Compiling unicode-width v0.1.4
   Compiling quote v0.3.15
   Compiling unicode-segmentation v1.1.0
   Compiling strsim v0.6.0
   Compiling libc v0.2.24
   Compiling serde v1.0.8
   Compiling vec_map v0.8.0
   Compiling ansi_term v0.9.0
   Compiling unicode-xid v0.0.4
   Compiling synom v0.11.3
   Compiling rand v0.3.15
   Compiling term_size v0.3.0
   Compiling atty v0.2.2
   Compiling syn v0.11.11
   Compiling textwrap v0.6.0
   Compiling clap v2.25.0
   Compiling serde_derive_internals v0.15.1
   Compiling toml v0.4.2
   Compiling serde_derive v1.0.8
   Compiling cargo-make v0.1.2 (file:///home/ubuntu/workspace)
    Finished dev [unoptimized + debuginfo] target(s) in 79.75 secs
[cargo-make] INFO - Running Task: test
[cargo-make] INFO - Execute Command: "cargo" "test"
   Compiling cargo-make v0.1.2 (file:///home/ubuntu/workspace)
    Finished dev [unoptimized + debuginfo] target(s) in 5.1 secs
     Running target/debug/deps/cargo_make-d5f8d30d73043ede

running 10 tests
test log::tests::create_info ... ok
test log::tests::get_level_error ... ok
test log::tests::create_verbose ... ok
test log::tests::get_level_info ... ok
test log::tests::get_level_other ... ok
test log::tests::get_level_verbose ... ok
test installer::tests::is_crate_installed_false ... ok
test installer::tests::is_crate_installed_true ... ok
test command::tests::validate_exit_code_error ... ok
test log::tests::create_error ... ok

test result: ok. 10 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

[cargo-make] INFO - Running Task: my-flow
[cargo-make] INFO - Build done in 72 seconds.
```

We now created a build script that can run on any platform.

The tasks can be stored in any toml file.  Invoke cargo-make with `--makefile other-filename.toml`
to start processing using `other-filename.toml`.

**cargo-make can be invoked as a cargo plugin via `cargo make` command, _or_ as a standalone executable via `makers` command.**<br>
<br>
**Important Note: if you are running this example in a cargo workspace, you will need to add the following to the top of the file:**<br>

```toml
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
```
**More on workspace support in the relevant sections in this document.**

<a name="usage-task-dependencies-alias"></a>
### Tasks, Dependencies, and Aliases
In many cases, certain tasks depend on other tasks.<br>
For example you would like to format the code before running build and run the build before running tests.<br>
Such flow can be defined as follows:

```toml
[tasks.format]
install_crate = "rustfmt"
command = "cargo"
args = ["fmt", "--", "--emit=files"]

[tasks.build]
command = "cargo"
args = ["build"]
dependencies = ["format"]

[tasks.test]
command = "cargo"
args = ["test"]
dependencies = ["build"]
```

When you run:

```sh
cargo make --makefile ./my_build.toml test
```

It will try to run test, see that it has dependencies and those have other dependencies.<br>
Therefore it will create an execution plan for the tasks based on the tasks and their dependencies.<br>
In our case it will invoke format -> build -> test.<br>

The same task will never be executed twice. So, if we have, for example:

```toml
[tasks.A]
dependencies = ["B", "C"]

[tasks.B]
dependencies = ["D"]

[tasks.C]
dependencies = ["D"]

[tasks.D]
script = "echo hello"
```

In this example, A depends on B and C, and both B and C are dependent on D.<br>
Task D, however, will not be invoked twice.<br>
The output of the execution will look something like this:

```console
[cargo-make] INFO - Task: A
[cargo-make] INFO - Setting Up Env.
[cargo-make] INFO - Running Task: D
[cargo-make] INFO - Execute Command: "sh" "/tmp/cargo-make/CNuU47tIix.sh"
hello
[cargo-make] INFO - Running Task: B
[cargo-make] INFO - Running Task: C
[cargo-make] INFO - Running Task: A
```

As you can see, 'hello' was printed once by task D as it was only invoked once.<br>
But what if we want to run D twice?<br>
Simple answer would be to duplicate task D, have B depend on D, and C depend on D2, which is a copy of D.<br>
But duplicating can lead to bugs and to huge makefiles, so we have aliases for that.<br>
An alias task has its own name and points to another task.<br>
All of the definitions of the alias task are ignored.<br>
So now, if we want to have D execute twice, we can do the following:

```toml
[tasks.A]
dependencies = ["B", "C"]

[tasks.B]
dependencies = ["D"]

[tasks.C]
dependencies = ["D2"]

[tasks.D]
script = "echo hello"

[tasks.D2]
alias="D"
```

Now C depends on D2, and D2 is an alias for D.<br>
Execution output of such make file would like as follows:

```console
[cargo-make] INFO - Task: A
[cargo-make] INFO - Setting Up Env.
[cargo-make] INFO - Running Task: D
[cargo-make] INFO - Execute Command: "sh" "/tmp/cargo-make/HP0UD7pgoX.sh"
hello
[cargo-make] INFO - Running Task: B
[cargo-make] INFO - Running Task: D2
[cargo-make] INFO - Execute Command: "sh" "/tmp/cargo-make/TuuZJkqCE2.sh"
hello
[cargo-make] INFO - Running Task: C
[cargo-make] INFO - Running Task: A
```

Now you can see that 'hello' was printed twice.

Tasks may also depend on tasks in other files.
To do this, specify the dependency with the object format, providing the path.
cargo-make will use this path as it would any other supplied on the command line:
If a filename is supplied, it searches that file.
Otherwise it search for the default `Makefile.toml` on that path.

```toml
[tasks.install]
command = "mv"
args = ["src/B/out", "src/C/static"]
dependencies = [
  { name = "compile", path = "src/B" },
  { name = "clean", path = "src/C/tasks.toml" },
]
```

*The run_task attribute will tell a task to invoke another task in a new execution plan. This will also result in dependencies being invoked multiple times.*

It is also possible to define platform specific aliases, for example:

```toml
[tasks.my_task]
linux_alias = "linux_my_task"
windows_alias = "windows_my_task"
mac_alias = "mac_my_task"

[tasks.linux_my_task]

[tasks.mac_my_task]

[tasks.windows_my_task]
```

If platform specific alias is found and matches current platform it will take precedence over the non platform alias definition.<br>
For example:

```toml
[tasks.my_task]
linux_alias = "run"
alias = "do_nothing"

[tasks.run]
script = "echo hello"

[tasks.do_nothing]
```

If you run task **my_task** on windows or mac, it will invoke the **do_nothing** task.<br>
However, if executed on a linux platform, it will invoke the **run** task.

*As a side note, cargo-make will attempt to invoke the task dependencies in the order that they were defined, unless they are defined also as sub dependencies.*

<a name="usage-task-command-script-task"></a>
### Commands, Scripts, and Sub Tasks
The actual operation that a task invokes can be defined in 3 ways.<br>
The below explains each one:

* **run_task** - Invokes another task with the name defined in this attribute. Unlike dependencies which are invoked before the current task, the task defined in the **run_task** is invoked after the current task.
* **command** - The command attribute defines what executable to invoke. You can use the **args** attribute to define what command line arguments to provide as part of the command.
* **script** - Invokes the script. You can change the executable used to invoke the script using the **script_runner** attribute. If not defined, the default platform runner is used (`cmd` for Windows, `sh` for others).

Only one of the definitions will be used.<br>
If multiple attributes are defined (for example both command and script), the task will fail during invocation.

The script attribute may hold non OS scripts, for example rust code to be compiled and executed.<br>
In order to use non OS script runners, you must define the special script_runner with the **@** prefix.<br>
The following runners are currently supported:

* **@duckscript** - Executes the defined duckscript code. See [example]#usage-task-command-script-task-exampleduckscript
* **@rust** - Compiles and executes the defined rust code. See [example]#usage-task-command-script-task-examplerust
* **@shell** - For Windows platforms, it will try to convert the shell commands to Windows batch commands (only basic scripts are supported) and execute the script; for other platforms, the script will be executed as-is. See [example]#usage-task-command-script-task-exampleshell2batch

Below are some basic examples of each action type.

<a name="usage-task-command-script-task-examplesubtask"></a>
#### Sub Task
In this example, if we execute the **flow** task, it will invoke the **echo** task defined in the **run_task** attribute.

```toml
[tasks.echo]
script = "echo hello world"

[tasks.flow]
run_task = "echo"
```

A more complex example below demonstrates the ability to define multiple task names and optional conditions attached to each task.<br>
The **first** task for which the conditions are met (or if no conditions are defined at all), will be invoked.<br>
If no task conditions are met, no sub task will be invoked.<br>
More on conditions can be found the [conditions section](#usage-conditions)

```toml
[tasks.test1]
command = "echo"
args = ["running test1"]

[tasks.test2]
command = "echo"
args = ["running test2"]

[tasks.test3]
command = "echo"
args = ["running test3"]

[tasks.test-default]
command = "echo"
args = ["running test-default"]

[tasks.test-routing]
run_task = [
    { name = "test1", condition = { platforms = ["windows", "linux"], channels = ["beta", "stable"] } },
    { name = "test2", condition = { platforms = ["mac"], rust_version = { min = "1.20.0", max = "1.30.0" } } },
    { name = "test3", condition_script = [ "somecommand" ] },
    { name = "test-default" }
]
```

It is also possible to run the sub task as a forked sub process using the **fork** attribute.<br>
This prevents any environment changes done in the sub task to impact the rest of the flow in the parent process.<br>
Example of invoking the sub task in a forked sub process:

```toml
[tasks.echo]
command = "echo"
args = ["hello world"]

[tasks.fork-example]
run_task = { name = "echo", fork = true }
```

The **name** attribute can hold either a single task name or a list of tasks.<br>
In case of a list, the tasks would be invoked one after the other in sequence.<br>
For example, below **simple-multi** and **routing-multi** both demonstrate different ways to define multi task invocations via **run_task**:

```toml
[tasks.echo1]
command = "echo"
args = ["1"]

[tasks.echo2]
command = "echo"
args = ["2"]

[tasks.simple-multi]
run_task = { name = ["echo1", "echo2"] }

[tasks.routing-multi]
run_task = [
    { name = ["echo1", "echo2"] },
]
```

You can also setup a **cleanup** task to run after the sub task even if the sub task failed.<br>
This is only supported in combination with **fork=true** attribute.<br>
For example:<br>

```toml
[tasks.echo1]
command = "echo"
args = ["1"]

[tasks.echo2]
command = "echo"
args = ["2"]

[tasks.fail]
script =  "exit 1"

[tasks.cleanup]
command = "echo"
args = ["cleanup"]

[tasks.cleanup-example]
run_task = { name = ["echo1", "echo2", "fail"], fork = true, cleanup_task = "cleanup" }
```

In order to run multiple tasks in parallel, add **parallel = true** to the `run_task` object.<br>
For example:

```toml
[tasks.echo1]
command = "echo"
args = ["1"]

[tasks.echo2]
command = "echo"
args = ["2"]

[tasks.parallel-multi]
run_task = { name = ["echo1", "echo2"], parallel = true }
```

This allows to run independent tasks in parallel and speed up the overall performance of the flow.<br>
Be aware that parallel invocation of tasks will cause issues if the following feature are used:

* Setting the task's current working directory via **cwd** attribute will result in all parallel tasks being affected.
* Avoid using **`CARGO_MAKE_CURRENT_TASK_`** type environment variables as those may hold incorrect values.

In addition, in some scenarios, child processes may be left as zombie processes.<br>
It is possible to setup a manual cleanup task to resolve it.

<a name="usage-task-command-script-task-examplecommand"></a>
#### Command
When running commands, you can also define the command line arguments, as shown in the example below, to invoke the cargo command with the plugin name as a command line argument:

```toml
[tasks.build-with-verbose]
command = "cargo"
args = ["build", "--verbose", "--all-features"]
```

It is possible to provide environment variables as part of the command and arguments to be replaced in runtime with actual values, for example:

```toml
[env]
SIMPLE = "SIMPLE VALUE"
ECHO_CMD = "echo"

[tasks.expand]
command = "${ECHO_CMD}"
args = [
    "VALUE: ${SIMPLE}"
]
```

cargo-make CLI also supports additional arguments which will be available to all tasks.<br>
The following example prints additional arguments:

```toml
[tasks.varargs]
command = "echo"
args = [
    "args are:", "${@}"
]
```

*For native scripts, use that native script syntax.*<br>
*For shell you can use ```${0}``` and for windows: ```%*```*

Invoking cargo-make with additional arguments would result in the following:

```console
> cargo make varargs arg1 arg2 arg3

[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: varargs
[cargo-make] INFO - Setting Up Env.
[cargo-make] INFO - Running Task: init
[cargo-make] INFO - Running Task: varargs
[cargo-make] INFO - Execute Command: "echo" "args are:" "arg1" "arg2" "arg3"
args are: arg1 arg2 arg3
[cargo-make] INFO - Running Task: end
[cargo-make] INFO - Build Done  in 0 seconds.
```

Invoking cargo-make without any additional arguments would result in the following:

```console
> cargo make varargs

[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: varargs
[cargo-make] INFO - Setting Up Env.
[cargo-make] INFO - Running Task: init
[cargo-make] INFO - Running Task: varargs
[cargo-make] INFO - Execute Command: "echo" "args are:"
args are:
[cargo-make] INFO - Running Task: end
[cargo-make] INFO - Build Done  in 0 seconds.
```

This can also be used for templating, for example:

```toml
[tasks.varargs]
command = "echo"
args = [
    "args are:", "-o=${@}"
]
```

Would output:

```console
> cargo make varargs arg1 arg2 arg3

[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: varargs
[cargo-make] INFO - Setting Up Env.
[cargo-make] INFO - Running Task: init
[cargo-make] INFO - Running Task: varargs
[cargo-make] INFO - Execute Command: "echo" "args are:" "arg1" "arg2" "arg3"
args are: -o=arg1 -o=arg2 -o=arg3
[cargo-make] INFO - Running Task: end
[cargo-make] INFO - Build Done  in 0 seconds.
```

Command line arguments can also contain [built-in functions](#usage-functions) (see below).

<a name="usage-task-command-script-task-examplescript"></a>
#### Script
Below is simple script which prints hello world.

```toml
[tasks.hello-world]
script = [
    "echo start...",
    "echo \"Hello World From Script\"",
    "echo end..."
]
```

You can use multi-line toml string to make the script more readable as follows:

```toml
[tasks.hello-world]
script = '''
echo start...
echo "Hello World From Script"
echo end...
'''
```

cargo-make CLI also supports additional arguments which will be available to all tasks.<br>
The following example prints additional arguments:

```toml
[tasks.cli-args]
script = "echo args are: ${@}"
```

Invoking cargo-make with additional arguments would result in the following:

```console
> cargo make cli-args arg1 arg2 arg3

[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: cli-args
[cargo-make] INFO - Setting Up Env.
[cargo-make] INFO - Running Task: init
[cargo-make] INFO - Running Task: cli-args
+ cd /projects/rust/cargo-make/examples
+ echo args are: arg1 arg2 arg3
args are: arg1 arg2 arg3
[cargo-make] INFO - Running Task: end
```

Invoking cargo-make without any additional arguments would result in the following:

```console
> cargo make cli-args

[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: cli-args
[cargo-make] INFO - Setting Up Env.
[cargo-make] INFO - Running Task: init
[cargo-make] INFO - Running Task: cli-args
+ cd /projects/rust/cargo-make/examples
+ echo args are:
args are:
[cargo-make] INFO - Running Task: end
[cargo-make] INFO - Build Done  in 0 seconds.
```

It is also possible to point to an existing script (instead of holding the script text inside the makefile) by using the **file** property as follows:

```toml
[tasks.hello-world-from-script-file]
script = { file = "script.sh" }
```

Script file paths are always relative to the current working directory, unless specified by the **absolute_path** attribute. For example:

```toml
[tasks.hello-world-from-script-file-absolute-path]
script = { file = "${CARGO_MAKE_WORKING_DIRECTORY}/script.sh", absolute_path = true }
```

File paths support environment substitution.<br><br>
**Favor commands over scripts, as commands support more features such as [automatic dependencies installation](#usage-installing-dependencies), [argument functions](#usage-functions), and more...**

In order to share common script content among multiple tasks, you can use the script pre/main/post form as follows:

```toml
[tasks.base-script]
script.pre = "echo start"
script.main = "echo old"
script.post = "echo end"

[tasks.extended-script]
extend = "base-script"
script.main = "echo new"
```

Running extended-script task would print:

```console
start
new
end
```

<a name="usage-task-command-script-task-exampleduckscript"></a>
#### Duckscript
[Duckscript](https://sagiegurari.github.io/duckscript/) is incredibly simple shell like language which provides cross platform shell scripting capability.<br>
[Duckscript](https://sagiegurari.github.io/duckscript/) is embedded inside cargo-make so unlike other scripting solutions or commands, duckscript can change cargo-make environment variables from inside the script.<br>
In addition you can run cargo-make tasks from within duckscript script.<br>
This allows a really powerful two way integration with cargo-make.

```toml
[tasks.duckscript-example]
script_runner = "@duckscript"
script = '''
task_name = get_env CARGO_MAKE_CURRENT_TASK_NAME
echo The currently running cargo make task is: ${task_name}

# since all env vars are auto loaded as duckscript variables by cargo-make
# you can access them directly
echo The currently running cargo make task is: ${CARGO_MAKE_CURRENT_TASK_NAME}

cd .. # this changes cargo-make current working directory (cargo-make will revert to original directory after script execution)
pwd
set_env CARGO_MAKE_CURRENT_TASK_NAME tricking_cargo_make
'''
```

The next example shows how to invoke cargo-make tasks from duckscript:

```toml
[tasks.run-task-from-duckscript]
script_runner = "@duckscript"
script = '''
echo first invocation of echo1 task:
cm_run_task echo1
echo second invocation of echo1 task:
cm_run_task echo1

echo running task: echo2:
cm_run_task echo2
'''

[tasks.echo1]
command = "echo"
args = ["1"]

[tasks.echo2]
command = "echo"
args = ["2"]
```

Same as OS scripts, the @duckscript runner also supports the cargo-make CLI arguments access.<br>
In addition, all environment variables are preloaded as duckscript variables, and can be directly read from the script. (No need to invoke the **get_env** command!)

<a name="usage-task-command-script-task-examplerust"></a>
#### Rust Code
In this example, when the **rust** task is invoked, the **script** content will be compiled and executed.
You can see how dependencies are defined in `Cargo.toml` format inside the code.

```toml
[tasks.rust]
script_runner = "@rust"
script = '''
//! ```cargo
//! [dependencies]
//! envmnt = "*"
//! ```
fn main() {
    let value = envmnt::get_or("PATH", "NO PATH VAR DEFINED");
    println!("Path Value: {}", &value);
}
'''
```

Same as OS scripts, the @rust runner also supports the cargo-make CLI arguments access.<br>
There are several different rust script runners currently available:

* [rust-script]https://crates.io/crates/rust-script
* [cargo-script]https://crates.io/crates/cargo-script
* [cargo-play]https://crates.io/crates/cargo-play

By default, rust-script is used, however this can be changed via environment variable **`CARGO_MAKE_RUST_SCRIPT_PROVIDER`** which should hold the crate name.<br>
This enables to define a different runner for each task by setting it in the **env** block of the specific tasks.<br>
For example:

```toml
[tasks.rust-script]
env = { "CARGO_MAKE_RUST_SCRIPT_PROVIDER" = "rust-script" }
script_runner = "@rust"
script = '''
fn main() {
    println!("test");
}
'''

[tasks.cargo-script]
env = { "CARGO_MAKE_RUST_SCRIPT_PROVIDER" = "cargo-script" }
script_runner = "@rust"
script = '''
fn main() {
    println!("test");
}
'''

[tasks.cargo-play]
env = { "CARGO_MAKE_RUST_SCRIPT_PROVIDER" = "cargo-play" }
script_runner = "@rust"
script = '''
fn main() {
    println!("test");
}
'''
```

Keep in mind that dependencies used by the rust script are defined differently for each runner.<br>
Please see the specific crate docs for learn more.

<a name="usage-task-command-script-task-exampleshell2batch"></a>
#### Cross Platform Shell
In this example, when the **shell** task is invoked, the **script** content will be automatically converted to Windows batch commands (when running on a Windows platform) and invoked.

```toml
[tasks.shell]
script_runner = "@shell"
script = '''
rm ./myfile.txt
'''
```

Same as OS scripts, the @shell runner also supports the cargo-make CLI arguments access.<br>
<br>
See [shell2batch](https://github.com/sagiegurari/shell2batch) project for complete set of features.

<a name="usage-task-command-script-task-examplegeneric"></a>
#### Other Programming Languages
cargo-make can also run scripts written in various scripting languages such as Python, Perl, Ruby, Javascript, and more...<br>
Any runner which takes the form of **command file** (for example **`python ./program.py`**) is supported.

Below are few examples:

```toml
[tasks.python]
script_runner = "python"
script_extension = "py"
script = '''
print("Hello, World!")
'''

[tasks.perl]
script_runner = "perl"
script_extension = "pl"
script = '''
print "Hello, World!\n";
'''

[tasks.javascript]
script_runner = "node"
script_extension = "js"
script = '''
console.log('Hello, World!');
'''

[tasks.php]
script_runner = "php"
script_extension = "php"
script = '''
<?php
echo "Hello, World!\n";
'''

[tasks.powershell]
script_runner = "powershell"
script_extension = "ps1"
script = '''
Write-Host "Hello, World!"
'''
```

In case you need to provider the script runner arguments before the script file, you can use the **script_runner_args** attribute.<br>
For example:

```toml
[tasks.php-with-args]
script_runner = "php"
script_runner_args = ["-f"]
script_extension = "php"
script = '''
<?php
echo "Hello, World!\n";
'''
```

*script_runner_args requires script_extension defined as well.*

<a name="usage-task-command-script-task-exampleshebang"></a>
#### Shebang Support
Instead of defining custom runners via **script_runner** attribute, it's possible to define it in the script shebang line.

In case of Windows, make sure not to use a runner which doesn't have the **#** character defined as comment (for example, `cmd.exe` does not!), which would lead to an error.

Example task using bash:

```toml
[tasks.shebang-sh]
script = '''
#!/usr/bin/env bash
echo hello
'''
```

Output:

```console
> cargo make --cwd ./examples --makefile ./shebang.toml shebang-sh
[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: ./shebang.toml
[cargo-make] INFO - Task: shebang-sh
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Setting Up Env.
[cargo-make] INFO - Running Task: init
[cargo-make] INFO - Running Task: shebang-sh
[cargo-make] INFO - Execute Command: "/usr/bin/env" "bash" "/tmp/cargo-make/cJf6XEXrL9.sh"
hello
[cargo-make] INFO - Running Task: end
[cargo-make] INFO - Build Done  in 0 seconds.
```

Example task using Python:

```toml
[tasks.shebang-python]
script = '''
#!/usr/bin/env python3
print("Hello, World!")
'''
```

Output:

```console
> cargo make --cwd ./examples --makefile ./shebang.toml shebang-python
[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: ./shebang.toml
[cargo-make] INFO - Task: shebang-python
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Setting Up Env.
[cargo-make] INFO - Running Task: init
[cargo-make] INFO - Running Task: shebang-python
[cargo-make] INFO - Execute Command: "/usr/bin/env" "python3" "/tmp/cargo-make/Wy3QMJiQaS.sh"
Hello, World!
[cargo-make] INFO - Running Task: end
[cargo-make] INFO - Build Done  in 0 seconds.
```

Another trick you can do with shebangs is to define one of the special runners like @duckscript as follows:

```toml
[tasks.duckscript-shebang-example]
script = '''
#!@duckscript
echo Running duckscript without runner attribute.
'''
```

However that language must support comments starting with the **#** character.

<a name="usage-default-tasks"></a>
### Default Tasks and Extending
There is no real need to define some of the basic **build**, **test**, ... tasks that were shown in the previous examples.<br>
cargo-make comes with a built-in toml file that will serve as a base for every execution.<br>
The **optional** external toml file that is provided while running cargo-make will only extend and add or overwrite
tasks that are defined in the [default makefiles](https://github.com/sagiegurari/cargo-make/blob/master/src/lib/descriptor/makefiles/).<br>

Let's take the built-in **build** task, defined in the default toml:

```toml
[tasks.build]
description = "Runs the rust compiler."
category = "Build"
command = "cargo"
args = ["build", "--all-features"]
```

If for example, you would like to add verbose output to it and remove the **--all-features** flag, you would just need to change the args and add the --verbose as follows:

```toml
[tasks.build]
args = ["build", "--verbose"]
```

If you want to disable some existing task (will also disable its dependencies), you can do it as follows:

```toml
[tasks.build]
disabled = true
```

There is no need to redefine existing properties of the task, only what needs to be added or overwritten.<br>
The default toml file comes with many steps and flows already built-in, so it is worth it to check it out first.<br>

In case you do want to delete all of the original task attributes in your extended task, you can use the **clear** attribute as follows:

```toml
[tasks.sometask]
clear = true
command = "echo"
args = [
    "extended task"
]
```

You can also extend additional external files from your external makefile by using the **extend** attribute, for example:

```toml
extend = "my_common_makefile.toml"
```

The file path in the **extend** attribute is always relative to the current toml file you are in, not to the process working directory.

The extend attribute can be very useful when you have a workspace with a `Makefile.toml` that contains all of the common custom tasks and in each project you can have a simple `Makefile.toml` which just has
the extend attribute pointing to the workspace makefile.

<a name="usage-workspace-extending-external-makefile"></a>
#### Extending External Makefiles
In order for a makefile to extend additional external files from your external file by using the extend attribute, for example:

```toml
extend = "my_common_makefile.toml"
```

The file path in the extend attribute is always relative to the current toml file you are in and not to the process working directory.<br>
The makefile pointed to in the extend attribute must exist or the build will fail.

In order to define optional extending makefiles, you will need to pass the optional flag in addition to the path as follows:

```toml
extend = { path = "does_not_exist_makefile.toml", optional = true }
```

You can also define a list of makefiles to extend from.<br>
All will be loaded in the order you define.<br>
For example:

```toml
extend = [ { path = "must_have_makefile.toml" }, { path = "optional_makefile.toml", optional = true }, { path = "another_must_have_makefile.toml" } ]
```

<a name="usage-workspace-extend"></a>
#### Automatically Extend Workspace Makefile
When running cargo make for modules which are part of a workspace, you can automatically have the member crates makefile (even if doesn't exist) extend the workspace level makefile.

The workspace level makefile **env** section must contain the following environment variable (you can also set it via CLI).

```toml
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
```

This allows you to maintaining a single makefile for the entire workspace but having access to those custom tasks in every member crate.
<br>
**This is only relevant for workspace builds which are triggered in the workspace root.<br>
Flows that start directly in the member crate, must manually extend the workspace level makefile using the extend keyword.**

<a name="usage-load-scripts"></a>
#### Load Scripts
In more complex scenarios, you may want multiple unrelated projects to share some common custom tasks. For example, you may wish to notify some internal company server of the build status.<br>
Instead of redefining those tasks in each project, you can create a single toml file with those definitions and have all projects extend that file.<br>
However, this “extend” functionality only knows to find the such files in the local file system. So, in order to pull some common toml from a remote server, (using `http` or `git clone` and so on...), you can use the load scripts.

Load scripts are defined in the config section using the **load_script** attribute and are invoked **before** the extend attribute is evaluated.<br>
This allows you to first pull the toml file from the remote server and put it in a location defined by the extend attribute.

Here is an example of a load script which downloads the common toml from a remote server using HTTP:

```toml
[config]
load_script = "wget -O /home/myuser/common.toml companyserver.com/common.toml"
```

Here is an example of pulling the common toml file from some git repo:

```toml
[config]
load_script = "git clone git@mygitserver:user/project.git /home/myuser/common"
```

You can run any command or set of commands you want. Therefore, you can build a more complex flow of how and from where to fetch the common toml file, and where to put it.<br>
If needed, you can override the load_script per platform using the **linux_load_script**, **windows_load_script** and **mac_load_script** attributes.

<a name="usage-predefined-makefiles"></a>
#### Predefined Makefiles

While cargo-make comes with many built in tasks, defined in the [default makefiles](https://github.com/sagiegurari/cargo-make/blob/master/src/lib/descriptor/makefiles/), they are not always relevant for every project.<br>
The [cargo-make-tasks](https://github.com/sagiegurari/cargo-make-tasks/) repository holds a collection of additional makefiles that can be loaded and provide replacement tasks for the built in cargo-make tasks.<br>
For example the cmake.toml provides cmake related tasks for projects using cmake.

See the [cargo-make-tasks](https://github.com/sagiegurari/cargo-make-tasks/) repository for more information and usage examples.

<a name="usage-default-task"></a>
#### The Default Task

When invoking the cargo make command without a task name, the default task is invoked.<br>
The default task is actually an alias to another task defined as follows:

```toml
[tasks.default]
alias = "dev-test-flow"
```

There are multiple ways to define the default task differently, for example:

* Alias to another task in your custom makefile

```toml
[tasks.default]
alias = "my-custom-task"
```

* Clear the alias and define the task actions

```toml
[tasks.default]
clear = true # clears the alias
command = "echo"
args = ["custom!!!"]
```

<a name="usage-extending-tasks"></a>
### Extending Tasks

There are multiple ways of extending tasks in the same or from extended makefiles.

* [Task Override](#usage-task-override)
* [Platform Override](#usage-platform-override)
* [Extend Attribute](#usage-task-extend-attribute)

<a name="usage-task-override"></a>
#### Task Override
cargo-make comes with many predefined tasks and flows that can be used without redefining them in your project.<br>
However in some cases, you would like to change them a bit to fit your needs without rewriting the entire task.<br>
Let's take, for example, the **build** task which is predefined internally inside cargo-make as follows:

```toml
[tasks.build]
description = "Runs the rust compiler."
category = "Build"
command = "cargo"
args = ["build", "--all-features"]
```

If you do not want to use the **--all-features** mode, you can just change the args of the task in your external `Makefile.toml` as follows:

```toml
[tasks.build]
args = ["build"]
```

When cargo-make starts up, it will load the external `Makefile.toml` and the internal makefile definitions and will merge them.<br>
Since the external file overrides the internal definitions, only the args attribute for the **build** task which was redefined,
will override the args attribute which was defined internally, and the actual result would be:

```toml
[tasks.build]
description = "Runs the rust compiler."
category = "Build"
command = "cargo"
args = ["build"]
```

The same process can be used to override tasks from other makefiles loaded using the extend keyword from [Extending External Makefiles](#usage-workspace-extending-external-makefile) section.

<a name="usage-platform-override"></a>
#### Platform Override
If you want to override a task (or specific attributes in a task) for specific platforms, you can define an override task with the platform name (currently Linux, Windows, and macOS) under the specific task.<br>
For example:

```toml
[tasks.hello-world]
script = '''
echo "Hello World From Unknown"
'''

[tasks.hello-world.linux]
script = '''
echo "Hello World From Linux"
'''
```

If you run cargo make with task 'hello-world' on Linux, it would redirect to hello-world.linux while on other platforms it will execute the original hello-world.<br>
In Linux the output would be:

```console
[cargo-make] INFO - Task: hello-world
[cargo-make] INFO - Setting Up Env.
[cargo-make] INFO - Running Task: hello-world
[cargo-make] INFO - Execute Command: "sh" "/tmp/cargo-make/kOUJfw8Vfc.sh"
Hello World From Linux
[cargo-make] INFO - Build done in 0 seconds.
```

While on other platforms it would output:

```console
[cargo-make] INFO - Task: hello-world
[cargo-make] INFO - Setting Up Env.
[cargo-make] INFO - Running Task: hello-world
[cargo-make] INFO - Execute Command: "sh" "/tmp/cargo-make/2gYnulOJLP.sh"
Hello World From Unknown
[cargo-make] INFO - Build done in 0 seconds.
```

In the override task, you can define any attribute that will override the attribute of the parent task, while undefined attributes will use the value from the parent task and will not be modified.<br>
If you need to delete attributes from the parent (for example, you have a command defined in the parent task, but you want to have a script defined in the override task), then you will
have to clear the parent task in the override task using the clear attribute as follows:

```toml
[tasks.hello-world.linux]
clear = true
script = '''
echo "Hello World From Linux"
'''
```

This means, however, that you will have to redefine all attributes in the override task that you want to carry with you from the parent task.<br>
**Important: alias comes before checking override task, so if the parent task has an alias, it will be redirected to that task instead of the override.**<br>
**To have an alias redirect per-platform, use the linux_alias, windows_alias, mac_alias attributes.**<br>
**In addition, aliases cannot be defined in platform override tasks, only in parent tasks.**

<a name="usage-task-extend-attribute"></a>
#### Extend Attribute
Until now, the override capability enabled to override the task with the same name from different makefile or in different platforms.<br>
However, the **extend** keyword is also available on the task level and enables you to override any task by name.<br>
Let's look at the following example:

```toml
[tasks.1]
category = "1"
description = "1"
command = "echo"
args = ["1"]

[tasks.2]
extend = "1"
category = "2"
args = ["2"]

[tasks.3]
extend = "2"
args = ["3"]
```

When task **3** is loaded, it loads task **2** which loads task **1**.<br>
The final task **3** definition would be:

```toml
[tasks.3]
extend = "2"
category = "2"
description = "1"
command = "echo"
args = ["3"]
```

We run task **3** the output would be:

```console
[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: task_extend.toml
[cargo-make] INFO - Task: 3
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: init
[cargo-make] INFO - Running Task: 3
[cargo-make] INFO - Execute Command: "echo" "3"
3
[cargo-make] INFO - Running Task: end
[cargo-make] INFO - Build Done  in 0 seconds.
```


<a name="usage-env"></a>
### Environment Variables
`cargo-make` enabled the definition of environment variables in several ways, which can later be accessed throughout task execution.

Because environment variables play a significant role in `cargo-make`, it provides multiple declarative ways to provide them at different levels of granularity.

* [Declaration](#env-declaration)
* [Global Configuration](#usage-env-config)
* [Task](#usage-env-task)
* [Command Line](#usage-env-cli)
* [Env File](#usage-env-file)
* [Env Setup Scripts](#usage-env-setup-scripts)
* [Loading Order](#usage-env-vars-loading-order)
* [Note about Ordering](#env-note-about-ordering)
* [Global](#usage-env-global)

<a name="env-declaration"></a>
#### Declaration

There are multiple ways to declare environment variables, all of which are suited for specific suitcases.

##### Simple

The most ordinary one is the definition of a simple `KEY=Value` pair, which is reminiscent of tools like [dotenv](https://www.npmjs.com/package/dotenv) and [bash scripts](https://www.gnu.org/software/bash/). Values can use other variables as values, which are interpolated at runtime, using the `${variable}` syntax.

```toml
STRING = "value"
RUST_BACKTRACE = 1
BOOL_VALUE = true
COMPOSITE = "${BOOL_VALUE} ${RUST_BACKTRACE}"
```

##### List

`cargo-make` also supports lists, which are joined using `;` at runtime.

```toml
LIST_VALUE = [ "VALUE1", "VALUE2", "VALUE3" ]
```

##### Script

`cargo-make` supports the use of simple scripts. The output of the said script will then determine the value of the environment variable.

The script's object has two additional arguments: `multiline` and `depends_on`. If `multiple` is set to `true`, the supplied script will be evaluated as a script with multiple lines. `depends_on` is a list of environment variables this script depends on, which is taken into account during reordering if unset `cargo-make` will try to guess the variables used during reordering.

> **Note:** This uses the default OS command runner (`cmd` on Windows, `sh` on UNIX systems), other runners like `duckscript`, `rust`, etc. are **not** supported.

```toml
EVALUATED_VAR = { script = ["echo SOME VALUE"] }
```

##### Decode Map

`cargo-make` supports the use of mappings where a `source` is matched against a dictionary of possible `mapping`s, where each key of the `mapping` is compared against the evaluated `source` value. Should the key and `source` be the same, the corresponding value to the key will be the value of the environment variable. If no key is matched, the `default_value` is used if provided. Otherwise, it will default to an empty string instead.

```toml
LIBRARY_EXTENSION = { source = "${CARGO_MAKE_RUST_TARGET_OS}", default_value = "unknown", mapping = {"linux" = "so", "macos" = "dylib", "windows" = "dll", "openbsd" = "so" } }
```

##### Path

`cargo-make` supports the use of glob syntax to find all files and directories in a given directory. The list of files will be joined using `;` during execution.

```toml
PATH_GLOB = { glob = "./src/**/mod.rs", include_files = true, include_dirs = false, ignore_type = "git" }
```

##### Conditional

`cargo-make` supports conditional variables, which are set to the `value` specified if the `condition` evaluates to true. To learn more about conditions, refer to [this chapter](#usage-conditions)

##### Unset

Variables can be unset.

```toml
VARIABLE = {unset = true}
```

<a name="usage-env-config"></a>
#### Global Configuration

Environmental variables can be set globally using the top level `[env]` key, with the ability to provide multiple profiles, which can be selected using `--profile <name>` when executing `cargo make`.

Environment variables set in the global `[env]` block [and default `Makefile.toml`](https://github.com/sagiegurari/cargo-make/blob/master/src/lib/descriptor/makefiles/stable.toml) will be set before running any tasks.

##### Example

```toml
[env]
RUST_BACKTRACE = 1
EVALUATED_VAR = { script = ["echo SOME VALUE"] }
TEST1 = "value1"
TEST2 = "value2"
BOOL_VALUE = true
DEV = false
PROD = false
COMPOSITE = "${TEST1} ${TEST2}"
MULTI_LINE_SCRIPT = { script = ["echo 1\necho 2"], multi_line = true }
CONDITIONAL_SCRIPT = { script = ["echo conditional_script"], condition = { env_not_set = ["CONDITIONAL_SCRIPT"] } }
LIBRARY_EXTENSION = { source = "${CARGO_MAKE_RUST_TARGET_OS}", default_value = "unknown", mapping = {"linux" = "so", "macos" = "dylib", "windows" = "dll", "openbsd" = "so" } }
TO_UNSET = { unset = true }
PREFER_EXISTING = { value = "new", condition = { env_not_set = ["PREFER_EXISTING"] } }
OVERWRITE_EXISTING = { value = "new", condition = { env_set = ["OVERWRITE_EXISTING"] } }
ENV_FROM_LIST = ["ARG1", "${SIMPLE}", "simple value: ${SIMPLE} script value: ${SCRIPT}"]
PATH_GLOB = { glob = "./src/**/mod.rs", include_files = true, include_dirs = false, ignore_type = "git" }

# profile based environment override
[env.development]
DEV = true

[env.production]
PROD = true
```

<a name="usage-env-task"></a>
#### Task

Environmental variables can be set in a task's scope, and will be merged with the global environment when that task gets executed. This means that the evaluation of environment variables takes place after all dependencies have run, but _before_ the task itself runs.

> **Note:** Reordering of task variables with global variables will **not** take place. Tasks simply overwrite previously declared variables.

> **Note:** Variables are **not** cleaned up after execution, meaning that tasks following the executed task will inherit the variables set by the previous task.

`cargo-make` supports the same capabilities outlined for global configuration on a individual task level.

```toml
[tasks.test-flow]
env = { "SOME_ENV_VAR" = "value" }
run_task = "actual-task"

[tasks.actual-task]
condition = { env_set = [ "SOME_ENV_VAR" ] }
script = '''
echo var: ${SOME_ENV_VAR}
'''
```

<a name="usage-env-cli"></a>
#### Command Line
Environment variables can be defined in the command line using the `--env` / `-e` argument as follows:

```console
cargo make --env ENV1=VALUE1 --env ENV2=VALUE2 -e ENV3=VALUE3
```

<a name="usage-env-file"></a>
#### Env File
It is also possible to provide an env file path as part of the CLI args as follows:

```console
cargo make --env-file=./env/production.env
```

This allows using the same `Makefile.toml`, but with a different set of environment variables loaded from the env file.

The env file is a simple `key=value`, which is similar to [dotenv](https://www.npmjs.com/package/dotenv), but only supports variable interpolation using the `${}` syntax.

```properties
#just a comment...
ENV1_TEST=TEST1
ENV2_TEST=TEST2
ENV3_TEST=VALUE OF ENV2 IS: ${ENV2_TEST}
```

Paths to environment files can also be defined globally in the `env_files` key of the `Makefile.toml`, which will be loaded in the order they are defined. All relative paths are relative to the directory containing the `Makefile.toml` they were defined in.

> **Note:** `env_files` can also be used on a task level. Be aware that relative paths will instead be relative to the **current working directory**

```toml
env_files = [
    "./env1.env",
    "./env2.env"
]
```

To only load environment variables whenever a variable hasn't been defined yet, use the `defaults_only` property.

```toml
env_files = [
    { path = "./load_only_undefined.env", defaults_only = true },
    { path = "./load_all.env" }
]
```

Use the `profile` property to only load environment variables whenever a specific profile is active.

> To learn more about profiles, check the [profiles section](#usage-profiles).

```toml
env_files = [
    { path = "./profile.env", profile = "development" },
    { path = "./env.env" }
]
```

<a name="usage-env-setup-scripts"></a>
#### Env Setup Scripts

Environment setup scripts are invoked after environment files and the env block. They are defined globally by the **env_scripts** attribute. These scripts can run anything needed before starting up the flow.

In the case of `duckscript` scripts invoked by the embedded runtime, it is possible to modify the `cargo-make` runtime environment variables directly.

For Example:

```toml
env_scripts = [
'''
#!@duckscript
echo first env script...

composite_env_value = get_env COMPOSITE
echo COMPOSITE = ${composite_env_value}

set_env COMPOSITE_2 ${composite_env_value}
''',
'''
#!@duckscript
echo second env script...

composite_env_value = get_env COMPOSITE_2
echo COMPOSITE_2 = ${composite_env_value}
'''
]

[env]
SIMPLE = "SIMPLE VALUE"
SCRIPT = { script = ["echo SCRIPT VALUE"] }
COMPOSITE = "simple value: ${SIMPLE} script value: ${SCRIPT}"
```

In this example, since the **env** block is invoked before the env scripts, the `duckscript`s have access to the `COMPOSITE` environment variable.<br>
These scripts use that value to create a new environment variable **`COMPOSITE_2`**, and in the second script, we print it.

<a name="usage-env-vars-loading-order"></a>
#### Loading Order

`cargo-make` will load the environment variables in the following order

* Load environment file provided on the command line
* Setup internal environment variables (see [Global](#usage-env-global) section). **Does not per-task variables.**
* Load global environment files defined in the **env_files** attribute.
* Load global environment variables provided on the command line.
* Load global environment variables defined in the **env** block and relevant sub env blocks based on profile/additional profiles.
* Load global environment variables defined in the **env.\[current profile\]** block.
* Load global environment setup scripts defined in the **env_scripts** attribute.
* **Per Task**
  * Setup **per task** internal environment variables (see [Global](#usage-env-global) section).
  * Load environment files defined in the **env_files** attribute (relative paths are treated differently than global env_files).
  * Load environment variables defined in the **env** block (same behavior as global env block).

During each step, variables can be reordered to ensure all dependencies are specified. The environment variables will be interpolated before every task run.

<a name="env-note-about-ordering"></a>
#### Note about Ordering

The ordering of environment variables in `cargo-make` is not necessarily the same between definition and evaluation. `cargo-make` instead looks at the values and reorders variables depending on the variables they mention.

This behavior has many benefits, like the ability to reference other variables freely or redefine them, in different scopes.

```toml
[env]
VAR1="${VAR2}"
VAR2=2
```

A naive implementation would now result in `VAR1=""`, `VAR2=2`, this behavior can be very unexpected, especially when extending existing declarations of environment variables. `cargo-make` is different and uses an approach that is similar to tools like [`terraform`](https://www.terraform.io), it will recognize that `VAR1` depends on `VAR2`, which will output `VAR1=2`, `VAR2=2`.

```toml
[env]
VAR1="${VAR2}"

[env.prod]
VAR2=2

[env.devel]
VAR2=3
```

This is an extended example, which would not work using the naive implementation, because the different profiles are merged with the environment (basically appending them). This is not the case with `cargo-make`, which will recognize dependencies and correctly resolve all values.

###### Naive Implementation

```
--release=test
    VAR1=""
--release=prod
    VAR1=""
    VAR2=2
--release=devel
    VAR1=""
    VAR2=3
```

###### `cargo-make` Implementation

```
--release=test
    VAR1=""
--release=prod
    VAR1="2"
    VAR2=2
--release=devel
    VAR1="3"
    VAR2=3
```

<a name="usage-env-global"></a>
#### Global
In addition to manually setting environment variables, cargo-make will also automatically add a few environment variables, which can be helpful when running task scripts, commands, conditions, and more.

* **`CARGO_MAKE`** - Set to "true" to help sub-processes identify they are running from `cargo` make.
* **`CARGO_MAKE_TASK`** - Holds the name of the main task being executed.
* **`CARGO_MAKE_TASK_ARGS`** - A list of arguments provided to cargo-make after the task name, separated with a ';' character.
* **`CARGO_MAKE_CURRENT_TASK_NAME`** - Holds the currently executed task name.
* **`CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE`** - Holds the full path to the makefile, which **initially** defined the currently executed task (not available for internal core tasks).
* **`CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY`** - Holds the full path to the directory containing the makefile **initially** defined the currently executed task (not available for internal core tasks).
* **`CARGO_MAKE_COMMAND`** - The command used to invoke cargo-make (for example: *cargo make* and *makers*)
* **`CARGO_MAKE_WORKING_DIRECTORY`** - The current working directory (can be defined by setting the `--cwd` CLI option)
* **`CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY`** - The original working directory of the workspace. Enables workspace members access to the workspace level `CARGO_MAKE_WORKING_DIRECTORY`.
* **`CARGO_MAKE_PROFILE`** - The current profile name in lower case (should not be manually modified by global/task env blocks)
* **`CARGO_MAKE_ADDITIONAL_PROFILES`** - The additional profile names in lower case, separated with a `;` character (should not be manually modified by global/task env blocks)
* **`CARGO_MAKE_PROJECT_NAME`** - For standalone crates, this will be the same as `CARGO_MAKE_CRATE_NAME`, and for workspace, it will default to the working directory basename.
* **`CARGO_MAKE_PROJECT_VERSION`** For standalone crates, this will be the same as `CARGO_MAKE_CRATE_VERSION`, and for workspaces, it will be the main crate version (main crate defined by the optional **main_project_member** attribute in the config section).
* **`CARGO_MAKE_CARGO_HOME`** - The path to `CARGO_HOME` as described in the [cargo documentation](https://doc.rust-lang.org/cargo/guide/cargo-home.html)
* **`CARGO_MAKE_CARGO_PROFILE`** - The [cargo profile](https://doc.rust-lang.org/cargo/reference/manifest.html#the-profile-sections) name mapped from the **`CARGO_MAKE_PROFILE`** (unmapped value will default to `CARGO_MAKE_PROFILE` value)
* **`CARGO_MAKE_RUST_VERSION`** - The rust version (for example 1.20.0)
* **`CARGO_MAKE_RUST_CHANNEL`** - Rust channel (stable, beta, nightly)
* **`CARGO_MAKE_RUST_TARGET_ARCH`** - x86, x86_64, arm, etc ... (see rust cfg feature)
* **`CARGO_MAKE_RUST_TARGET_ENV`** - gnu, msvc, etc ... (see rust cfg feature)
* **`CARGO_MAKE_RUST_TARGET_OS`** - Windows, macOS, iOS, Linux, Android, etc. ... (see rust cfg feature)
* **`CARGO_MAKE_RUST_TARGET_POINTER_WIDTH`** - 32, 64
* **`CARGO_MAKE_RUST_TARGET_VENDOR`** - apple, pc, unknown
* **`CARGO_MAKE_RUST_TARGET_TRIPLE`** - x86_64-unknown-linux-gnu, x86_64-apple-darwin, x86_64-pc-windows-msvc, etc ...
* **`CARGO_MAKE_CRATE_TARGET_DIRECTORY`** - Gets target directory where cargo stores the output of a build, respects `${CARGO_TARGET_DIR}`, `.cargo/config.toml`'s and `${CARGO_HOME}/config.toml`, but not `--target-dir` command-line flag.
* **`CARGO_MAKE_CRATE_CUSTOM_TRIPLE_TARGET_DIRECTORY`** - Like `CARGO_MAKE_CRATE_TARGET_DIRECTORY` but respects `build.target` in `.cargo/config.toml`.
* **`CARGO_MAKE_CRATE_HAS_DEPENDENCIES`** - Holds `true`/`false` based if there are dependencies defined in the `Cargo.toml` or not (defined as *false* if no `Cargo.toml` is found)
* **`CARGO_MAKE_CRATE_IS_WORKSPACE`** - Holds `true`/`false` based if this is a workspace crate or not (defined even if no `Cargo.toml` is found)
* **`CARGO_MAKE_CRATE_WORKSPACE_MEMBERS`** - Holds a list of member paths (defined as empty value if no `Cargo.toml` is found)
* **`CARGO_MAKE_CRATE_CURRENT_WORKSPACE_MEMBER`** - Holds the name of the current workspace member being built (only if flow started as a workspace level flow)
* **`CARGO_MAKE_CRATE_LOCK_FILE_EXISTS`** - Holds `true`/`false` if a `Cargo.lock` file exists in the current working directory (in workspace projects, each member has a different working directory).
* **`CARGO_MAKE_CRATE_TARGET_TRIPLE`** - Gets target triple that will be build with by default, respects `.cargo/config.toml` and `${CARGO_HOME}/config.toml`.
* **`CARGO_MAKE_WORKSPACE_PACKAGE_NAME`** - Holds the root package name of the workspace from the `Cargo.toml` file in the current working directory.
* **`CARGO_MAKE_WORKSPACE_PACKAGE_VERSION`** - Holds the root package version of the workspace from the `Cargo.toml` file in the current working directory.
* **`CARGO_MAKE_WORKSPACE_PACKAGE_DESCRIPTION`** - Holds the root package description of the workspace from the `Cargo.toml` file in the current working directory.
* **`CARGO_MAKE_WORKSPACE_PACKAGE_LICENSE`** - Holds the root package license of the workspace from the `Cargo.toml` file in the current working directory.
* **`CARGO_MAKE_WORKSPACE_PACKAGE_DOCUMENTATION`** - Holds the root package documentation link of the workspace from the `Cargo.toml` file in the current working directory.
* **`CARGO_MAKE_WORKSPACE_PACKAGE_HOMEPAGE`** - Holds the root package homepage link of the workspace from the `Cargo.toml` file in the current working directory.
* **`CARGO_MAKE_WORKSPACE_PACKAGE_REPOSITORY`** - Holds the root package repository link of the workspace from the `Cargo.toml` file in the current working directory.
* **`CARGO_MAKE_CI`** - Holds `true`/`false` if the task runs in a continuous integration system (such as Travis CI).
* **`CARGO_MAKE_PR`** - Holds `true`/`false` if the task runs in a continuous integration system (such as Travis CI) as part of a pull request build (unknown is set as false).
* **`CARGO_MAKE_CI_BRANCH_NAME`** - Holds the continuous integration branch name (if available).
* **`CARGO_MAKE_CI_VENDOR`** - Holds the continuous integration vendor name (if available).
* **`CARGO_MAKE_DUCKSCRIPT_VERSION`** - The embedded `duckscript` runtime version.
* **`CARGO_MAKE_DUCKSCRIPT_SDK_VERSION`** - The embedded `duckscript` SDK version.

The following environment variables will be set by cargo-make if `Cargo.toml` file exists and the relevant value is defined:

* **`CARGO_MAKE_CRATE_NAME`** - Holds the crate name from the `Cargo.toml` file in the current working directory.
* **`CARGO_MAKE_CRATE_FS_NAME`** - Same as `CARGO_MAKE_CRATE_NAME` however some characters are replaced (for example '-' to '_').
* **`CARGO_MAKE_CRATE_VERSION`** - Holds the crate version from the `Cargo.toml` file found in the current working directory.
* **`CARGO_MAKE_CRATE_DESCRIPTION`** - Holds the crate description from the `Cargo.toml` file in the current working directory.
* **`CARGO_MAKE_CRATE_LICENSE`** - Holds the crate license from the `Cargo.toml` file in the current working directory.
* **`CARGO_MAKE_CRATE_DOCUMENTATION`** - Holds the crate documentation link from the `Cargo.toml` file in the current working directory.
* **`CARGO_MAKE_CRATE_HOMEPAGE`** - Holds the crate homepage link from the `Cargo.toml` file in the current working directory.
* **`CARGO_MAKE_CRATE_REPOSITORY`** - Holds the crate repository link from the `Cargo.toml` file in the current working directory.

The following environment variables will be set by cargo-make if the project is part of a git repo:

* **`CARGO_MAKE_GIT_BRANCH`** - The current branch name.
* **`CARGO_MAKE_GIT_USER_NAME`** - The user name pulled from the git config user.name key.
* **`CARGO_MAKE_GIT_USER_EMAIL`** - The user email, which was taken from the git config `user.email` key.
* **`CARGO_MAKE_GIT_HEAD_LAST_COMMIT_HASH`** - The last HEAD commit hash.
* **`CARGO_MAKE_GIT_HEAD_LAST_COMMIT_HASH_PREFIX`** - The last HEAD commit hash prefix.

<a name="usage-setting-up-working-directory"></a>
### Setting Up Working Directory
To modify the current working directory for a specific task (not entire run), use the **cwd** attribute.<br>
For example:

```toml
[tasks.move-dir]
cwd = "./mysubdir/"
```

<a name="usage-ignoring-errors"></a>
### Ignoring Errors
In some cases you want to run optional tasks as part of a bigger flow, but do not want to break your entire build in case of any error in those optional tasks.<br>
For those tasks, you can add the **ignore_errors=true** attribute.

```toml
[tasks.unstable_task]
ignore_errors = true
```

<a name="usage-conditions"></a>
### Conditions
Conditions allow you to evaluate at runtime if to run a specific task or not.<br>
These conditions are evaluated before the task is running its installation and/or commands and if the condition is not fulfilled, the task will not be invoked.<br>
The task dependencies however are not affected by parent task condition outcome.

There are two types of conditions:

* [Criteria](#usage-conditions-structure)
* [Scripts](#usage-conditions-script)

The task runner will evaluate any condition defined and a task definition may contain both types at the same time.

<a name="usage-conditions-structure"></a>
#### Criteria
The condition attribute may define multiple parameters to validate.<br>
All defined parameters must be valid for the condition as a whole to be true and enable the task to run.

Below is an example of a condition definition that checks that we are running on Windows or Linux (but not macOS) and that we are running on beta or nightly (but not stable):

```toml
[tasks.test-condition]
condition = { platforms = ["windows", "linux"], channels = ["beta", "nightly"] }
script = '''
echo "condition was met"
'''
```

The following condition types are available:

* **profile** - See [profiles](#usage-profiles) for more info
* **os** - List of OS names (Windows, macOS, iOS, Linux, Android, etc... as defined by cfg!(target_os))
* **platforms** - List of platform names (windows, linux, mac)
* **channels** - List of rust channels (stable, beta, nightly)
* **env_set** - List of environment variables that must be defined
* **env_not_set** - List of environment variables that must not be defined
* **env_true** - List of environment variables that must be defined and must not be set to any of the following (case insensitive): false, no, 0 or empty
* **env_false** - List of environment variables that must be defined and set to any of the following (case insensitive): false, no, 0 or empty
* **env** - Map of environment variables that must be defined and equal to the provided values
* **env_contains** - Map of environment variables that must be defined and contain (case insensitive) the provided values
* **rust_version** - Optional definition of min, max, and/or specific rust version
* **files_exist** - List of absolute path files to check they exist. Environment substitution is supported so you can define relative paths such as **`${CARGO_MAKE_WORKING_DIRECTORY}/Cargo.toml`**
* **files_not_exist** - List of absolute path files to check they do not exist. Environment substitution is supported so you can define relative paths such as **`${CARGO_MAKE_WORKING_DIRECTORY}/Cargo.toml`**
* **files_modified** - Lists input and output globs. If any input file is newer than all output files, the condition is met. Environment substitution is supported so you can define relative paths such as **`${CARGO_MAKE_WORKING_DIRECTORY}/Cargo.toml`**

Few examples:

```toml
[tasks.test-condition]
condition = {
    profiles = ["development", "production"],
    platforms = ["windows", "linux"],
    channels = ["beta", "nightly"],
    env_set = [ "CARGO_MAKE_KCOV_VERSION" ],
    env_not_set = [ "CARGO_MAKE_SKIP_CODECOV" ],
    env = { "CARGO_MAKE_CI" = true, "CARGO_MAKE_RUN_CODECOV" = true },
    rust_version = { min = "1.20.0", max = "1.30.0" },
    files_exist = ["${CARGO_MAKE_WORKING_DIRECTORY}/Cargo.toml"],
    files_not_exist = ["${CARGO_MAKE_WORKING_DIRECTORY}/Cargo2.toml"],
    files_modified = { input = ["${CARGO_MAKE_WORKING_DIRECTORY}/Cargo.toml", "./src/**/*.rs"], output = ["./target/**/myapp*"] }
}
```

To setup a custom failure message, use the **fail_message** inside the condition object, for example:

```toml
[tasks.test-condition-with-message]
condition = { platforms = ["windows"], fail_message = "Condition Failed." }
command = "echo"
args = ["condition was met"]
```

Fail messages are only printed if log level is verbose or reduce output flag is set to false in the config as follows:

```toml
[config]
reduce_output = false
```

<a name="usage-conditions-script"></a>
#### Scripts
These script are invoked before the task is running its installation and/or commands and if the exit code of the condition script is non zero, the task will not be invoked.

Below is an example of a condition script that always returns a non zero value, in which case the command is never executed:

```toml
[tasks.never]
condition_script = """
exit 1
"""
command = "cargo"
args = ["build"]
```

Condition scripts can be used to ensure that the task is only invoked if a specific condition is met, for example if a specific 3rd party is installed.

To setup a custom failure message, use the **fail_message** inside the condition object, for example:

```toml
[tasks.test-condition-script-with-message]
condition = { fail_message = "Condition Script Failed." }
condition_script = [
    "exit 1"
]
command = "echo"
args = ["condition was met"]
```

<a name="usage-conditions-and-or"></a>
#### And/Or/Group Or

By default all conditions groups and all conditions inside each group are evaluated and an 'AND' is used to validate everything is as requested.<br>
However, there are other condition types available:

* Or - All groups and all conditions inside each group are searched for a single condition that is met
* GroupOr - All conditions in each group are searched for a single condition that is met but all condition groups must pass.

Simply add the condition_type with any of these values inside the condition object.<br>
For example:

```
[tasks.test-or-condition]
condition = { condition_type = "Or", env_true = [
  "TRUE_ENV",
  "FALSE_ENV",
], env_false = [
  "TRUE_ENV",
  "FALSE_ENV",
] }
script = '''
echo "condition was met"
'''
```

<a name="usage-conditions-and-subtasks"></a>
#### Combining Conditions and Sub Tasks

Conditions and run_task combined can enable you to define a conditional sub flow.<br>
For example, if you have a coverage flow that should only be invoked on linux in a CI build, and only if the `CARGO_MAKE_RUN_CODECOV` environment variable is defined as "true":

```toml
[tasks.ci-coverage-flow]
description = "Runs the coverage flow and uploads the results to codecov."
condition = { platforms = ["linux"], env = { "CARGO_MAKE_CI" = true, "CARGO_MAKE_RUN_CODECOV" = true } }
run_task = "codecov-flow"

[tasks.codecov-flow]
description = "Runs the full coverage flow and uploads the results to codecov."
windows_alias = "empty"
dependencies = [
    "coverage-flow",
    "codecov"
]
```

The first task **ci-coverage-flow** defines the condition that checks we are on linux, running as part of a CI build and the `CARGO_MAKE_RUN_CODECOV` environment variable is set to "true".<br>
Only if all conditions are met, it will run the **codecov-flow** task.<br>
We can't define the condition directly on the **codecov-flow** task, as it will invoke the task dependencies before checking the condition.

<a name="usage-running-tasks-only-if-sources-changed"></a>
#### Running Tasks Only If Sources Changed

The **files_modified** condition enables tasks to be skipped based on file modifications timestamp.<br>
The condition will cause the task to be skipped if no input file was found to be newer then any of the files in the output.<br>
The input and output are defined as arrays of **globs** (not regex) of files to check.<br>
In the below example, if the target binaries are newer then the Cargo.toml or any of the rust sources in the src directory, it will not run cargo build command.

```toml
[tasks.compile-if-modified]
condition = { files_modified = { input = ["${CARGO_MAKE_WORKING_DIRECTORY}/Cargo.toml", "./src/**/*.rs"], output = ["./target/**/myapp*"] } }
command = "cargo"
args = ["build"]
```

<a name="usage-installing-dependencies"></a>
### Installing Dependencies

Some tasks will require third party crates, rustup components, or other native tools.<br>
cargo-make provides multiple ways to setup those dependencies before running the task.

* [Cargo Plugins](#usage-installing-cargo-plugins)
* [Crates](#usage-installing-crates)
* [Rustup Components](#usage-installing-rustup-components)
* [Native Dependencies](#usage-installing-native-dependencies)
* [Defining Version](#usage-installing-version)
* [Global Lock Of Versions](#usage-installing-locked)
* [Installation Priorities](#usage-installing-dependencies-priorities)
* [Multiple Installations](#usage-installing-dependencies-multiple)

<a name="usage-installing-cargo-plugins"></a>
#### Cargo Plugins

When a task invokes a cargo plugin using the **command** attribute, for example:

```toml
[tasks.audit]
command = "cargo"
args = ["audit"]
```

cargo-make will first check the command is available.<br>
Only if the command is not available, it will attempt to install it by running **cargo install cargo-<first arg>**<br>
In case the cargo plugin has a different name, you can specify it manually via **install_crate** attribute.<br>
You can specify additional installation arguments using the **install_crate_args** attribute (for example: version).

To disable the automatic crate installation, you can set the **install_crate** attribute as false, for example:

```toml
[tasks.test]
command = "cargo"
args = ["test"]
install_crate = false
```

<a name="usage-installing-crates"></a>
#### Crates

cargo-make can verify third party crates are installed if the relevant installation info is provided.<br>
First it will check the crate is installed, and only if not available it will attempt to install it.<br>
Installation of third party crates is first done via rustup if the component name is provided.<br>
If rustup failed or component name is not provided, it will resort to using cargo install command.<br>
For example:

```toml
[tasks.rustfmt]
install_crate = { crate_name = "rustfmt-nightly", rustup_component_name = "rustfmt-preview", binary = "rustfmt", test_arg = "--help" }
command = "rustfmt"
```

In this example, cargo will first test that the command **rustfmt --help** works well and only if fails, it will first attempt
to install via rustup the component **rustfmt-preview** and if failed, it will try to run cargo install for the crate name **rustfmt-nightly**.

If passing multiple arguments is necessary, `test_arg` may contain an array of arguments. For example:

```toml
[tasks.doc-upload]
install_crate = { crate_name = "cargo-travis", binary = "cargo", test_arg = ["doc-upload", "--help"] }
command = "cargo"
args = ["doc-upload"]
```

In this example, cargo-make will test the presence of cargo-travis by running the command `cargo doc-upload --help`, and
install the crate only if this command fails.

<a name="usage-installing-rustup-components"></a>
#### Rustup Components

Rustup components that are not deployed as crates or components which are pure sources (no executable binary), can also be installed via cargo-make.<br>
The following example show how to install a rustup component with binaries:

```toml
[tasks.install-rls]
install_crate = { rustup_component_name = "rls-preview", binary = "rls", test_arg = "--help" }
```

In this example, cargo-make will first check if **rls** binary is available and only if failed to execute it, it will
install the **rls** component using rustup.<br>
<br>
Some rustup components are pure sources and therefore in those cases, cargo-make cannot verify that they are already installed, and
will attempt to install them every time.<br>
Example:

```toml
[tasks.install-rust-src]
install_crate = { rustup_component_name = "rust-src" }
```

<a name="usage-installing-native-dependencies"></a>
#### Native Dependencies

Native dependencies can also be installed, however it is up to the Makefile author to write the script which checks the dependency exists and if
not, to install it correctly.<br>
This is done by setting up an installation script in the **install_script** attribute of the task.<br>
It is possible to use platform overrides to specify different installation scripts for Linux/macOS/Windows platforms.<br>
For example:

```toml
[tasks.coverage-kcov]
windows_alias = "empty"
install_script = '''
KCOV_INSTALLATION_DIRECTORY=""
KCOV_BINARY_DIRECTORY=""
if [ -n "CARGO_MAKE_KCOV_INSTALLATION_DIRECTORY" ]; then
    mkdir -p ${CARGO_MAKE_KCOV_INSTALLATION_DIRECTORY}
    cd ${CARGO_MAKE_KCOV_INSTALLATION_DIRECTORY}
    KCOV_INSTALLATION_DIRECTORY="$(pwd)/"
    cd -
    echo "Kcov Installation Directory: ${KCOV_INSTALLATION_DIRECTORY}"
    KCOV_BINARY_DIRECTORY="${KCOV_INSTALLATION_DIRECTORY}/build/src/"
    echo "Kcov Binary Directory: ${KCOV_BINARY_DIRECTORY}"
fi

# get help info to fetch all supported command line arguments
KCOV_HELP_INFO=`${KCOV_BINARY_DIRECTORY}kcov --help` || true

# check needed arguments are supported, else install
if [[ $KCOV_HELP_INFO != *"--include-pattern"* ]] || [[ $KCOV_HELP_INFO != *"--exclude-line"* ]] || [[ $KCOV_HELP_INFO != *"--exclude-region"* ]]; then
    # check we are on a supported platform
    if [ "$(grep -Ei 'debian|buntu|mint' /etc/*release)" ]; then
        echo "Installing/Upgrading kcov..."
        sudo apt-get update || true
        sudo apt-get install -y libcurl4-openssl-dev libelf-dev libdw-dev cmake gcc binutils-dev

        mkdir -p ${CARGO_MAKE_KCOV_DOWNLOAD_DIRECTORY}
        cd ${CARGO_MAKE_KCOV_DOWNLOAD_DIRECTORY}
        KCOV_DOWNLOAD_DIRECTORY=$(pwd)

        wget https://github.com/SimonKagstrom/kcov/archive/v${CARGO_MAKE_KCOV_VERSION}.zip
        unzip v${CARGO_MAKE_KCOV_VERSION}.zip
        cd kcov-${CARGO_MAKE_KCOV_VERSION}
        mkdir -p build
        cd ./build
        cmake ..
        make

        # if custom installation directory, leave kcov as local
        if [ -n "CARGO_MAKE_KCOV_INSTALLATION_DIRECTORY" ]; then
            cd ${KCOV_DOWNLOAD_DIRECTORY}/kcov-${CARGO_MAKE_KCOV_VERSION}
            mv ./* ${KCOV_INSTALLATION_DIRECTORY}
        else
            sudo make install
            cd ../..
            rm -rf kcov-${CARGO_MAKE_KCOV_VERSION}
        fi
    fi
fi
'''
```

This task checks if kcov is installed; if not, it will install it and any other dependency it requires.

<a name="usage-installing-version"></a>
#### Defining Version

It is possible to define minimal version of depended crates, for example:

```toml
[tasks.simple-example]
install_crate = { min_version = "0.0.1" }
command = "cargo"
args = ["make", "--version"]

[tasks.complex-example]
install_crate = { crate_name = "cargo-make", binary = "cargo", test_arg = ["make", "--version"], min_version = "0.0.1" }
command = "cargo"
args = ["make", "--version"]
```

This ensures we are using a crate version that supports the feature we require for the build.<br>
Currently there are few limitations when defining **min_version**:

* Specifying **toolchain** in the task or **rustup_component_name** in the install_crate structure, will make cargo-make ignore the min version value.
* In case cargo-make is unable to detect the currently installed version due to any error, cargo-make will assume the version is valid and printout a warning.

If you want to ensure a specific version is used, you can define the **version** attribute instead, for example:

```toml
[tasks.complex-example]
install_crate = { crate_name = "cargo-make", binary = "cargo", test_arg = ["make", "--version"], version = "0.0.1" }
command = "cargo"
args = ["make", "--version"]
```

<a name="usage-installing-locked"></a>
#### Global Lock Of Versions

In case [min_version](#usage-installing-version) is defined,
you can have the **--locked** flag automatically added to the crate installation command
by defining the **`CARGO_MAKE_CRATE_INSTALLATION_LOCKED`=true** environment variable.
If version is defined instead of min_version, this will automatically be set as true.

<a name="usage-installing-alternate-cargo-install-commands"></a>
#### Alternate Cargo Install Commands

You can specify a different cargo install command in order to make the crate installation to use some custom cargo installer plugin.
For example, if you want to use instead of **install** a plugin such as **local-install** simply add the **install_command** attribute with the relevant value.<br>
For example:

```toml
[tasks.alt-command-example1]
install_crate = { install_command = "custom-install" }
command = "cargo"
args = ["somecrate"]

[tasks.alt-command-example2]
install_crate = { crate_name = "somecrate", install_command = "custom-install" }
```

By default, the **--force** flag is added. In order to remove it, add the force=false to the install_crate definition as follows:

```toml
[tasks.alt-command-example2]
install_crate = { crate_name = "somecrate", install_command = "custom-install", force = false }
```

<a name="usage-installing-dependencies-priorities"></a>
### Installation Priorities

Only one type of installation will be invoked per task.<br>
The following defines the installation types sorted by priority for which cargo-make uses to decide which installation flow to invoke:

* **install_crate** - Enables to install crates and rustup components.
* **install_script** - Custom script which can be used to install or run anything that is needed by the task command.
* **automatic cargo plugin** - In case the command is **cargo**, cargo-make will check which cargo plugin to automatically install (if needed).

In case multiple installation types are defined (for example both install_crate and install_script), only one installation type will be invoked based on the above priority list.

<a name="usage-installing-dependencies-multiple"></a>
### Multiple Installations

In some cases, tasks require multiple items installed in order to run properly.<br>
For example, you might need rustup component **rls** and **rust-src** and cargo plugin **cargo-xbuild** at the same task.<br>
In order to achieve this, you can split the task to invocation task and installation task and set the installation task as a dependency.<br>
The following example defines a flow of two similar tasks that have the same dependencies: cargo-xbuild crate, rls rustup binary component and rust-src rustup sources only component.<br>
You can have both rustup dependencies as an installation only tasks which are set as dependencies for the xbuild tasks.<br>
Since dependencies are only invoked once, it will also ensure that those rustup components are not installed twice.

```toml
[tasks.install-rls]
# install rls-preview only if needed
install_crate = { rustup_component_name = "rls-preview", binary = "rls", test_arg = "--help" }

[tasks.install-rust-src]
# always install rust-src via rustup component add
install_crate = { rustup_component_name = "rust-src" }

[tasks.xbuild1]
# run cargo xbuild, if xbuild is not installed, it will be automatically installed for you
command = "cargo"
args = [ "xbuild", "some arg" ]
dependencies = [ "install-rls", "install-rust-src" ]

[tasks.xbuild2]
# run cargo xbuild, if xbuild is not installed, it will be automatically installed for you
command = "cargo"
args = [ "xbuild", "another arg" ]
dependencies = [ "install-rls", "install-rust-src" ]

[tasks.myflow]
dependencies = [ "xbuild1", "xbuild2" ]
```

<a name="usage-workspace-support"></a>
### Workspace Support
In case cargo-make detects that the current working directory is a workspace root (A directory with `Cargo.toml` which defines a workspace and its members), it will not invoke the requested tasks in that directory.<br>
Instead, it will generate a task definition in runtime which will go to each member directory and invoke the requested task on that member.<br>
For example if we have the following directory structure:

```console
workspace
├── Cargo.toml
├── member1
│   └── Cargo.toml
└── member2
    └── Cargo.toml
```

And we ran **cargo make mytask**, it will go to each workspace member directory and execute: **cargo make mytask** at that directory,
where mytask is the original task that was requested on the workspace level.<br>
The order of the members is defined by the member attribute in the workspace `Cargo.toml`.

This flow is called a **workspace** flow, as it identifies the workspace and handles the request for each workspace member, while the root directory which defines the workspace structure is ignored.

We can use this capability to run same functionality on all workspace member crates, for example if we want to format all crates, we can run in the workspace directory: **cargo make format**.<br>

Member crate makefiles can also automatically extend the workspace directory makefile.<br>
See more info at the [relevant section.](#usage-workspace-extend)

<a name="usage-workspace-disabling-workspace-support"></a>
#### Disabling Workspace Support
In case you wish to run the tasks on the workspace root directory and not on the members (for example generating a workspace level README file), use the **`--no-workspace`** CLI flag when running cargo make.<br>
For example:

```sh
cargo make --no-workspace mytask
```

This makes cargo-make ignore that this directory is a workspace root, and just runs a simple flow as if this was a simple directory with a makefile.

Another way to call a task on the workspace level (rather than for each member) is to define that task in the workspace `Makefile.toml` with **workspace** set to false as follows:

```toml
[tasks.ignore-members]
workspace = false
```

Setting **workspace=false** for the task requested on the cargo-make command line is equivalent to calling it with the **--no-workspace** flag.<br>
This flag is only checked for the task on the cargo-make command line and is completely ignored for all other tasks which are executed as part of the flow.<br>
By default, the workspace flag for all tasks is set to true, but that can be configured differently in the config section as follows:

```toml
[config]
default_to_workspace = false
```

In which case, workspace level support is **always** disabled unless a task defines **workspace=true**.

<a name="usage-workspace-composite-flow"></a>
#### Composite Flow

You can define a composite flow that runs tasks on both the workspace root directory and member directories.<br>
This is an example of a workspace level `Makefile.toml` which enables to run such a flow:

```toml
[tasks.composite]
dependencies = ["member_flow", "workspace_flow"]

[tasks.member_flow]
# by forking, cargo make starts and by default detects it is a workspace and runs the member_task for each member
run_task = { name = "member_task", fork = true }

[tasks.workspace_flow]
#run some workspace level command or flow
```

You can start this composite flow as follows:

```sh
cargo make --no-workspace composite
```

<a name="usage-workspace-profiles"></a>
#### Profiles

You can prevent profiles from being passed down to workspace members by setting **`CARGO_MAKE_USE_WORKSPACE_PROFILE`** to false:

```toml
[env]
CARGO_MAKE_USE_WORKSPACE_PROFILE = false
```

See more on profiles in the [profile section](#usage-profiles).

<a name="usage-workspace-support-skip-include-members"></a>
#### Skipping/Including Specific Members

In most cases you will want to run a specific flow on all members, but in rare cases you will want to skip specific members.

By setting the **`CARGO_MAKE_WORKSPACE_SKIP_MEMBERS`** environment variable to hold the member names to skip (as an array), you can define if you want those members not to participate in the flow.

In the below example we will skip member3 and member4 (should be defined in the workspace level `Makefile.toml`):

```toml
[env]
CARGO_MAKE_WORKSPACE_SKIP_MEMBERS = ["member3", "member4"]
```

You can also define glob paths, for example:

```toml
[env]
CARGO_MAKE_WORKSPACE_SKIP_MEMBERS = "tools/*"
```

However there are some cases you will want to skip specific members only if a specific condition is met.<br>
For example, you want to build a member module only if we are running on a rust nightly compiler.<br>
This is a simple example of a conditioned skip for member3 and member4 (should be defined in the workspace level `Makefile.toml`):

```toml
[tasks.workspace-task]
condition = { channels = ["beta", "stable"] }
env = { "CARGO_MAKE_WORKSPACE_SKIP_MEMBERS" = ["member3", "member4"] }
run_task = { name = "member-task", fork = true }
```

You will have to invoke this as a composite flow:

```sh
cargo make workspace-task --no-workspace
```

In addition you can also state the opposite, meaning which members to include via **`CARGO_MAKE_WORKSPACE_INCLUDE_MEMBERS`** environment variable.<br>
It follows the same rules as the **`CARGO_MAKE_WORKSPACE_SKIP_MEMBERS`** environment variable.<br>
If you define both, the included members will be a subset of the non excluded members, meaning both filters will apply.

<a name="usage-workspace-emulation"></a>
#### Workspace Emulation
Workspace emulation enables you to create a workspace like structure for your project without actually defining a rust workspace.<br>
This means you can have a project directory without a `Cargo.toml` and have many child crates.<br>
This enables to run cargo make on all **member** crates while on the root project folder without having the need of an actual cargo workspace which has some side effects (such as shared target folder and dependencies).

In order to setup the workspace emulation, you will need to define the following in your workspace level `Makefile.toml`:

```toml
[env]
# this tells cargo-make that this directory acts as a workspace root
CARGO_MAKE_WORKSPACE_EMULATION = true

# a list of crate members. since we do not have a Cargo.toml, we will need to specify this in here.
CARGO_MAKE_CRATE_WORKSPACE_MEMBERS = [
    "member1",
    "member2"
]
```

<a name="usage-toolchain"></a>
### Toolchain
cargo-make supports setting the toolchain to be used when invoking commands and installing rust dependencies by setting
the **toolchain** attribute as part of the task definition.<br>
The following example shows how to print both stable and nightly rustc versions currently installed:

```toml
[tasks.rustc-version-stable]
toolchain = "stable"
command = "rustc"
args = [ "--version" ]

[tasks.rustc-version-nightly]
toolchain = "nightly"
command = "rustc"
args = [ "--version" ]

[tasks.rustc-version-flow]
dependencies = [
    "rustc-version-stable",
    "rustc-version-nightly"
]
```

An example output of the above **rustc-version-flow** is:

```console
[cargo-make] INFO - Task: rustc-version-flow
[cargo-make] INFO - Setting Up Env.
[cargo-make] INFO - Running Task: init
[cargo-make] INFO - Running Task: rustc-version-stable
[cargo-make] INFO - Execute Command: "rustup" "run" "stable" "rustc" "--version"
rustc 1.30.1 (1433507eb 2018-11-07)
[cargo-make] INFO - Running Task: rustc-version-nightly
[cargo-make] INFO - Execute Command: "rustup" "run" "nightly" "rustc" "--version"
rustc 1.32.0-nightly (451987d86 2018-11-01)
[cargo-make] INFO - Running Task: rustc-version-flow
[cargo-make] INFO - Running Task: end
[cargo-make] INFO - Build Done  in 2 seconds.
```

When defined with scripts (as opposed to commands), the **`CARGO`** environment variable will be defined for the requested toolchain.<br>
The following example shows how to print both stable and nightly CARGO binary paths:

```toml
[tasks.echo-cargo-stable]
toolchain = "stable"
script = '''
echo ${CARGO}
'''

[tasks.echo-cargo-nightly]
toolchain = "nightly"
script = '''
echo ${CARGO}
'''

[tasks.echo-cargo-all]
dependencies = ["echo-cargo-stable", "echo-cargo-nightly"]
```

An example output of the above **echo-cargo-all** is:

```console
[cargo-make] INFO - Task: echo-cargo-all
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: legacy-migration
[cargo-make] INFO - Running Task: echo-cargo-stable
/home/someuser/.rustup/toolchains/stable-armv7-unknown-linux-gnueabihf/bin/cargo
[cargo-make] INFO - Running Task: echo-cargo-nightly
/home/someuser/.rustup/toolchains/nightly-armv7-unknown-linux-gnueabihf/bin/cargo
[cargo-make] INFO - Build Done in 4.44 seconds.
```

It's also possible to assert a minimum required version of rustc with a channel. This can help
to document required compiler features and to remind developers to upgrade their installation.

```toml
[tasks.requires-stable-edition-2021]
toolchain = { channel = "stable", min_version = "1.56" }
command = "rustc"
args = ["--version"]
```

The task will fail when the toolchain is either not installed or the existing version is smaller
than the specified **min_version**.

<a name="usage-init-end-tasks"></a>
### Init and End tasks
Every task or flow that is executed by the cargo-make has additional 2 tasks.<br>
An init task that gets invoked at the start of all flows and end task that is invoked at the end of all flows.<br>
The names of the init and end tasks are defined in the config section in the toml file, the below shows the default settings:

```toml
[config]
init_task = "init"
end_task = "end"

[tasks.init]

[tasks.end]
```

By default the init and end tasks are empty and can be modified by external toml files or you can simply change the names of the init and end tasks in the external toml files to point to different tasks.<br>
These tasks allow common actions to be invoked no matter what flow you are running.

Important to mention that init and end tasks invocation is different than other tasks.

* Aliases and dependencies are ignored
* If the same task is defined in the executed flow, those tasks will be invoked multiple times

Therefore it is not recommended to use the init/end tasks also inside your flows.

<a name="usage-catching-errors"></a>
### Catching Errors
By default any error in any task that does not have **ignore_errors=true** set to it, will cause the entire flow to fail.<br>
However, there are scenarios in which you would like to run some sort of cleanups before the failed flow finishes.<br>
cargo make enables you to define an **on error** task which will only be invoked in case the flow failed.<br>
In order to define this special task you must add the **on_error_task** attribute in the **config** section in your Makefile and point it to your task, for example:

```toml
[config]
on_error_task = "catch"

[tasks.catch]
script = '''
echo "Doing cleanups in catch"
'''
```

<a name="usage-cargo-alias-tasks"></a>
### Cargo Alias Tasks

[Cargo alias commands](https://doc.rust-lang.org/cargo/reference/config.html#alias) can be automatically loaded as cargo-make tasks.<br>
To automatically loading them, the following must be defined in the `Makefile.toml` config section:

```toml
[config]
load_cargo_aliases = true
```

Each alias defined in the config.toml will be loaded as a task with the same name as the alias.<Br>
In case a task with that name already exists, it will be ignored.<br>
The task definition will simply call cargo and the alias value, therefore no automatic cargo plugin installation will be invoked.

<a name="usage-profiles"></a>
### Profiles

Profiles are a useful tool used to define custom behaviour.<br>
In order to set the execution profile, use the **`--profile`** or **`-p`** CLI argument and provide the profile name.<br>
Profile names are automatically converted to underscores and are trimmed.<br>
If no profile name is provided, the profile will be defaulted to **development**.

Example Setting Profile:

```sh
cargo make --profile production mytask
```

Profiles provide multiple capabilities:

* [Environment variables](#usage-profiles-env) overrides
* [Conditions by profiles](#usage-profiles-conditions), for example:
```toml
condition = { profiles = ["development", "production"] }
```
* [New environment variable](#usage-env-global) **`CARGO_MAKE_PROFILE`** which holds the profile name and can be used by conditions, scripts and commands.

It is possible to activate multiple profiles simultaneously using **additional_profiles**, but these have limited support.<br>
The default profile (if not provided via command line) is `"development"`.<br>
However, this can be overridden by setting the `CARGO_MAKE_DEFAULT_PROFILE` environment variable.

```toml
[config]
additional_profiles = ["second_profile", "another_profile"]
```

Additional profiles can be used to define additional environment blocks and they will be defined in a new environment variable **`CARGO_MAKE_ADDITIONAL_PROFILES`**

<a name="usage-profiles-env"></a>
#### Environment Variables

Profiles enable you to define a new subset of environment variables that will only be set in runtime if the current profile matches the env profile.

```toml
[env]
RUST_BACKTRACE = "1"
EVALUATED_VAR = { script = ["echo SOME VALUE"] }
TEST1 = "value1"
TEST2 = "value2"
COMPOSITE = "${TEST1} ${TEST2}"

# profile based environment override
[env.development]
DEV = true

[env.production]
PROD = true
```

For example, given the following makefile with 2 profile-based env maps:

```toml
[env]
COMMON = "COMMON"
PROFILE_NAME = "${CARGO_MAKE_PROFILE}"

[env.development]
IS_DEV = true
IS_PROD = false

[env.production]
IS_DEV = false
IS_PROD = true

[tasks.echo]
script = [
'''
echo COMMON: ${COMMON}
echo PROFILE_NAME: ${PROFILE_NAME}
echo IS_DEV: ${IS_DEV}
echo IS_PROD: ${IS_PROD}
'''
]
```

We run the **echo** task with **production** profile as follows:

```sh
cargo make --cwd ./examples --makefile profile.toml --profile production echo
```

Output:

```console
[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: profile.toml
[cargo-make] INFO - Task: echo
[cargo-make] INFO - Profile: production
[cargo-make] INFO - Setting Up Env.
[cargo-make] INFO - Running Task: init
[cargo-make] INFO - Running Task: echo
+ cd /media/devhdd/projects/rust/cargo-make/examples
+ echo COMMON: COMMON
COMMON: COMMON
+ echo PROFILE_NAME: production
PROFILE_NAME: production
+ echo IS_DEV: FALSE
IS_DEV: FALSE
+ echo IS_PROD: TRUE
IS_PROD: TRUE
[cargo-make] INFO - Running Task: end
[cargo-make] INFO - Build Done  in 0 seconds.
```

Env files also can be filtered based on profile using the **profile** attribute as follows:

```toml
env_files = [
    { path = "./development.env", profile = "development" },
    { path = "./production.env", profile = "production" },
    { path = "./env.env" }
]
```

Additional profiles defined in the config section will also result in additional env blocks/files to be loaded, for example:

```toml
env_files = [
    { path = "./second.env", profile = "second_profile" },
    { path = "./another.env", profile = "another_profile" }
]

[config]
additional_profiles = ["second_profile", "another_profile"]

[env.second_profile]
IS_SECOND_AVAILABLE = true

[env.another_profile]
IS_OTHER_AVAILABLE = true
```

This could be quite handy in having environment variable blocks which will enable/disable specific tasks.

<a name="usage-profiles-conditions"></a>
#### Conditions

[Conditions](#usage-conditions) enable you to trigger/skip tasks.<br>
Conditions have built in support for profiles, so you can trigger/skip tasks based on the profile name.

Example:

```toml
[tasks.echo-development]
condition = { profiles = [ "development" ] }
command = "echo"
args = [ "running in development profile" ]

[tasks.echo-production]
condition = { profiles = [ "production" ] }
command = "echo"
args = [ "running in production profile" ]
```

<a name="usage-profiles-built-in"></a>
#### Built In Profiles

cargo-make comes with few built in profiles to quickly enable additional conditional tasks.

* **ci-coverage-tasks** - Will enable all code coverage tasks and setup rust compilation to remove dead code.
* **none-thread-safe-tests** - Sets up rust test runner to a single thread
* **multi-phase-tests** - Enable to split the tests to multiple phases (thread safe, multi threaded, custom)
* **ci-static-code-analysis-tasks** - Will enable all static code analysis tasks such as format checking and clippy as part of the CI flow (see special note about backward compatibility below).
* **ci-all-build-tasks** - Will enable all extra compilation tasks (i.e. bench and example code) as part of the CI flow (see special note about backward compatibility below).
* **all-default-tasks** - Will enable extra tasks invoked while running the default task (such as toml formatting).

*Some of these profiles may change in the future to enable more tasks which may break your build and by definition will never be backward compatible.*<br>
*Use them with care.*

<a name="usage-private-tasks"></a>
### Private Tasks

Private tasks are tasks that should only be invoked by other tasks and not directly from the CLI.

In order to define a task as private, add the **private** attribute with value true as follows:

```toml
[tasks.internal-task]
private = true
```

<a name="usage-deprecated-tasks"></a>
### Deprecated Tasks

It is possible to mark tasks as deprecated in order to warn users that they should no longer use this task and switch to a newer/different task instead.<br>
Once invoked, a warning message will be displayed with the deprecation information.<br>
You can define a task deprecated by setting the **deprecated** to true or by providing a relevant message.<br>
For example:

```toml
[tasks.legacy]
deprecated = "Please use task OTHER instead"

[tasks.legacy-extended]
extend = "legacy"
deprecated = false

[tasks.legacy2]
deprecated = true
```

When invoking **legacy** task for example, the output is:

```console
[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: deprecated.toml
[cargo-make] INFO - Task: legacy
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: empty
[cargo-make] INFO - Running Task: legacy
[cargo-make] WARN - Task: legacy is deprecated - Please use task OTHER instead
[cargo-make] INFO - Running Task: empty
[cargo-make] INFO - Build Done in 0 seconds.
```

When listing tasks, deprecated tasks will contain this information as well:

```console
No Category
----------
default - Empty Task
empty - Empty Task
legacy - No Description. (deprecated - Please use task OTHER instead)
legacy-extended - No Description.
legacy2 - No Description. (deprecated)
```

<a name="usage-watch"></a>
### Watch
Watching for changes in your project and firing a task via cargo-make is very easy.<br>
Simply add the **watch** attribute for the task and set it to true and once the task is triggered, it will run every time a file changes in the project.<br>
The process needs to be killed in order to stop the watch.

Example:

```toml
[tasks.watch-example]
command = "echo"
args = [ "Triggered by watch" ]
watch = true
```

Below is a sample output of invoking the task:

```console
[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: ./examples/watch.toml
[cargo-make] INFO - Task: watch-example
[cargo-make] INFO - Setting Up Env.
[cargo-make] INFO - Running Task: init
[cargo-make] INFO - Running Task: watch-example
[cargo-make] INFO - Running Task: watch-example-watch
[cargo-make] INFO - Execute Command: "cargo" "watch" "-q" "-x" "make --disable-check-for-updates --no-on-error --loglevel=info --makefile=/projects/rust/cargo-make/examples/watch.toml watch-example"
[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: /projects/rust/cargo-make/examples/watch.toml
[cargo-make] INFO - Task: watch-example
[cargo-make] INFO - Setting Up Env.
[cargo-make] INFO - Running Task: init
[cargo-make] INFO - Running Task: watch-example
[cargo-make] INFO - Execute Command: "echo" "Triggered by watch"
Triggered by watch
[cargo-make] INFO - Running Task: end
[cargo-make] INFO - Build Done  in 0 seconds.
^C
```

You can also fine tune the watch setup (which is based on **cargo-watch**) by providing an object to the **watch** attribute as follows:

```toml
[tasks.watch-args-example]
command = "echo"
args = [ "Triggered by watch" ]
watch = { postpone = true, no_git_ignore = true, ignore_pattern = "examples/files/*", watch = ["./docs/"] }
```

See [the documentation](https://sagiegurari.github.io/cargo-make/api/cli/types/struct.WatchOptions.html) for a description of all the options available.

<a name="usage-watch-running-multiple-blocking-watches"></a>
#### Running Multiple Blocking Watches

In scenarios that you are required to run multiple blocking watches (for example running compilation + http server) you will need to run all such watches as parallel forked sub tasks.<br>
In order to implement that, you will need to use both fork=true and parallel=true attributes.<br>
For example:

```toml
[tasks.multiple-watches]
run_task = { name = ["build", "http-server", "something-else"], fork = true, parallel = true }
```

<a name="usage-functions"></a>
### Functions

cargo-make comes with built in functions which help extend capabilities missing with environment variables.<br>
Functions are not supported everywhere in the makefile and are currently only supported in command arguments array structure.<br>
In order to define a function call, the following format is used **@@FUNCTION_NAME(ARG1,ARG2,ARG3,...)**<br>
For example:

```toml
[tasks.split-example]
command = "echo"
args = ["@@split(ENV_VAR,|)"]
```

Currently Supported Functions:

* [Split](#usage-functions-split)
* [GetAt](#usage-functions-getat)
* [Remove Empty](#usage-functions-remove-empty)
* [Trim](#usage-functions-trim)
* [Decode](#usage-functions-decode)

<a name="usage-functions-split"></a>
#### Split

The split function accepts two arguments:

* environment variable name
* split by character

And returns an array of sub strings.<br>
This enables to split an environment variable to multiple command arguments, for example:

```toml
[env]
MULTIPLE_VALUES="1 2 3 4"

[tasks.split]
command = "echo"
args = ["@@split(MULTIPLE_VALUES, )"]

[tasks.no-split]
command = "echo"
args = ["${MULTIPLE_VALUES}"]
```

```console
> cargo make --cwd ./examples --makefile functions.toml split
[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: functions.toml
[cargo-make] INFO - Task: split
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: init
[cargo-make] INFO - Running Task: split
[cargo-make] INFO - Execute Command: "echo" "1" "2" "3" "4"
1 2 3 4
[cargo-make] INFO - Running Task: end
[cargo-make] INFO - Build Done  in 0 seconds.

> cargo make --cwd ./examples --makefile functions.toml no-split
[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: functions.toml
[cargo-make] INFO - Task: no-split
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: init
[cargo-make] INFO - Running Task: no-split
[cargo-make] INFO - Execute Command: "echo" "1 2 3 4"
1 2 3 4
[cargo-make] INFO - Running Task: end
[cargo-make] INFO - Build Done  in 0 seconds.
```

The split function also supports optional third *mode* attribute.<br>
If mode: *remove-empty* the output will not include empty values.

<a name="usage-functions-getat"></a>
#### GetAt

The getat function accepts three arguments:

* environment variable name
* split by character
* index of the item to return

And returns an array with a single value based on the given index.<br>
This enables to split an environment variable and extract only the needed param, for example:

```toml
[env]
MULTIPLE_VALUES="1 2 3 4"

[tasks.getat]
command = "echo"
args = ["@@getat(MULTIPLE_VALUES,|,3)"]
```

```console
> cargo make --cwd ./examples --makefile functions.toml getat
[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: functions.toml
[cargo-make] INFO - Task: getat
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: getat
[cargo-make] INFO - Execute Command: "echo" "4"
4
[cargo-make] INFO - Build Done in 0 seconds.
```

<a name="usage-functions-remove-empty"></a>
#### Remove Empty

The remove empty function accepts a single argument:

* environment variable name

It will completely remove that command line argument in case the environment variable is not defined or is empty or it returns the actual environment variable value.

```toml
[tasks.remove-empty]
command = "echo"
args = ["1", "@@remove-empty(DOES_NOT_EXIST)", "2"]
```

```console
> cargo make --cwd ./examples --makefile functions.toml remove-empty
[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: functions.toml
[cargo-make] INFO - Task: remove-empty
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: init
[cargo-make] INFO - Running Task: remove-empty
[cargo-make] INFO - Execute Command: "echo" "1" "2"
1 2
[cargo-make] INFO - Running Task: end
[cargo-make] INFO - Build Done  in 0 seconds.
```

<a name="usage-functions-trim"></a>
#### Trim

The trim function accepts the following arguments:

* environment variable name
* optionally a trim type: start/end (if not provided, it will trim both start and end)

It will completely remove that command line argument in case the environment variable is not defined or after it is trimmed, it is empty or it returns the actual environment variable value.

```toml
[env]
TRIM_VALUE="   123    "

[tasks.trim]
command = "echo"
args = ["@@trim(TRIM_VALUE)"]
```

```console
> cargo make --cwd ./examples --makefile functions.toml remove-empty
[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: functions.toml
[cargo-make] INFO - Task: trim
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: init
[cargo-make] INFO - Running Task: trim
[cargo-make] INFO - Execute Command: "echo" "123"
123
[cargo-make] INFO - Running Task: end
[cargo-make] INFO - Build Done  in 0 seconds.
```

Below are examples when using the start/end attributes:

```toml
[env]
TRIM_VALUE="   123    "

[tasks.trim-start]
command = "echo"
args = ["@@trim(TRIM_VALUE,start)"]

[tasks.trim-end]
command = "echo"
args = ["@@trim(TRIM_VALUE,end)"]
```

```console
> cargo make --cwd ./examples --makefile functions.toml trim-start
[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: functions.toml
[cargo-make] INFO - Task: trim-start
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: init
[cargo-make] INFO - Running Task: trim-start
[cargo-make] INFO - Execute Command: "echo" "123    "
123
[cargo-make] INFO - Running Task: end
[cargo-make] INFO - Build Done  in 0 seconds.

> cargo make --cwd ./examples --makefile functions.toml trim-end
[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: functions.toml
[cargo-make] INFO - Task: trim-end
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: init
[cargo-make] INFO - Running Task: trim-end
[cargo-make] INFO - Execute Command: "echo" "   123"
   123
[cargo-make] INFO - Running Task: end
[cargo-make] INFO - Build Done  in 0 seconds.
```

<a name="usage-functions-decode"></a>
#### Decode

The decode function accepts the following arguments:

* environment variable name
* optional a list of mapping values (source/target)
* optional default value

It will completely remove that command line argument in case the output it is empty.

For example:

```toml
[tasks.decode]
command = "echo"
args = ["Env:", "${CARGO_MAKE_PROFILE}", "Decoded:", "@@decode(CARGO_MAKE_PROFILE,development,dev,ci,test)"]
```

We check the `CARGO_MAKE_PROFILE` environment variable value and look for it in the mappings.<br>
If the value is **development** it will be mapped to **dev** while **ci** is mapped to **test**.<br>
In case no mapping is found, the original value is returned.<br>
Sample run for a mapping that was found:

```console
cargo make --cwd ./examples --makefile functions.toml -e DECODE_ENV_VAR=development decode
[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: functions.toml
[cargo-make] INFO - Task: decode
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: empty
[cargo-make] INFO - Running Task: decode
[cargo-make] INFO - Execute Command: "echo" "Env:" "development" "Decoded:" "dev"
Env: development Decoded: dev
[cargo-make] INFO - Running Task: empty
[cargo-make] INFO - Build Done in 0 seconds.
```

Another sample run for a mapping that was not found:

```console
cargo make --cwd ./examples --makefile functions.toml -e DECODE_ENV_VAR=unmapped decode
[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: functions.toml
[cargo-make] INFO - Task: decode
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: empty
[cargo-make] INFO - Running Task: decode
[cargo-make] INFO - Execute Command: "echo" "Env:" "unmapped" "Decoded:" "unmapped"
Env: unmapped Decoded: unmapped
[cargo-make] INFO - Running Task: empty
[cargo-make] INFO - Build Done in 0 seconds.
```

Another example:

```toml
[tasks.decode-with-default]
command = "echo"
args = ["Env:", "${DECODE_ENV_VAR}", "Decoded:", "@@decode(DECODE_ENV_VAR,development,dev,ci,test,unknown)"]
```

Same as previous example, but the difference here is that if not mapping is found, the default value (last argument) is returned.<br>
Sample run:

```console
cargo make --cwd ./examples --makefile functions.toml -e DECODE_ENV_VAR=unmapped decode-with-default
[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: functions.toml
[cargo-make] INFO - Task: decode-with-default
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: empty
[cargo-make] INFO - Running Task: decode-with-default
[cargo-make] INFO - Execute Command: "echo" "Env:" "unmapped" "Decoded:" "unknown"
Env: unmapped Decoded: unknown
[cargo-make] INFO - Running Task: empty
[cargo-make] INFO - Build Done in 0 seconds.
```

Mapped values can hold environment expressions, for example:

```toml
[tasks.decode-with-eval]
command = "echo"
args = ["Env:", "${DECODE_ENV_VAR}", "Decoded:", "@@decode(DECODE_ENV_VAR,test,The current profile is: ${CARGO_MAKE_PROFILE})"]
```

Sample run:

```console
cargo make --cwd ./examples --makefile functions.toml -e DECODE_ENV_VAR=test decode-with-eval
[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: functions.toml
[cargo-make] INFO - Task: decode-with-eval
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: empty
[cargo-make] INFO - Running Task: decode-with-eval
[cargo-make] INFO - Execute Command: "echo" "Env:" "test" "Decoded:" "The current profile is: development"
Env: test Decoded: The current profile is: development
[cargo-make] INFO - Running Task: empty
[cargo-make] INFO - Build Done in 0 seconds.
```

<a name="usage-ci"></a>
### Continuous Integration
cargo-make comes with a predefined flow for continuous integration build executed by internal or online services such as travis-ci and appveyor.<br>
It is recommended to install cargo-make with the debug flag for faster installation.

<a name="usage-ci-github-actions"></a>
#### Github Actions
Add the following to your workflow yml file:

```yaml
- name: Install cargo-make
  uses: actions-rs/cargo@v1
  with:
    command: install
    args: --debug cargo-make
- name: Run CI
  uses: actions-rs/cargo@v1
  with:
    command: make
    args: ci-flow
```

This will use the latest cargo-make with all latest features.

You can see full yaml file at: [ci.yml](https://github.com/sagiegurari/ci_info/blob/master/.github/workflows/ci.yml)

If you want to run code coverage and upload it to codecov, also define the following environment variable:

```toml
CARGO_MAKE_RUN_CODECOV=true
```

When working with workspaces, in order to run the ci-flow for each member and package all coverage data, use the following command:

```yaml
- name: Install cargo-make
  uses: actions-rs/cargo@v1
  with:
    command: install
    args: --debug cargo-make
- name: Run CI
  uses: actions-rs/cargo@v1
  with:
    command: make
    args: --no-workspace workspace-ci-flow
```

To speed up cargo-make installation during the build, you can use the [rust-cargo-make](https://github.com/marketplace/actions/rust-cargo-make) github action to download the prebuilt binary.

<a name="usage-ci-travis"></a>
#### Travis
Add the following to `.travis.yml` file:

```yaml
script:
  - cargo install --debug cargo-make
  - cargo make ci-flow
```

This will use the latest cargo-make with all latest features.
<br>
When caching `cargo`:

```yaml
cache: cargo
script:
  - which cargo-make || cargo install cargo-make
  - cargo make ci-flow
```

*NOTE: While using cache, in order to update cargo-make, you will need to manually clear the travis cache*

If you want to run code coverage and upload it to codecov, also define the following environment variable:

```yaml
env:
  global:
    - CARGO_MAKE_RUN_CODECOV="true"
```

*NOTE: If you are using kcov coverage, you can cache the kcov installation by setting the `CARGO_MAKE_KCOV_INSTALLATION_DIRECTORY` environment variable to a location which is cached by travis.*

When working with workspaces, in order to run the ci-flow for each member and package all coverage data, use the following command:

```yaml
script:
  - cargo install --debug cargo-make
  - cargo make --no-workspace workspace-ci-flow
```

<a name="usage-ci-appveyor"></a>
#### AppVeyor
Add the following to the `appveyor.yml` file:

```yaml
build: false

test_script:
  - cargo install --debug cargo-make
  - cargo make ci-flow
```

When working with workspaces, in order to run the ci-flow for each member and package all coverage data, use the following command:

```yaml
build: false

test_script:
  - cargo install --debug cargo-make
  - cargo make --no-workspace workspace-ci-flow
```

<a name="usage-ci-gitlab"></a>
#### GitLab CI
Add the following to your `gitlab-ci.yml` file:

```yaml
test:cargo:
  script:
  - cargo install --debug cargo-make
  - cargo make ci-flow
```

When working with workspaces, in order to run the ci-flow for each member and package all coverage data, use the following command:

```yaml
build: false

test:cargo:
  script:
  - cargo install --debug cargo-make
  - cargo make --no-workspace workspace-ci-flow
```

To upload your coverage information to codecov, you'll need to go to repo settings for your GitLab repo,
[and add a secret variable](https://docs.gitlab.com/ce/ci/variables/README.html#secret-variables) with your codecov token for that repository.

Then you can add the following in your `gitlab-ci.yml` to enable coverage support:

```yaml
variables:
  CARGO_MAKE_RUN_CODECOV: "true"
```

<a name="usage-ci-circleci"></a>
#### CircleCI
Add the following to your `.circleci/config.yml` file:

```yaml
- run:
    name: install cargo-make
    command: cargo install --debug cargo-make
- run:
    name: ci flow
    command: cargo make ci-flow
```

This will use the latest cargo-make with all latest features.
<br>
When caching `cargo`:

```yaml
  - restore_cache:
      key: project-cache
  # ....
  - run:
      name: install cargo-make
      command: which cargo-make || cargo install cargo-make
  - run:
      name: ci flow
      command: cargo make ci-flow
  # ....
  - save_cache:
      key: project-cache
      paths:
        - "~/.cargo"
```

*NOTE: While using cache, in order to update cargo-make, you will need to manually clear the CircleCI cache*

*NOTE: If you are using kcov coverage, you can cache the kcov installation by setting the `CARGO_MAKE_KCOV_INSTALLATION_DIRECTORY` environment variable to a location which is cached by CircleCI.*

When working with workspaces, in order to run the ci-flow for each member and package all coverage data, use the following command:

```yaml
- run:
    name: install cargo-make
    command: cargo install --debug cargo-make
- run:
    name: ci flow
    command: cargo make --no-workspace workspace-ci-flow
```

<a name="usage-ci-azure-pipelines"></a>
#### Azure Pipelines
Add the following to your `azure-pipelines.yml` file:

```yaml
- script: cargo install --debug cargo-make
  displayName: install cargo-make
- script: cargo make ci-flow
  displayName: ci flow
```

When working with workspaces, in order to run the ci-flow for each member and package all coverage data, use the following setup:

```yaml
- script: cargo install --debug cargo-make
  displayName: install cargo-make
- script: cargo make --no-workspace workspace-ci-flow
  displayName: ci flow
```

<a name="usage-ci-drone-io"></a>
#### drone.io
This is a minimal `.drone.yml` example for running the ci-flow task with the docker runner:

```yaml
pipeline:
  ci-flow:
    image: rust:1.38-slim
    commands:
    - cargo install --debug cargo-make
    - cargo make ci-flow
```

<a name="usage-ci-cirrus"></a>
#### Cirrus CI
This is a minimal `.cirrus.yml` example for running the ci-flow task:

```yaml
container:
  image: rust:latest

task:
  name: ci-flow
  install_script: cargo install --debug cargo-make
  flow_script: cargo make ci-flow
```

<a name="usage-predefined-flows"></a>
### Predefined Flows
The [default makefiles](https://github.com/sagiegurari/cargo-make/blob/master/src/lib/descriptor/makefiles/) file comes with many predefined tasks and flows.<br>
The following are some of the main flows that can be used without any need of an external `Makefile.toml` definition.

* **default** - Can be executed without adding the task name, simply run `cargo make`. This task is an alias for dev-test-flow.
* **dev-test-flow** - Also the default flow so it can be invoked without writing any task name (simply run **cargo make**).<br>This task runs formatting, cargo build and cargo test and will most likely be the set of tasks that you will run while developing and testing a rust project.
* **watch-flow** - Watches for any file change and if any change is detected, it will invoke the test flow.
* **ci-flow** - Should be used in CI builds (such as travis/appveyor) and it runs build and test with verbose level.
* **workspace-ci-flow** - Should be used in CI builds (such as travis/appveyor) for workspace projects.
* **publish-flow** - Cleans old target directory and publishes the project.
* **build-flow** - Runs full cycle of build, tests, security checks, dependencies up to date validations, and documentation generation.<br>This flow can be used to make sure your project is fully tested and up to date.
* **coverage-flow** - Creates coverage report from all unit and integration tests (not supported on windows). By default cargo-make uses kcov for code coverage; however, additional unsupported implementations are defined.
* **codecov-flow** - Runs the coverage-flow and uploads the coverage results to codecov (not supported on windows).

<a name="usage-predefined-flows-coverage"></a>
#### Coverage
cargo-make has built in support for multiple coverage tasks.<br>
Switching between them without modifying the flows is done by setting the coverage provider name in the **`CARGO_MAKE_COVERAGE_PROVIDER`** environment variable as follows:

```toml
[env]
# can be defined as kcov, tarpaulin, ...
CARGO_MAKE_COVERAGE_PROVIDER = "kcov"
```

In case you have a custom coverage task, it can be plugged into the coverage flow by changing the main coverage task alias, for example:

```toml
[tasks.coverage]
alias = "coverage-some-custom-provider"
```

You can run:

```sh
cargo make --list-all-steps | grep "coverage-"
```

To view all currently supported providers. Example output:

```console
ci-coverage-flow: No Description.
coverage-tarpaulin: Runs coverage using tarpaulin rust crate (linux only)
coverage-flow: Runs the full coverage flow.
coverage-kcov: Installs (if missing) and runs coverage using kcov (not supported on windows)
```

All built in coverage providers are supported by their authors and not by cargo-make.

Based on the above explanation, to generate a coverage report for a simple project, run the following command:

```sh
cargo make coverage
```

In order to run coverage in a workspace project and package all member coverage reports in the workspace level, run the following command:

```sh
cargo make --no-workspace workspace-coverage
```

If you are using **kcov**, you may declare the following environment variables in your Makefile.toml to customize the coverage task:

Specify lines or regions of code to ignore:

```toml
[env]
CARGO_MAKE_KCOV_EXCLUDE_LINE = "unreachable,kcov-ignore"             # your choice of pattern(s)
CARGO_MAKE_KCOV_EXCLUDE_REGION = "kcov-ignore-start:kcov-ignore-end" # your choice of markers
```

By default, the binaries executed to collect coverage are filtered by a regular expression. You may override the following in case it does not match the binaries generated on your system:

```toml
[env]
# for example: cargo make filter regex would be cargo_make-[a-z0-9]*$
CARGO_MAKE_TEST_COVERAGE_BINARY_FILTER = "${CARGO_MAKE_CRATE_FS_NAME}-[a-z0-9]*$"
```

*For grcov support, checkout the following repo for instructions:*<br>
*https://github.com/kazuk/cargo-make-coverage-grcov*

<a name="usage-predefined-flows-full"></a>
#### Full List

See [full list of all predefined tasks](https://github.com/sagiegurari/cargo-make/blob/master/docs/cargo_make_task_list.md) (generated via **`cargo make --list-all-steps`**)

<a name="usage-predefined-flows-disable"></a>
#### Disabling Predefined Tasks/Flows

In order to prevent loading of internal core tasks and flows, simply add the following configuration property in your external Makefile.toml:

```toml
[config]
skip_core_tasks = true
```

*Few empty tasks would be loaded even with skipping core tasks to ensure cargo-make has a default task defined.*

<a name="usage-predefined-flows-modify"></a>
#### Modifying Predefined Tasks/Flows

It is possible to modify the internal core tasks.<br>
All modifications are defines in the **config.modify_core_tasks** section.

```toml
[config.modify_core_tasks]
# if true, all core tasks are set to private (default false)
private = true

# if set to some value, all core tasks are modified to: <namespace>::<name> for example default::build
namespace = "default"
```

<a name="usage-min-version"></a>
### Minimal Version
In case you are using cargo-make features that are only available from a specific version, you can ensure the build will fail if it is invoked by an older cargo-make version.<br>
In order to specify the minimal version, use the **min_version** in the config section as follows:

```toml
[config]
min_version = "0.37.16"
```

<a name="usage-performance-tuning"></a>
### Performance Tuning
Some features of cargo-make can be disabled which can improve the startup time.<br>
Below is a list of all current features:

```toml
[config]
# Skip loading of all core tasks which saves up a bit on toml parsing and task creation
skip_core_tasks = true
# Skips loading Git related environment variables
skip_git_env_info = true
# Skips loading rust related environment variables
skip_rust_env_info = true
# Skips loading the current crate related environment variables
skip_crate_env_info = true
```

When running in a rust workspace, you can disable some of the features in the member makefiles.<br>
For example, if the members are in the same git repo as the entire project, you can add **skip_git_env_info** in the members
makefiles and they will still have the environment variables setup from the parent process.

For tasks that can be skipped in case no input file has been modified, see the [Running Tasks Only If Sources Changed](#usage-running-tasks-only-if-sources-changed) section.

<a name="usage-command-groups"></a>
### Command Groups (Subcommands)

You can expose the tasks as *groups* by creating a top level task which will call other internal tasks.

There are two possible approaches for this.

#### Local tasks

Using private tasks (private is not mandatory) are more suited for simple cases and redirect one command to another.

This approach has some limitations:
- `--list-all-steps` will not list private tasks
- the tasks required a specific naming pattern

For example, if you want to have server start/stop and client start/stop commands and execute them as follows:

```sh
cargo make server start
cargo make server stop
cargo make client start
cargo make client stop
```

You can define two top level tasks (server and client) that will invoke the internal ones.<br>
Example implementation:

```toml
[tasks.server]
private = false
extend = "subcommand"
env = { "SUBCOMMAND_PREFIX" = "server" }

[tasks.client]
private = false
extend = "subcommand"
env = { "SUBCOMMAND_PREFIX" = "client" }

[tasks.subcommand]
private = true
script = '''
#!@duckscript

cm_run_task ${SUBCOMMAND_PREFIX}_${1}
'''

[tasks.server_start]
private = true
command = "echo"
args = ["starting server..."]

[tasks.server_stop]
private = true
command = "echo"
args = ["stopping server..."]

[tasks.client_start]
private = true
command = "echo"
args = ["starting client..."]

[tasks.client_stop]
private = true
command = "echo"
args = ["stopping client..."]
```

#### External subcommand file

Another approach is to use a different configuration file for the subcommands.

This allows using `--list-all-steps` for the subcommand and also set `[config]` options in the subcommand file.

For projects with subprojects in folders, a `Makefile.toml` can be created for each subproject and be reached as subcommands from the main folder.

Example implementation of a `foo` sobcommand with a configuration file in the `foo/` folder.

```toml
[tasks.foo]
description = "Foo subcommands"
category = "Subcommands"
cwd = "foo/"
command = "makers"
args = ["${@}"]
```

Example implementation of a `foo` sobcommand with a `Makefile.foo.toml` configuration file in the same folder.

```toml
[tasks.foo]
description = "Foo subcommands"
category = "Subcommands"
command = "makers"
args = ["--makefile", "Makefile.foo.toml", "${@}"]
```

<a name="usage-diff-changes"></a>
### Diff Changes
Using the **`--diff-steps`** CLI command flag, you can diff your correct overrides compared to the prebuilt internal makefile flow.

Example Usage:

```console
cargo make --diff-steps --makefile ./examples/override_core.toml post-build
[cargo-make] INFO - cargo make 0.37.16
[cargo-make] INFO - Build File: ./examples/override_core.toml
[cargo-make] INFO - Task: post-build
[cargo-make] INFO - Setting Up Env.
[cargo-make] INFO - Printing diff...
[cargo-make] INFO - Execute Command: "git" "diff" "--no-index" "/tmp/cargo-make/Lz7lFgjj0x.toml" "/tmp/cargo-make/uBpOa9THwD.toml"
diff --git a/tmp/cargo-make/Lz7lFgjj0x.toml b/tmp/cargo-make/uBpOa9THwD.toml
index 5152290..ba0ef1d 100644
--- a/tmp/cargo-make/Lz7lFgjj0x.toml
+++ b/tmp/cargo-make/uBpOa9THwD.toml
@@ -42,7 +42,9 @@
         name: "post-build",
         config: Task {
             clear: None,
-            description: None,
+            description: Some(
+                "Override description"
+            ),
             category: Some(
                 "Build"
             ),
[cargo-make] INFO - Done
```

*Git is required to be available as it is used to diff the structures and output it to the console using standard git coloring scheme.*

<a name="usage-unstable-features"></a>
### Unstable Features
Some cargo-make capabilities, while working well, are not yet set as default behaviour.<br>
Therefore they are gated using the **unstable_features** attribute.<br>
In order to enable such a feature, you need to define its name.<br>
For example, for the xxx feature would be defined as follows:<br>

```toml
[config]
unstable_features = ["CTRL_C_HANDLING"]
```

Below is a list of currently existing unstable features

* **CTRL_C_HANDLING** - Adds <kbd>ctrl-c</kbd> handler, which will stop any currently running command invoked by the current task and exit cargo-make

<a name="usage-cli"></a>
### CLI Options
These are the following options available while running cargo-make:

```console
USAGE:
    [makers | cargo make | cargo-make make] [OPTIONS] [--] [<TASK_CMD>...]

ARGS:
    <TASK_CMD>    The task to execute, potentially including arguments which can be accessed in the task itself.

OPTIONS:
    --help, -h                           Print help information
    --version, -V                        Print version information
    --makefile <FILE>                    The optional toml file containing the tasks definitions
    --task, -t <TASK>                    The task name to execute (can omit the flag if the task name is the last argument) [default: default]
    --profile, -p <PROFILE>              The profile name (will be converted to lower case) [default: development]
    --cwd <DIRECTORY>                    Will set the current working directory. The search for the makefile will be from this directory if defined.
    --no-workspace                       Disable workspace support (tasks are triggered on workspace and not on members)
    --no-on-error                        Disable on error flow even if defined in config sections
    --allow-private                      Allow invocation of private tasks
    --skip-init-end-tasks                If set, init and end tasks are skipped
    --skip-tasks <SKIP_TASK_PATTERNS>    Skip all tasks that match the provided regex (example: pre.*|post.*)
    --env-file <FILE>                    Set environment variables from provided file
    --env, -e <ENV>                      Set environment variables
    --loglevel, -l <LOG LEVEL>           The log level (verbose, info, error, off) [default: info]
    --verbose, -v                        Sets the log level to verbose (shorthand for --loglevel verbose)
    --quiet                              Sets the log level to error (shorthand for --loglevel error)
    --silent                             Sets the log level to off (shorthand for --loglevel off)
    --no-color                           Disables colorful output
    --time-summary                       Print task level time summary at end of flow
    --experimental                       Allows access unsupported experimental predefined tasks.
    --disable-check-for-updates          Disables the update check during startup
    --output-format <OUTPUT FORMAT>      The print/list steps format (some operations do not support all formats) (default, short-description, markdown, markdown-single-page, markdown-sub-section, autocomplete)
    --output-file <OUTPUT_FILE>          The list steps output file name
    --hide-uninteresting                 Hide any minor tasks such as pre/post hooks.
    --print-steps                        Only prints the steps of the build in the order they will be invoked but without invoking them
    --list-all-steps                     Lists all known steps
    --list-category-steps <CATEGORY>     List steps for a given category
    --diff-steps                         Runs diff between custom flow and prebuilt flow (requires git)
```

<a name="usage-plugins"></a>
### Plugins

Plugins enable users to take full control of the task execution.<br>
cargo-make would still create the execution plan based on the tasks and their dependencies, but would leave the individual task execution to the plugin code.<br>
<br>
Plugins are basically a single duckscript code block with access to the task and flow meta data and can invoke cargo-make specific commands or general duckscript commands.<br>
For example, if a task defined a command and arguments to execute and the plugin simply needs to invoke them, you can implement a simple plugin as follows:

```sh
args_string = array_join ${task.args} " " # simple example which doesn't support args that contain spaces in them
exec --fail-on-error ${task.command} %{args_string}
```

Once a plugin is defined for a task, the task execution control moves to the plugin itself.<br>
All scripts, commands, conditions, env, etc... are ignored and should be handled by the plugin code itself.<br>
All specific task environment variables will not be defined globally (all CARGO_MAKE_CURRENT_TASK_ variables) and instead available in the task env block in the json string.

<a name="usage-plugins-defining-plugins"></a>
### Defining Plugins

Plugins are defined under the `plugin.impl` prefix, for example:

```toml
[plugins.impl.command-runner]
script = '''
echo task: ${task.name}

args_string = array_join ${task.args} " " # simple example which doesn't support args that contain spaces in them
exec --fail-on-error ${task.command} %{args_string}
'''
```

You can defining as many plugins as needed.<br>
It is also possible to provide them aliases to map new names to existing plugins.<br>
For example:

```toml
[plugins.aliases]
original = "new"
this = "that"
```

For a task to pass the execution control to the plugin, simply put the plugin name in the **plugin** attribute.<br>
For example:

```toml
[tasks.my-task]
plugin = "my-plugin"
# other attributes as needed...
```

**You can create reusable plugins and load them using the [load scripts](#usage-load-scripts) built in capability.**

<a name="usage-plugins-plugin-sdk"></a>
### Plugin SDK

The plugin SDK contains the following:

* [Common Duckscript SDK](https://github.com/sagiegurari/duckscript/blob/master/docs/sdk.md)
* Metadata variables
    * flow.task.name - Holds the flow task (not current task) which triggered this task
    * flow.cli.args - Array holding all the task arguments provided to cargo-make on the command line
    * plugin.impl.name - The current plugin name (after aliases modifications)
    * task.as_json - The entire task config as json string (can use json_parse to convert to duckscript variables).
    * task.has_condition - true if the task has any condition definition (including empty one)
    * task.has_env  - true if the task has any env definition (including empty one)
    * task.has_install_instructions - true of the task has installation definition.
    * task.has_command - true if the task has a command definition
    * task.has_script - true if the task has a script definition
    * task.has_run_task - true if the task has a run_task definition
    * task.has_dependencies - true if the task has dependencies
    * task.has_toolchain_specifier - true if the task has toolchain definition
    * task.name - The task name
    * task.description - The description
    * task.category - The category
    * task.disabled - true/false based on the disabled attributes
    * task.private - true/false based on the private attributes
    * task.deprecated - true/false based on the deprecated attributes
    * task.workspace - true/false based on the workspace attributes
    * task.plugin.name - The plugin name defined in the task (before aliases)
    * task.watch - true/false based on the watch attributes
    * task.ignore_errors - true/false based on the ignore_errors attributes
    * task.cwd - The task's current working directory value
    * task.command - The command
    * task.args - Array of all the command arguments
    * task.script_runner - The script runner value
    * task.script_runner_args = Array of all the script runner arguments
    * task.script_extension - The script file extension value
* cargo-make task script specific commands
    * ```cm_run_task [--async] takename``` - Runs a task and dependencies. Supports async execution (via --async flag). Must get the task name to invoke.
* cargo-make plugin specific commands
    * ```cm_plugin_run_task``` - Runs the current task that invoked the plugin (not including dependencies), including condition handling, env, cwd and all the logic that cargo-make has.
    * ```cm_plugin_run_custom_task``` - Accepts a task json string and runs the task definition (not including dependencies), including condition handling, env, cwd and all the logic that cargo-make has.
    * ```cm_plugin_check_task_condition``` - Returns true/false if the current task conditions are met
    * ```cm_plugin_force_plugin_set``` - All tasks that are going to be invoked in the future will call the current plugin regardless of their config
    * ```cm_plugin_force_plugin_clear``` - Undos the cm_plugin_force_plugin_set change and tasks will behave as before

<a name="usage-plugins-plugin-example-dockerize"></a>
### Plugin Example - Docker Integration

Below is a simple example which runs a task (and the rest of the flow from that point) in a docker container.

```toml
[plugins.impl.dockerize]
script = '''
plugin_force_set = get_env PLUGIN_FORCE_SET
plugin_force_set = eq "${plugin_force_set}" 1

if not ${plugin_force_set}
    cm_plugin_force_plugin_set
    set_env PLUGIN_FORCE_SET 1

    dockerfile = set ""
    fn add_docker
        dockerfile = set "${dockerfile}${1}\n"
    end

    taskjson = json_parse ${task.as_json}
    makefile = basename ${taskjson.env.CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE}

    add_docker "FROM debian:stable"
    add_docker "RUN mkdir /workdir/"
    add_docker "RUN mkdir /workdir/project/"
    add_docker "RUN apt-get update"
    add_docker "RUN apt-get install -y curl build-essential libssl-dev pkg-config"
    add_docker "ENV PATH=\"$PATH:$HOME/.cargo/bin\""
    add_docker "RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y"
    add_docker "RUN $HOME/.cargo/bin/cargo install cargo-make"
    add_docker "RUN $HOME/.cargo/bin/cargo make --version"
    add_docker "RUN echo \"cd ./workdir/project/ && ls -lsa && $HOME/.cargo/bin/cargo make --makefile ${makefile} --profile ${CARGO_MAKE_PROFILE} ${CARGO_MAKE_TASK}\" > ./run.sh"
    add_docker "RUN chmod 777 ./run.sh"
    add_docker "ADD . /workdir/project/"
    add_docker "CMD [\"sh\", \"./run.sh\"]"

    writefile ./Dockerfile ${dockerfile}
    exec --fail-on-error docker build --tag cmimg:build ./

    exec --fail-on-error docker run cmimg:build
end
'''

[tasks.default]
alias = "docker_flow"

[tasks.docker_flow]
dependencies = ["part1", "part2", "part3"]

[tasks.base-task]
command = "echo"
args = ["task", "${CARGO_MAKE_CURRENT_TASK_NAME}"]

[tasks.part1]
plugin = "dockerize"
extend = "base-task"

[tasks.part2]
extend = "base-task"

[tasks.part3]
extend = "base-task"
```

Running:

```sh
cargo make docker_flow
```

Will result in creation of a new docker container that will run parts 1-3 inside it.<br>
**The example works. However, it does not support several features like passing CLI args, etc....**

<a name="usage-plugins-plugin-example-parallel-workspace-members"></a>
### Plugin Example - Run workspace members in parallel

The following example shows how to define a task on workspace level makefile to enable to invoke it on each member in parallel.

```toml
[plugins.impl.parallel-members]
script = '''
plugin_used = get_env PLUGIN_USED
plugin_used = eq "${plugin_used}" 1

if not ${plugin_used}
    set_env PLUGIN_USED 1
    members = split ${CARGO_MAKE_CRATE_WORKSPACE_MEMBERS} ,

    workspace_dir = pwd
    for member in ${members}
        cd ./${member}
        spawn cargo make --disable-check-for-updates --allow-private --no-on-error ${flow.task.name} %{args}
        cd ${workspace_dir}
    end

    release ${members}
else
    task_definition = json_parse --collection ${task.as_json}
    map_remove ${task_definition} workspace
    task_json = json_encode --collection ${task_definition}
    cm_plugin_run_custom_task ${task_json}
end
'''

[tasks.sometask]
# to make this task serial and not parallel, remove following 2 lines
plugin = "parallel-members"
workspace = false
```

<a name="usage-plugins-plugin-example-rustenv"></a>
### Plugin Example - Load Env From Rust Script

The following example shows how to enable rust scripts invoked from cargo-make to update the main cargo-make process env.<br>
It assumes the task has a script line and that the script is rust. It will execute it (ignoring any rust script provider config for sake of simplicity) and load each output line as an env key/value pair.

```toml
[plugins.impl.rust-env]
script = '''
# make sure the task has a script
assert ${task.has_script}

taskjson = json_parse ${task.as_json}
script = set ${taskjson.script}
writefile ./target/_tempplugin/main.rs ${script}

out = exec --fail-on-error rust-script ./target/_tempplugin/main.rs

output = trim ${out.stdout}
lines = split ${output} \n
for line in ${lines}
    parts = split ${line} =
    key = array_get ${parts} 0
    value = array_get ${parts} 1
    set_env ${key} ${value}
end
'''

[tasks.default]
alias = "test"

[tasks.test]
dependencies = ["dorust"]
command = "echo"
args = ["${ENV_FROM_RUST1}", "${ENV_FROM_RUST2}"]

[tasks.dorust]
private = true
plugin = "rust-env"
script = '''
fn main() {
    println!("ENV_FROM_RUST1=hello");
    println!("ENV_FROM_RUST2=world");
}
'''
```

<a name="usage-plugins-plugin-example-powershell"></a>
### Plugin Example - Adding Simpler Windows Powershell Support

In the below example, we add the a simple powershell command support.<br>
This plugin will take an existing task, set its command to powershell and prepend the **`-C`** argument.<br>
This example also shows how to create new tasks in runtime and invoke them.

```toml
[plugins.impl.powershell]
script = '''
# Adds simpler powershell integration

# make sure we are on windows
windows = is_windows
assert ${windows}

# make sure the task has args
args_empty = array_is_empty ${task.args}
assert_false ${args_empty}

task_definition = json_parse --collection ${task.as_json}

# prepend powershell args to task args
powershell_args = array -C
all_args = array_concat ${powershell_args} ${task.args}
args = map_get ${task_definition} args
release ${args}
map_put ${task_definition} args ${all_args}

# set powershell command
map_put ${task_definition} command pwsh.exe

powershell_task_json = json_encode --collection ${task_definition}

echo Custom Task:\n${powershell_task_json}
cm_plugin_run_custom_task ${powershell_task_json}
'''

[tasks.default]
alias = "test"

[tasks.test]
plugin = "powershell"
args = ["echo hello from windows powershell"]
```

<a name="usage-shell-completion"></a>
### Shell Completion

cargo-make comes with shell auto completion support, however in order to provide the exact task names that are
available in the current directory, it will run the `--list-all-steps` command which might take a bit to finish.

<a name="usage-shell-completion-bash"></a>
#### Bash
Source the `makers-completion.bash` file (found in `extra/shell` folder) at the start of your shell session.
It will enable auto completion for the **makers** executable.

<a name="usage-shell-completion-zsh"></a>
#### zsh
zsh supports bash auto completion. Therefore, the existing bash autocomplete can be used by running the following script:

```
autoload -U +X compinit && compinit
autoload -U +X bashcompinit && bashcompinit

# make sure to update the path based on your file system location
source ./extra/shell/makers-completion.bash
```

It will enable auto completion for the **makers** executable.

<a name="usage-shell-completion-fig"></a>
#### Fig / Amazon CodeWhisperer for command line

Fig supports cargo-make as of [this PR](https://github.com/withfig/autocomplete/pull/2180), no special configuration is needed, just download the latest version of [Fig](https://fig.io/) or [Amazon CodeWhisperer for command line](https://aws.amazon.com/blogs/devops/introducing-amazon-codewhisperer-for-command-line/).

Double check if `cargo-make` is globally installed by running:

```bash
cargo --list
```

If you can see `make` on the list, Fig should work and load the completion automatically from `./Makefile.toml` or any directory you specify with `--makefile <path>`

<a name="cargo-make-global-config"></a>
### Global Configuration
Some of the default CLI values and cargo-make behaviour can be configured via optional global configuration file `config.toml` located in the cargo-make directory.

The cargo-make directory location can be defined via `CARGO_MAKE_HOME` environment variable value.<br>
If `CARGO_MAKE_HOME` has not been defined, the cargo-make default location is:

| OS      | Location                          |
| ------- | --------------------------------- |
| Linux   | $XDG_CONFIG_HOME or $HOME/.config |
| Windows | RoamingAppData                    |
| Mac     | $HOME/Library/Preferences         |

If for any reason, the above paths are not valid for the given platform, it will default to `$HOME/.cargo-make`.

The following example `config.toml` shows all possible options with their default values:

```toml
# The default log level if not defined by the `--loglevel` CLI argument
log_level = "info"

# The default configuration whether output coloring is disabled
disable_color = false

# The default task name if no task was provided as part of the cargo-make invocation
default_task_name = "default"

# cargo-make checks for updates during invocation.
# This configuration defines the minimum amount of time which must pass before cargo-make invocations will try to check for updates.
# If the minimum amount of time did not pass, cargo-make will not check for updates (same as --disable-check-for-updates)
# Valid values are: always, daily, weekly, monthly
# If any other value is provided, it will be treated as weekly.
update_check_minimum_interval = "weekly"

# If set to true and cwd was not provided in the command line arguments and the current cwd is not the project root (Cargo.toml not present),
# cargo make will attempt to find the project root by searching the parent directories, until a directory with a Cargo.toml is found.
# cargo make will set the cwd to that directory and will use any Makefile.toml found at that location.
search_project_root = false
```

<a name="descriptor-definition"></a>
## Makefile Definition

[Config Section](https://sagiegurari.github.io/cargo-make/api/cli/types/struct.ConfigSection.html)

[Task](https://sagiegurari.github.io/cargo-make/api/cli/types/struct.Task.html)

[Platform Override](https://sagiegurari.github.io/cargo-make/api/cli/types/struct.PlatformOverrideTask.html)

[Condition](https://sagiegurari.github.io/cargo-make/api/cli/types/struct.TaskCondition.html)

More info can be found in the [types](https://sagiegurari.github.io/cargo-make/api/cli/types/index.html) section of the API documentation.

<a name="task-name-conventions"></a>
## Task Naming Conventions
This section explains the logic behind the default task names.<br>
While the default names logic can be used as a convention for any new task defined in some project Makefile.toml, it is not required.

The [default makefiles](https://github.com/sagiegurari/cargo-make/blob/master/src/lib/descriptor/makefiles/) file comes with several types of tasks:

* Single command or script task (for example **cargo build**)
* Tasks that come before or after the single command tasks (hooks)
* Tasks that define flows using dependencies
* Tasks which only install some dependency

Single command tasks are named based on their command (in most cases), for example the task that runs cargo build is named build.

```toml
[tasks.build]
command = "cargo"
args = ["build"]
```

This allows to easily understand what this task does.

Tasks that are invoked before/after those tasks are named the same way as the original task but with the pre/post prefix.<br>
For example for task build the default toml also defines pre-build and post-build tasks.

```toml
[tasks.pre-build]

[tasks.post-build]
```

In the [default makefiles](https://github.com/sagiegurari/cargo-make/blob/master/src/lib/descriptor/makefiles/), all pre/post tasks are empty and are there as placeholders
for external `Makefile.toml` to override so custom functionality can be defined easily before/after running a specific task.

Flows are named with the flow suffix.  For example, **ci-flow**:

```toml
[tasks.ci-flow]
# CI task will run cargo build and cargo test with verbose output
dependencies = [
    "pre-build",
    "build-verbose",
    "post-build",
    "pre-test",
    "test-verbose",
    "post-test"
]
```

This prevents flow task names to conflict with single command task names and quickly allow users to understand that this task is a flow definition.

Tasks which only install some dependency but do not invoke any command start with the **install-** prefix, for example:

```toml
[tasks.install-rust-src]
install_crate = { rustup_component_name = "rust-src" }
```

<a name="error-codes"></a>
## Error Codes

<a name="e001"></a>
### E001: Environment Variables Cycle Detected

A cycle between different environment variables has been detected;
This can happen during the merging of environments (at every loading step).
Due to reordering and to make sure that no circular references exist,
this error is emitted.

You can fix this issue, by looking at your env config, and seeing if at any point a circular reference could have occurred.
The error message mentions the environment variables that are likely candidates for the cause of the cycle.

Your best bet is to try to break the cycle, by creating a new environment variable or use a static value multiple times.
Cycles are usually caused by rapidly changing configs, forgotten and unused env variables or design problems,
even without cycle detection or no reordering this would likely cause hidden issues during
execution, as `cargo-make` would need to otherwise set instances to an empty value instead.
This way you are able to investigate and fix it yourself before it becomes an unexpected,
hidden and hard to debug issue.

> **Note:** Scripts are known to sometimes cause false-positives.
> In that case use the `depends_on` property, to explicitly tell `cargo-make`, which
> environment variables should be considered a dependency instead of trying to guess from the script.


<a name="articles"></a>
## Articles
Below is a list of articles which explain most of the cargo-make features.

* [Introduction and Basics](https://medium.com/@sagiegurari/automating-your-rust-workflows-with-cargo-make-part-1-of-5-introduction-and-basics-b19ced7e7057)
* [Extending Tasks, Platform Overrides and Aliases](https://medium.com/@sagiegurari/automating-your-rust-workflows-with-cargo-make-part-2-of-5-extending-tasks-platform-overrides-1527386dcf87)
* [Environment Variables, Conditions, Sub Tasks and Mixing](https://medium.com/@sagiegurari/automating-your-rust-workflows-with-cargo-make-part-3-of-5-environment-variables-conditions-3c740a837a01)
* [Workspace Support, Init/End Tasks and Makefiles](https://medium.com/@sagiegurari/automating-your-rust-workflows-with-cargo-make-part-4-of-5-workspace-support-init-end-tasks-c3e738699421)
* [Predefined Tasks, CI Support and Conventions](https://medium.com/@sagiegurari/automating-your-rust-workflows-with-cargo-make-part-5-final-predefined-tasks-ci-support-and-4594812e57da)

The articles are missing some of the new features which have been added after they were published, such as:

* [Rust Task](#usage-task-command-script-task-examplerust)
* [Cross Platform Shell](#usage-task-command-script-task-exampleshell2batch)
* [Full List of Predefined Flows](#usage-predefined-flows)
* [Global Configuration](#cargo-make-global-config)
* [Catching Errors](#usage-catching-errors)
* [Env File](#usage-env-file)
* [Private Tasks](#usage-private-tasks)
* [Other Programming Languages](#usage-task-command-script-task-examplegeneric)
* [Rust Version Conditions](#usage-conditions-structure)
* [Toolchain](#usage-toolchain)
* [Watch](#usage-watch)
* [Profiles](#usage-profiles)
* [Functions](#usage-functions)
* [Minimal Version](#usage-min-version)
* [Deprecated Tasks](#usage-deprecated-tasks)

And more...

<a name="badge"></a>
## Badge
If you are using cargo-make in your project and want to display it in your project README or website, you can embed the "Built with cargo-make" badge.

[![Built with cargo-make](https://sagiegurari.github.io/cargo-make/assets/badges/cargo-make.svg)](https://sagiegurari.github.io/cargo-make)

Here are few snapshots:

### Markdown


```md
[![Built with cargo-make](https://sagiegurari.github.io/cargo-make/assets/badges/cargo-make.svg)](https://sagiegurari.github.io/cargo-make)
```

### HTML

```html
<a href="https://sagiegurari.github.io/cargo-make">
  <img src="https://sagiegurari.github.io/cargo-make/assets/badges/cargo-make.svg" alt="Built with cargo-make">
</a>
```

<a name="roadmap"></a>
## Roadmap
While already feature rich, cargo-make is still under heavy development.<br>
You can view the future development items list in the [github project issues](https://github.com/sagiegurari/cargo-make/issues)

<a name="editor-support"></a>
## Editor Support

<a name="editor-support-vim"></a>
### Vim

* [vim-cargo-make](https://github.com/nastevens/vim-cargo-make)
* [vim-duckscript](https://github.com/nastevens/vim-duckscript)

<a name="editor-support-vs-code"></a>
### VSCode

For debugging purposes there are some example .vscode files located within the [docs/vscode-example](./docs/vscode-example/) directory

You may also need:

  * A local install of LLVM (For the LLDB Debugger) installed and reachable on the path
  * VSCode Extension - CodeLLDB
  * VSCode Extension - "rust-analyser" (not the "rust" one)
  * VSCode Extension - "Task Explorer"
  * VSCode Extension - "crates"

## Contributing
See [contributing guide](.github/CONTRIBUTING.md)

<a name="history"></a>
## Release History

See [Changelog](https://github.com/sagiegurari/cargo-make/blob/master/CHANGELOG.md)

<a name="license"></a>
## License
Developed by Sagie Gur-Ari and licensed under the Apache 2 open source license.