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
|
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2017 - ROLI Ltd.
JUCE is an open source library subject to commercial or open-source
licensing.
By using JUCE, you agree to the terms of both the JUCE 5 End-User License
Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
27th April 2017).
End User License Agreement: www.juce.com/juce-5-licence
Privacy Policy: www.juce.com/juce-5-privacy-policy
Or: You may also use this code under the terms of the GPL v3 (see
www.gnu.org/licenses).
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
#include "../Application/jucer_Headers.h"
#include "jucer_Project.h"
#include "../ProjectSaving/jucer_ProjectSaver.h"
#include "../Application/jucer_Application.h"
#include "../LiveBuildEngine/jucer_CompileEngineSettings.h"
namespace
{
String makeValid4CC (const String& seed)
{
auto s = CodeHelpers::makeValidIdentifier (seed, false, true, false) + "xxxx";
return s.substring (0, 1).toUpperCase()
+ s.substring (1, 4).toLowerCase();
}
}
//==============================================================================
Project::Project (const File& f)
: FileBasedDocument (projectFileExtension,
String ("*") + projectFileExtension,
"Choose a Jucer project to load",
"Save Jucer project")
{
Logger::writeToLog ("Loading project: " + f.getFullPathName());
setFile (f);
removeDefunctExporters();
exporterPathsModuleList.reset (new AvailableModuleList());
updateOldModulePaths();
updateOldStyleConfigList();
setCppVersionFromOldExporterSettings();
moveOldPropertyFromProjectToAllExporters (Ids::bigIcon);
moveOldPropertyFromProjectToAllExporters (Ids::smallIcon);
initialiseProjectValues();
initialiseMainGroup();
initialiseAudioPluginValues();
parsedPreprocessorDefs = parsePreprocessorDefs (preprocessorDefsValue.get());
getEnabledModules().sortAlphabetically();
projectRoot.addListener (this);
compileEngineSettings.reset (new CompileEngineSettings (projectRoot));
setChangedFlag (false);
modificationTime = getFile().getLastModificationTime();
}
Project::~Project()
{
projectRoot.removeListener (this);
ProjucerApplication::getApp().openDocumentManager.closeAllDocumentsUsingProject (*this, false);
}
const char* Project::projectFileExtension = ".jucer";
//==============================================================================
void Project::setTitle (const String& newTitle)
{
projectNameValue = newTitle;
updateTitleDependencies();
}
void Project::updateTitleDependencies()
{
auto projectName = getProjectNameString();
getMainGroup().getNameValue() = projectName;
pluginNameValue. setDefault (projectName);
pluginDescriptionValue. setDefault (projectName);
bundleIdentifierValue. setDefault (getDefaultBundleIdentifierString());
pluginAUExportPrefixValue.setDefault (CodeHelpers::makeValidIdentifier (projectName, false, true, false) + "AU");
pluginAAXIdentifierValue. setDefault (getDefaultAAXIdentifierString());
}
String Project::getDocumentTitle()
{
return getProjectNameString();
}
void Project::updateCompanyNameDependencies()
{
bundleIdentifierValue.setDefault (getDefaultBundleIdentifierString());
pluginAAXIdentifierValue.setDefault (getDefaultAAXIdentifierString());
pluginManufacturerValue.setDefault (getDefaultPluginManufacturerString());
}
void Project::updateProjectSettings()
{
projectRoot.setProperty (Ids::jucerVersion, ProjectInfo::versionString, nullptr);
projectRoot.setProperty (Ids::name, getDocumentTitle(), nullptr);
}
bool Project::setCppVersionFromOldExporterSettings()
{
auto highestLanguageStandard = -1;
for (Project::ExporterIterator exporter (*this); exporter.next();)
{
if (exporter->isXcode()) // cpp version was per-build configuration for xcode exporters
{
for (ProjectExporter::ConfigIterator config (*exporter); config.next();)
{
auto cppLanguageStandard = config->getValue (Ids::cppLanguageStandard).getValue();
if (cppLanguageStandard != var())
{
auto versionNum = cppLanguageStandard.toString().getLastCharacters (2).getIntValue();
if (versionNum > highestLanguageStandard)
highestLanguageStandard = versionNum;
}
}
}
else
{
auto cppLanguageStandard = exporter->getSetting (Ids::cppLanguageStandard).getValue();
if (cppLanguageStandard != var())
{
if (cppLanguageStandard.toString().containsIgnoreCase ("latest"))
{
cppStandardValue = "latest";
return true;
}
auto versionNum = cppLanguageStandard.toString().getLastCharacters (2).getIntValue();
if (versionNum > highestLanguageStandard)
highestLanguageStandard = versionNum;
}
}
}
if (highestLanguageStandard != -1 && highestLanguageStandard >= 11)
{
cppStandardValue = highestLanguageStandard;
return true;
}
return false;
}
void Project::updateDeprecatedProjectSettingsInteractively()
{
jassert (! ProjucerApplication::getApp().isRunningCommandLine);
for (Project::ExporterIterator exporter (*this); exporter.next();)
exporter->updateDeprecatedProjectSettingsInteractively();
}
void Project::initialiseMainGroup()
{
// Create main file group if missing
if (! projectRoot.getChildWithName (Ids::MAINGROUP).isValid())
{
Item mainGroup (*this, ValueTree (Ids::MAINGROUP), false);
projectRoot.addChild (mainGroup.state, 0, nullptr);
}
getMainGroup().initialiseMissingProperties();
}
void Project::initialiseProjectValues()
{
projectNameValue.referTo (projectRoot, Ids::name, getUndoManager(), "JUCE Project");
projectUIDValue.referTo (projectRoot, Ids::ID, getUndoManager(), createAlphaNumericUID());
if (projectUIDValue.isUsingDefault())
projectUIDValue = projectUIDValue.getDefault();
companyNameValue.referTo (projectRoot, Ids::companyName, getUndoManager());
companyCopyrightValue.referTo (projectRoot, Ids::companyCopyright, getUndoManager());
companyWebsiteValue.referTo (projectRoot, Ids::companyWebsite, getUndoManager());
companyEmailValue.referTo (projectRoot, Ids::companyEmail, getUndoManager());
projectTypeValue.referTo (projectRoot, Ids::projectType, getUndoManager(), ProjectType_GUIApp::getTypeName());
versionValue.referTo (projectRoot, Ids::version, getUndoManager(), "1.0.0");
bundleIdentifierValue.referTo (projectRoot, Ids::bundleIdentifier, getUndoManager(), getDefaultBundleIdentifierString());
displaySplashScreenValue.referTo (projectRoot, Ids::displaySplashScreen, getUndoManager(), ! ProjucerApplication::getApp().isPaidOrGPL());
splashScreenColourValue.referTo (projectRoot, Ids::splashScreenColour, getUndoManager(), "Dark");
reportAppUsageValue.referTo (projectRoot, Ids::reportAppUsage, getUndoManager());
if (ProjucerApplication::getApp().isPaidOrGPL())
{
reportAppUsageValue.setDefault (ProjucerApplication::getApp().licenseController->getState().applicationUsageDataState
== LicenseState::ApplicationUsageData::enabled);
}
else
{
reportAppUsageValue.setDefault (true);
}
cppStandardValue.referTo (projectRoot, Ids::cppLanguageStandard, getUndoManager(), "14");
headerSearchPathsValue.referTo (projectRoot, Ids::headerPath, getUndoManager());
preprocessorDefsValue.referTo (projectRoot, Ids::defines, getUndoManager());
userNotesValue.referTo (projectRoot, Ids::userNotes, getUndoManager());
maxBinaryFileSizeValue.referTo (projectRoot, Ids::maxBinaryFileSize, getUndoManager(), 10240 * 1024);
// this is here for backwards compatibility with old projects using the incorrect id
if (projectRoot.hasProperty ("includeBinaryInAppConfig"))
includeBinaryDataInJuceHeaderValue.referTo (projectRoot, "includeBinaryInAppConfig", getUndoManager(), true);
else
includeBinaryDataInJuceHeaderValue.referTo (projectRoot, Ids::includeBinaryInJuceHeader, getUndoManager(), true);
binaryDataNamespaceValue.referTo (projectRoot, Ids::binaryDataNamespace, getUndoManager(), "BinaryData");
}
void Project::initialiseAudioPluginValues()
{
pluginFormatsValue.referTo (projectRoot, Ids::pluginFormats, getUndoManager(),
Array<var> (Ids::buildVST3.toString(), Ids::buildAU.toString(), Ids::buildStandalone.toString()), ",");
pluginCharacteristicsValue.referTo (projectRoot, Ids::pluginCharacteristicsValue, getUndoManager(), Array<var> (), ",");
pluginNameValue.referTo (projectRoot, Ids::pluginName, getUndoManager(), getProjectNameString());
pluginDescriptionValue.referTo (projectRoot, Ids::pluginDesc, getUndoManager(), getProjectNameString());
pluginManufacturerValue.referTo (projectRoot, Ids::pluginManufacturer, getUndoManager(), getDefaultPluginManufacturerString());
pluginManufacturerCodeValue.referTo (projectRoot, Ids::pluginManufacturerCode, getUndoManager(), "Manu");
pluginCodeValue.referTo (projectRoot, Ids::pluginCode, getUndoManager(), makeValid4CC (getProjectUIDString() + getProjectUIDString()));
pluginChannelConfigsValue.referTo (projectRoot, Ids::pluginChannelConfigs, getUndoManager());
pluginAAXIdentifierValue.referTo (projectRoot, Ids::aaxIdentifier, getUndoManager(), getDefaultAAXIdentifierString());
pluginAUExportPrefixValue.referTo (projectRoot, Ids::pluginAUExportPrefix, getUndoManager(),
CodeHelpers::makeValidIdentifier (getProjectNameString(), false, true, false) + "AU");
pluginAUMainTypeValue.referTo (projectRoot, Ids::pluginAUMainType, getUndoManager(), getDefaultAUMainTypes(), ",");
pluginAUSandboxSafeValue.referTo (projectRoot, Ids::pluginAUIsSandboxSafe, getUndoManager(), false);
pluginVSTCategoryValue.referTo (projectRoot, Ids::pluginVSTCategory, getUndoManager(), getDefaultVSTCategories(), ",");
pluginVST3CategoryValue.referTo (projectRoot, Ids::pluginVST3Category, getUndoManager(), getDefaultVST3Categories(), ",");
pluginRTASCategoryValue.referTo (projectRoot, Ids::pluginRTASCategory, getUndoManager(), getDefaultRTASCategories(), ",");
pluginAAXCategoryValue.referTo (projectRoot, Ids::pluginAAXCategory, getUndoManager(), getDefaultAAXCategories(), ",");
}
void Project::updateOldStyleConfigList()
{
auto deprecatedConfigsList = projectRoot.getChildWithName (Ids::CONFIGURATIONS);
if (deprecatedConfigsList.isValid())
{
projectRoot.removeChild (deprecatedConfigsList, nullptr);
for (Project::ExporterIterator exporter (*this); exporter.next();)
{
if (exporter->getNumConfigurations() == 0)
{
auto newConfigs = deprecatedConfigsList.createCopy();
if (! exporter->isXcode())
{
for (auto j = newConfigs.getNumChildren(); --j >= 0;)
{
auto config = newConfigs.getChild (j);
config.removeProperty (Ids::osxSDK, nullptr);
config.removeProperty (Ids::osxCompatibility, nullptr);
config.removeProperty (Ids::osxArchitecture, nullptr);
}
}
exporter->settings.addChild (newConfigs, 0, nullptr);
}
}
}
}
void Project::moveOldPropertyFromProjectToAllExporters (Identifier name)
{
if (projectRoot.hasProperty (name))
{
for (Project::ExporterIterator exporter (*this); exporter.next();)
exporter->settings.setProperty (name, projectRoot [name], nullptr);
projectRoot.removeProperty (name, nullptr);
}
}
void Project::removeDefunctExporters()
{
auto exporters = projectRoot.getChildWithName (Ids::EXPORTFORMATS);
StringPairArray oldExporters;
oldExporters.set ("ANDROID", "Android Ant Exporter");
oldExporters.set ("MSVC6", "MSVC6");
oldExporters.set ("VS2010", "Visual Studio 2010");
oldExporters.set ("VS2012", "Visual Studio 2012");
for (auto& key : oldExporters.getAllKeys())
{
auto oldExporter = exporters.getChildWithName (key);
if (oldExporter.isValid())
{
AlertWindow::showMessageBox (AlertWindow::WarningIcon,
TRANS (oldExporters[key]),
TRANS ("The " + oldExporters[key] + " Exporter is deprecated. The exporter will be removed from this project."));
exporters.removeChild (oldExporter, nullptr);
}
}
}
void Project::updateOldModulePaths()
{
for (Project::ExporterIterator exporter (*this); exporter.next();)
exporter->updateOldModulePaths();
}
Array<Identifier> Project::getLegacyPluginFormatIdentifiers() noexcept
{
static Array<Identifier> legacyPluginFormatIdentifiers { Ids::buildVST, Ids::buildVST3, Ids::buildAU, Ids::buildAUv3,
Ids::buildRTAS, Ids::buildAAX, Ids::buildStandalone, Ids::enableIAA };
return legacyPluginFormatIdentifiers;
}
Array<Identifier> Project::getLegacyPluginCharacteristicsIdentifiers() noexcept
{
static Array<Identifier> legacyPluginCharacteristicsIdentifiers { Ids::pluginIsSynth, Ids::pluginWantsMidiIn, Ids::pluginProducesMidiOut,
Ids::pluginIsMidiEffectPlugin, Ids::pluginEditorRequiresKeys, Ids::pluginRTASDisableBypass,
Ids::pluginRTASDisableMultiMono, Ids::pluginAAXDisableBypass, Ids::pluginAAXDisableMultiMono };
return legacyPluginCharacteristicsIdentifiers;
}
void Project::coalescePluginFormatValues()
{
Array<var> formatsToBuild;
for (auto& formatIdentifier : getLegacyPluginFormatIdentifiers())
{
if (projectRoot.getProperty (formatIdentifier, false))
formatsToBuild.add (formatIdentifier.toString());
}
if (formatsToBuild.size() > 0)
{
if (pluginFormatsValue.isUsingDefault())
{
pluginFormatsValue = formatsToBuild;
}
else
{
auto formatVar = pluginFormatsValue.get();
if (auto* arr = formatVar.getArray())
arr->addArray (formatsToBuild);
}
shouldWriteLegacyPluginFormatSettings = true;
}
}
void Project::coalescePluginCharacteristicsValues()
{
Array<var> pluginCharacteristics;
for (auto& characteristicIdentifier : getLegacyPluginCharacteristicsIdentifiers())
{
if (projectRoot.getProperty (characteristicIdentifier, false))
pluginCharacteristics.add (characteristicIdentifier.toString());
}
if (pluginCharacteristics.size() > 0)
{
pluginCharacteristicsValue = pluginCharacteristics;
shouldWriteLegacyPluginCharacteristicsSettings = true;
}
}
void Project::updatePluginCategories()
{
{
auto aaxCategory = projectRoot.getProperty (Ids::pluginAAXCategory, {}).toString();
if (getAllAAXCategoryVars().contains (aaxCategory))
pluginAAXCategoryValue = aaxCategory;
else if (getAllAAXCategoryStrings().contains (aaxCategory))
pluginAAXCategoryValue = Array<var> (getAllAAXCategoryVars()[getAllAAXCategoryStrings().indexOf (aaxCategory)]);
}
{
auto rtasCategory = projectRoot.getProperty (Ids::pluginRTASCategory, {}).toString();
if (getAllRTASCategoryVars().contains (rtasCategory))
pluginRTASCategoryValue = rtasCategory;
else if (getAllRTASCategoryStrings().contains (rtasCategory))
pluginRTASCategoryValue = Array<var> (getAllRTASCategoryVars()[getAllRTASCategoryStrings().indexOf (rtasCategory)]);
}
{
auto vstCategory = projectRoot.getProperty (Ids::pluginVSTCategory, {}).toString();
if (vstCategory.isNotEmpty() && getAllVSTCategoryStrings().contains (vstCategory))
pluginVSTCategoryValue = Array<var> (vstCategory);
else
pluginVSTCategoryValue.resetToDefault();
}
{
auto auMainType = projectRoot.getProperty (Ids::pluginAUMainType, {}).toString();
if (auMainType.isNotEmpty())
{
if (getAllAUMainTypeVars().contains (auMainType))
pluginAUMainTypeValue = Array<var> (auMainType);
else if (getAllAUMainTypeVars().contains (auMainType.quoted ('\'')))
pluginAUMainTypeValue = Array<var> (auMainType.quoted ('\''));
else if (getAllAUMainTypeStrings().contains (auMainType))
pluginAUMainTypeValue = Array<var> (getAllAUMainTypeVars()[getAllAUMainTypeStrings().indexOf (auMainType)]);
}
else
{
pluginAUMainTypeValue.resetToDefault();
}
}
}
void Project::writeLegacyPluginFormatSettings()
{
if (pluginFormatsValue.isUsingDefault())
{
for (auto& formatIdentifier : getLegacyPluginFormatIdentifiers())
projectRoot.removeProperty (formatIdentifier, nullptr);
}
else
{
auto formatVar = pluginFormatsValue.get();
if (auto* arr = formatVar.getArray())
{
for (auto& formatIdentifier : getLegacyPluginFormatIdentifiers())
projectRoot.setProperty (formatIdentifier, arr->contains (formatIdentifier.toString()), nullptr);
}
}
}
void Project::writeLegacyPluginCharacteristicsSettings()
{
if (pluginFormatsValue.isUsingDefault())
{
for (auto& characteristicIdentifier : getLegacyPluginCharacteristicsIdentifiers())
projectRoot.removeProperty (characteristicIdentifier, nullptr);
}
else
{
auto characteristicsVar = pluginCharacteristicsValue.get();
if (auto* arr = characteristicsVar.getArray())
{
for (auto& characteristicIdentifier : getLegacyPluginCharacteristicsIdentifiers())
projectRoot.setProperty (characteristicIdentifier, arr->contains (characteristicIdentifier.toString()), nullptr);
}
}
}
//==============================================================================
static int getVersionElement (StringRef v, int index)
{
StringArray parts = StringArray::fromTokens (v, "., ", {});
return parts [parts.size() - index - 1].getIntValue();
}
static int getJuceVersion (const String& v)
{
return getVersionElement (v, 2) * 100000
+ getVersionElement (v, 1) * 1000
+ getVersionElement (v, 0);
}
static int getBuiltJuceVersion()
{
return JUCE_MAJOR_VERSION * 100000
+ JUCE_MINOR_VERSION * 1000
+ JUCE_BUILDNUMBER;
}
static bool isModuleNewerThanProjucer (const ModuleDescription& module)
{
if (module.getID().startsWith ("juce_")
&& getJuceVersion (module.getVersion()) > getBuiltJuceVersion())
return true;
return false;
}
void Project::warnAboutOldProjucerVersion()
{
for (auto& juceModule : ProjucerApplication::getApp().getJUCEPathModuleList().getAllModules())
{
if (isModuleNewerThanProjucer ({ juceModule.second }))
{
// Projucer is out of date!
if (ProjucerApplication::getApp().isRunningCommandLine)
std::cout << "WARNING! This version of the Projucer is out-of-date!" << std::endl;
else
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
"Projucer",
"This version of the Projucer is out-of-date!"
"\n\n"
"Always make sure that you're running the very latest version, "
"preferably compiled directly from the JUCE repository that you're working with!");
return;
}
}
}
//==============================================================================
static File lastDocumentOpened;
File Project::getLastDocumentOpened() { return lastDocumentOpened; }
void Project::setLastDocumentOpened (const File& file) { lastDocumentOpened = file; }
static void registerRecentFile (const File& file)
{
RecentlyOpenedFilesList::registerRecentFileNatively (file);
getAppSettings().recentFiles.addFile (file);
getAppSettings().flush();
}
static void forgetRecentFile (const File& file)
{
RecentlyOpenedFilesList::forgetRecentFileNatively (file);
getAppSettings().recentFiles.removeFile (file);
getAppSettings().flush();
}
//==============================================================================
Result Project::loadDocument (const File& file)
{
auto xml = parseXML (file);
if (xml == nullptr || ! xml->hasTagName (Ids::JUCERPROJECT.toString()))
return Result::fail ("Not a valid Jucer project!");
auto newTree = ValueTree::fromXml (*xml);
if (! newTree.hasType (Ids::JUCERPROJECT))
return Result::fail ("The document contains errors and couldn't be parsed!");
registerRecentFile (file);
enabledModuleList.reset();
projectRoot = newTree;
initialiseProjectValues();
initialiseMainGroup();
initialiseAudioPluginValues();
coalescePluginFormatValues();
coalescePluginCharacteristicsValues();
updatePluginCategories();
parsedPreprocessorDefs = parsePreprocessorDefs (preprocessorDefsValue.get());
removeDefunctExporters();
updateOldModulePaths();
setChangedFlag (false);
if (! ProjucerApplication::getApp().isRunningCommandLine)
warnAboutOldProjucerVersion();
compileEngineSettings.reset (new CompileEngineSettings (projectRoot));
exporterPathsModuleList.reset (new AvailableModuleList());
rescanExporterPathModules (! ProjucerApplication::getApp().isRunningCommandLine);
return Result::ok();
}
Result Project::saveDocument (const File& file)
{
return saveProject (file, false);
}
Result Project::saveProject (const File& file, bool isCommandLineApp)
{
if (isSaving)
return Result::ok();
if (isTemporaryProject())
{
askUserWhereToSaveProject();
return Result::ok();
}
updateProjectSettings();
if (! isCommandLineApp)
{
ProjucerApplication::getApp().openDocumentManager.saveAll();
if (! isTemporaryProject())
registerRecentFile (file);
}
const ScopedValueSetter<bool> vs (isSaving, true, false);
ProjectSaver saver (*this, file);
return saver.save (! isCommandLineApp, shouldWaitAfterSaving, specifiedExporterToSave);
}
Result Project::saveResourcesOnly (const File& file)
{
ProjectSaver saver (*this, file);
return saver.saveResourcesOnly();
}
//==============================================================================
void Project::setTemporaryDirectory (const File& dir) noexcept
{
tempDirectory = dir;
// remove this file from the recent documents list as it is a temporary project
forgetRecentFile (getFile());
}
void Project::askUserWhereToSaveProject()
{
FileChooser fc ("Save Project");
fc.browseForDirectory();
if (fc.getResult().exists())
moveTemporaryDirectory (fc.getResult());
}
void Project::moveTemporaryDirectory (const File& newParentDirectory)
{
auto newDirectory = newParentDirectory.getChildFile (tempDirectory.getFileName());
auto oldJucerFileName = getFile().getFileName();
saveProjectRootToFile();
tempDirectory.copyDirectoryTo (newDirectory);
tempDirectory.deleteRecursively();
tempDirectory = File();
// reload project from new location
if (auto* window = ProjucerApplication::getApp().mainWindowList.getMainWindowForFile (getFile()))
{
Component::SafePointer<MainWindow> safeWindow (window);
MessageManager::callAsync ([safeWindow, newDirectory, oldJucerFileName]
{
if (safeWindow != nullptr)
safeWindow.getComponent()->moveProject (newDirectory.getChildFile (oldJucerFileName));
});
}
}
bool Project::saveProjectRootToFile()
{
std::unique_ptr<XmlElement> xml (projectRoot.createXml());
if (xml == nullptr)
{
jassertfalse;
return false;
}
MemoryOutputStream mo;
xml->writeToStream (mo, {});
return FileHelpers::overwriteFileWithNewDataIfDifferent (getFile(), mo);
}
//==============================================================================
static void sendProjectSettingAnalyticsEvent (StringRef label)
{
StringPairArray data;
data.set ("label", label);
Analytics::getInstance()->logEvent ("Project Setting", data, ProjucerAnalyticsEvent::projectEvent);
}
void Project::valueTreePropertyChanged (ValueTree& tree, const Identifier& property)
{
if (tree.getRoot() == tree)
{
if (property == Ids::projectType)
{
sendChangeMessage();
sendProjectSettingAnalyticsEvent ("Project Type = " + projectTypeValue.get().toString());
}
else if (property == Ids::name)
{
updateTitleDependencies();
}
else if (property == Ids::companyName)
{
updateCompanyNameDependencies();
}
else if (property == Ids::defines)
{
parsedPreprocessorDefs = parsePreprocessorDefs (preprocessorDefsValue.get());
}
else if (property == Ids::cppLanguageStandard)
{
sendProjectSettingAnalyticsEvent ("C++ Standard = " + cppStandardValue.get().toString());
}
else if (property == Ids::pluginFormats)
{
if (shouldWriteLegacyPluginFormatSettings)
writeLegacyPluginFormatSettings();
}
else if (property == Ids::pluginCharacteristicsValue)
{
pluginAUMainTypeValue.setDefault (getDefaultAUMainTypes());
pluginVSTCategoryValue.setDefault (getDefaultVSTCategories());
pluginVST3CategoryValue.setDefault (getDefaultVST3Categories());
pluginRTASCategoryValue.setDefault (getDefaultRTASCategories());
pluginAAXCategoryValue.setDefault (getDefaultAAXCategories());
if (shouldWriteLegacyPluginCharacteristicsSettings)
writeLegacyPluginCharacteristicsSettings();
}
changed();
}
}
void Project::valueTreeChildAdded (ValueTree&, ValueTree&) { changed(); }
void Project::valueTreeChildRemoved (ValueTree&, ValueTree&, int) { changed(); }
void Project::valueTreeChildOrderChanged (ValueTree&, int, int) { changed(); }
void Project::valueTreeParentChanged (ValueTree&) {}
//==============================================================================
bool Project::hasProjectBeenModified()
{
auto oldModificationTime = modificationTime;
modificationTime = getFile().getLastModificationTime();
return (modificationTime.toMilliseconds() > (oldModificationTime.toMilliseconds() + 1000LL));
}
//==============================================================================
File Project::resolveFilename (String filename) const
{
if (filename.isEmpty())
return {};
filename = replacePreprocessorDefs (getPreprocessorDefs(), filename);
#if ! JUCE_WINDOWS
if (filename.startsWith ("~"))
return File::getSpecialLocation (File::userHomeDirectory).getChildFile (filename.trimCharactersAtStart ("~/"));
#endif
if (FileHelpers::isAbsolutePath (filename))
return File::createFileWithoutCheckingPath (FileHelpers::currentOSStylePath (filename)); // (avoid assertions for windows-style paths)
return getFile().getSiblingFile (FileHelpers::currentOSStylePath (filename));
}
String Project::getRelativePathForFile (const File& file) const
{
auto filename = file.getFullPathName();
auto relativePathBase = getFile().getParentDirectory();
auto p1 = relativePathBase.getFullPathName();
auto p2 = file.getFullPathName();
while (p1.startsWithChar (File::getSeparatorChar()))
p1 = p1.substring (1);
while (p2.startsWithChar (File::getSeparatorChar()))
p2 = p2.substring (1);
if (p1.upToFirstOccurrenceOf (File::getSeparatorString(), true, false)
.equalsIgnoreCase (p2.upToFirstOccurrenceOf (File::getSeparatorString(), true, false)))
{
filename = FileHelpers::getRelativePathFrom (file, relativePathBase);
}
return filename;
}
//==============================================================================
const ProjectType& Project::getProjectType() const
{
if (auto* type = ProjectType::findType (getProjectTypeString()))
return *type;
auto* guiType = ProjectType::findType (ProjectType_GUIApp::getTypeName());
jassert (guiType != nullptr);
return *guiType;
}
bool Project::shouldBuildTargetType (ProjectType::Target::Type targetType) const noexcept
{
auto& projectType = getProjectType();
if (! projectType.supportsTargetType (targetType))
return false;
switch (targetType)
{
case ProjectType::Target::VSTPlugIn:
return shouldBuildVST();
case ProjectType::Target::VST3PlugIn:
return shouldBuildVST3();
case ProjectType::Target::AAXPlugIn:
return shouldBuildAAX();
case ProjectType::Target::RTASPlugIn:
return shouldBuildRTAS();
case ProjectType::Target::AudioUnitPlugIn:
return shouldBuildAU();
case ProjectType::Target::AudioUnitv3PlugIn:
return shouldBuildAUv3();
case ProjectType::Target::StandalonePlugIn:
return shouldBuildStandalonePlugin();
case ProjectType::Target::UnityPlugIn:
return shouldBuildUnityPlugin();
case ProjectType::Target::AggregateTarget:
case ProjectType::Target::SharedCodeTarget:
return projectType.isAudioPlugin();
case ProjectType::Target::unspecified:
return false;
default:
break;
}
return true;
}
ProjectType::Target::Type Project::getTargetTypeFromFilePath (const File& file, bool returnSharedTargetIfNoValidSuffix)
{
if (LibraryModule::CompileUnit::hasSuffix (file, "_AU")) return ProjectType::Target::AudioUnitPlugIn;
else if (LibraryModule::CompileUnit::hasSuffix (file, "_AUv3")) return ProjectType::Target::AudioUnitv3PlugIn;
else if (LibraryModule::CompileUnit::hasSuffix (file, "_AAX")) return ProjectType::Target::AAXPlugIn;
else if (LibraryModule::CompileUnit::hasSuffix (file, "_RTAS")) return ProjectType::Target::RTASPlugIn;
else if (LibraryModule::CompileUnit::hasSuffix (file, "_VST2")) return ProjectType::Target::VSTPlugIn;
else if (LibraryModule::CompileUnit::hasSuffix (file, "_VST3")) return ProjectType::Target::VST3PlugIn;
else if (LibraryModule::CompileUnit::hasSuffix (file, "_Standalone")) return ProjectType::Target::StandalonePlugIn;
else if (LibraryModule::CompileUnit::hasSuffix (file, "_Unity")) return ProjectType::Target::UnityPlugIn;
return (returnSharedTargetIfNoValidSuffix ? ProjectType::Target::SharedCodeTarget : ProjectType::Target::unspecified);
}
const char* ProjectType::Target::getName() const noexcept
{
switch (type)
{
case GUIApp: return "App";
case ConsoleApp: return "ConsoleApp";
case StaticLibrary: return "Static Library";
case DynamicLibrary: return "Dynamic Library";
case VSTPlugIn: return "VST";
case VST3PlugIn: return "VST3";
case AudioUnitPlugIn: return "AU";
case StandalonePlugIn: return "Standalone Plugin";
case AudioUnitv3PlugIn: return "AUv3 AppExtension";
case AAXPlugIn: return "AAX";
case RTASPlugIn: return "RTAS";
case UnityPlugIn: return "Unity Plugin";
case SharedCodeTarget: return "Shared Code";
case AggregateTarget: return "All";
default: return "undefined";
}
}
ProjectType::Target::TargetFileType ProjectType::Target::getTargetFileType() const noexcept
{
switch (type)
{
case GUIApp: return executable;
case ConsoleApp: return executable;
case StaticLibrary: return staticLibrary;
case DynamicLibrary: return sharedLibraryOrDLL;
case VSTPlugIn: return pluginBundle;
case VST3PlugIn: return pluginBundle;
case AudioUnitPlugIn: return pluginBundle;
case StandalonePlugIn: return executable;
case AudioUnitv3PlugIn: return macOSAppex;
case AAXPlugIn: return pluginBundle;
case RTASPlugIn: return pluginBundle;
case UnityPlugIn: return pluginBundle;
case SharedCodeTarget: return staticLibrary;
default:
break;
}
return unknown;
}
//==============================================================================
void Project::createPropertyEditors (PropertyListBuilder& props)
{
props.add (new TextPropertyComponent (projectNameValue, "Project Name", 256, false),
"The name of the project.");
props.add (new TextPropertyComponent (versionValue, "Project Version", 16, false),
"The project's version number. This should be in the format major.minor.point[.point] where you should omit the final "
"(optional) [.point] if you are targeting AU and AUv3 plug-ins as they only support three number versions.");
props.add (new TextPropertyComponent (companyNameValue, "Company Name", 256, false),
"Your company name, which will be added to the properties of the binary where possible");
props.add (new TextPropertyComponent (companyCopyrightValue, "Company Copyright", 256, false),
"Your company copyright, which will be added to the properties of the binary where possible");
props.add (new TextPropertyComponent (companyWebsiteValue, "Company Website", 256, false),
"Your company website, which will be added to the properties of the binary where possible");
props.add (new TextPropertyComponent (companyEmailValue, "Company E-mail", 256, false),
"Your company e-mail, which will be added to the properties of the binary where possible");
{
String licenseRequiredTagline ("Required for closed source applications without an Indie or Pro JUCE license");
String licenseRequiredInfo ("In accordance with the terms of the JUCE 5 End-Use License Agreement (www.juce.com/juce-5-licence), "
"this option can only be disabled for closed source applications if you have a JUCE Indie or Pro "
"license, or are using JUCE under the GPL v3 license.");
StringPairArray description;
description.set ("Report JUCE app usage", "This option controls the collection of usage data from users of this JUCE application.");
description.set ("Display the JUCE splash screen", "This option controls the display of the standard JUCE splash screen.");
if (ProjucerApplication::getApp().isPaidOrGPL())
{
props.add (new ChoicePropertyComponent (reportAppUsageValue, String ("Report JUCE App Usage") + " (" + licenseRequiredTagline + ")"),
description["Report JUCE app usage"] + " " + licenseRequiredInfo);
props.add (new ChoicePropertyComponent (displaySplashScreenValue, String ("Display the JUCE Splash Screen") + " (" + licenseRequiredTagline + ")"),
description["Display the JUCE splash screen"] + " " + licenseRequiredInfo);
}
else
{
StringArray options;
Array<var> vars;
options.add (licenseRequiredTagline);
vars.add (var());
props.add (new ChoicePropertyComponent (Value(), "Report JUCE App Usage", options, vars),
description["Report JUCE app usage"] + " " + licenseRequiredInfo);
props.add (new ChoicePropertyComponent (Value(), "Display the JUCE Splash Screen", options, vars),
description["Display the JUCE splash screen"] + " " + licenseRequiredInfo);
}
}
props.add (new ChoicePropertyComponent (splashScreenColourValue, "Splash Screen Colour",
{ "Dark", "Light" },
{ "Dark", "Light" }),
"Choose the colour of the JUCE splash screen.");
{
StringArray projectTypeNames;
Array<var> projectTypeCodes;
auto types = ProjectType::getAllTypes();
for (int i = 0; i < types.size(); ++i)
{
projectTypeNames.add (types.getUnchecked(i)->getDescription());
projectTypeCodes.add (types.getUnchecked(i)->getType());
}
props.add (new ChoicePropertyComponent (projectTypeValue, "Project Type", projectTypeNames, projectTypeCodes),
"The project type for which settings should be shown.");
}
props.add (new TextPropertyComponent (bundleIdentifierValue, "Bundle Identifier", 256, false),
"A unique identifier for this product, mainly for use in OSX/iOS builds. It should be something like 'com.yourcompanyname.yourproductname'");
if (getProjectType().isAudioPlugin())
createAudioPluginPropertyEditors (props);
{
const int maxSizes[] = { 20480, 10240, 6144, 2048, 1024, 512, 256, 128, 64 };
StringArray maxSizeNames;
Array<var> maxSizeCodes;
for (int i = 0; i < numElementsInArray (maxSizes); ++i)
{
auto sizeInBytes = maxSizes[i] * 1024;
maxSizeNames.add (File::descriptionOfSizeInBytes (sizeInBytes));
maxSizeCodes.add (sizeInBytes);
}
props.add (new ChoicePropertyComponent (maxBinaryFileSizeValue, "BinaryData.cpp Size Limit", maxSizeNames, maxSizeCodes),
"When splitting binary data into multiple cpp files, the Projucer attempts to keep the file sizes below this threshold. "
"(Note that individual resource files which are larger than this size cannot be split across multiple cpp files).");
}
props.add (new ChoicePropertyComponent (includeBinaryDataInJuceHeaderValue, "Include BinaryData in JuceHeader"),
"Include BinaryData.h in the JuceHeader.h file");
props.add (new TextPropertyComponent (binaryDataNamespaceValue, "BinaryData Namespace", 256, false),
"The namespace containing the binary assests.");
props.add (new ChoicePropertyComponent (cppStandardValue, "C++ Language Standard",
{ "C++11", "C++14", "C++17", "Use Latest" },
{ "11", "14", "17", "latest" }),
"The standard of the C++ language that will be used for compilation.");
props.add (new TextPropertyComponent (preprocessorDefsValue, "Preprocessor Definitions", 32768, true),
"Global preprocessor definitions. Use the form \"NAME1=value NAME2=value\", using whitespace, commas, or "
"new-lines to separate the items - to include a space or comma in a definition, precede it with a backslash.");
props.addSearchPathProperty (headerSearchPathsValue, "Header Search Paths", "Global header search paths.");
props.add (new TextPropertyComponent (userNotesValue, "Notes", 32768, true),
"Extra comments: This field is not used for code or project generation, it's just a space where you can express your thoughts.");
}
void Project::createAudioPluginPropertyEditors (PropertyListBuilder& props)
{
props.add (new MultiChoicePropertyComponent (pluginFormatsValue, "Plugin Formats",
{ "VST3", "AU", "AUv3", "RTAS", "AAX", "Standalone", "Unity", "Enable IAA", "VST (Legacy)" },
{ Ids::buildVST3.toString(), Ids::buildAU.toString(), Ids::buildAUv3.toString(),
Ids::buildRTAS.toString(), Ids::buildAAX.toString(), Ids::buildStandalone.toString(), Ids::buildUnity.toString(),
Ids::enableIAA.toString(), Ids::buildVST.toString() }),
"Plugin formats to build. If you have selected \"VST (Legacy)\" then you will need to ensure that you have a VST2 SDK "
"in your header search paths. The VST2 SDK can be obtained from the vstsdk3610_11_06_2018_build_37 (or older) VST3 SDK "
"or JUCE version 5.3.2. You also need a VST2 license from Steinberg to distribute VST2 plug-ins.");
props.add (new MultiChoicePropertyComponent (pluginCharacteristicsValue, "Plugin Characteristics",
{ "Plugin is a Synth", "Plugin MIDI Input", "Plugin MIDI Output", "MIDI Effect Plugin", "Plugin Editor Requires Keyboard Focus",
"Disable RTAS Bypass", "Disable AAX Bypass", "Disable RTAS Multi-Mono", "Disable AAX Multi-Mono" },
{ Ids::pluginIsSynth.toString(), Ids::pluginWantsMidiIn.toString(), Ids::pluginProducesMidiOut.toString(),
Ids::pluginIsMidiEffectPlugin.toString(), Ids::pluginEditorRequiresKeys.toString(), Ids::pluginRTASDisableBypass.toString(),
Ids::pluginAAXDisableBypass.toString(), Ids::pluginRTASDisableMultiMono.toString(), Ids::pluginAAXDisableMultiMono.toString() }),
"Some characteristics of your plugin such as whether it is a synth, produces MIDI messages, accepts MIDI messages etc.");
props.add (new TextPropertyComponent (pluginNameValue, "Plugin Name", 128, false),
"The name of your plugin (keep it short!)");
props.add (new TextPropertyComponent (pluginDescriptionValue, "Plugin Description", 256, false),
"A short description of your plugin.");
props.add (new TextPropertyComponent (pluginManufacturerValue, "Plugin Manufacturer", 256, false),
"The name of your company (cannot be blank).");
props.add (new TextPropertyComponent (pluginManufacturerCodeValue, "Plugin Manufacturer Code", 4, false),
"A four-character unique ID for your company. Note that for AU compatibility, this must contain at least one upper-case letter!");
props.add (new TextPropertyComponent (pluginCodeValue, "Plugin Code", 4, false),
"A four-character unique ID for your plugin. Note that for AU compatibility, this must contain at least one upper-case letter!");
props.add (new TextPropertyComponent (pluginChannelConfigsValue, "Plugin Channel Configurations", 1024, false),
"This list is a comma-separated set list in the form {numIns, numOuts} and each pair indicates a valid plug-in "
"configuration. For example {1, 1}, {2, 2} means that the plugin can be used either with 1 input and 1 output, "
"or with 2 inputs and 2 outputs. If your plug-in requires side-chains, aux output buses etc., then you must leave "
"this field empty and override the isBusesLayoutSupported callback in your AudioProcessor.");
props.add (new TextPropertyComponent (pluginAAXIdentifierValue, "Plugin AAX Identifier", 256, false),
"The value to use for the JucePlugin_AAXIdentifier setting");
props.add (new TextPropertyComponent (pluginAUExportPrefixValue, "Plugin AU Export Prefix", 128, false),
"A prefix for the names of exported entry-point functions that the component exposes - typically this will be a version of your plugin's name that can be used as part of a C++ token.");
props.add (new MultiChoicePropertyComponent (pluginAUMainTypeValue, "Plugin AU Main Type", getAllAUMainTypeStrings(), getAllAUMainTypeVars(), 1),
"AU main type.");
props.add (new ChoicePropertyComponent (pluginAUSandboxSafeValue, "Plugin AU is sandbox safe"),
"Check this box if your plug-in is sandbox safe. A sand-box safe plug-in is loaded in a restricted path and can only access it's own bundle resources and "
"the Music folder. Your plug-in must be able to deal with this. Newer versions of GarageBand require this to be enabled.");
{
Array<var> vst3CategoryVars;
for (auto s : getAllVST3CategoryStrings())
vst3CategoryVars.add (s);
props.add (new MultiChoicePropertyComponent (pluginVST3CategoryValue, "Plugin VST3 Category", getAllVST3CategoryStrings(), vst3CategoryVars),
"VST3 category. Most hosts require either \"Fx\" or \"Instrument\" to be selected in order for the plugin to be recognised. "
"If neither of these are selected, the appropriate one will be automatically added based on the \"Plugin is a synth\" option.");
}
props.add (new MultiChoicePropertyComponent (pluginRTASCategoryValue, "Plugin RTAS Category", getAllRTASCategoryStrings(), getAllRTASCategoryVars()),
"RTAS category.");
props.add (new MultiChoicePropertyComponent (pluginAAXCategoryValue, "Plugin AAX Category", getAllAAXCategoryStrings(), getAllAAXCategoryVars()),
"AAX category.");
{
Array<var> vstCategoryVars;
for (auto s : getAllVSTCategoryStrings())
vstCategoryVars.add (s);
props.add (new MultiChoicePropertyComponent (pluginVSTCategoryValue, "Plugin VST (Legacy) Category", getAllVSTCategoryStrings(), vstCategoryVars, 1),
"VST category.");
}
}
//==============================================================================
static StringArray getVersionSegments (const Project& p)
{
auto segments = StringArray::fromTokens (p.getVersionString(), ",.", "");
segments.trim();
segments.removeEmptyStrings();
return segments;
}
int Project::getVersionAsHexInteger() const
{
auto segments = getVersionSegments (*this);
auto value = (segments[0].getIntValue() << 16)
+ (segments[1].getIntValue() << 8)
+ segments[2].getIntValue();
if (segments.size() > 3)
value = (value << 8) + segments[3].getIntValue();
return value;
}
String Project::getVersionAsHex() const
{
return "0x" + String::toHexString (getVersionAsHexInteger());
}
File Project::getBinaryDataCppFile (int index) const
{
auto cpp = getGeneratedCodeFolder().getChildFile ("BinaryData.cpp");
if (index > 0)
return cpp.getSiblingFile (cpp.getFileNameWithoutExtension() + String (index + 1))
.withFileExtension (cpp.getFileExtension());
return cpp;
}
Project::Item Project::getMainGroup()
{
return { *this, projectRoot.getChildWithName (Ids::MAINGROUP), false };
}
PropertiesFile& Project::getStoredProperties() const
{
return getAppSettings().getProjectProperties (getProjectUIDString());
}
static void findImages (const Project::Item& item, OwnedArray<Project::Item>& found)
{
if (item.isImageFile())
{
found.add (new Project::Item (item));
}
else if (item.isGroup())
{
for (int i = 0; i < item.getNumChildren(); ++i)
findImages (item.getChild (i), found);
}
}
void Project::findAllImageItems (OwnedArray<Project::Item>& items)
{
findImages (getMainGroup(), items);
}
//==============================================================================
Project::Item::Item (Project& p, const ValueTree& s, bool isModuleCode)
: project (p), state (s), belongsToModule (isModuleCode)
{
}
Project::Item::Item (const Item& other)
: project (other.project), state (other.state), belongsToModule (other.belongsToModule)
{
}
Project::Item Project::Item::createCopy() { Item i (*this); i.state = i.state.createCopy(); return i; }
String Project::Item::getID() const { return state [Ids::ID]; }
void Project::Item::setID (const String& newID) { state.setProperty (Ids::ID, newID, nullptr); }
Drawable* Project::Item::loadAsImageFile() const
{
const MessageManagerLock mml (ThreadPoolJob::getCurrentThreadPoolJob());
if (! mml.lockWasGained())
return nullptr;
return isValid() ? Drawable::createFromImageFile (getFile())
: nullptr;
}
Project::Item Project::Item::createGroup (Project& project, const String& name, const String& uid, bool isModuleCode)
{
Item group (project, ValueTree (Ids::GROUP), isModuleCode);
group.setID (uid);
group.initialiseMissingProperties();
group.getNameValue() = name;
return group;
}
bool Project::Item::isFile() const { return state.hasType (Ids::FILE); }
bool Project::Item::isGroup() const { return state.hasType (Ids::GROUP) || isMainGroup(); }
bool Project::Item::isMainGroup() const { return state.hasType (Ids::MAINGROUP); }
bool Project::Item::isImageFile() const
{
return isFile() && (ImageFileFormat::findImageFormatForFileExtension (getFile()) != nullptr
|| getFile().hasFileExtension ("svg"));
}
Project::Item Project::Item::findItemWithID (const String& targetId) const
{
if (state [Ids::ID] == targetId)
return *this;
if (isGroup())
{
for (auto i = getNumChildren(); --i >= 0;)
{
auto found = getChild(i).findItemWithID (targetId);
if (found.isValid())
return found;
}
}
return Item (project, ValueTree(), false);
}
bool Project::Item::canContain (const Item& child) const
{
if (isFile())
return false;
if (isGroup())
return child.isFile() || child.isGroup();
jassertfalse;
return false;
}
bool Project::Item::shouldBeAddedToTargetProject() const { return isFile(); }
Value Project::Item::getShouldCompileValue() { return state.getPropertyAsValue (Ids::compile, getUndoManager()); }
bool Project::Item::shouldBeCompiled() const { return state [Ids::compile]; }
Value Project::Item::getShouldAddToBinaryResourcesValue() { return state.getPropertyAsValue (Ids::resource, getUndoManager()); }
bool Project::Item::shouldBeAddedToBinaryResources() const { return state [Ids::resource]; }
Value Project::Item::getShouldAddToXcodeResourcesValue() { return state.getPropertyAsValue (Ids::xcodeResource, getUndoManager()); }
bool Project::Item::shouldBeAddedToXcodeResources() const { return state [Ids::xcodeResource]; }
Value Project::Item::getShouldInhibitWarningsValue() { return state.getPropertyAsValue (Ids::noWarnings, getUndoManager()); }
bool Project::Item::shouldInhibitWarnings() const { return state [Ids::noWarnings]; }
bool Project::Item::isModuleCode() const { return belongsToModule; }
String Project::Item::getFilePath() const
{
if (isFile())
return state [Ids::file].toString();
return {};
}
File Project::Item::getFile() const
{
if (isFile())
return project.resolveFilename (state [Ids::file].toString());
return {};
}
void Project::Item::setFile (const File& file)
{
setFile (RelativePath (project.getRelativePathForFile (file), RelativePath::projectFolder));
jassert (getFile() == file);
}
void Project::Item::setFile (const RelativePath& file)
{
jassert (isFile());
state.setProperty (Ids::file, file.toUnixStyle(), getUndoManager());
state.setProperty (Ids::name, file.getFileName(), getUndoManager());
}
bool Project::Item::renameFile (const File& newFile)
{
auto oldFile = getFile();
if (oldFile.moveFileTo (newFile)
|| (newFile.exists() && ! oldFile.exists()))
{
setFile (newFile);
ProjucerApplication::getApp().openDocumentManager.fileHasBeenRenamed (oldFile, newFile);
return true;
}
return false;
}
bool Project::Item::containsChildForFile (const RelativePath& file) const
{
return state.getChildWithProperty (Ids::file, file.toUnixStyle()).isValid();
}
Project::Item Project::Item::findItemForFile (const File& file) const
{
if (getFile() == file)
return *this;
if (isGroup())
{
for (auto i = getNumChildren(); --i >= 0;)
{
auto found = getChild(i).findItemForFile (file);
if (found.isValid())
return found;
}
}
return Item (project, ValueTree(), false);
}
File Project::Item::determineGroupFolder() const
{
jassert (isGroup());
File f;
for (int i = 0; i < getNumChildren(); ++i)
{
f = getChild(i).getFile();
if (f.exists())
return f.getParentDirectory();
}
auto parent = getParent();
if (parent != *this)
{
f = parent.determineGroupFolder();
if (f.getChildFile (getName()).isDirectory())
f = f.getChildFile (getName());
}
else
{
f = project.getProjectFolder();
if (f.getChildFile ("Source").isDirectory())
f = f.getChildFile ("Source");
}
return f;
}
void Project::Item::initialiseMissingProperties()
{
if (! state.hasProperty (Ids::ID))
setID (createAlphaNumericUID());
if (isFile())
{
state.setProperty (Ids::name, getFile().getFileName(), nullptr);
}
else if (isGroup())
{
for (auto i = getNumChildren(); --i >= 0;)
getChild(i).initialiseMissingProperties();
}
}
Value Project::Item::getNameValue()
{
return state.getPropertyAsValue (Ids::name, getUndoManager());
}
String Project::Item::getName() const
{
return state [Ids::name];
}
void Project::Item::addChild (const Item& newChild, int insertIndex)
{
state.addChild (newChild.state, insertIndex, getUndoManager());
}
void Project::Item::removeItemFromProject()
{
state.getParent().removeChild (state, getUndoManager());
}
Project::Item Project::Item::getParent() const
{
if (isMainGroup() || ! isGroup())
return *this;
return { project, state.getParent(), belongsToModule };
}
struct ItemSorter
{
static int compareElements (const ValueTree& first, const ValueTree& second)
{
return first [Ids::name].toString().compareNatural (second [Ids::name].toString());
}
};
struct ItemSorterWithGroupsAtStart
{
static int compareElements (const ValueTree& first, const ValueTree& second)
{
auto firstIsGroup = first.hasType (Ids::GROUP);
auto secondIsGroup = second.hasType (Ids::GROUP);
if (firstIsGroup == secondIsGroup)
return first [Ids::name].toString().compareNatural (second [Ids::name].toString());
return firstIsGroup ? -1 : 1;
}
};
static void sortGroup (ValueTree& state, bool keepGroupsAtStart, UndoManager* undoManager)
{
if (keepGroupsAtStart)
{
ItemSorterWithGroupsAtStart sorter;
state.sort (sorter, undoManager, true);
}
else
{
ItemSorter sorter;
state.sort (sorter, undoManager, true);
}
}
static bool isGroupSorted (const ValueTree& state, bool keepGroupsAtStart)
{
if (state.getNumChildren() == 0)
return false;
if (state.getNumChildren() == 1)
return true;
auto stateCopy = state.createCopy();
sortGroup (stateCopy, keepGroupsAtStart, nullptr);
return stateCopy.isEquivalentTo (state);
}
void Project::Item::sortAlphabetically (bool keepGroupsAtStart, bool recursive)
{
sortGroup (state, keepGroupsAtStart, getUndoManager());
if (recursive)
for (auto i = getNumChildren(); --i >= 0;)
getChild(i).sortAlphabetically (keepGroupsAtStart, true);
}
Project::Item Project::Item::getOrCreateSubGroup (const String& name)
{
for (auto i = state.getNumChildren(); --i >= 0;)
{
auto child = state.getChild (i);
if (child.getProperty (Ids::name) == name && child.hasType (Ids::GROUP))
return { project, child, belongsToModule };
}
return addNewSubGroup (name, -1);
}
Project::Item Project::Item::addNewSubGroup (const String& name, int insertIndex)
{
auto newID = createGUID (getID() + name + String (getNumChildren()));
int n = 0;
while (project.getMainGroup().findItemWithID (newID).isValid())
newID = createGUID (newID + String (++n));
auto group = createGroup (project, name, newID, belongsToModule);
jassert (canContain (group));
addChild (group, insertIndex);
return group;
}
bool Project::Item::addFileAtIndex (const File& file, int insertIndex, const bool shouldCompile)
{
if (file == File() || file.isHidden() || file.getFileName().startsWithChar ('.'))
return false;
if (file.isDirectory())
{
auto group = addNewSubGroup (file.getFileName(), insertIndex);
for (DirectoryIterator iter (file, false, "*", File::findFilesAndDirectories); iter.next();)
if (! project.getMainGroup().findItemForFile (iter.getFile()).isValid())
group.addFileRetainingSortOrder (iter.getFile(), shouldCompile);
}
else if (file.existsAsFile())
{
if (! project.getMainGroup().findItemForFile (file).isValid())
addFileUnchecked (file, insertIndex, shouldCompile);
}
else
{
jassertfalse;
}
return true;
}
bool Project::Item::addFileRetainingSortOrder (const File& file, bool shouldCompile)
{
auto wasSortedGroupsNotFirst = isGroupSorted (state, false);
auto wasSortedGroupsFirst = isGroupSorted (state, true);
if (! addFileAtIndex (file, 0, shouldCompile))
return false;
if (wasSortedGroupsNotFirst || wasSortedGroupsFirst)
sortAlphabetically (wasSortedGroupsFirst, false);
return true;
}
void Project::Item::addFileUnchecked (const File& file, int insertIndex, const bool shouldCompile)
{
Item item (project, ValueTree (Ids::FILE), belongsToModule);
item.initialiseMissingProperties();
item.getNameValue() = file.getFileName();
item.getShouldCompileValue() = shouldCompile && file.hasFileExtension (fileTypesToCompileByDefault);
item.getShouldAddToBinaryResourcesValue() = project.shouldBeAddedToBinaryResourcesByDefault (file);
if (canContain (item))
{
item.setFile (file);
addChild (item, insertIndex);
}
}
bool Project::Item::addRelativeFile (const RelativePath& file, int insertIndex, bool shouldCompile)
{
Item item (project, ValueTree (Ids::FILE), belongsToModule);
item.initialiseMissingProperties();
item.getNameValue() = file.getFileName();
item.getShouldCompileValue() = shouldCompile;
item.getShouldAddToBinaryResourcesValue() = project.shouldBeAddedToBinaryResourcesByDefault (file);
if (canContain (item))
{
item.setFile (file);
addChild (item, insertIndex);
return true;
}
return false;
}
Icon Project::Item::getIcon (bool isOpen) const
{
auto& icons = getIcons();
if (isFile())
{
if (isImageFile())
return Icon (icons.imageDoc, Colours::transparentBlack);
return { icons.file, Colours::transparentBlack };
}
if (isMainGroup())
return { icons.juceLogo, Colours::orange };
return { isOpen ? icons.openFolder : icons.closedFolder, Colours::transparentBlack };
}
bool Project::Item::isIconCrossedOut() const
{
return isFile()
&& ! (shouldBeCompiled()
|| shouldBeAddedToBinaryResources()
|| getFile().hasFileExtension (headerFileExtensions));
}
bool Project::Item::needsSaving() const noexcept
{
auto& odm = ProjucerApplication::getApp().openDocumentManager;
if (odm.anyFilesNeedSaving())
{
for (int i = 0; i < odm.getNumOpenDocuments(); ++i)
{
auto* doc = odm.getOpenDocument (i);
if (doc->needsSaving() && doc->getFile() == getFile())
return true;
}
}
return false;
}
//==============================================================================
ValueTree Project::getConfigNode()
{
return projectRoot.getOrCreateChildWithName (Ids::JUCEOPTIONS, nullptr);
}
ValueWithDefault Project::getConfigFlag (const String& name)
{
auto configNode = getConfigNode();
return { configNode, name, getUndoManagerFor (configNode) };
}
bool Project::isConfigFlagEnabled (const String& name, bool defaultIsEnabled) const
{
auto configValue = projectRoot.getChildWithName (Ids::JUCEOPTIONS).getProperty (name, "default");
if (configValue == "default")
return defaultIsEnabled;
return configValue;
}
//==============================================================================
static String getCompanyNameOrDefault (StringRef str)
{
if (str.isEmpty())
return "yourcompany";
return str;
}
String Project::getDefaultBundleIdentifierString() const
{
return "com." + getCompanyNameOrDefault (getCompanyNameString()) + "." + CodeHelpers::makeValidIdentifier (getProjectNameString(), false, true, false);
}
String Project::getDefaultPluginManufacturerString() const
{
return getCompanyNameOrDefault (getCompanyNameString());
}
String Project::getAUMainTypeString() const noexcept
{
auto v = pluginAUMainTypeValue.get();
if (auto* arr = v.getArray())
return arr->getFirst().toString();
jassertfalse;
return {};
}
bool Project::isAUSandBoxSafe() const noexcept
{
return pluginAUSandboxSafeValue.get();
}
String Project::getVSTCategoryString() const noexcept
{
auto v = pluginVSTCategoryValue.get();
if (auto* arr = v.getArray())
return arr->getFirst().toString();
jassertfalse;
return {};
}
static String getVST3CategoryStringFromSelection (Array<var> selected, const Project& p) noexcept
{
StringArray categories;
for (auto& category : selected)
categories.add (category);
// One of these needs to be selected in order for the plug-in to be recognised in Cubase
if (! categories.contains ("Fx") && ! categories.contains ("Instrument"))
{
categories.insert (0, p.isPluginSynth() ? "Instrument"
: "Fx");
}
else
{
// "Fx" and "Instrument" should come first and if both are present prioritise "Fx"
if (categories.contains ("Instrument"))
categories.move (categories.indexOf ("Instrument"), 0);
if (categories.contains ("Fx"))
categories.move (categories.indexOf ("Fx"), 0);
}
return categories.joinIntoString ("|");
}
String Project::getVST3CategoryString() const noexcept
{
auto v = pluginVST3CategoryValue.get();
if (auto* arr = v.getArray())
return getVST3CategoryStringFromSelection (*arr, *this);
jassertfalse;
return {};
}
int Project::getAAXCategory() const noexcept
{
int res = 0;
auto v = pluginAAXCategoryValue.get();
if (auto* arr = v.getArray())
{
for (auto c : *arr)
res |= static_cast<int> (c);
}
return res;
}
int Project::getRTASCategory() const noexcept
{
int res = 0;
auto v = pluginRTASCategoryValue.get();
if (auto* arr = v.getArray())
{
for (auto c : *arr)
res |= static_cast<int> (c);
}
return res;
}
String Project::getIAATypeCode()
{
String s;
if (pluginWantsMidiInput())
{
if (isPluginSynth())
s = "auri";
else
s = "aurm";
}
else
{
if (isPluginSynth())
s = "aurg";
else
s = "aurx";
}
return s;
}
String Project::getIAAPluginName()
{
auto s = getPluginManufacturerString();
s << ": ";
s << getPluginNameString();
return s;
}
//==============================================================================
bool Project::isAUPluginHost()
{
return getEnabledModules().isModuleEnabled ("juce_audio_processors") && isConfigFlagEnabled ("JUCE_PLUGINHOST_AU");
}
bool Project::isVSTPluginHost()
{
return getEnabledModules().isModuleEnabled ("juce_audio_processors") && isConfigFlagEnabled ("JUCE_PLUGINHOST_VST");
}
bool Project::isVST3PluginHost()
{
return getEnabledModules().isModuleEnabled ("juce_audio_processors") && isConfigFlagEnabled ("JUCE_PLUGINHOST_VST3");
}
//==============================================================================
StringArray Project::getAllAUMainTypeStrings() noexcept
{
static StringArray auMainTypeStrings { "kAudioUnitType_Effect", "kAudioUnitType_FormatConverter", "kAudioUnitType_Generator", "kAudioUnitType_MIDIProcessor",
"kAudioUnitType_Mixer", "kAudioUnitType_MusicDevice", "kAudioUnitType_MusicEffect", "kAudioUnitType_OfflineEffect",
"kAudioUnitType_Output", "kAudioUnitType_Panner" };
return auMainTypeStrings;
}
Array<var> Project::getAllAUMainTypeVars() noexcept
{
static Array<var> auMainTypeVars { "'aufx'", "'aufc'", "'augn'", "'aumi'",
"'aumx'", "'aumu'", "'aumf'", "'auol'",
"'auou'", "'aupn'" };
return auMainTypeVars;
}
Array<var> Project::getDefaultAUMainTypes() const noexcept
{
if (isPluginMidiEffect()) return { "'aumi'" };
if (isPluginSynth()) return { "'aumu'" };
if (pluginWantsMidiInput()) return { "'aumf'" };
return { "'aufx'" };
}
StringArray Project::getAllVSTCategoryStrings() noexcept
{
static StringArray vstCategoryStrings { "kPlugCategUnknown", "kPlugCategEffect", "kPlugCategSynth", "kPlugCategAnalysis", "kPlugCategMastering",
"kPlugCategSpacializer", "kPlugCategRoomFx", "kPlugSurroundFx", "kPlugCategRestoration", "kPlugCategOfflineProcess",
"kPlugCategShell", "kPlugCategGenerator" };
return vstCategoryStrings;
}
Array<var> Project::getDefaultVSTCategories() const noexcept
{
if (isPluginSynth())
return { "kPlugCategSynth" };
return { "kPlugCategEffect" };
}
StringArray Project::getAllVST3CategoryStrings() noexcept
{
static StringArray vst3CategoryStrings { "Fx", "Instrument", "Analyzer", "Delay", "Distortion", "Drum", "Dynamics", "EQ", "External", "Filter",
"Generator", "Mastering", "Modulation", "Mono", "Network", "NoOfflineProcess", "OnlyOfflineProcess", "OnlyRT",
"Pitch Shift", "Restoration", "Reverb", "Sampler", "Spatial", "Stereo", "Surround", "Synth", "Tools", "Up-Downmix" };
return vst3CategoryStrings;
}
Array<var> Project::getDefaultVST3Categories() const noexcept
{
if (isPluginSynth())
return { "Instrument", "Synth" };
return { "Fx" };
}
StringArray Project::getAllAAXCategoryStrings() noexcept
{
static StringArray aaxCategoryStrings { "AAX_ePlugInCategory_None", "AAX_ePlugInCategory_EQ", "AAX_ePlugInCategory_Dynamics", "AAX_ePlugInCategory_PitchShift",
"AAX_ePlugInCategory_Reverb", "AAX_ePlugInCategory_Delay", "AAX_ePlugInCategory_Modulation", "AAX_ePlugInCategory_Harmonic",
"AAX_ePlugInCategory_NoiseReduction", "AAX_ePlugInCategory_Dither", "AAX_ePlugInCategory_SoundField", "AAX_ePlugInCategory_HWGenerators",
"AAX_ePlugInCategory_SWGenerators", "AAX_ePlugInCategory_WrappedPlugin", "AAX_EPlugInCategory_Effect" };
return aaxCategoryStrings;
}
Array<var> Project::getAllAAXCategoryVars() noexcept
{
static Array<var> aaxCategoryVars { 0x00000000, 0x00000001, 0x00000002, 0x00000004,
0x00000008, 0x00000010, 0x00000020, 0x00000040,
0x00000080, 0x00000100, 0x00000200, 0x00000400,
0x00000800, 0x00001000, 0x00002000 };
return aaxCategoryVars;
}
Array<var> Project::getDefaultAAXCategories() const noexcept
{
if (isPluginSynth())
return getAllAAXCategoryVars()[getAllAAXCategoryStrings().indexOf ("AAX_ePlugInCategory_SWGenerators")];
return getAllAAXCategoryVars()[getAllAAXCategoryStrings().indexOf ("AAX_ePlugInCategory_None")];
}
StringArray Project::getAllRTASCategoryStrings() noexcept
{
static StringArray rtasCategoryStrings { "ePlugInCategory_None", "ePlugInCategory_EQ", "ePlugInCategory_Dynamics", "ePlugInCategory_PitchShift",
"ePlugInCategory_Reverb", "ePlugInCategory_Delay", "ePlugInCategory_Modulation", "ePlugInCategory_Harmonic",
"ePlugInCategory_NoiseReduction", "ePlugInCategory_Dither", "ePlugInCategory_SoundField", "ePlugInCategory_HWGenerators",
"ePlugInCategory_SWGenerators", "ePlugInCategory_WrappedPlugin", "ePlugInCategory_Effect" };
return rtasCategoryStrings;
}
Array<var> Project::getAllRTASCategoryVars() noexcept
{
static Array<var> rtasCategoryVars { 0x00000000, 0x00000001, 0x00000002, 0x00000004,
0x00000008, 0x00000010, 0x00000020, 0x00000040,
0x00000080, 0x00000100, 0x00000200, 0x00000400,
0x00000800, 0x00001000, 0x00002000 };
return rtasCategoryVars;
}
Array<var> Project::getDefaultRTASCategories() const noexcept
{
if (isPluginSynth())
return getAllRTASCategoryVars()[getAllRTASCategoryStrings().indexOf ("ePlugInCategory_SWGenerators")];
return getAllRTASCategoryVars()[getAllRTASCategoryStrings().indexOf ("ePlugInCategory_None")];
}
//==============================================================================
EnabledModuleList& Project::getEnabledModules()
{
if (enabledModuleList == nullptr)
enabledModuleList.reset (new EnabledModuleList (*this, projectRoot.getOrCreateChildWithName (Ids::MODULES, nullptr)));
return *enabledModuleList;
}
static StringArray getModulePathsFromExporters (Project& project, bool onlyThisOS)
{
StringArray paths;
for (Project::ExporterIterator exporter (project); exporter.next();)
{
if (onlyThisOS && ! exporter->mayCompileOnCurrentOS())
continue;
auto& modules = project.getEnabledModules();
auto n = modules.getNumModules();
for (int i = 0; i < n; ++i)
{
auto id = modules.getModuleID (i);
if (modules.shouldUseGlobalPath (id))
continue;
auto path = exporter->getPathForModuleString (id);
if (path.isNotEmpty())
paths.addIfNotAlreadyThere (path);
}
auto oldPath = exporter->getLegacyModulePath();
if (oldPath.isNotEmpty())
paths.addIfNotAlreadyThere (oldPath);
}
return paths;
}
static Array<File> getExporterModulePathsToScan (Project& project)
{
auto exporterPaths = getModulePathsFromExporters (project, true);
if (exporterPaths.isEmpty())
exporterPaths = getModulePathsFromExporters (project, false);
Array<File> files;
for (auto& path : exporterPaths)
{
auto f = project.resolveFilename (path);
if (f.isDirectory())
{
files.addIfNotAlreadyThere (f);
if (f.getChildFile ("modules").isDirectory())
files.addIfNotAlreadyThere (f.getChildFile ("modules"));
}
}
return files;
}
AvailableModuleList& Project::getExporterPathsModuleList()
{
return *exporterPathsModuleList;
}
void Project::rescanExporterPathModules (bool async)
{
if (async)
exporterPathsModuleList->scanPathsAsync (getExporterModulePathsToScan (*this));
else
exporterPathsModuleList->scanPaths (getExporterModulePathsToScan (*this));
}
ModuleIDAndFolder Project::getModuleWithID (const String& id)
{
if (! getEnabledModules().shouldUseGlobalPath (id))
{
const auto& mod = exporterPathsModuleList->getModuleWithID (id);
if (mod.second != File())
return mod;
}
const auto& list = (isJUCEModule (id) ? ProjucerApplication::getApp().getJUCEPathModuleList().getAllModules()
: ProjucerApplication::getApp().getUserPathsModuleList().getAllModules());
for (auto& m : list)
if (m.first == id)
return m;
return exporterPathsModuleList->getModuleWithID (id);
}
//==============================================================================
ValueTree Project::getExporters()
{
return projectRoot.getOrCreateChildWithName (Ids::EXPORTFORMATS, nullptr);
}
int Project::getNumExporters()
{
return getExporters().getNumChildren();
}
ProjectExporter* Project::createExporter (int index)
{
jassert (index >= 0 && index < getNumExporters());
return ProjectExporter::createExporter (*this, getExporters().getChild (index));
}
void Project::addNewExporter (const String& exporterName)
{
std::unique_ptr<ProjectExporter> exp (ProjectExporter::createNewExporter (*this, exporterName));
exp->getTargetLocationValue() = exp->getTargetLocationString()
+ getUniqueTargetFolderSuffixForExporter (exp->getName(), exp->getTargetLocationString());
auto exportersTree = getExporters();
exportersTree.appendChild (exp->settings, getUndoManagerFor (exportersTree));
}
void Project::createExporterForCurrentPlatform()
{
addNewExporter (ProjectExporter::getCurrentPlatformExporterName());
}
String Project::getUniqueTargetFolderSuffixForExporter (const String& exporterName, const String& base)
{
StringArray buildFolders;
auto exportersTree = getExporters();
auto type = ProjectExporter::getValueTreeNameForExporter (exporterName);
for (int i = 0; i < exportersTree.getNumChildren(); ++i)
{
auto exporterNode = exportersTree.getChild (i);
if (exporterNode.getType() == Identifier (type))
buildFolders.add (exporterNode.getProperty ("targetFolder").toString());
}
if (buildFolders.size() == 0 || ! buildFolders.contains (base))
return {};
buildFolders.remove (buildFolders.indexOf (base));
int num = 1;
for (auto f : buildFolders)
{
if (! f.endsWith ("_" + String (num)))
break;
++num;
}
return "_" + String (num);
}
//==============================================================================
bool Project::shouldSendGUIBuilderAnalyticsEvent() noexcept
{
if (! hasSentGUIBuilderAnalyticsEvent)
{
hasSentGUIBuilderAnalyticsEvent = true;
return true;
}
return false;
}
//==============================================================================
String Project::getFileTemplate (const String& templateName)
{
int dataSize;
if (auto* data = BinaryData::getNamedResource (templateName.toUTF8(), dataSize))
return String::fromUTF8 (data, dataSize);
jassertfalse;
return {};
}
//==============================================================================
Project::ExporterIterator::ExporterIterator (Project& p) : index (-1), project (p) {}
Project::ExporterIterator::~ExporterIterator() {}
bool Project::ExporterIterator::next()
{
if (++index >= project.getNumExporters())
return false;
exporter.reset (project.createExporter (index));
if (exporter == nullptr)
{
jassertfalse; // corrupted project file?
return next();
}
return true;
}
|