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 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071
|
<!DOCTYPE sconsdoc [
<!ENTITY % scons SYSTEM "../scons.mod">
%scons;
<!ENTITY % builders-mod SYSTEM "builders.mod">
%builders-mod;
<!ENTITY % functions-mod SYSTEM "functions.mod">
%functions-mod;
<!ENTITY % tools-mod SYSTEM "tools.mod">
%tools-mod;
<!ENTITY % variables-mod SYSTEM "variables.mod">
%variables-mod;
]>
<variablelist xmlns="http://www.scons.org/dbxsd/v1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.scons.org/dbxsd/v1.0 http://www.scons.org/dbxsd/v1.0/scons.xsd">
<varlistentry id="f-Action">
<term><function>Action</function>(<parameter>action, [output, [var, ...]] [key=value, ...]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Action</methodname>(<parameter>action, [output, [var, ...]] [key=value, ...]</parameter>)</term>
<listitem><para>
A factory function to create an Action object for
the specified
<parameter>action</parameter>.
See the manpage section "Action Objects"
for a complete explanation of the arguments and behavior.
</para>
<para>
Note that the &f-env-Action;
form of the invocation will expand
construction variables in any argument strings,
including the
<parameter>action</parameter>
argument, at the time it is called
using the construction variables in the
<replaceable>env</replaceable>
construction environment through which
&f-env-Action; was called.
The &f-Action; global function
form delays all variable expansion
until the Action object is actually used.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-AddMethod">
<term><function>AddMethod</function>(<parameter>object, function, [name]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>AddMethod</methodname>(<parameter>function, [name]</parameter>)</term>
<listitem><para>
Adds <parameter>function</parameter> to an object as a method.
<parameter>function</parameter> will be called with an instance
object as the first argument as for other methods.
If <parameter>name</parameter> is given, it is used as
the name of the new method, else the name of
<parameter>function</parameter> is used.
</para>
<para>
When the global function &f-AddMethod; is called,
the object to add the method to must be passed as the first argument;
typically this will be &Environment;,
in order to create a method which applies to all &consenvs;
subsequently constructed.
When called using the &f-env-AddMethod; form,
the method is added to the specified &consenv; only.
Added methods propagate through &f-env-Clone; calls.
</para>
<para>
More examples:
</para>
<example_commands>
# Function to add must accept an instance argument.
# The Python convention is to call this 'self'.
def my_method(self, arg):
print("my_method() got", arg)
# Use the global function to add a method to the Environment class:
AddMethod(Environment, my_method)
env = Environment()
env.my_method('arg')
# Use the optional name argument to set the name of the method:
env.AddMethod(my_method, 'other_method_name')
env.other_method_name('another arg')
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-AddOption">
<term><function>AddOption</function>(<parameter>opt_str, ..., attr=value, ...</parameter>)</term>
<listitem><para>
Adds a local (project-specific) command-line option.
One or more <parameter>opt_str</parameter> values are
the strings representing how the option can be called,
while the keyword arguments define attributes of the option.
For the most part these are the same as for the
<function>OptionParser.add_option</function>
method in the standard Python library module
<systemitem>optparse</systemitem>,
but with a few additional capabilities noted below.
See the
<ulink url="https://docs.python.org/3/library/optparse.html">
optparse documentation</ulink>
for a thorough discussion of its option-processing capabities.
All options added through &f-AddOption; are placed
in a special "Local Options" option group.
</para>
<para>
In addition to the arguments and values supported by the
<systemitem>optparse</systemitem>
<function>add_option</function>
method, &f-AddOption;
allows setting the
<parameter>nargs</parameter>
keyword value to
a string <literal>'?'</literal> (question mark)
to indicate that the option argument for
that option string may be omitted.
If the option string is present on the
command line but has no matching option
argument, the value of the
<parameter>const</parameter>
keyword argument is produced as the value
of the option.
If the option string is omitted from
the command line, the value of the
<parameter>default</parameter>
keyword argument is produced, as usual;
if there is no
<parameter>default</parameter>
keyword argument in the &f-AddOption; call,
<constant>None</constant> is produced.
</para>
<para>
<systemitem>optparse</systemitem> recognizes
abbreviations of long option names,
as long as they can be unambiguously resolved.
For example, if
<function>add_option</function> is called to
define a <option>--devicename</option> option,
it will recognize <option>--device</option>,
<option>--dev</option>
and so forth as long as there is no other option
which could also match to the same abbreviation.
Options added via
&f-AddOption; do not support
the automatic recognition of abbreviations.
Instead, to allow specific abbreviations,
include them as synonyms in the &f-AddOption; call itself.
</para>
<para>
Once a new command-line option has been added with
&f-AddOption;,
the option value may be accessed using
&f-link-GetOption;
or
&f-link-env-GetOption;.
If the <parameter>settable=True</parameter> argument
was supplied in the &AddOption; call,
the value may also be set later using
&f-link-SetOption;
or
&f-link-env-SetOption;,
if conditions in an
&SConscript; file
require overriding any default value.
Note however that a
value specified on the command line will
<emphasis>always</emphasis>
override a value set in an SConscript file.
</para>
<para>
<emphasis>Changed in 4.8.0</emphasis>: added the
<parameter>settable</parameter> keyword argument
to enable an added option to be settable via &SetOption;.
</para>
<para>
Help text for an option is a combination
of the string supplied in the
<parameter>help</parameter> keyword
argument to &f-AddOption; and information
collected from the other keyword arguments.
Such help is displayed if the
<option>-h</option> command line option
is used (but not with <option>-H</option>).
Help for all local options is displayed
under the separate heading
<emphasis role="bold">Local Options</emphasis>.
The options are unsorted - they will appear
in the help text in the order in which the
&f-AddOption;
calls occur.
</para>
<para>
Example:
</para>
<example_commands>
AddOption(
'--prefix',
dest='prefix',
nargs=1,
type='string',
action='store',
metavar='DIR',
help='installation prefix',
)
env = Environment(PREFIX=GetOption('prefix'))
</example_commands>
<para>For that example,
the following help text would be produced:</para>
<screen>
Local Options:
--prefix=DIR installation prefix
</screen>
<para>
Help text for local options may be unavailable if
the &f-link-Help; function has been called,
see the &f-Help; documentation for details.
</para>
<note>
<para>
As an artifact of the internal implementation,
the behavior of options added by &AddOption;
which take option arguments is undefined
<emphasis>if</emphasis> whitespace
(rather than an <literal>=</literal> sign) is used as
the separator on the command line.
Users should avoid such usage; it is recommended
to add a note to this effect to project documentation
if the situation is likely to arise.
In addition, if the <parameter>nargs</parameter>
keyword is used to specify more than one following
option argument (that is, with a value of <constant>2</constant>
or greater), such arguments would necessarily
be whitespace separated, triggering the issue.
Developers should not use &AddOption; this way.
Future versions of &SCons; will likely forbid such usage.
</para>
</note>
</listitem>
</varlistentry>
<varlistentry id="f-AddPostAction">
<term><function>AddPostAction</function>(<parameter>target, action</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>AddPostAction</methodname>(<parameter>target, action</parameter>)</term>
<listitem><para>
Arranges for the specified
<parameter>action</parameter>
to be performed
after the specified
<parameter>target</parameter>
has been built.
<parameter>action</parameter> may be
an Action object, or anything that
can be converted into an Action object.
See the manpage section "Action Objects"
for a complete explanation.
</para>
<para>
When multiple targets are supplied,
the action may be called multiple times,
once after each action that generates
one or more targets in the list.
</para>
<example_commands>
foo = Program('foo.c')
# remove execute permission from binary:
AddPostAction(foo, Chmod('$TARGET', "a-x"))
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-AddPreAction">
<term><function>AddPreAction</function>(<parameter>target, action</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>AddPreAction</methodname>(<parameter>target, action</parameter>)</term>
<listitem><para>
Arranges for the specified
<parameter>action</parameter>
to be performed
before the specified
<parameter>target</parameter>
is built.
<parameter>action</parameter> may be
an Action object, or anything that
can be converted into an Action object.
See the manpage section "Action Objects"
for a complete explanation.
</para>
<para>
When multiple targets are specified,
the action(s) may be called multiple times,
once before each action that generates
one or more targets in the list.
</para>
<para>
Note that if any of the targets are built in multiple steps,
the action will be invoked just
before the "final" action that specifically
generates the specified target(s).
For example, when building an executable program
from a specified source
<filename>.c</filename>
file via an intermediate object file:
</para>
<example_commands>
foo = Program('foo.c')
AddPreAction(foo, 'pre_action')
</example_commands>
<para>
The specified
<literal>pre_action</literal>
would be executed before
&scons;
calls the link command that actually
generates the executable program binary
<filename>foo</filename>,
not before compiling the
<filename>foo.c</filename>
file into an object file.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-Alias">
<term><function>Alias</function>(<parameter>alias, [source, [action]]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Alias</methodname>(<parameter>alias, [source, [action]]</parameter>)</term>
<listitem><para>
Creates an <firstterm>alias</firstterm> target that
can be used as a reference to zero or more other targets,
specified by the optional <parameter>source</parameter> parameter.
Aliases provide a way to give a shorter or more descriptive
name to specific targets,
and to group multiple targets under a single name.
The alias name, or an Alias Node object,
may be used as a dependency of any other target,
including another alias.
</para>
<para>
<parameter>alias</parameter> and <parameter>source</parameter>
may each be a string or Node object,
or a list of strings or Node objects;
if Nodes are used for
<parameter>alias</parameter>
they must be Alias nodes.
If <parameter>source</parameter> is omitted,
the alias is created but has no reference;
if selected for building this will result in a
<quote>Nothing to be done.</quote> message.
An empty alias can be used to define the alias
in a visible place in the project;
it can later be appended to in a subsidiary SConscript file
with the actual target(s) to refer to.
The optional
<parameter>action</parameter>
parameter specifies an action or list of actions
that will be executed
whenever the any of the alias targets are out-of-date.
</para>
<para>
&f-Alias; can be called for an existing alias,
which appends the <parameter>alias</parameter>
and/or <parameter>action</parameter> arguments
to the existing lists for that alias.
</para>
<para>
Returns a list of Alias Node objects representing the alias(es),
which exist outside of any physical file system.
The alias name space is separate from the name space for
tangible targets; to avoid confusion do not reuse
target names as alias names.
</para>
<para>
Examples:
</para>
<example_commands>
Alias('install')
Alias('install', '/usr/bin')
Alias(['install', 'install-lib'], '/usr/local/lib')
env.Alias('install', ['/usr/local/bin', '/usr/local/lib'])
env.Alias('install', ['/usr/local/man'])
env.Alias('update', ['file1', 'file2'], "update_database $SOURCES")
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-AllowSubstExceptions">
<term><function>AllowSubstExceptions</function>(<parameter>[exception, ...]</parameter>)</term>
<listitem><para>
Specifies the exceptions that will be allowed
when expanding construction variables.
By default,
any construction variable expansions that generate a
<literal>NameError</literal>
or
<literal>IndexError</literal>
exception will expand to a
<literal>''</literal>
(an empty string) and not cause scons to fail.
All exceptions not in the specified list
will generate an error message
and terminate processing.
</para>
<para>
If
&f-AllowSubstExceptions;
is called multiple times,
each call completely overwrites the previous list
of allowed exceptions.
</para>
<para>
Example:
</para>
<example_commands>
# Requires that all construction variable names exist.
# (You may wish to do this if you want to enforce strictly
# that all construction variables must be defined before use.)
AllowSubstExceptions()
# Also allow a string containing a zero-division expansion
# like '${1 / 0}' to evalute to ''.
AllowSubstExceptions(IndexError, NameError, ZeroDivisionError)
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-AlwaysBuild">
<term><function>AlwaysBuild</function>(<parameter>target, ...</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>AlwaysBuild</methodname>(<parameter>target, ...</parameter>)</term>
<listitem><para>
Marks each given
<parameter>target</parameter>
so that it is always assumed to be out of date,
and will always be rebuilt if needed.
Note, however, that
&f-AlwaysBuild;
does not add its target(s) to the default target list,
so the targets will only be built
if they are specified on the command line,
or are a dependent of a target specified on the command line--but
they will
<emphasis>always</emphasis>
be built if so specified.
Multiple targets can be passed in to a single call to
&f-AlwaysBuild;.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-Append">
<term><replaceable>env</replaceable>.<methodname>Append</methodname>(<parameter>key=val, [...]</parameter>)</term>
<listitem><para>
Appends value(s) intelligently to &consvars; in
<varname>env</varname>.
The &consvars; and values to add to them are passed as
<parameter>key=val</parameter> pairs (&Python; keyword arguments).
&f-env-Append; is designed to allow adding values
without having to think about the data type of an existing &consvar;.
Regular &Python; syntax can also be used to manipulate the &consvar;,
but for that you may need to know the types involved,
for example pure &Python; lets you directly "add" two lists of strings,
but adding a string to a list or a list to a string requires
different syntax - things &f-Append; takes care of.
Some pre-defined &consvars; do have type expectations
based on how &SCons; will use them:
for example &cv-link-CPPDEFINES; is often a string or a list of strings,
but can also be a list of tuples or a dictionary;
while &cv-link-LIBEMITTER;
is expected to be a callable or list of callables,
and &cv-link-BUILDERS; is expected to be a dictionary.
Consult the documentation for the various &consvars; for more details.
</para>
<para>
The following descriptions apply to both the &f-Append;
and &f-Prepend; methods, as well as their
<emphasis role="bold">Unique</emphasis> variants,
with the differences being the insertion point of the added values
and whether duplication is allowed.
</para>
<para>
<parameter>val</parameter> can be almost any type.
If <varname>env</varname> does not have a &consvar;
named <parameter>key</parameter>,
then <parameter>key</parameter> is simply
stored with a value of <parameter>val</parameter>.
Otherwise, <parameter>val</parameter> is
combinined with the existing value,
possibly converting into an appropriate type
which can hold the expanded contents.
There are a few special cases to be aware of.
Normally, when two strings are combined,
the result is a new string containing their concatenation
(and you are responsible for supplying any needed separation);
however, the contents of &cv-link-CPPDEFINES; will
will be postprocessed by adding a prefix and/or suffix
to each entry when the command line is produced,
so &SCons; keeps them separate -
appending a string will result in a separate string entry,
not a combined string.
For &cv-CPPDEFINES;. as well as
&cv-link-LIBS;, and the various <literal>*PATH</literal> variables,
&SCons; will amend the variable by supplying the compiler-specific
syntax (e.g. prepending a <literal>-D</literal> or <literal>/D</literal>
prefix for &cv-CPPDEFINES;), so you should omit this syntax when
adding values to these variables.
Examples (gcc syntax shown in the expansion of &CPPDEFINES;):
</para>
<example_commands>
env = Environment(CXXFLAGS="-std=c11", CPPDEFINES="RELEASE")
print(f"CXXFLAGS = {env['CXXFLAGS']}, CPPDEFINES = {env['CPPDEFINES']}")
# notice including a leading space in CXXFLAGS addition
env.Append(CXXFLAGS=" -O", CPPDEFINES="EXTRA")
print(f"CXXFLAGS = {env['CXXFLAGS']}, CPPDEFINES = {env['CPPDEFINES']}")
print("CPPDEFINES will expand to", env.subst('$_CPPDEFFLAGS'))
</example_commands>
<screen>
$ scons -Q
CXXFLAGS = -std=c11, CPPDEFINES = RELEASE
CXXFLAGS = -std=c11 -O, CPPDEFINES = deque(['RELEASE', 'EXTRA'])
CPPDEFINES will expand to -DRELEASE -DEXTRA
scons: `.' is up to date.
</screen>
<para>
Because &cv-link-CPPDEFINES; is intended for command-line
specification of C/C++ preprocessor macros,
additional syntax is accepted when adding to it.
The preprocessor accepts arguments to predefine a macro name by itself
(<computeroutput>-DFOO</computeroutput> for most compilers,
<computeroutput>/DFOO</computeroutput> for Microsoft C++),
which gives it an implicit value of <constant>1</constant>,
or can be given with a replacement value
(<computeroutput>-DBAR=TEXT</computeroutput>).
&SCons; follows these rules when adding to &cv-CPPDEFINES;:
</para>
<itemizedlist>
<listitem>
<para>A string is split on spaces,
giving an easy way to enter multiple macros in one addition.
Use an <literal>=</literal> to specify a valued macro.</para>
</listitem>
<listitem>
<para>A tuple is treated as a valued macro.
Use the value <constant>None</constant> if the macro should not have a value.
It is an error to supply more than two elements in such a tuple.</para>
</listitem>
<listitem>
<para>A list is processed in order,
adding each item without further interpretation.
In this case, space-separated strings are not split.</para>
</listitem>
<listitem>
<para>A dictionary is processed in order,
adding each key-value pair as a valued macro.
Use the value <constant>None</constant> if the macro should not have a value.
</para>
</listitem>
</itemizedlist>
<para>
Examples:
</para>
<example_commands>
env = Environment(CPPDEFINES="FOO")
print("CPPDEFINES =", env['CPPDEFINES'])
env.Append(CPPDEFINES="BAR=1")
print("CPPDEFINES =", env['CPPDEFINES'])
env.Append(CPPDEFINES=[("OTHER", 2)])
print("CPPDEFINES =", env['CPPDEFINES'])
env.Append(CPPDEFINES={"EXTRA": "arg"})
print("CPPDEFINES =", env['CPPDEFINES'])
print("CPPDEFINES will expand to", env.subst('$_CPPDEFFLAGS'))
</example_commands>
<screen>
$ scons -Q
CPPDEFINES = FOO
CPPDEFINES = deque(['FOO', 'BAR=1'])
CPPDEFINES = deque(['FOO', 'BAR=1', ('OTHER', 2)])
CPPDEFINES = deque(['FOO', 'BAR=1', ('OTHER', 2), ('EXTRA', 'arg')])
CPPDEFINES will expand to -DFOO -DBAR=1 -DOTHER=2 -DEXTRA=arg
scons: `.' is up to date.
</screen>
<para>
Examples of adding multiple macros:
</para>
<example_commands>
env = Environment()
env.Append(CPPDEFINES=[("ONE", 1), "TWO", ("THREE", )])
print("CPPDEFINES =", env['CPPDEFINES'])
env.Append(CPPDEFINES={"FOUR": 4, "FIVE": None})
print("CPPDEFINES =", env['CPPDEFINES'])
print("CPPDEFINES will expand to", env.subst('$_CPPDEFFLAGS'))
</example_commands>
<screen>
$ scons -Q
CPPDEFINES = [('ONE', 1), 'TWO', ('THREE',)]
CPPDEFINES = deque([('ONE', 1), 'TWO', ('THREE',), ('FOUR', 4), ('FIVE', None)])
CPPDEFINES will expand to -DONE=1 -DTWO -DTHREE -DFOUR=4 -DFIVE
scons: `.' is up to date.
</screen>
<para>
<emphasis>Changed in version 4.5</emphasis>:
clarifined the use of tuples vs. other types,
handling is now consistent across the four functions.
</para>
<example_commands>
env = Environment()
env.Append(CPPDEFINES=("MACRO1", "MACRO2"))
print("CPPDEFINES =", env['CPPDEFINES'])
env.Append(CPPDEFINES=[("MACRO3", "MACRO4")])
print("CPPDEFINES =", env['CPPDEFINES'])
print("CPPDEFINES will expand to", env.subst('$_CPPDEFFLAGS'))
</example_commands>
<screen>
$ scons -Q
CPPDEFINES = ('MACRO1', 'MACRO2')
CPPDEFINES = deque(['MACRO1', 'MACRO2', ('MACRO3', 'MACRO4')])
CPPDEFINES will expand to -DMACRO1 -DMACRO2 -DMACRO3=MACRO4
scons: `.' is up to date.
</screen>
<para>
See &cv-link-CPPDEFINES; for more details.
</para>
<para>
Appending a string <parameter>val</parameter>
to a dictonary-typed &consvar; enters
<parameter>val</parameter> as the key in the dictionary,
and <literal>None</literal> as its value.
Using a tuple type to supply a key-value pair
only works for the special case of &cv-CPPDEFINES;
described above.
</para>
<para>
Although most combinations of types work without
needing to know the details, some combinations
do not make sense and &Python; raises an exception.
</para>
<para>
When using &f-env-Append; to modify &consvars;
which are path specifications (conventionally,
the names of such end in <literal>PATH</literal>),
it is recommended to add the values as a list of strings,
even if you are only adding a single string.
The same goes for adding library names to &cv-LIBS;.
</para>
<example_commands>
env.Append(CPPPATH=["#/include"])
</example_commands>
<para>
See also &f-link-env-AppendUnique;,
&f-link-env-Prepend; and &f-link-env-PrependUnique;.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-AppendENVPath">
<term><replaceable>env</replaceable>.<methodname>AppendENVPath</methodname>(<parameter>name, newpath, [envname, sep, delete_existing=False]</parameter>)</term>
<listitem><para>
Append path elements specified by <parameter>newpath</parameter>
to the given search path string or list <parameter>name</parameter>
in mapping <parameter>envname</parameter> in the &consenv;.
Supplying <parameter>envname</parameter> is optional:
the default is the execution environment &cv-link-ENV;.
Optional <parameter>sep</parameter> is used as the search path separator,
the default is the platform's separator (<systemitem>os.pathsep</systemitem>).
A path element will only appear once.
Any duplicates in <parameter>newpath</parameter> are dropped,
keeping the last appearing (to preserve path order).
If <parameter>delete_existing</parameter>
is <constant>False</constant> (the default)
any addition duplicating an existing path element is ignored;
if <parameter>delete_existing</parameter>
is <constant>True</constant> the existing value will
be dropped and the path element will be added at the end.
To help maintain uniqueness all paths are normalized (using
<systemitem>os.path.normpath</systemitem>
and
<systemitem>os.path.normcase</systemitem>).
</para>
<para>
Example:
</para>
<example_commands>
print('before:', env['ENV']['INCLUDE'])
include_path = '/foo/bar:/foo'
env.AppendENVPath('INCLUDE', include_path)
print('after:', env['ENV']['INCLUDE'])
</example_commands>
<para>Yields:</para>
<screen>
before: /foo:/biz
after: /biz:/foo/bar:/foo
</screen>
<para>
See also &f-link-env-PrependENVPath;.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-AppendUnique">
<term><replaceable>env</replaceable>.<methodname>AppendUnique</methodname>(<parameter>key=val, [...], [delete_existing=False]</parameter>)</term>
<listitem><para>
Append values to &consvars; in the current &consenv;,
maintaining uniqueness.
Works like &f-link-env-Append;,
except that values that would become duplicates
are not added.
If <parameter>delete_existing</parameter>
is set to a true value, then for any duplicate,
the existing instance of <parameter>val</parameter> is first removed,
then <parameter>val</parameter> is appended,
having the effect of moving it to the end.
</para>
<para>
Example:
</para>
<example_commands>
env.AppendUnique(CCFLAGS='-g', FOO=['foo.yyy'])
</example_commands>
<para>
See also &f-link-env-Append;,
&f-link-env-Prepend;
and &f-link-env-PrependUnique;.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-Builder">
<term><function>Builder</function>(<parameter>action, [arguments]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Builder</methodname>(<parameter>action, [arguments]</parameter>)</term>
<listitem><para>
Creates a Builder object for
the specified
<parameter>action</parameter>.
See the manpage section "Builder Objects"
for a complete explanation of the arguments and behavior.
</para>
<para>
Note that the
<function>env.Builder</function>()
form of the invocation will expand
construction variables in any arguments strings,
including the
<parameter>action</parameter>
argument,
at the time it is called
using the construction variables in the
<varname>env</varname>
construction environment through which
&f-env-Builder; was called.
The
&f-Builder;
form delays all variable expansion
until after the Builder object is actually called.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-CacheDir">
<term><function>CacheDir</function>(<parameter>cache_dir, custom_class=None</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>CacheDir</methodname>(<parameter>cache_dir, custom_class=None</parameter>)</term>
<listitem><para>
Direct
&scons;
to maintain a derived-file cache in
<parameter>cache_dir</parameter>.
The derived files in the cache will be shared
among all the builds specifying the same
<parameter>cache_dir</parameter>.
Specifying a
<parameter>cache_dir</parameter>
of
<constant>None</constant>
disables derived file caching.
</para>
<para>
Calling the environment method
&f-link-env-CacheDir;
limits the effect to targets built
through the specified construction environment.
Calling the global function
&f-link-CacheDir;
sets a global default
that will be used by all targets built
through construction environments
that do not set up environment-specific
caching by calling &f-env-CacheDir;.
</para>
<para>
Caching behavior can be configured by passing a specialized cache
class as the optional <parameter>custom_class</parameter> parameter.
This class must be a subclass of
<classname>SCons.CacheDir.CacheDir</classname>.
&SCons; will internally invoke the custom class for performing
caching operations.
If the parameter is omitted or set to
<constant>None</constant>, &SCons; will use the default
<classname>SCons.CacheDir.CacheDir</classname> class.
</para>
<para>
When derived-file caching
is being used and
&scons;
finds a derived file that needs to be rebuilt,
it will first look in the cache to see if a
file with matching &buildsig; exists
(indicating the input file(s) and build action(s)
were identical to those for the current target),
and if so, will retrieve the file from the cache.
&scons;
will report
<computeroutput>Retrieved `file' from cache</computeroutput>
instead of the normal build message.
If the derived file is not present in the cache,
&scons;
will build it and
then place a copy of the built file in the cache,
identified by its &buildsig;, for future use.
</para>
<para>
The
<computeroutput>Retrieved `file' from cache</computeroutput>
messages are useful for human consumption,
but less useful when comparing log files between
&scons; runs which will show differences that are
noisy and not actually significant.
To disable,
use the <option>--cache-show</option> option.
With this option, &scons; changes printing
to always show the action that would
have been used to build the file without caching.
</para>
<para>
Derived-file caching
may be disabled for any invocation
of &scons; by giving the
<option>--cache-disable</option>
command line option;
cache updating may be disabled, leaving cache
fetching enabled, by giving the
<option>--cache-readonly</option> option.
</para>
<para>
If the
<option>--cache-force</option>
option is used,
&scons;
will place a copy of
<emphasis>all</emphasis>
derived files into the cache,
even if they already existed
and were not built by this invocation.
This is useful to populate a cache
the first time a
<parameter>cache_dir</parameter>
is used for a build,
or to bring a cache up to date after
a build with cache updating disabled
(<option>--cache-disable</option>
or <option>--cache-readonly</option>)
has been done.
</para>
<para>
The
&f-link-NoCache;
method can be used to disable caching of specific files. This can be
useful if inputs and/or outputs of some tool are impossible to
predict or prohibitively large.
</para>
<para>
Note that (at this time) &SCons; provides no facilities
for managing the derived-file cache. It is up to the developer
to arrange for cache pruning, expiry, access control, etc. if needed.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-Clean">
<term><function>Clean</function>(<parameter>targets, files_or_dirs</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Clean</methodname>(<parameter>targets, files_or_dirs</parameter>)</term>
<listitem><para>
This specifies a list of files or directories which should be removed
whenever the targets are specified with the
<option>-c</option>
command line option.
The specified targets may be a list
or an individual target.
Multiple calls to
&f-Clean;
are legal,
and create new targets or add files and directories to the
clean list for the specified targets.
</para>
<para>
Multiple files or directories should be specified
either as separate arguments to the
&f-Clean;
method, or as a list.
&f-Clean;
will also accept the return value of any of the construction environment
Builder methods.
Examples:
</para>
<para>
The related
&f-link-NoClean;
function overrides calling
&f-Clean;
for the same target,
and any targets passed to both functions will
<emphasis>not</emphasis>
be removed by the
<option>-c</option>
option.
</para>
<para>
Examples:
</para>
<example_commands>
Clean('foo', ['bar', 'baz'])
Clean('dist', env.Program('hello', 'hello.c'))
Clean(['foo', 'bar'], 'something_else_to_clean')
</example_commands>
<para>
In this example,
installing the project creates a subdirectory for the documentation.
This statement causes the subdirectory to be removed
if the project is deinstalled.
</para>
<example_commands>
Clean(docdir, os.path.join(docdir, projectname))
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-Clone">
<term><replaceable>env</replaceable>.<methodname>Clone</methodname>(<parameter>[key=val, ...]</parameter>)</term>
<listitem><para>
Returns an independent copy of a &consenv;.
If there are any unrecognized keyword arguments specified,
they are added as &consvars; in the copy,
overwriting any existing values
for those keywords.
See the manpage section "Construction Environments" for more details.
</para>
<para>
Example:
</para>
<example_commands>
env2 = env.Clone()
env3 = env.Clone(CCFLAGS='-g')
</example_commands>
<para>
A list of <parameter>tools</parameter>
and a <parameter>toolpath</parameter> may be specified,
as in the &f-link-Environment; constructor:
</para>
<example_commands>
def MyTool(env):
env['FOO'] = 'bar'
env4 = env.Clone(tools=['msvc', MyTool])
</example_commands>
<para>
The
<parameter>parse_flags</parameter>
keyword argument is also recognized, to allow merging command-line
style arguments into the appropriate construction
variables (see &f-link-env-MergeFlags;).
</para>
<example_commands>
# create an environment for compiling programs that use wxWidgets
wx_env = env.Clone(parse_flags='!wx-config --cflags --cxxflags')
</example_commands>
<para>
The <parameter>variables</parameter>
keyword argument is also recognized, to allow (re)initializing
&consvars; from a <literal>Variables</literal> object.
</para>
<para>
<emphasis>Changed in version 4.8.0:</emphasis>
the <parameter>variables</parameter> parameter was added.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-Command">
<term><function>Command</function>(<parameter>target, source, action, [key=val, ...]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Command</methodname>(<parameter>target, source, action, [key=val, ...]</parameter>)</term>
<listitem><para>
Creates an anonymous builder and calls it,
thus recording <parameter>action</parameter>
to build <parameter>target</parameter>
from <parameter>source</parameter>
into the dependency tree.
This can be more convenient for a single special-case build
than having to define and add a new named Builder.
</para>
<para>
The
&Command; function accepts the
<parameter>source_scanner</parameter> and
<parameter>target_scanner</parameter>
keyword arguments which are used to specify
custom scanners for the specified sources or targets.
The value must be a Scanner object.
For example, the global
<literal>DirScanner</literal>
object can be used
if any of the sources will be directories
that must be scanned on-disk for
changes to files that aren't
already specified in other Builder or function calls.
</para>
<para>
The
&Command; function also accepts the
<parameter>source_factory</parameter> and
<parameter>target_factory</parameter>
keyword arguments which are used to specify
factory functions to create &SCons; Nodes
from any sources or targets specified as strings.
If any sources or targets are already Node objects,
they are not further transformed even if
a factory is specified for them.
The default for each is the &Entry; factory.
</para>
<para>
These four arguments, if given, are used
in the creation of the Builder.
Other Builder-specific keyword arguments
are not recognized as such.
See the manpage section "Builder Objects"
for more information about how these
arguments work in a Builder.
</para>
<para>
Any remaining keyword arguments are passed on to the
generated builder when it is called,
and behave as described in the manpage section "Builder Methods",
in short:
recognized arguments have their specified meanings,
while the rest are used to override
any same-named existing &consvars;
from the &consenv;.
</para>
<para>
<parameter>action</parameter> can be an external command,
specified as a string,
or a callable &Python; object;
see the manpage section "Action Objects"
for more complete information.
Also note that a string specifying an external command
may be preceded by an at-sign
(<literal>@</literal>)
to suppress printing the command in question,
or by a hyphen
(<literal>-</literal>)
to ignore the exit status of the external command.
</para>
<para>
Examples:
</para>
<example_commands>
env.Command(
target='foo.out',
source='foo.in',
action="$FOO_BUILD < $SOURCES > $TARGET"
)
env.Command(
target='bar.out',
source='bar.in',
action=["rm -f $TARGET", "$BAR_BUILD < $SOURCES > $TARGET"],
ENV={'PATH': '/usr/local/bin/'},
)
import os
def rename(env, target, source):
os.rename('.tmp', str(target[0]))
env.Command(
target='baz.out',
source='baz.in',
action=["$BAZ_BUILD < $SOURCES > .tmp", rename],
)
</example_commands>
<para>
Note that the
&Command;
function will usually assume, by default,
that the specified targets and/or sources are Files,
if no other part of the configuration
identifies what type of entries they are.
If necessary, you can explicitly specify
that targets or source nodes should
be treated as directories
by using the
&f-link-Dir;
or
&f-link-env-Dir;
functions.
</para>
<para>
Examples:
</para>
<example_commands>
env.Command('ddd.list', Dir('ddd'), 'ls -l $SOURCE > $TARGET')
env['DISTDIR'] = 'destination/directory'
env.Command(env.Dir('$DISTDIR')), None, make_distdir)
</example_commands>
<para>
Also note that SCons will usually
automatically create any directory necessary to hold a target file,
so you normally don't need to create directories by hand.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-Configure">
<term><function>Configure</function>(<parameter>env, [custom_tests, conf_dir, log_file, config_h]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Configure</methodname>(<parameter>[custom_tests, conf_dir, log_file, config_h]</parameter>)</term>
<listitem><para>
Creates a &Configure; object for integrated
functionality similar to GNU <command>autoconf</command>.
See the manpage section "Configure Contexts"
for a complete explanation of the arguments and behavior.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-DebugOptions">
<term><function>DebugOptions</function>(<parameter>[json]</parameter>)</term>
<listitem><para>
Allows setting options for SCons debug options. Currently the only supported value is
<emphasis>json</emphasis> which sets the path to the json file created when
<literal>--debug=json</literal> is set.
</para>
<example_commands>
DebugOptions(json='#/build/output/scons_stats.json')
</example_commands>
<para><emphasis>New in version 4.6.0.</emphasis></para>
</listitem>
</varlistentry>
<varlistentry id="f-Decider">
<term><function>Decider</function>(<parameter>function</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Decider</methodname>(<parameter>function</parameter>)</term>
<listitem><para>
Specifies that all up-to-date decisions for
targets built through this construction environment
will be handled by the specified
<parameter>function</parameter>.
<parameter>function</parameter> can be the name of
a function or one of the following strings
that specify the predefined decision function
that will be applied:
</para>
<para>
<variablelist>
<varlistentry>
<term><literal>"content"</literal></term>
<listitem>
<para>
Specifies that a target shall be considered out of date and rebuilt
if the dependency's content has changed since the last time
the target was built,
as determined by performing a checksum
on the dependency's contents using the selected hash function,
and comparing it to the checksum recorded the
last time the target was built.
<literal>content</literal> is the default decider.
</para>
<para>
<emphasis>Changed in version 4.1:</emphasis>
The decider was renamed to <literal>content</literal>
since the hash function is now selectable.
The former name, <literal>MD5</literal>,
can still be used as a synonym, but is deprecated.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>"content-timestamp"</literal></term>
<listitem>
<para>
Specifies that a target shall be considered out of date and rebuilt
if the dependency's content has changed since the last time
the target was built,
except that dependencies with a timestamp that matches
the last time the target was rebuilt will be
assumed to be up-to-date and
<emphasis>not</emphasis>
rebuilt.
This provides behavior very similar
to the
<literal>content</literal>
behavior of always checksumming file contents,
with an optimization of not checking
the contents of files whose timestamps haven't changed.
The drawback is that SCons will
<emphasis>not</emphasis>
detect if a file's content has changed
but its timestamp is the same,
as might happen in an automated script
that runs a build,
updates a file,
and runs the build again,
all within a single second.
</para>
<para>
<emphasis>Changed in version 4.1:</emphasis>
The decider was renamed to <literal>content-timestamp</literal>
since the hash function is now selectable.
The former name, <literal>MD5-timestamp</literal>,
can still be used as a synonym, but is deprecated.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>"timestamp-newer"</literal></term>
<listitem>
<para>
Specifies that a target shall be considered out of date and rebuilt
if the dependency's timestamp is newer than the target file's timestamp.
This is the behavior of the classic Make utility,
and
<literal>make</literal>
can be used a synonym for
<literal>timestamp-newer</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>"timestamp-match"</literal></term>
<listitem>
<para>
Specifies that a target shall be considered out of date and rebuilt
if the dependency's timestamp is different than the
timestamp recorded the last time the target was built.
This provides behavior very similar to the classic Make utility
(in particular, files are not opened up so that their
contents can be checksummed)
except that the target will also be rebuilt if a
dependency file has been restored to a version with an
<emphasis>earlier</emphasis>
timestamp, such as can happen when restoring files from backup archives.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<para>
Examples:
</para>
<example_commands>
# Use exact timestamp matches by default.
Decider('timestamp-match')
# Use hash content signatures for any targets built
# with the attached construction environment.
env.Decider('content')
</example_commands>
<para>
In addition to the above already-available functions, the
<parameter>function</parameter>
argument may be a &Python; function you supply.
Such a function must accept the following four arguments:
</para>
<para>
<variablelist>
<varlistentry>
<term><parameter>dependency</parameter></term>
<listitem>
<para>
The Node (file) which
should cause the
<parameter>target</parameter>
to be rebuilt
if it has "changed" since the last tme
<parameter>target</parameter>
was built.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>target</parameter></term>
<listitem>
<para>
The Node (file) being built.
In the normal case,
this is what should get rebuilt
if the
<parameter>dependency</parameter>
has "changed."
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>prev_ni</parameter></term>
<listitem>
<para>
Stored information about the state of the
<parameter>dependency</parameter>
the last time the
<parameter>target</parameter>
was built.
This can be consulted to match various
file characteristics
such as the timestamp,
size, or &contentsig;.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>repo_node</parameter></term>
<listitem>
<para>
If set, use this Node instead of the one specified by
<parameter>dependency</parameter>
to determine if the dependency has changed.
This argument is optional so should be written
as a default argument (typically it would be
written as <parameter>repo_node=None</parameter>).
A caller will normally only set this if the
target only exists in a Repository.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<para>
The
<parameter>function</parameter>
should return a value which evaluates
<constant>True</constant>
if the
<parameter>dependency</parameter>
has "changed" since the last time
the
<parameter>target</parameter>
was built
(indicating that the target
<emphasis>should</emphasis>
be rebuilt),
and a value which evaluates
<constant>False</constant>
otherwise
(indicating that the target should
<emphasis>not</emphasis>
be rebuilt).
Note that the decision can be made
using whatever criteria are appopriate.
Ignoring some or all of the function arguments
is perfectly normal.
</para>
<para>
Example:
</para>
<example_commands>
def my_decider(dependency, target, prev_ni, repo_node=None):
return not os.path.exists(str(target))
env.Decider(my_decider)
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-Default">
<term><function>Default</function>(<parameter>target[, ...]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Default</methodname>(<parameter>target[, ...]</parameter>)</term>
<listitem><para>
Specify default targets to the &SCons; target selection mechanism.
Any call to &f-Default; will cause &SCons; to use the
defined default target list instead of
its built-in algorithm for determining default targets
(see the manpage section "Target Selection").
</para>
<para>
<parameter>target</parameter> may be one or more strings,
a list of strings,
a <classname>NodeList</classname> as returned by a Builder,
or <constant>None</constant>.
A string <parameter>target</parameter> may be the name of
a file or directory, or a target previously defined by a call to
&f-link-Alias; (defining the alias later will still create
the alias, but it will not be recognized as a default).
Calls to &f-Default; are additive.
A <parameter>target</parameter> of
<literal>None</literal>
will clear any existing default target list;
subsequent calls to
&f-Default;
will add to the (now empty) default target list
like normal.
</para>
<para>
Both forms of this call affect the
same global list of default targets; the
construction environment method applies
construction variable expansion to the targets.
</para>
<para>
The current list of targets added using
&f-Default; is available in the
&DEFAULT_TARGETS; list (see below).
</para>
<para>
Examples:
</para>
<example_commands>
Default('foo', 'bar', 'baz')
env.Default(['a', 'b', 'c'])
hello = env.Program('hello', 'hello.c')
env.Default(hello)
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-DefaultEnvironment">
<term><function>DefaultEnvironment</function>(<parameter>[key=value, ...]</parameter>)</term>
<listitem><para>
Instantiates and returns the global &consenv; object.
The <firstterm>&DefEnv;</firstterm> is used internally by &SCons;
when executing a global function
or the global form of a Builder method
that requires access to a &consenv;.
</para>
<para>
On the first call,
arguments are interpreted as for the &f-link-Environment; function.
The &DefEnv; is a singleton;
subsequent calls to &f-DefaultEnvironment; return
the already-constructed object,
and any keyword arguments are silently ignored.
</para>
<para>
The &DefEnv; can be modified after instantiation,
similar to other &consenvs;,
although some &consenv; methods may be unavailable.
Modifying the &DefEnv; has no effect on any other &consenv;,
either existing or newly constructed.
</para>
<para>
It is not necessary to explicitly call &f-DefaultEnvironment;.
&SCons; instantiates the &defenv; automatically when the
build phase begins, if has not already been done.
However, calling it explicitly provides the opportunity to
affect and examine its contents.
Instantiation occurs even if nothing in the build system
appars to use it, due to internal uses.
</para>
<para>
If the project &SConscript; files do not use global functions or Builders,
a small performance gain may be achieved by calling
&f-DefaultEnvironment; with an empty tools list
(<userinput>DefaultEnvironment(tools=[])</userinput>).
This avoids the tool initialization cost for the &DefEnv;,
which is mainly of interest in the test suite
where &scons; is launched repeatedly in a short time period.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-Depends">
<term><function>Depends</function>(<parameter>target, dependency</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Depends</methodname>(<parameter>target, dependency</parameter>)</term>
<listitem><para>
Specifies an explicit dependency;
the
<parameter>target</parameter>
will be rebuilt
whenever the
<parameter>dependency</parameter>
has changed.
Both the specified
<parameter>target</parameter>
and
<parameter>dependency</parameter>
can be a string
(usually the path name of a file or directory)
or Node objects,
or a list of strings or Node objects
(such as returned by a Builder call).
This should only be necessary
for cases where the dependency
is not caught by a Scanner
for the file.
</para>
<para>
Example:
</para>
<example_commands>
env.Depends('foo', 'other-input-file-for-foo')
mylib = env.Library('mylib.c')
installed_lib = env.Install('lib', mylib)
bar = env.Program('bar.c')
# Arrange for the library to be copied into the installation
# directory before trying to build the "bar" program.
# (Note that this is for example only. A "real" library
# dependency would normally be configured through the $LIBS
# and $LIBPATH variables, not using an env.Depends() call.)
env.Depends(bar, installed_lib)
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-Detect">
<term><replaceable>env</replaceable>.<methodname>Detect</methodname>(<parameter>progs</parameter>)</term>
<listitem><para>
Find an executable from one or more choices:
<parameter>progs</parameter> may be a string or a list of strings.
Returns the first value from <parameter>progs</parameter>
that was found, or <constant>None</constant>.
Executable is searched by checking the paths in the execution environment
(<varname>env</varname><literal>['ENV']['PATH']</literal>).
On Windows systems, additionally applies the filename suffixes found in
the execution environment
(<varname>env</varname><literal>['ENV']['PATHEXT']</literal>)
but will not include any such extension in the return value.
&f-env-Detect; is a wrapper around &f-link-env-WhereIs;.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-Dictionary">
<term><replaceable>env</replaceable>.<methodname>Dictionary</methodname>(<parameter>[vars]</parameter>)</term>
<listitem><para>
Returns a dictionary object
containing the &consvars; in the &consenv;.
If there are any arguments specified,
the values of the specified &consvars;
are returned as a string (if one
argument) or as a list of strings.
</para>
<para>
Example:
</para>
<example_commands>
cvars = env.Dictionary()
cc_values = env.Dictionary('CC', 'CCFLAGS', 'CCCOM')
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-Dir">
<term><function>Dir</function>(<parameter>name, [directory]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Dir</methodname>(<parameter>name, [directory]</parameter>)</term>
<listitem><para>
Returns Directory Node(s).
A Directory Node is an object that represents a directory.
<parameter>name</parameter>
can be a relative or absolute path or a list of such paths.
<parameter>directory</parameter>
is an optional directory that will be used as the parent directory.
If no
<parameter>directory</parameter>
is specified, the current script's directory is used as the parent.
</para>
<para>
If
<parameter>name</parameter>
is a single pathname, the corresponding node is returned.
If
<parameter>name</parameter>
is a list, SCons returns a list of nodes.
Construction variables are expanded in
<parameter>name</parameter>.
</para>
<para>
Directory Nodes can be used anywhere you
would supply a string as a directory name
to a Builder method or function.
Directory Nodes have attributes and methods
that are useful in many situations;
see manpage section "Filesystem Nodes"
for more information.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-Dump">
<term><replaceable>env</replaceable>.<methodname>Dump</methodname>(<parameter>[key, ...], [format=]</parameter>)</term>
<listitem><para>
Serializes &consvars; from the current &consenv;
to a string.
The method supports the following formats specified by
<parameter>format</parameter>,
which must be used a a keyword argument:
</para>
<variablelist>
<varlistentry>
<term><literal>pretty</literal></term>
<listitem>
<para>
Returns a pretty-printed representation of the variables
(this is the default).
The variables will be presented in &Python; dict form.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>json</literal></term>
<listitem>
<para>
Returns a JSON-formatted string representation of the variables.
The variables will be presented as a JSON object literal,
the JSON equivalent of a &Python; dict.
</para>
</listitem>
</varlistentry>
</variablelist>
<para>
If no <varname>key</varname> is supplied,
all the &consvars; are serialized.
If one or more keys are supplied,
only those keys and their values are serialized.
</para>
<para>
<emphasis>Changed in NEXT_VERSION</emphasis>:
More than one <parameter>key</parameter> can be specified.
The returned string always looks like a dict (or JSON equivalent);
previously a single key serialized only the value,
not the key with the value.
</para>
<para>
This SConstruct:
</para>
<example_commands>
env = Environment()
print(env.Dump('CCCOM'))
print(env.Dump('CC', 'CCFLAGS', format='json'))
</example_commands>
<para>
will print something like:
</para>
<example_commands>
{'CCCOM': '$CC -o $TARGET -c $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES'}
{
"CC": "gcc",
"CCFLAGS": []
}
</example_commands>
<para>
While this SConstruct:
</para>
<example_commands>
env = Environment()
print(env.Dump())
</example_commands>
<para>
will print something like:
</para>
<example_commands>
{ 'AR': 'ar',
'ARCOM': '$AR $ARFLAGS $TARGET $SOURCES\n$RANLIB $RANLIBFLAGS $TARGET',
'ARFLAGS': ['r'],
'AS': 'as',
'ASCOM': '$AS $ASFLAGS -o $TARGET $SOURCES',
'ASFLAGS': [],
...
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-EnsurePythonVersion">
<term><function>EnsurePythonVersion</function>(<parameter>major, minor</parameter>)</term>
<listitem><para>
Ensure that the Python version is at least
<varname>major</varname>.<varname>minor</varname>.
This function will
print out an error message and exit SCons with a non-zero exit code if the
actual Python version is not late enough.
</para>
<para>
Example:
</para>
<example_commands>
EnsurePythonVersion(2,2)
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-EnsureSConsVersion">
<term><function>EnsureSConsVersion</function>(<parameter>major, minor, [revision]</parameter>)</term>
<listitem><para>
Ensure that the SCons version is at least
<varname>major.minor</varname>,
or
<varname>major.minor.revision</varname>.
if
<varname>revision</varname>
is specified.
This function will
print out an error message and exit SCons with a non-zero exit code if the
actual SCons version is not late enough.
</para>
<para>
Examples:
</para>
<example_commands>
EnsureSConsVersion(0,14)
EnsureSConsVersion(0,96,90)
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-Environment">
<term><function>Environment</function>(<parameter>[key=value, ...]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Environment</methodname>(<parameter>[key=value, ...]</parameter>)</term>
<listitem><para>
Return a new &consenv;
initialized with the specified
<parameter>key</parameter>=<replaceable>value</replaceable>
pairs.
The keyword arguments
<parameter>parse_flags</parameter>,
<parameter>platform</parameter>,
<parameter>toolpath</parameter>,
<parameter>tools</parameter>
and <parameter>variables</parameter>
are specially recognized and do not lead to
&consvar; creation.
See the manpage section "Construction Environments" for more details.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-Execute">
<term><function>Execute</function>(<parameter>action, [actionargs ...]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Execute</methodname>(<parameter>action, [actionargs ...]</parameter>)</term>
<listitem><para>
Executes an Action.
<parameter>action</parameter>
may be an Action object
or it may be a command-line string,
list of commands,
or executable &Python; function,
each of which will first be converted
into an Action object
and then executed.
Any additional arguments to &f-Execute;
are passed on to the &f-link-Action; factory function
which actually creates the Action object
(see the manpage section <link linkend="action_objects">Action Objects</link>
for a description). Example:
</para>
<example_commands>
Execute(Copy('file.out', 'file.in'))
</example_commands>
<para>&f-Execute; performs its action immediately,
as part of the SConscript-reading phase.
There are no sources or targets declared in an
&f-Execute; call, so any objects it manipulates
will not be tracked as part of the &SCons; dependency graph.
In the example above, neither
<filename>file.out</filename> nor
<filename>file.in</filename> will be tracked objects.
</para>
<para>
&f-Execute; returns the exit value of the command
or return value of the &Python; function.
&scons;
prints an error message if the executed
<parameter>action</parameter>
fails (exits with or returns a non-zero value),
however it does
<emphasis>not</emphasis>,
automatically terminate the build for such a failure.
If you want the build to stop in response to a failed
&f-Execute;
call,
you must explicitly check for a non-zero return value:
</para>
<example_commands>
if Execute("mkdir sub/dir/ectory"):
# The mkdir failed, don't try to build.
Exit(1)
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-Exit">
<term><function>Exit</function>(<parameter>[value]</parameter>)</term>
<listitem><para>
This tells
&scons;
to exit immediately
with the specified
<varname>value</varname>.
A default exit value of
<literal>0</literal>
(zero)
is used if no value is specified.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-Export">
<term><function>Export</function>(<parameter>[vars...], [key=value...]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Export</methodname>(<parameter>[vars...], [key=value...]</parameter>)</term>
<listitem><para>
Exports variables for sharing with other SConscript files.
The variables are added to a global collection where
they can be imported by other SConscript files.
<parameter>vars</parameter> may be one or more
strings, or a list of strings. If any string
contains whitespace, it is split automatically
into individual strings. Each string must
match the name of a variable that is in scope
during evaluation of the current SConscript file,
or an exception is raised.
</para>
<para>
A <parameter>vars</parameter> argument
may also be a dictionary or
individual keyword arguments;
in accordance with &Python; syntax rules,
keyword arguments must come after any
non-keyword arguments.
The dictionary/keyword form can be used
to map the local name of a variable to
a different name to be used for imports.
See the Examples for an illustration of the syntax.
</para>
<para>
&f-Export; calls are cumulative. Specifying a previously
exported variable will replace the previous value in the collection.
Both local variables and global variables can be exported.
</para>
<para>
To use an exported variable, an SConscript must
call &f-link-Import; to bring it into its own scope.
Importing creates an additional reference to the object that
was originally exported, so if that object is mutable,
changes made will be visible to other users of that object.
</para>
<para>
Examples:
</para>
<example_commands>
env = Environment()
# Make env available for all SConscript files to Import().
Export("env")
package = 'my_name'
# Make env and package available for all SConscript files:.
Export("env", "package")
# Make env and package available for all SConscript files:
Export(["env", "package"])
# Make env available using the name debug:
Export(debug=env)
# Make env available using the name debug:
Export({"debug": env})
</example_commands>
<para>
Note that the
&f-link-SConscript;
function also supports an &exports;
argument that allows exporting one or more variables
to the SConscript files invoked by that call (only).
See the description of that function for details.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-File">
<term><function>File</function>(<parameter>name, [directory]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>File</methodname>(<parameter>name, [directory]</parameter>)</term>
<listitem><para>
Returns File Node(s).
A File Node is an object that represents a file.
<parameter>name</parameter>
can be a relative or absolute path or a list of such paths.
<parameter>directory</parameter>
is an optional directory that will be used as the parent directory.
If no
<parameter>directory</parameter>
is specified, the current script's directory is used as the parent.
</para>
<para>
If
<parameter>name</parameter>
is a single pathname, the corresponding node is returned.
If
<parameter>name</parameter>
is a list, SCons returns a list of nodes.
Construction variables are expanded in
<parameter>name</parameter>.
</para>
<para>
File Nodes can be used anywhere you
would supply a string as a file name
to a Builder method or function.
File Nodes have attributes and methods
that are useful in many situations;
see manpage section "Filesystem Nodes"
for more information.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-FindFile">
<term><function>FindFile</function>(<parameter>file, dirs</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>FindFile</methodname>(<parameter>file, dirs</parameter>)</term>
<listitem><para>
Search for
<parameter>file</parameter>
in the path specified by
<parameter>dirs</parameter>.
<parameter>dirs</parameter>
may be a list of directory names or a single directory name.
In addition to searching for files that exist in the filesystem,
this function also searches for derived files
that have not yet been built.
</para>
<para>
Example:
</para>
<example_commands>
foo = env.FindFile('foo', ['dir1', 'dir2'])
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-FindInstalledFiles">
<term><function>FindInstalledFiles</function>()</term>
<term><replaceable>env</replaceable>.<methodname>FindInstalledFiles</methodname>()</term>
<listitem><para>
Returns the list of targets set up by the
&b-link-Install;
or
&b-link-InstallAs;
builders.
</para>
<para>
This function serves as a convenient method to select the contents of
a binary package.
</para>
<para>
Example:
</para>
<example_commands>
Install('/bin', ['executable_a', 'executable_b'])
# will return the file node list
# ['/bin/executable_a', '/bin/executable_b']
FindInstalledFiles()
Install('/lib', ['some_library'])
# will return the file node list
# ['/bin/executable_a', '/bin/executable_b', '/lib/some_library']
FindInstalledFiles()
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-FindPathDirs">
<term><function>FindPathDirs</function>(<parameter>variable</parameter>)</term>
<listitem><para>
Returns a function
(actually a callable Python object)
intended to be used as the
<varname>path_function</varname>
of a Scanner object.
The returned object will look up the specified
<varname>variable</varname>
in a construction environment
and treat the construction variable's value as a list of
directory paths that should be searched
(like
&cv-link-CPPPATH;,
&cv-link-LIBPATH;,
etc.).
</para>
<para>
Note that use of
&f-FindPathDirs;
is generally preferable to
writing your own
<varname>path_function</varname>
for the following reasons:
1) The returned list will contain all appropriate directories
found in source trees
(when
&f-link-VariantDir;
is used)
or in code repositories
(when
&f-Repository;
or the
<option>-Y</option>
option are used).
2) scons will identify expansions of
<varname>variable</varname>
that evaluate to the same list of directories as,
in fact, the same list,
and avoid re-scanning the directories for files,
when possible.
</para>
<para>
Example:
</para>
<example_commands>
def my_scan(node, env, path, arg):
# Code to scan file contents goes here...
return include_files
scanner = Scanner(name = 'myscanner',
function = my_scan,
path_function = FindPathDirs('MYPATH'))
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-FindSourceFiles">
<term><function>FindSourceFiles</function>(<parameter>node='"."'</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>FindSourceFiles</methodname>(<parameter>node='"."'</parameter>)</term>
<listitem><para>
Returns the list of nodes which serve as the source of the built files.
It does so by inspecting the dependency tree starting at the optional
argument
<parameter>node</parameter>
which defaults to the '"."'-node. It will then return all leaves of
<parameter>node</parameter>.
These are all children which have no further children.
</para>
<para>
This function is a convenient method to select the contents of a Source
Package.
</para>
<para>
Example:
</para>
<example_commands>
Program('src/main_a.c')
Program('src/main_b.c')
Program('main_c.c')
# returns ['main_c.c', 'src/main_a.c', 'SConstruct', 'src/main_b.c']
FindSourceFiles()
# returns ['src/main_b.c', 'src/main_a.c' ]
FindSourceFiles('src')
</example_commands>
<para>
As you can see build support files (SConstruct in the above example)
will also be returned by this function.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-Flatten">
<term><function>Flatten</function>(<parameter>sequence</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Flatten</methodname>(<parameter>sequence</parameter>)</term>
<listitem><para>
Takes a sequence (that is, a &Python; list or tuple)
that may contain nested sequences
and returns a flattened list containing
all of the individual elements in any sequence.
This can be helpful for collecting
the lists returned by calls to Builders;
other Builders will automatically
flatten lists specified as input,
but direct &Python; manipulation of
these lists does not.
</para>
<para>
Examples:
</para>
<example_commands>
foo = Object('foo.c')
bar = Object('bar.c')
# Because `foo' and `bar' are lists returned by the Object() Builder,
# `objects' will be a list containing nested lists:
objects = ['f1.o', foo, 'f2.o', bar, 'f3.o']
# Passing such a list to another Builder is all right because
# the Builder will flatten the list automatically:
Program(source = objects)
# If you need to manipulate the list directly using &Python;, you need to
# call Flatten() yourself, or otherwise handle nested lists:
for object in Flatten(objects):
print(str(object))
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-GetBuildFailures">
<term><function>GetBuildFailures</function>()</term>
<listitem><para>
Returns a list of exceptions for the
actions that failed while
attempting to build targets.
Each element in the returned list is a
<classname>BuildError</classname>
object
with the following attributes
that record various aspects
of the build failure:
</para>
<para>
<literal>.node</literal>
The node that was being built
when the build failure occurred.
</para>
<para>
<literal>.status</literal>
The numeric exit status
returned by the command or Python function
that failed when trying to build the
specified Node.
</para>
<para>
<literal>.errstr</literal>
The SCons error string
describing the build failure.
(This is often a generic
message like "Error 2"
to indicate that an executed
command exited with a status of 2.)
</para>
<para>
<literal>.filename</literal>
The name of the file or
directory that actually caused the failure.
This may be different from the
<literal>.node</literal>
attribute.
For example,
if an attempt to build a target named
<filename>sub/dir/target</filename>
fails because the
<filename>sub/dir</filename>
directory could not be created,
then the
<literal>.node</literal>
attribute will be
<filename>sub/dir/target</filename>
but the
<literal>.filename</literal>
attribute will be
<filename>sub/dir</filename>.
</para>
<para>
<literal>.executor</literal>
The SCons Executor object
for the target Node
being built.
This can be used to retrieve
the construction environment used
for the failed action.
</para>
<para>
<literal>.action</literal>
The actual SCons Action object that failed.
This will be one specific action
out of the possible list of
actions that would have been
executed to build the target.
</para>
<para>
<literal>.command</literal>
The actual expanded command that was executed and failed,
after expansion of
&cv-link-TARGET;,
&cv-link-SOURCE;,
and other construction variables.
</para>
<para>
Note that the
&f-GetBuildFailures;
function
will always return an empty list
until any build failure has occurred,
which means that
&f-GetBuildFailures;
will always return an empty list
while the
&SConscript;
files are being read.
Its primary intended use is
for functions that will be
executed before SCons exits
by passing them to the
standard Python
<function>atexit.register</function>()
function.
Example:
</para>
<example_commands>
import atexit
def print_build_failures():
from SCons.Script import GetBuildFailures
for bf in GetBuildFailures():
print("%s failed: %s" % (bf.node, bf.errstr))
atexit.register(print_build_failures)
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-GetBuildPath">
<term><function>GetBuildPath</function>(<parameter>file, [...]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>GetBuildPath</methodname>(<parameter>file, [...]</parameter>)</term>
<listitem><para>
Returns the
&scons;
path name (or names) for the specified
<parameter>file</parameter>
(or files).
The specified
<parameter>file</parameter>
or files
may be
&scons;
Nodes or strings representing path names.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-GetLaunchDir">
<term><function>GetLaunchDir</function>()</term>
<listitem><para>
Returns the absolute path name of the directory from which
&scons;
was initially invoked.
This can be useful when using the
<option>-u</option>,
<option>-U</option>
or
<option>-D</option>
options, which internally
change to the directory in which the
&SConstruct;
file is found.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-GetOption">
<term><function>GetOption</function>(<parameter>name</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>GetOption</methodname>(<parameter>name</parameter>)</term>
<listitem><para>
Query the value of settable options which may have been set
on the command line, via option defaults,
or by using the &f-link-SetOption; function.
The value of the option is returned in a type matching how the
option was declared - see the documentation of the
corresponding command line option for information about each specific
option.
</para>
<para>
<parameter>name</parameter> can be an entry from the following table,
which shows the corresponding command line arguments
that could affect the value.
<parameter>name</parameter> can be also be the destination
variable name from a project-specific option added using the
&f-link-AddOption; function, as long as that addition has been
processed prior to the &f-GetOption; call in the &SConscript; files.
</para>
<informaltable rowsep="1" colsep="1" frame="topbot">
<tgroup cols="3">
<thead>
<row>
<entry align="left">Query name</entry>
<entry align="left">Command-line options</entry>
<entry align="left">Notes</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>cache_debug</varname></entry>
<entry><option>--cache-debug</option></entry>
</row>
<row>
<entry><varname>cache_disable</varname></entry>
<entry>
<option>--cache-disable</option>,
<option>--no-cache</option>
</entry>
</row>
<row>
<entry><varname>cache_force</varname></entry>
<entry>
<option>--cache-force</option>,
<option>--cache-populate</option>
</entry>
</row>
<row>
<entry><varname>cache_readonly</varname></entry>
<entry><option>--cache-readonly</option></entry>
</row>
<row>
<entry><varname>cache_show</varname></entry>
<entry><option>--cache-show</option></entry>
</row>
<row>
<entry><varname>clean</varname></entry>
<entry>
<option>-c</option>,
<option>--clean</option>,
<option>--remove</option>
</entry>
</row>
<row>
<entry><varname>climb_up</varname></entry>
<entry>
<option>-D</option>
<option>-U</option>
<option>-u</option>
<option>--up</option>
<option>--search_up</option>
</entry>
</row>
<row>
<entry><varname>config</varname></entry>
<entry><option>--config</option></entry>
</row>
<row>
<entry><varname>debug</varname></entry>
<entry><option>--debug</option></entry>
</row>
<row>
<entry><varname>directory</varname></entry>
<entry><option>-C</option>, <option>--directory</option></entry>
</row>
<row>
<entry><varname>diskcheck</varname></entry>
<entry><option>--diskcheck</option></entry>
</row>
<row>
<entry><varname>duplicate</varname></entry>
<entry><option>--duplicate</option></entry>
</row>
<row>
<entry><varname>enable_virtualenv</varname></entry>
<entry><option>--enable-virtualenv</option></entry>
</row>
<row>
<entry><varname>experimental</varname></entry>
<entry><option>--experimental</option></entry>
<entry><emphasis>since 4.2</emphasis></entry>
</row>
<row>
<entry><varname>file</varname></entry>
<entry>
<option>-f</option>,
<option>--file</option>,
<option>--makefile</option>,
<option>--sconstruct</option>
</entry>
</row>
<row>
<entry><varname>hash_format</varname></entry>
<entry><option>--hash-format</option></entry>
<entry><emphasis>since 4.2</emphasis></entry>
</row>
<row>
<entry><varname>help</varname></entry>
<entry><option>-h</option>, <option>--help</option></entry>
</row>
<row>
<entry><varname>ignore_errors</varname></entry>
<entry><option>-i</option>, <option>--ignore-errors</option></entry>
</row>
<row>
<entry><varname>ignore_virtualenv</varname></entry>
<entry><option>--ignore-virtualenv</option></entry>
</row>
<row>
<entry><varname>implicit_cache</varname></entry>
<entry><option>--implicit-cache</option></entry>
</row>
<row>
<entry><varname>implicit_deps_changed</varname></entry>
<entry><option>--implicit-deps-changed</option></entry>
</row>
<row>
<entry><varname>implicit_deps_unchanged</varname></entry>
<entry><option>--implicit-deps-unchanged</option></entry>
</row>
<row>
<entry><varname>include_dir</varname></entry>
<entry><option>-I</option>, <option>--include-dir</option></entry>
</row>
<row>
<entry><varname>install_sandbox</varname></entry>
<entry><option>--install-sandbox</option></entry>
<entry>Available only if the &t-link-install; tool has been called</entry>
</row>
<row>
<entry><varname>keep_going</varname></entry>
<entry><option>-k</option>, <option>--keep-going</option></entry>
</row>
<row>
<entry><varname>max_drift</varname></entry>
<entry><option>--max-drift</option></entry>
</row>
<row>
<entry><varname>md5_chunksize</varname></entry>
<entry>
<option>--hash-chunksize</option>,
<option>--md5-chunksize</option>
</entry>
<entry><emphasis><option>--hash-chunksize</option> since 4.2</emphasis></entry>
</row>
<row>
<entry><varname>no_exec</varname></entry>
<entry>
<option>-n</option>,
<option>--no-exec</option>,
<option>--just-print</option>,
<option>--dry-run</option>,
<option>--recon</option>
</entry>
</row>
<row>
<entry><varname>no_progress</varname></entry>
<entry><option>-Q</option></entry>
</row>
<row>
<entry><varname>num_jobs</varname></entry>
<entry><option>-j</option>, <option>--jobs</option></entry>
</row>
<row>
<entry><varname>package_type</varname></entry>
<entry><option>--package-type</option></entry>
<entry>Available only if the &t-link-packaging; tool has been called</entry>
</row>
<row>
<entry><varname>profile_file</varname></entry>
<entry><option>--profile</option></entry>
</row>
<row>
<entry><varname>question</varname></entry>
<entry><option>-q</option>, <option>--question</option></entry>
</row>
<row>
<entry><varname>random</varname></entry>
<entry><option>--random</option></entry>
</row>
<row>
<entry><varname>repository</varname></entry>
<entry>
<option>-Y</option>,
<option>--repository</option>,
<option>--srcdir</option>
</entry>
</row>
<row>
<entry><varname>silent</varname></entry>
<entry>
<option>-s</option>,
<option>--silent</option>,
<option>--quiet</option>
</entry>
</row>
<row>
<entry><varname>site_dir</varname></entry>
<entry><option>--site-dir</option>, <option>--no-site-dir</option></entry>
</row>
<row>
<entry><varname>stack_size</varname></entry>
<entry><option>--stack-size</option></entry>
</row>
<row>
<entry><varname>taskmastertrace_file</varname></entry>
<entry><option>--taskmastertrace</option></entry>
</row>
<row>
<entry><varname>tree_printers</varname></entry>
<entry><option>--tree</option></entry>
</row>
<row>
<entry><varname>warn</varname></entry>
<entry><option>--warn</option>, <option>--warning</option></entry>
</row>
</tbody>
</tgroup>
</informaltable>
</listitem>
</varlistentry>
<varlistentry id="f-GetSConsVersion">
<term><function>GetSConsVersion</function>()</term>
<listitem><para>
Returns the current SCons version in the form of a Tuple[int, int, int],
representing the major, minor, and revision values respectively.
<emphasis>Added in 4.8.0</emphasis>.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-Glob">
<term><function>Glob</function>(<parameter>pattern, [ondisk=True, source=False, strings=False, exclude=None]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Glob</methodname>(<parameter>pattern, [ondisk=True, source=False, strings=False, exclude=None]</parameter>)</term>
<listitem><para>
Returns a possibly empty list of Nodes (or strings) that match
pathname specification <parameter>pattern</parameter>.
<parameter>pattern</parameter> can be absolute,
top-relative,
or (most commonly) relative to the directory of the current
&SConscript; file.
&f-Glob; matches both files stored on disk and Nodes
which &SCons; already knows about, even if any corresponding
file is not currently stored on disk.
The evironment method form (&f-env-Glob;)
performs string substition on
<parameter>pattern</parameter>
and returns whatever matches the resulting expanded pattern.
The results are sorted, unlike for the similar &Python;
<systemitem>glob.glob</systemitem> function,
to ensure build order will be stable.
</para>
<para>
<parameter>pattern</parameter>
can contain POSIX-style shell metacharacters for matching:
</para>
<informaltable rowsep="1" colsep="1" frame="topbot">
<tgroup cols="2">
<thead>
<row>
<entry>Pattern</entry>
<entry>Meaning</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>*</literal></entry>
<entry>matches everything</entry>
</row>
<row>
<entry><literal>?</literal></entry>
<entry>matches any single character</entry>
</row>
<row>
<entry><literal>[seq]</literal></entry>
<entry>matches any character in <emphasis>seq</emphasis>
(can be a list or a range).</entry>
</row>
<row>
<entry><literal>[!seq]</literal></entry>
<entry>matches any character not in <emphasis>seq</emphasis></entry>
</row>
</tbody>
</tgroup>
</informaltable>
<para>
For a literal match, wrap the metacharacter in brackets to
escape the normal behavior.
For example, <literal>'[?]'</literal> matches the character
<literal>'?'</literal>.
</para>
<para>
Filenames starting with a dot are specially handled -
they can only be matched by patterns that start with a dot
(or have a dot immediately following a pathname separator
character, or slash), they are not not matched by the metacharacters.
Metacharacter matches also do not span directory separators.
</para>
<para>
&f-Glob;
understands repositories
(see the
&f-link-Repository;
function)
and source directories
(see the
&f-link-VariantDir;
function)
and returns a Node (or string, if so configured) match
in the local (SConscript) directory
if a matching Node is found
anywhere in a corresponding
repository or source directory.
</para>
<para>
If the optional
<parameter>ondisk</parameter>
argument evaluates false,
the search for matches on disk is disabled,
and only matches from
already-configured File or Dir Nodes are returned.
The default is to return Nodes for
matches on disk as well.
</para>
<para>
If the optional
<parameter>source</parameter>
argument evaluates true,
and the local directory is a variant directory,
then &f-Glob; returnes Nodes from
the corresponding source directory,
rather than the local directory.
<!-- XXX what about generated files that don't exist in src but will be sources? -->
</para>
<para>
If the optional
<parameter>strings</parameter>
argument evaluates true,
&f-Glob;
returns matches as strings, rather than Nodes.
The returned strings will be relative to
the local (SConscript) directory.
(Note that while this may make it easier to perform
arbitrary manipulation of file names,
it loses the context &SCons; would have in the Node,
so if the returned strings are
passed to a different
&SConscript;
file,
any Node translation there will be relative
to that
&SConscript;
directory,
not to the original
&SConscript;
directory.)
</para>
<para>
The optional
<parameter>exclude</parameter>
argument may be set to a pattern or a list of patterns
descibing files or directories
to filter out of the match list.
Elements matching a least one specified pattern will be excluded.
These patterns use the same syntax as for
<parameter>pattern</parameter>.
</para>
<para>
Examples:
</para>
<example_commands>
Program("foo", Glob("*.c"))
Zip("/tmp/everything", Glob(".??*") + Glob("*"))
sources = Glob("*.cpp", exclude=["os_*_specific_*.cpp"]) \
+ Glob("os_%s_specific_*.cpp" % currentOS)
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-Help">
<term><function>Help</function>(<parameter>text, append=False, local_only=False</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Help</methodname>(<parameter>text, append=False, local_only=False</parameter>)</term>
<listitem><para>
Adds <parameter>text</parameter> to the help message shown when
&scons; is called with the
<option>-h</option> or <option>--help</option>
argument.
</para>
<para>
On the first call to &f-Help;,
if <parameter>append</parameter> is <constant>False</constant>
(the default), any existing help text is discarded.
The default help text is the help for the &scons;
command itself plus help collected from any
project-local &f-link-AddOption; calls.
This is the help printed if &f-Help; has never been called.
If <parameter>append</parameter> is <constant>True</constant>,
<parameter>text</parameter> is appended to
the existing help text.
If <parameter>local_only</parameter> is also <constant>True</constant>
(the default is <constant>False</constant>),
the project-local help from &f-AddOption; calls is preserved
in the help message but the &scons; command help is not.
</para>
<para>
Subsequent calls to
&f-Help; ignore the keyword arguments
<parameter>append</parameter> and
<parameter>local_only</parameter>
and always append to the existing help text.
</para>
<para>
<emphasis>Changed in 4.6.0</emphasis>: added <parameter>local_only</parameter>.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-Ignore">
<term><function>Ignore</function>(<parameter>target, dependency</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Ignore</methodname>(<parameter>target, dependency</parameter>)</term>
<listitem><para>
Ignores <parameter>dependency</parameter>
when deciding if
<parameter>target</parameter> needs to be rebuilt.
<parameter>target</parameter> and
<parameter>dependency</parameter>
can each be a single filename or Node
or a list of filenames or Nodes.
</para>
<para>
&f-Ignore; can also be used to
remove a target from the default build
by specifying the directory the target will be built in as
<parameter>target</parameter>
and the file you want to skip selecting for building as
<parameter>dependency</parameter>.
Note that this only removes the target from
the default target selection algorithm:
if it is a dependency of another object being
built &SCons; still builds it normally.
See the third and forth examples below.
</para>
<para>
Examples:
</para>
<example_commands>
env.Ignore('foo', 'foo.c')
env.Ignore('bar', ['bar1.h', 'bar2.h'])
env.Ignore('.', 'foobar.obj')
env.Ignore('bar', 'bar/foobar.obj')
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-Import">
<term><function>Import</function>(<parameter>vars...</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Import</methodname>(<parameter>vars...</parameter>)</term>
<listitem><para>
Imports variables into the scope of the current SConscript file.
<parameter>vars</parameter>
must be strings representing names of variables
which have been previously exported either by the
&f-link-Export; function or by the
&exports; argument to the
&f-link-SConscript; function.
Variables exported by the
&f-SConscript; call
take precedence.
Multiple variable names can be passed to
&f-Import;
as separate arguments, as a list of strings,
or as words in a space-separated string.
The wildcard <literal>"*"</literal> can be used to import all
available variables.
</para>
<para>
If the imported variable is mutable,
changes made locally will be reflected in the object the
variable is bound to. This allows subsidiary SConscript files
to contribute to building up, for example, a &consenv;.
</para>
<para>
Examples:
</para>
<example_commands>
Import("env")
Import("env", "variable")
Import(["env", "variable"])
Import("*")
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-Literal">
<term><function>Literal</function>(<parameter>string</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Literal</methodname>(<parameter>string</parameter>)</term>
<listitem><para>
The specified
<parameter>string</parameter>
will be preserved as-is
and not have construction variables expanded.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-Local">
<term><function>Local</function>(<parameter>targets</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Local</methodname>(<parameter>targets</parameter>)</term>
<listitem><para>
The specified
<parameter>targets</parameter>
will have copies made in the local tree,
even if an already up-to-date copy
exists in a repository.
Returns a list of the target Node or Nodes.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-MergeFlags">
<term><replaceable>env</replaceable>.<methodname>MergeFlags</methodname>(<parameter>arg, [unique]</parameter>)</term>
<listitem><para>
Merges values from
<parameter>arg</parameter>
into &consvars; in <parameter>env</parameter>.
If <parameter>arg</parameter> is a dictionary,
each key-value pair represents a
&consvar; name and the corresponding flags to merge.
If <parameter>arg</parameter>
is not a dictionary,
&MergeFlags; attempts to convert it to one
before the values are merged.
&f-link-env-ParseFlags; is used for this,
so values to be converted are subject to the
same limitations:
&ParseFlags; has knowledge of which &consvars; certain
flags should go to, but not all;
and only for GCC and compatible compiler chains.
<parameter>arg</parameter>
must be a single object,
so to pass multiple strings,
enclose them in a list.
</para>
<para>
If <literal>unique</literal> is true (the default),
duplicate values are not retained.
In case of duplication,
any &consvar; names that end in
<literal>PATH</literal>
keep the left-most value so the
path searcb order is not altered.
All other &consvars; keep
the right-most value.
If <literal>unique</literal> is false,
values are appended even if they are duplicates.
</para>
<para>
Examples:
</para>
<example_commands>
# Add an optimization flag to $CCFLAGS.
env.MergeFlags({'CCFLAGS': '-O3'})
# Combine the flags returned from running pkg-config with an optimization
# flag and merge the result into the construction variables.
env.MergeFlags(['!pkg-config gtk+-2.0 --cflags', '-O3'])
# Combine an optimization flag with the flags returned from running pkg-config
# for two distinct packages and merge into the construction variables.
env.MergeFlags(
[
'-O3',
'!pkg-config gtk+-2.0 --cflags --libs',
'!pkg-config libpng12 --cflags --libs',
]
)
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-NoCache">
<term><function>NoCache</function>(<parameter>target, ...</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>NoCache</methodname>(<parameter>target, ...</parameter>)</term>
<listitem><para>
Specifies a list of files which should
<emphasis>not</emphasis>
be cached whenever the
&f-link-CacheDir;
method has been activated.
The specified targets may be a list
or an individual target.
</para>
<para>
Multiple files should be specified
either as separate arguments to the
&f-NoCache;
method, or as a list.
&f-NoCache;
will also accept the return value of any of the construction environment
Builder methods.
</para>
<para>
Calling
&f-NoCache;
on directories and other non-File Node types has no effect because
only File Nodes are cached.
</para>
<para>
Examples:
</para>
<example_commands>
NoCache('foo.elf')
NoCache(env.Program('hello', 'hello.c'))
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-NoClean">
<term><function>NoClean</function>(<parameter>target, ...</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>NoClean</methodname>(<parameter>target, ...</parameter>)</term>
<listitem><para>
Specifies a list of files or directories which should
<emphasis>not</emphasis>
be removed whenever the targets (or their dependencies)
are specified with the
<option>-c</option>
command line option.
The specified targets may be a list
or an individual target.
Multiple calls to
&f-NoClean;
are legal,
and prevent each specified target
from being removed by calls to the
<option>-c</option>
option.
</para>
<para>
Multiple files or directories should be specified
either as separate arguments to the
&f-NoClean;
method, or as a list.
&f-NoClean;
will also accept the return value of any of the construction environment
Builder methods.
</para>
<para>
Calling
&f-NoClean;
for a target overrides calling
&f-link-Clean;
for the same target,
and any targets passed to both functions will
<emphasis>not</emphasis>
be removed by the
<option>-c</option>
option.
</para>
<para>
Examples:
</para>
<example_commands>
NoClean('foo.elf')
NoClean(env.Program('hello', 'hello.c'))
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-ParseConfig">
<term><replaceable>env</replaceable>.<methodname>ParseConfig</methodname>(<parameter>command, [function, unique]</parameter>)</term>
<listitem><para>
Updates the current &consenv; with the values extracted
from the output of running external <parameter>command</parameter>,
by passing it to a helper <parameter>function</parameter>.
<parameter>command</parameter> may be a string
or a list of strings representing the command and
its arguments.
If <parameter>function</parameter>
is omitted or <constant>None</constant>,
&f-link-env-MergeFlags; is used.
By default,
duplicate values are not
added to any construction variables;
you can specify
<parameter>unique=False</parameter>
to allow duplicate values to be added.
</para>
<para>
<parameter>command</parameter> is executed using the
SCons execution environment (that is, the &consvar;
&cv-link-ENV; in the current &consenv;).
If <parameter>command</parameter> needs additional information
to operate properly, that needs to be set in the execution environment.
For example, <command>pkg-config</command>
may need a custom value set in the <envar>PKG_CONFIG_PATH</envar>
environment variable.
</para>
<para>
&f-env-MergeFlags; needs to understand
the output produced by <parameter>command</parameter>
in order to distribute it to appropriate &consvars;.
&f-env-MergeFlags; uses a separate function to
do that processing -
see &f-link-env-ParseFlags; for the details, including a
a table of options and corresponding construction variables.
To provide alternative processing of the output of
<parameter>command</parameter>,
you can suppply a custom
<parameter>function</parameter>,
which must accept three arguments:
the &consenv; to modify,
a string argument containing the output from running
<parameter>command</parameter>,
and the optional
<parameter>unique</parameter> flag.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-ParseDepends">
<term><function>ParseDepends</function>(<parameter>filename, [must_exist, only_one]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>ParseDepends</methodname>(<parameter>filename, [must_exist, only_one]</parameter>)</term>
<listitem><para>
Parses the contents of <parameter>filename</parameter>
as a list of dependencies in the style of
&Make;
or
<application>mkdep</application>,
and explicitly establishes all of the listed dependencies.
</para>
<para>
By default,
it is not an error
if <parameter>filename</parameter>
does not exist.
The optional
<parameter>must_exist</parameter>
argument may be set to <constant>True</constant>
to have &SCons;
raise an exception if the file does not exist,
or is otherwise inaccessible.
</para>
<para>
The optional
<parameter>only_one</parameter>
argument may be set to <constant>True</constant>
to have &SCons; raise an exception
if the file contains dependency
information for more than one target.
This can provide a small sanity check
for files intended to be generated
by, for example, the
<literal>gcc -M</literal>
flag,
which should typically only
write dependency information for
one output file into a corresponding
<filename>.d</filename>
file.
</para>
<para>
<parameter>filename</parameter>
and all of the files listed therein
will be interpreted relative to
the directory of the
&SConscript;
file which calls the
&f-ParseDepends;
function.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-ParseFlags">
<term><replaceable>env</replaceable>.<methodname>ParseFlags</methodname>(<parameter>flags, ...</parameter>)</term>
<listitem><para>
Parses one or more strings containing
typical command-line flags for GCC-style tool chains
and returns a dictionary with the flag values
separated into the appropriate SCons construction variables.
Intended as a companion to the
&f-link-env-MergeFlags;
method, but allows for the values in the returned dictionary
to be modified, if necessary,
before merging them into the construction environment.
(Note that
&f-env-MergeFlags;
will call this method if its argument is not a dictionary,
so it is usually not necessary to call
&f-env-ParseFlags;
directly unless you want to manipulate the values.)
</para>
<para>
If the first character in any string is
an exclamation mark (<literal>!</literal>),
the rest of the string is executed as a command,
and the output from the command is
parsed as GCC tool chain command-line flags
and added to the resulting dictionary.
This can be used to call a <filename>*-config</filename>
command typical of the POSIX programming environment
(for example,
<command>pkg-config</command>).
Note that such a command is executed using the
SCons execution environment;
if the command needs additional information,
that information needs to be explicitly provided.
See &f-link-ParseConfig; for more details.
</para>
<para>
Flag values are translated according to the prefix found,
and added to the following construction variables:
</para>
<example_commands>
-arch CCFLAGS, LINKFLAGS
-D CPPDEFINES
-framework FRAMEWORKS
-frameworkdir= FRAMEWORKPATH
-fmerge-all-constants CCFLAGS, LINKFLAGS
-fopenmp CCFLAGS, LINKFLAGS
-fsanitize CCFLAGS, LINKFLAGS
-include CCFLAGS
-imacros CCFLAGS
-isysroot CCFLAGS, LINKFLAGS
-isystem CCFLAGS
-iquote CCFLAGS
-idirafter CCFLAGS
-I CPPPATH
-l LIBS
-L LIBPATH
-mno-cygwin CCFLAGS, LINKFLAGS
-mwindows LINKFLAGS
-openmp CCFLAGS, LINKFLAGS
-pthread CCFLAGS, LINKFLAGS
-std= CFLAGS
-stdlib= CXXFLAGS
-Wa, ASFLAGS, CCFLAGS
-Wl,-rpath= RPATH
-Wl,-R, RPATH
-Wl,-R RPATH
-Wl, LINKFLAGS
-Wp, CPPFLAGS
- CCFLAGS
+ CCFLAGS, LINKFLAGS
</example_commands>
<para>
Any other strings not associated with options
are assumed to be the names of libraries
and added to the
&cv-LIBS;
construction variable.
</para>
<para>
Examples (all of which produce the same result):
</para>
<example_commands>
dict = env.ParseFlags('-O2 -Dfoo -Dbar=1')
dict = env.ParseFlags('-O2', '-Dfoo', '-Dbar=1')
dict = env.ParseFlags(['-O2', '-Dfoo -Dbar=1'])
dict = env.ParseFlags('-O2', '!echo -Dfoo -Dbar=1')
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-Platform">
<term><function>Platform</function>(<parameter>plat</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Platform</methodname>(<parameter>plat</parameter>)</term>
<listitem><para>
When called as a global function,
returns a callable platform object
selected by <parameter>plat</parameter>
(defaults to the detected platform for the
current system)
that can be used to initialize
a construction environment by passing it as the
<parameter>platform</parameter> keyword argument to the
&f-link-Environment; function.
</para>
<para>
Example:
</para>
<example_commands>
env = Environment(platform=Platform('win32'))
</example_commands>
<para>
When called as a method of an environment,
calls the platform object indicated by
<parameter>plat</parameter>
to update that environment.
</para>
<example_commands>
env.Platform('posix')
</example_commands>
<para>
See the manpage section "Construction Environments" for more details.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-Precious">
<term><function>Precious</function>(<parameter>target, ...</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Precious</methodname>(<parameter>target, ...</parameter>)</term>
<listitem><para>
Marks <varname>target</varname> as precious so it is not
deleted before it is rebuilt.
Normally &SCons; deletes a target before building it.
Multiple targets can be passed in a single call,
and may be strings and/or nodes.
Returns a list of the affected target nodes.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-Prepend">
<term><replaceable>env</replaceable>.<methodname>Prepend</methodname>(<parameter>key=val, [...]</parameter>)</term>
<listitem><para>
Prepend values to &consvars; in the current &consenv;,
Works like &f-link-env-Append; (see for details),
except that values are added to the front,
rather than the end, of any existing value of the &consvar;
</para>
<para>
Example:
</para>
<example_commands>
env.Prepend(CCFLAGS='-g ', FOO=['foo.yyy'])
</example_commands>
<para>
See also &f-link-env-Append;,
&f-link-env-AppendUnique;
and &f-link-env-PrependUnique;.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-PrependENVPath">
<term><replaceable>env</replaceable>.<methodname>PrependENVPath</methodname>(<parameter>name, newpath, [envname, sep, delete_existing=True]</parameter>)</term>
<listitem><para>
Prepend path elements specified by <parameter>newpath</parameter>
to the given search path string or list <parameter>name</parameter>
in mapping <parameter>envname</parameter> in the &consenv;.
Supplying <parameter>envname</parameter> is optional:
the default is the execution environment &cv-link-ENV;.
Optional <parameter>sep</parameter> is used as the search path separator,
the default is the platform's separator (<systemitem>os.pathsep</systemitem>).
A path element will only appear once.
Any duplicates in <parameter>newpath</parameter> are dropped,
keeping the first appearing (to preserve path order).
If <parameter>delete_existing</parameter>
is <constant>False</constant>
any addition duplicating an existing path element is ignored;
if <parameter>delete_existing</parameter>
is <constant>True</constant> (the default) the existing value will
be dropped and the path element will be inserted at the beginning.
To help maintain uniqueness all paths are normalized (using
<systemitem>os.path.normpath</systemitem>
and
<systemitem>os.path.normcase</systemitem>).
</para>
<para>
Example:
</para>
<example_commands>
print('before:', env['ENV']['INCLUDE'])
include_path = '/foo/bar:/foo'
env.PrependENVPath('INCLUDE', include_path)
print('after:', env['ENV']['INCLUDE'])
</example_commands>
<para>Yields:</para>
<screen>
before: /biz:/foo
after: /foo/bar:/foo:/biz
</screen>
<para>
See also &f-link-env-AppendENVPath;.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-PrependUnique">
<term><replaceable>env</replaceable>.<methodname>PrependUnique</methodname>(<parameter>key=val, [...], [delete_existing=False]</parameter>)</term>
<listitem><para>
Prepend values to &consvars; in the current &consenv;,
maintaining uniqueness.
Works like &f-link-env-Append;,
except that values are added to the front,
rather than the end, of the &consvar;,
and values that would become duplicates
are not added.
If <parameter>delete_existing</parameter>
is set to a true value, then for any duplicate,
the existing instance of <parameter>val</parameter> is first removed,
then <parameter>val</parameter> is inserted,
having the effect of moving it to the front.
</para>
<para>
Example:
</para>
<example_commands>
env.PrependUnique(CCFLAGS='-g', FOO=['foo.yyy'])
</example_commands>
<para>
See also &f-link-env-Append;,
&f-link-env-AppendUnique;
and &f-link-env-Prepend;.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-Progress">
<term><function>Progress</function>(<parameter>callable, [interval]</parameter>)</term>
<term><function>Progress</function>(<parameter>string, [interval, file, overwrite]</parameter>)</term>
<term><function>Progress</function>(<parameter>list_of_strings, [interval, file, overwrite]</parameter>)</term>
<listitem><para>
Allows SCons to show progress made during the build
by displaying a string or calling a function while
evaluating Nodes (e.g. files).
</para>
<para>
If the first specified argument is a Python callable
(a function or an object that has a
<methodname>__call__</methodname> method),
the function will be called
once every
<varname>interval</varname>
times a Node is evaluated (default <constant>1</constant>).
The callable will be passed the evaluated Node
as its only argument.
(For future compatibility,
it's a good idea to also add
<parameter>*args</parameter>
and
<parameter>**kwargs</parameter>
as arguments to your function or method signatures.
This will prevent the code from breaking
if &SCons; ever changes the interface
to call the function with additional arguments in the future.)
</para>
<para>
An example of a simple custom progress function
that prints a string containing the Node name
every 10 Nodes:
</para>
<example_commands>
def my_progress_function(node, *args, **kwargs):
print('Evaluating node %s!' % node)
Progress(my_progress_function, interval=10)
</example_commands>
<para>
A more complicated example of a custom progress display object
that prints a string containing a count
every 100 evaluated Nodes.
Note the use of
<literal>\r</literal>
(a carriage return)
at the end so that the string
will overwrite itself on a display:
</para>
<example_commands>
import sys
class ProgressCounter(object):
count = 0
def __call__(self, node, *args, **kw):
self.count += 100
sys.stderr.write('Evaluated %s nodes\r' % self.count)
Progress(ProgressCounter(), interval=100)
</example_commands>
<para>
If the first argument to
&f-Progress; is a string or list of strings,
it is taken as text to be displayed every
<varname>interval</varname>
evaluated Nodes.
If the first argument is a list of strings,
then each string in the list will be displayed
in rotating fashion every
<varname>interval</varname>
evaluated Nodes.
</para>
<para>
The default is to print the string on standard output.
An alternate output stream
may be specified with the
<parameter>file</parameter>
keyword argument, which the
caller must pass already opened.
</para>
<para>
The following will print a series of dots
on the error output,
one dot for every 100 evaluated Nodes:
</para>
<example_commands>
import sys
Progress('.', interval=100, file=sys.stderr)
</example_commands>
<para>
If the string contains the verbatim substring
<literal>$TARGET;</literal>,
it will be replaced with the Node.
Note that, for performance reasons, this is
<emphasis>not</emphasis>
a regular SCons variable substition,
so you can not use other variables
or use curly braces.
The following example will print the name of
every evaluated Node,
using a carriage return)
(<literal>\r</literal>)
to cause each line to overwritten by the next line,
and the
<parameter>overwrite</parameter>
keyword argument (default <literal>False</literal>)
to make sure the previously-printed
file name is overwritten with blank spaces:
</para>
<example_commands>
import sys
Progress('$TARGET\r', overwrite=True)
</example_commands>
<para>
A list of strings can be used to implement a "spinner"
on the user's screen as follows, changing every
five evaluated Nodes:
</para>
<example_commands>
Progress(['-\r', '\\\r', '|\r', '/\r'], interval=5)
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-Pseudo">
<term><function>Pseudo</function>(<parameter>target, ...</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Pseudo</methodname>(<parameter>target, ...</parameter>)</term>
<listitem><para>
Marks <parameter>target</parameter> as a pseudo target,
not representing the production of any physical target file.
If any pseudo <parameter>target</parameter> does exist,
&SCons; will abort the build with an error.
Multiple targets can be passed in a single call,
and may be strings and/or Nodes.
Returns a list of the affected target nodes.
</para>
<para>
&f-Pseudo; may be useful in conjuction with a builder
call (such as &f-link-Command;) which does not create a physical target,
and the behavior if the target accidentally existed would be incorrect.
This is similar in concept to the GNU <application>make</application>
<literal>.PHONY</literal> target.
&SCons; also provides a powerful target alias capability
(see &f-link-Alias;) which may provide more flexibility
in many situations when defining target names that are not directly built.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-PyPackageDir">
<term><function>PyPackageDir</function>(<parameter>modulename</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>PyPackageDir</methodname>(<parameter>modulename</parameter>)</term>
<listitem><para>
Finds the location of <parameter>modulename</parameter>,
which can be a string or a sequence of strings,
each representing the name of a &Python; module.
Construction variables are expanded in
<parameter>modulename</parameter>.
Returns a Directory Node (see &f-link-Dir;),
or a list of Directory Nodes if
<parameter>modulename</parameter> is a sequence.
<literal>None</literal> is returned for any module not found.
</para>
<para>
When a Tool module which is installed as a
&Python; module is used, you need
to specify a <parameter>toolpath</parameter> argument to
&f-link-Tool;,
&f-link-Environment;
or &f-link-Clone;,
as tools outside the standard project locations
(<filename>site_scons/site_tools</filename>)
will not be found otherwise.
Using &f-PyPackageDir; allows this path to be
discovered at runtime instead of hardcoding the path.
</para>
<para>
Example:
</para>
<example_commands>
env = Environment(
tools=["default", "ExampleTool"],
toolpath=[PyPackageDir("example_tool")]
)
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-Replace">
<term><replaceable>env</replaceable>.<methodname>Replace</methodname>(<parameter>key=val, [...]</parameter>)</term>
<listitem><para>
Replaces construction variables in the Environment
with the specified keyword arguments.
</para>
<para>
Example:
</para>
<example_commands>
env.Replace(CCFLAGS='-g', FOO='foo.xxx')
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-Repository">
<term><function>Repository</function>(<parameter>directory</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Repository</methodname>(<parameter>directory</parameter>)</term>
<listitem><para>
Specifies that
<parameter>directory</parameter>
is a repository to be searched for files.
Multiple calls to
&f-Repository;
are legal,
and each one adds to the list of
repositories that will be searched.
</para>
<para>
To
&scons;,
a repository is a copy of the source tree,
from the top-level directory on down,
which may contain
both source files and derived files
that can be used to build targets in
the local source tree.
The canonical example would be an
official source tree maintained by an integrator.
If the repository contains derived files,
then the derived files should have been built using
&scons;,
so that the repository contains the necessary
signature information to allow
&scons;
to figure out when it is appropriate to
use the repository copy of a derived file,
instead of building one locally.
</para>
<para>
Note that if an up-to-date derived file
already exists in a repository,
&scons;
will
<emphasis>not</emphasis>
make a copy in the local directory tree.
In order to guarantee that a local copy
will be made,
use the
&f-link-Local;
method.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-Requires">
<term><function>Requires</function>(<parameter>target, prerequisite</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Requires</methodname>(<parameter>target, prerequisite</parameter>)</term>
<listitem><para>
Specifies an order-only relationship
between <parameter>target</parameter>
and <parameter>prerequisite</parameter>.
The prerequisites
will be (re)built, if necessary,
<emphasis>before</emphasis>
the target file(s),
but the target file(s) do not actually
depend on the prerequisites
and will not be rebuilt simply because
the prerequisite file(s) change.
<parameter>target</parameter> and
<parameter>prerequisite</parameter> may each
be a string or Node, or a list of strings or Nodes.
If there are multiple
<parameter>target</parameter> values,
the prerequisite(s) are added to each one.
Returns a list of the affected target nodes.
</para>
<para>
Example:
</para>
<example_commands>
env.Requires('foo', 'file-that-must-be-built-before-foo')
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-Return">
<term><function>Return</function>(<parameter>[vars..., stop=True]</parameter>)</term>
<listitem><para>
Return to the calling SConscript, optionally
returning the values of variables named in
<varname>vars</varname>.
Multiple strings contaning variable names may be passed to
&f-Return;. A string containing white space
is split into individual variable names.
Returns the value if one variable is specified,
else returns a tuple of values.
Returns an empty tuple if <parameter>vars</parameter>
is omitted.
</para>
<para>
By default &Return; stops processing the current SConscript
and returns immediately.
The optional
<literal>stop</literal>
keyword argument
may be set to a false value
to continue processing the rest of the SConscript
file after the
&f-Return;
call (this was the default behavior prior to SCons 0.98.)
However, the values returned
are still the values of the variables in the named
<varname>vars</varname>
at the point
&f-Return;
was called.
</para>
<para>
Examples:
</para>
<example_commands>
# Returns no values (evaluates False)
Return()
# Returns the value of the 'foo' Python variable.
Return("foo")
# Returns the values of the Python variables 'foo' and 'bar'.
Return("foo", "bar")
# Returns the values of Python variables 'val1' and 'val2'.
Return('val1 val2')
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-Scanner">
<term><function>Scanner</function>(<parameter>function, [name, argument, skeys, path_function, node_class, node_factory, scan_check, recursive]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Scanner</methodname>(<parameter>function, [name, argument, skeys, path_function, node_class, node_factory, scan_check, recursive]</parameter>)</term>
<listitem><para>
Creates a Scanner object for
the specified
<parameter>function</parameter>.
See manpage section "Scanner Objects"
for a complete explanation of the arguments and behavior.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-SConscript">
<term><function>SConscript</function>(<parameter>scriptnames, [exports, variant_dir, duplicate, must_exist]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>SConscript</methodname>(<parameter>scriptnames, [exports, variant_dir, duplicate, must_exist]</parameter>)</term>
<term><function>SConscript</function>(<parameter>dirs=subdirs, [name=scriptname, exports, variant_dir, duplicate, must_exist]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>SConscript</methodname>(<parameter>dirs=subdirs, [name=scriptname, exports, variant_dir, duplicate, must_exist]</parameter>)</term>
<listitem><para>
Executes subsidiary SConscript (build configuration) file(s).
There are two ways to call the
&f-SConscript; function.
</para>
<para>
The first calling style is to supply
one or more SConscript file names
as the first positional argument,
which can be a string or a list of strings.
If there is a second positional argument,
it is treated as if the
<varname>exports</varname>
keyword argument had been given (see below).
Examples:
</para>
<example_commands>
SConscript('SConscript') # run SConscript in the current directory
SConscript('src/SConscript') # run SConscript in the src directory
SConscript(['src/SConscript', 'doc/SConscript'])
SConscript(Split('src/SConscript doc/SConscript'))
config = SConscript('MyConfig.py')
</example_commands>
<para>
The second calling style is to omit the positional argument naming
the script and instead specify directory names using the
<varname>dirs</varname> keyword argument.
The value can be a string or list of strings.
In this case,
&scons;
will execute a subsidiary configuration file named
&SConscript; (by default)
in each of the specified directories.
You may specify a name other than
&SConscript;
by supplying an optional
<varname>name</varname>=<replaceable>scriptname</replaceable>
keyword argument.
The first three examples below have the same effect
as the first three examples above:
</para>
<example_commands>
SConscript(dirs='.') # run SConscript in the current directory
SConscript(dirs='src') # run SConscript in the src directory
SConscript(dirs=['src', 'doc'])
SConscript(dirs=['sub1', 'sub2'], name='MySConscript')
</example_commands>
<para>
The optional
<varname>exports</varname>
keyword argument specifies variables to make available
for use by the called SConscripts,
which are evaluated in an isolated context
and otherwise do not have access to local variables
from the calling SConscript.
The value may be a string or list of strings representing
variable names, or a dictionary mapping local names to
the names they can be imported by.
For the first (scriptnames) calling style,
a second positional argument will also be interpreted as
<varname>exports</varname>;
the second (directory) calling style accepts no
positional arguments and must use the keyword form.
These variables are locally exported only to the called
SConscript file(s), and take precedence over any same-named
variables in the global pool managed by the
&f-link-Export;
function.
<!-- If multiple dirs are provided, each script gets a fresh export. -->
The subsidiary SConscript files
must use the
&f-link-Import;
function to import the variables into their local scope.
Examples:
</para>
<example_commands>
foo = SConscript('sub/SConscript', exports='env')
SConscript('dir/SConscript', exports=['env', 'variable'])
SConscript(dirs='subdir', exports='env variable')
SConscript(dirs=['one', 'two', 'three'], exports='shared_info')
</example_commands>
<para>
If the optional
<varname>variant_dir</varname>
argument is present, it causes an effect equivalent to the
&f-link-VariantDir; function,
but in effect only within the scope of the &f-SConscript; call.
The <varname>variant_dir</varname>
argument is interpreted relative to the directory of the
<emphasis>calling</emphasis> SConscript file.
The source directory is the directory in which the
<emphasis>called</emphasis> SConscript
file resides and the SConscript
file is evaluated as if it were in the
<varname>variant_dir</varname>
directory. Thus:
</para>
<example_commands>
SConscript('src/SConscript', variant_dir='build')
</example_commands>
<para>
is equivalent to:
</para>
<example_commands>
VariantDir('build', 'src')
SConscript('build/SConscript')
</example_commands>
<para>
If the sources are in the same directory as the
&SConstruct;,
</para>
<example_commands>
SConscript('SConscript', variant_dir='build')
</example_commands>
<para>
is equivalent to:
</para>
<example_commands>
VariantDir('build', '.')
SConscript('build/SConscript')
</example_commands>
<para>
The optional
<varname>duplicate</varname> argument is
interpreted as for &f-link-VariantDir;.
If the <varname>variant_dir</varname> argument
is omitted, the <varname>duplicate</varname> argument is ignored.
See the description of
&f-link-VariantDir;
for additional details and restrictions.
</para>
<para>
<!--
If
<varname>variant_dir</varname>
and"
<varname>src_dir</varname>
are both present,
xxxxx everything is in a state of confusion.
</para>
<example_commands>
SConscript(dirs = 'src', variant_dir = 'build', src_dir = '.')
runs src/SConscript in build/src, but
SConscript(dirs = 'lib', variant_dir = 'build', src_dir = 'src')
runs lib/SConscript (in lib!). However,
SConscript(dirs = 'src', variant_dir = 'build', src_dir = 'src')
runs src/SConscript in build. Moreover,
SConscript(dirs = 'src/lib', variant_dir = 'build', src_dir = 'src')
runs src/lib/SConscript in build/lib. Moreover,
SConscript(dirs = 'build/src/lib', variant_dir = 'build', src_dir = 'src')
can't find build/src/lib/SConscript, even though it ought to exist.
</example_commands>
<para>
is equivalent to
</para>
<example_commands>
????????????????
</example_commands>
<para>
and what about this alternative?
TODO??? SConscript('build/SConscript', src_dir='src')
-->
</para>
<para>
If the optional
<varname>must_exist</varname>
is <constant>True</constant> (the default),
an exception is raised if a requested
SConscript file is not found.
To allow missing scripts to be silently ignored
(the default behavior prior to &SCons; version 3.1),
pass
<literal>must_exist=False</literal> in the &f-SConscript; call.
</para>
<para>
<emphasis>Changed in 4.6.0</emphasis>: <parameter>must_exist</parameter>
now defaults to <constant>True</constant>.
</para>
<para>
Here are some composite examples:
</para>
<example_commands>
# collect the configuration information and use it to build src and doc
shared_info = SConscript('MyConfig.py')
SConscript('src/SConscript', exports='shared_info')
SConscript('doc/SConscript', exports='shared_info')
</example_commands>
<example_commands>
# build debugging and production versions. SConscript
# can use Dir('.').path to determine variant.
SConscript('SConscript', variant_dir='debug', duplicate=0)
SConscript('SConscript', variant_dir='prod', duplicate=0)
</example_commands>
<example_commands>
# build debugging and production versions. SConscript
# is passed flags to use.
opts = { 'CPPDEFINES' : ['DEBUG'], 'CCFLAGS' : '-pgdb' }
SConscript('SConscript', variant_dir='debug', duplicate=0, exports=opts)
opts = { 'CPPDEFINES' : ['NODEBUG'], 'CCFLAGS' : '-O' }
SConscript('SConscript', variant_dir='prod', duplicate=0, exports=opts)
</example_commands>
<example_commands>
# build common documentation and compile for different architectures
SConscript('doc/SConscript', variant_dir='build/doc', duplicate=0)
SConscript('src/SConscript', variant_dir='build/x86', duplicate=0)
SConscript('src/SConscript', variant_dir='build/ppc', duplicate=0)
</example_commands>
<para>
&f-SConscript; returns the values of any variables
named by the executed SConscript file(s) in arguments
to the &f-link-Return; function.
If a single &f-SConscript; call causes multiple scripts to
be executed, the return value is a tuple containing
the returns of each of the scripts. If an executed
script does not explicitly call &Return;, it returns
<constant>None</constant>.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-SConscriptChdir">
<term><function>SConscriptChdir</function>(<parameter>value</parameter>)</term>
<listitem><para>
By default,
&scons;
changes its working directory
to the directory in which each
subsidiary SConscript file lives
while reading and processing that script.
This behavior may be disabled
by specifying an argument which
evaluates false, in which case
&scons;
will stay in the top-level directory
while reading all SConscript files.
(This may be necessary when building from repositories,
when all the directories in which SConscript files may be found
don't necessarily exist locally.)
You may enable and disable
this ability by calling
&f-SConscriptChdir;
multiple times.
</para>
<para>
Example:
</para>
<example_commands>
SConscriptChdir(False)
SConscript('foo/SConscript') # will not chdir to foo
SConscriptChdir(True)
SConscript('bar/SConscript') # will chdir to bar
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-SConsignFile">
<term><function>SConsignFile</function>(<parameter>[name, dbm_module]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>SConsignFile</methodname>(<parameter>[name, dbm_module]</parameter>)</term>
<listitem><para>
Specify where to store the &SCons; file signature database,
and which database format to use.
This may be useful to specify alternate
database files and/or file locations for different types of builds.
</para>
<para>
The optional <parameter>name</parameter> argument
is the base name of the database file(s).
If not an absolute path name,
these are placed relative to the directory containing the
top-level &SConstruct; file.
The default is
<filename>.sconsign</filename>.
The actual database file(s) stored on disk
may have an appropriate suffix appended
by the chosen
<parameter>dbm_module</parameter>
</para>
<para>
The optional <parameter>dbm_module</parameter>
argument specifies which
&Python; database module to use
for reading/writing the file.
The module must be imported first;
then the imported module name
is passed as the argument.
The default is a custom
<systemitem>SCons.dblite</systemitem>
module that uses pickled
&Python; data structures,
which works on all &Python; versions.
See documentation of the &Python;
<systemitem>dbm</systemitem> module
for other available types.
</para>
<para>
If called with no arguments,
the database will default to
<filename>.sconsign.dblite</filename>
in the top directory of the project,
which is also the default if
if &f-SConsignFile; is not called.
</para>
<para>
The setting is global, so the only difference
between the global function and the environment method form
is variable expansion on <parameter>name</parameter>.
There should only be one active call to this
function/method in a given build setup.
</para>
<para>
If
<parameter>name</parameter>
is set to
<constant>None</constant>,
&scons;
will store file signatures
in a separate
<filename>.sconsign</filename>
file in each directory,
not in a single combined database file.
This is a backwards-compatibility meaure to support
what was the default behavior
prior to &SCons; 0.97 (i.e. before 2008).
Use of this mode is discouraged and may be
deprecated in a future &SCons; release.
</para>
<para>
Examples:
</para>
<example_commands>
# Explicitly stores signatures in ".sconsign.dblite"
# in the top-level SConstruct directory (the default behavior).
SConsignFile()
# Stores signatures in the file "etc/scons-signatures"
# relative to the top-level SConstruct directory.
# SCons will add a database suffix to this name.
SConsignFile("etc/scons-signatures")
# Stores signatures in the specified absolute file name.
# SCons will add a database suffix to this name.
SConsignFile("/home/me/SCons/signatures")
# Stores signatures in a separate .sconsign file
# in each directory.
SConsignFile(None)
# Stores signatures in a GNU dbm format .sconsign file
import dbm.gnu
SConsignFile(dbm_module=dbm.gnu)
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-SetDefault">
<term><replaceable>env</replaceable>.<methodname>SetDefault</methodname>(<parameter>key=val, [...]</parameter>)</term>
<listitem><para>
Sets construction variables to default values specified with the keyword
arguments if (and only if) the variables are not already set.
The following statements are equivalent:
</para>
<example_commands>
env.SetDefault(FOO='foo')
if 'FOO' not in env:
env['FOO'] = 'foo'
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-SetOption">
<term><function>SetOption</function>(<parameter>name, value</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>SetOption</methodname>(<parameter>name, value</parameter>)</term>
<listitem><para>
Sets &scons; option variable <parameter>name</parameter>
to <parameter>value</parameter>.
These options are all also settable via
command-line options but the variable name
may differ from the command-line option name -
see the table for correspondences.
A value set via command-line option will take
precedence over one set with &f-SetOption;, which
allows setting a project default in the scripts and
temporarily overriding it via command line.
&f-SetOption; calls can also be placed in the
<filename>site_init.py</filename> file.
</para>
<para>
See the documentation in the manpage for the
corresponding command line option for information about each specific option.
The <parameter>value</parameter> parameter is mandatory,
for option values which are boolean in nature
(that is, the command line option does not take an argument)
use a <parameter>value</parameter>
which evaluates to true (e.g. <constant>True</constant>,
<constant>1</constant>) or false (e.g. <constant>False</constant>,
<constant>0</constant>).
</para>
<para>
Options which affect the reading and processing of SConscript files
are not settable using &f-SetOption; since those files must
be read in order to find the &f-SetOption; call in the first place.
</para>
<para>
For project-specific options (sometimes called
<firstterm>local options</firstterm>)
added via an &f-link-AddOption; call,
&f-SetOption; is available only after the
&f-AddOption; call has completed successfully,
and only if that call included the
<parameter>settable=True</parameter> argument.
</para>
<para>
The settable variables with their associated command-line options are:
</para>
<informaltable rowsep="1" colsep="1" frame="topbot">
<tgroup cols="3">
<thead>
<row>
<entry align="left">Settable name</entry>
<entry align="left">Command-line options</entry>
<entry align="left">Notes</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>clean</varname></entry>
<entry>
<option>-c</option>,
<option>--clean</option>,
<option>--remove</option>
</entry>
</row>
<row>
<entry><varname>diskcheck</varname></entry>
<entry><option>--diskcheck</option></entry>
</row>
<row>
<entry><varname>duplicate</varname></entry>
<entry><option>--duplicate</option></entry>
</row>
<row>
<entry><varname>experimental</varname></entry>
<entry><option>--experimental</option></entry>
<entry><emphasis>since 4.2</emphasis></entry>
</row>
<row>
<entry><varname>hash_chunksize</varname></entry>
<entry><option>--hash-chunksize</option></entry>
<entry>
Actually sets <varname>md5_chunksize</varname>.
<emphasis>since 4.2</emphasis>
</entry>
</row>
<row>
<entry><varname>hash_format</varname></entry>
<entry><option>--hash-format</option></entry>
<entry><emphasis>since 4.2</emphasis></entry>
</row>
<row>
<entry><varname>help</varname></entry>
<entry><option>-h</option>, <option>--help</option></entry>
</row>
<row>
<entry><varname>implicit_cache</varname></entry>
<entry><option>--implicit-cache</option></entry>
</row>
<row>
<entry><varname>implicit_deps_changed</varname></entry>
<entry><option>--implicit-deps-changed</option></entry>
<entry>
Also sets <varname>implicit_cache</varname>.
<emphasis>(settable since 4.2)</emphasis>
</entry>
</row>
<row>
<entry><varname>implicit_deps_unchanged</varname></entry>
<entry><option>--implicit-deps-unchanged</option></entry>
<entry>
Also sets <varname>implicit_cache</varname>.
<emphasis>(settable since 4.2)</emphasis>
</entry>
</row>
<row>
<entry><varname>max_drift</varname></entry>
<entry><option>--max-drift</option></entry>
</row>
<row>
<entry><varname>md5_chunksize</varname></entry>
<entry><option>--md5-chunksize</option></entry>
</row>
<row>
<entry><varname>no_exec</varname></entry>
<entry>
<option>-n</option>,
<option>--no-exec</option>,
<option>--just-print</option>,
<option>--dry-run</option>,
<option>--recon</option>
</entry>
</row>
<row>
<entry><varname>no_progress</varname></entry>
<entry><option>-Q</option></entry>
<entry>See
<footnote>
<para>If <varname>no_progress</varname> is set via &f-SetOption;
in an SConscript file
(but not if set in a <filename>site_init.py</filename> file)
there will still be an initial status message about
reading SConscript files since &SCons; has
to start reading them before it can see the
&f-SetOption;.
</para>
</footnote>
</entry>
</row>
<row>
<entry><varname>num_jobs</varname></entry>
<entry><option>-j</option>, <option>--jobs</option></entry>
</row>
<row>
<entry><varname>random</varname></entry>
<entry><option>--random</option></entry>
</row>
<row>
<entry><varname>silent</varname></entry>
<entry>
<option>-s</option>,
<option>--silent</option>,
<option>--quiet</option>
</entry>
</row>
<row>
<entry><varname>stack_size</varname></entry>
<entry><option>--stack-size</option></entry>
</row>
<row>
<entry><varname>warn</varname></entry>
<entry><option>--warn</option></entry>
</row>
</tbody>
</tgroup>
</informaltable>
<para>
Example:
</para>
<example_commands>
SetOption('max_drift', 0)
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-SideEffect">
<term><function>SideEffect</function>(<parameter>side_effect, target</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>SideEffect</methodname>(<parameter>side_effect, target</parameter>)</term>
<listitem><para>
Declares
<parameter>side_effect</parameter>
as a side effect of building
<parameter>target</parameter>.
Both
<parameter>side_effect</parameter>
and
<parameter>target</parameter>
can be a list, a file name, or a node.
A side effect is a target file that is created or updated
as a side effect of building other targets.
For example, a Windows PDB
file is created as a side effect of building the .obj
files for a static library,
and various log files are created updated
as side effects of various TeX commands.
If a target is a side effect of multiple build commands,
&scons;
will ensure that only one set of commands
is executed at a time.
Consequently, you only need to use this method
for side-effect targets that are built as a result of
multiple build commands.
</para>
<para>
Because multiple build commands may update
the same side effect file,
by default the
<parameter>side_effect</parameter>
target is
<emphasis>not</emphasis>
automatically removed
when the
<parameter>target</parameter>
is removed by the
<option>-c</option>
option.
(Note, however, that the
<parameter>side_effect</parameter>
might be removed as part of
cleaning the directory in which it lives.)
If you want to make sure the
<parameter>side_effect</parameter>
is cleaned whenever a specific
<parameter>target</parameter>
is cleaned,
you must specify this explicitly
with the
&f-link-Clean;
or
&f-env-Clean;
function.
</para>
<para>
This function returns the list of side effect Node objects that were successfully added.
If the list of side effects contained any side effects that had already been added,
they are not added and included in the returned list.
</para>
</listitem>
</varlistentry>
<varlistentry id="f-Split">
<term><function>Split</function>(<parameter>arg</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Split</methodname>(<parameter>arg</parameter>)</term>
<listitem><para>
If <parameter>arg</parameter> is a string,
splits on whitespace and returns a list of
strings without whitespace.
This mode is the most common case,
and can be used to split a list of filenames
(for example) rather than having to type them as a
list of individually quoted words.
If <parameter>arg</parameter> is a list or tuple
returns the list or tuple unchanged.
If <parameter>arg</parameter> is any other type of object,
returns a list containing just the object.
These non-string cases do not actually do any spliting,
but allow an argument variable to be passed to
&f-Split; without having to first check its type.
</para>
<para>
Example:
</para>
<example_commands>
files = Split("f1.c f2.c f3.c")
files = env.Split("f4.c f5.c f6.c")
files = Split("""
f7.c
f8.c
f9.c
""")
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-subst">
<term><replaceable>env</replaceable>.<methodname>subst</methodname>(<parameter>input, [raw, target, source, conv]</parameter>)</term>
<listitem><para>
Performs &consvar; interpolation
(<firstterm>substitution</firstterm>)
on <parameter>input</parameter>,
which can be a string or a sequence.
Substitutable elements take the form
<literal>${<replaceable>expression</replaceable>}</literal>,
although if there is no ambiguity in recognizing the element,
the braces can be omitted.
A literal <emphasis role="bold">$</emphasis> can be entered by
using <emphasis role="bold">$$</emphasis>.
</para>
<para>
By default,
leading or trailing white space will
be removed from the result,
and all sequences of white space
will be compressed to a single space character.
Additionally, any
<literal>$(</literal>
and
<literal>$)</literal>
character sequences will be stripped from the returned string,
The optional
<parameter>raw</parameter>
argument may be set to
<literal>1</literal>
if you want to preserve white space and
<literal>$(</literal>-<literal>$)</literal>
sequences.
The
<parameter>raw</parameter>
argument may be set to
<literal>2</literal>
if you want to additionally discard
all characters between any
<literal>$(</literal>
and
<literal>$)</literal>
pairs
(as is done for signature calculation).
</para>
<para>
If <parameter>input</parameter> is a sequence
(list or tuple),
the individual elements of
the sequence will be expanded,
and the results will be returned as a list.
</para>
<para>
The optional
<parameter>target</parameter>
and
<parameter>source</parameter>
keyword arguments
must be set to lists of
target and source nodes, respectively,
if you want the
&cv-TARGET;,
&cv-TARGETS;,
&cv-SOURCE;
and
&cv-SOURCES;
to be available for expansion.
This is usually necessary if you are
calling
&f-env-subst;
from within a &Python; function used
as an SCons action.
</para>
<para>
Returned string values or sequence elements
are converted to their string representation by default.
The optional
<parameter>conv</parameter>
argument
may specify a conversion function
that will be used in place of
the default.
For example, if you want &Python; objects
(including SCons Nodes)
to be returned as &Python; objects,
you can use a &Python;
lambda expression to pass in an unnamed function
that simply returns its unconverted argument.
</para>
<para>
Example:
</para>
<example_commands>
print(env.subst("The C compiler is: $CC"))
def compile(target, source, env):
sourceDir = env.subst(
"${SOURCE.srcdir}",
target=target,
source=source
)
source_nodes = env.subst('$EXPAND_TO_NODELIST', conv=lambda x: x)
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-Tag">
<term><function>Tag</function>(<parameter>node, tags</parameter>)</term>
<listitem><para>
Annotates file or directory Nodes with
information about how the
&b-link-Package;
Builder should package those files or directories.
All Node-level tags are optional.
</para>
<para>
Examples:
</para>
<example_commands>
# makes sure the built library will be installed with 644 file access mode
Tag(Library('lib.c'), UNIX_ATTR="0o644")
# marks file2.txt to be a documentation file
Tag('file2.txt', DOC)
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-Tool">
<term><function>Tool</function>(<parameter>name, [toolpath, key=value, ...]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Tool</methodname>(<parameter>name, [toolpath, key=value, ...]</parameter>)</term>
<listitem><para>
Locates the tool specification module <parameter>name</parameter>
and returns a callable tool object for that tool.
When the environment method (&f-env-Tool;) form is used,
the tool object is automatically called before the method returns
to update <varname>env</varname>,
and <parameter>name</parameter> is
appended to the &cv-link-TOOLS;
&consvar; in that environment.
When the global function &f-Tool; form is used,
the tool object is constructed but not called,
as it lacks the context of an environment to update,
and the returned object needs to be used to arrange for the call.
</para>
<para>
The tool module is searched for in the tool search paths (see the
<emphasis role="bold">Tools</emphasis> section in the manual page
for details)
and in any paths specified by the optional
<parameter>toolpath</parameter> parameter,
which must be a list of strings.
If <parameter>toolpath</parameter> is omitted,
the <parameter>toolpath</parameter>
supplied when the environment was created,
if any, is used.
</para>
<para>
Any remaining keyword arguments are saved in
the tool object,
and will be passed to the tool module's
<function>generate</function> function
when the tool object is actually called.
The <function>generate</function> function
can update the &consenv; with &consvars; and arrange
any other initialization
needed to use the mechanisms that tool describes,
and can use these extra arguments to help
guide its actions.
</para>
<para>
<emphasis>Changed in version 4.2:</emphasis>
&f-env-Tool; now returns the tool object,
previously it did not return (i.e. returned <constant>None</constant>).
</para>
<para>
Examples:
</para>
<example_commands>
env.Tool('gcc')
env.Tool('opengl', toolpath=['build/tools'])
</example_commands>
<para>
The returned tool object can be passed to an
&f-link-Environment; or &f-link-Clone; call
as part of the <parameter>tools</parameter> keyword argument,
in which case the tool is applied to the environment being constructed,
or it can be called directly,
in which case a &consenv; to update must be
passed as the argument.
Either approach will also update the
&cv-TOOLS; &consvar;.
</para>
<para>
Examples:
</para>
<example_commands>
env = Environment(tools=[Tool('msvc')])
env = Environment()
msvctool = Tool('msvc')
msvctool(env) # adds 'msvc' to the TOOLS variable
gltool = Tool('opengl', toolpath = ['tools'])
gltool(env) # adds 'opengl' to the TOOLS variable
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-ValidateOptions">
<term><function>ValidateOptions</function>(<parameter>[throw_exception=False]</parameter>)</term>
<listitem><para>
Check that all the options specified on the command line are either
&SCons; built-in options or defined via calls to &f-link-AddOption;.
&SCons; will eventually fail on unknown options anyway, but calling
this function allows the build to "fail fast" before executing
expensive logic later in the build.
</para>
<para>
This function should only be called after the last &f-AddOption;
call in your &SConscript; logic.
Be aware that some tools call &f-AddOption;, if you are getting
error messages for arguments that they add, you will need to ensure
that those tools are loaded before calling &f-ValidateOptions;.
</para>
<para>
If there are any unknown command line options, &f-ValidateOptions;
prints an error message and exits with an error exit status.
If the optional <parameter>throw_exception</parameter> argument is
<literal>True</literal> (default is <literal>False</literal>),
a <exceptionname>SConsBadOptionError</exceptionname> is raised,
giving an opportunity for the &SConscript; logic to catch that
exception and handle invalid options appropriately. Note that
this exception name needs to be imported (see the example below).
</para>
<para>
A common build problem is typos (or thinkos) - a user enters an option
that is just a little off the expected value, or perhaps a different
word with a similar meaning. It may be useful to abort the build
before going too far down the wrong path. For example:
</para>
<screen>
$ <userinput>scons --compilers=mingw</userinput> # the correct flag is --compiler
</screen>
<para>
Here &SCons; could go off and run a bunch of configure steps with
the default value of <literal>--compiler</literal>, since the
incorrect command line did not actually supply a value to it,
costing developer time to track down why the configure logic
made the "wrong" choices. This example shows catching this:
</para>
<programlisting language="python">
from SCons.Script.SConsOptions import SConsBadOptionError
AddOption(
'--compiler',
dest='compiler',
action='store',
default='gcc',
type='string',
)
# ... other SConscript logic ...
try:
ValidateOptions(throw_exception=True)
except SConsBadOptionError as e:
print(f"ValidateOptions detects a fail: ", e.opt_str)
Exit(3)
</programlisting>
<para><emphasis>New in version 4.5.0</emphasis></para>
</listitem>
</varlistentry>
<varlistentry id="f-Value">
<term><function>Value</function>(<parameter>value, [built_value], [name]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>Value</methodname>(<parameter>value, [built_value], [name]</parameter>)</term>
<listitem><para>
Returns a Node object representing the specified &Python;
<parameter>value</parameter>.
Value Nodes can be used as dependencies of targets.
If the string representation of the Value Node
changes between &SCons; runs, it is considered
out of date and any targets depending it will be rebuilt.
Since Value Nodes have no filesystem representation,
timestamps are not used; the timestamp deciders
perform the same content-based up to date check.
</para>
<para>
The optional
<parameter>built_value</parameter>
argument can be specified
when the Value Node is created
to indicate the Node should already be considered "built."
</para>
<para>
The optional <parameter>name</parameter> parameter can be provided as an
alternative name for the resulting <literal>Value</literal> node;
this is advised if the <parameter>value</parameter> parameter
cannot be converted to a string.
</para>
<para>
Value Nodes have a
<methodname>write</methodname>
method that can be used to "build" a Value Node
by setting a new value.
The corresponding
<methodname>read</methodname>
method returns the built value of the Node.
</para>
<para>
<emphasis>Changed in version 4.0:</emphasis>
the <parameter>name</parameter> parameter was added.
</para>
<para>
Examples:
</para>
<example_commands>
env = Environment()
def create(target, source, env):
"""Action function to create a file from a Value.
Writes 'prefix=$SOURCE' into the file name given as $TARGET.
"""
with open(str(target[0]), 'wb') as f:
f.write(b'prefix=' + source[0].get_contents() + b'\n')
# Fetch the prefix= argument, if any, from the command line.
# Use /usr/local as the default.
prefix = ARGUMENTS.get('prefix', '/usr/local')
# Attach builder named Config to the construction environment
# using the 'create' action function above.
env['BUILDERS']['Config'] = Builder(action=create)
env.Config(target='package-config', source=Value(prefix))
def build_value(target, source, env):
"""Action function to "build" a Value.
Writes contents of $SOURCE into $TARGET, thus updating if it existed.
"""
target[0].write(source[0].get_contents())
output = env.Value('before')
input = env.Value('after')
# Attach a builder named UpdateValue to the construction environment
# using the 'build_value' action function above.
env['BUILDERS']['UpdateValue'] = Builder(action=build_value)
env.UpdateValue(target=Value(output), source=Value(input))
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-VariantDir">
<term><function>VariantDir</function>(<parameter>variant_dir, src_dir, [duplicate]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>VariantDir</methodname>(<parameter>variant_dir, src_dir, [duplicate]</parameter>)</term>
<listitem><para>
Sets up a mapping to define a variant build directory in
<parameter>variant_dir</parameter>.
<parameter>src_dir</parameter> must not be underneath
<parameter>variant_dir</parameter>.
A &f-VariantDir; mapping is global, even if called using the
&f-env-VariantDir; form.
&f-VariantDir;
can be called multiple times with the same
<parameter>src_dir</parameter>
to set up multiple variant builds with different options.
</para>
<para>
Note if <parameter>variant_dir</parameter>
is not under the project top directory,
target selection rules will not pick targets in the
variant directory unless they are explicitly specified.
</para>
<para>
When files in <parameter>variant_dir</parameter> are referenced,
&SCons; backfills as needed with files from <parameter>src_dir</parameter>
to create a complete build directory.
By default, &SCons;
physically duplicates the source files, SConscript files,
and directory structure as needed into the variant directory.
Thus, a build performed in the variant directory is guaranteed to be identical
to a build performed in the source directory even if
intermediate source files are generated during the build,
or if preprocessors or other scanners search for included files
using paths relative to the source file,
or if individual compilers or other invoked tools are hard-coded
to put derived files in the same directory as source files.
Only the files &SCons; calculates are needed for the build are
duplicated into <parameter>variant_dir</parameter>.
If possible on the platform,
the duplication is performed by linking rather than copying.
This behavior is affected by the
<option>--duplicate</option>
command-line option.
</para>
<para>
Duplicating the source files may be disabled by setting the
<parameter>duplicate</parameter>
argument to
<constant>False</constant>.
This will cause
&SCons;
to invoke Builders using the path names of source files in
<parameter>src_dir</parameter>
and the path names of derived files within
<parameter>variant_dir</parameter>.
This is more efficient than duplicating,
and is safe for most builds;
revert to <literal>duplicate=True</literal>
if it causes problems.
</para>
<para>
&f-VariantDir;
works most naturally when used with a subsidiary SConscript file.
The subsidiary SConscript file must be called as if it were in
<parameter>variant_dir</parameter>,
regardless of the value of
<parameter>duplicate</parameter>.
When calling an SConscript file, you can use the
<parameter>exports</parameter> keyword argument
to pass parameters (individually or as an appropriately set up environment)
so the SConscript can pick up the right settings for that variant build.
The SConscript must &f-link-Import; these to use them. Example:
</para>
<example_commands>
env1 = Environment(...settings for variant1...)
env2 = Environment(...settings for variant2...)
# run src/SConscript in two variant directories
VariantDir('build/variant1', 'src')
SConscript('build/variant1/SConscript', exports={"env": env1})
VariantDir('build/variant2', 'src')
SConscript('build/variant2/SConscript', exports={"env": env2})
</example_commands>
<para>
See also the
&f-link-SConscript; function
for another way to specify a variant directory
in conjunction with calling a subsidiary SConscript file.
</para>
<para>
More examples:
</para>
<example_commands>
# use names in the build directory, not the source directory
VariantDir('build', 'src', duplicate=0)
Program('build/prog', 'build/source.c')
# this builds both the source and docs in a separate subtree
VariantDir('build', '.', duplicate=0)
SConscript(dirs=['build/src','build/doc'])
# same as previous example, but only uses SConscript
SConscript(dirs='src', variant_dir='build/src', duplicate=0)
SConscript(dirs='doc', variant_dir='build/doc', duplicate=0)
</example_commands>
</listitem>
</varlistentry>
<varlistentry id="f-WhereIs">
<term><function>WhereIs</function>(<parameter>program, [path, pathext, reject]</parameter>)</term>
<term><replaceable>env</replaceable>.<methodname>WhereIs</methodname>(<parameter>program, [path, pathext, reject]</parameter>)</term>
<listitem><para>
Searches for the specified executable
<parameter>program</parameter>,
returning the full path to the program
or <constant>None</constant>.
</para>
<para>
When called as a &consenv; method,
searches the paths in the
<parameter>path</parameter> keyword argument,
or if <constant>None</constant> (the default)
the paths listed in the &consenv;
(<varname>env</varname><literal>['ENV']['PATH']</literal>).
The external environment's path list
(<literal>os.environ['PATH']</literal>)
is used as a fallback if the key
<varname>env</varname><literal>['ENV']['PATH']</literal>
does not exist.
</para>
<para>
On Windows systems, searches for executable
programs with any of the file extensions listed in the
<parameter>pathext</parameter> keyword argument,
or if <constant>None</constant> (the default)
the pathname extensions listed in the &consenv;
(<varname>env</varname><literal>['ENV']['PATHEXT']</literal>).
The external environment's pathname extensions list
(<literal>os.environ['PATHEXT']</literal>)
is used as a fallback if the key
<varname>env</varname><literal>['ENV']['PATHEXT']</literal>
does not exist.
</para>
<para>
When called as a global function, uses the external
environment's path
<literal>os.environ['PATH']</literal>
and path extensions
<literal>os.environ['PATHEXT']</literal>,
respectively, if
<parameter>path</parameter> and
<parameter>pathext</parameter> are
<constant>None</constant>.
</para>
<para>
Will not select any
path name or names
in the optional
<parameter>reject</parameter>
list.
</para>
</listitem>
</varlistentry>
</variablelist>
|