1#---------------------------------------------------------------------------- 2# Project: Horizon 3# File: targetdefs.om 4# 5# Copyright (C)2009-2011 Nintendo Co., Ltd. All rights reserved. 6# 7# These coded instructions, statements, and computer programs contain 8# proprietary information of Nintendo of America Inc. and/or Nintendo 9# Company Ltd., and are protected by Federal copyright law. They may 10# not be disclosed to third parties or copied or duplicated in any form, 11# in whole or in part, without the prior written consent of Nintendo. 12# 13# $Rev: 40245 $ 14#---------------------------------------------------------------------------- 15 16#---------------------------------------------------------------------------- 17# Function definitions 18#---------------------------------------------------------------------------- 19 20#------------------------------------------------------- 21# getOutputBaseDirectory 22# 23# Overview 24# Function to get directory not dependent on the target 25# 26# Referenced global variables 27# | 28#------------------------------------------------------- 29getOutputBaseDirectory() = 30 abs_cwd = $(absname $(CWD)) 31 #println(abs_cwd: $(abs_cwd)) 32 # Is the project root HORIZON_ROOT? (SDK build?) 33 if $(equal $(AROOT), $(HORIZON_ROOT)) 34 return $(dir $(HORIZON_ROOT)) 35 36 # Is the current directory in HORIZON_ROOT? 37 subdir = $(removeprefix $(HORIZON_ROOT), $(abs_cwd)) 38 if $(not $(equal $(subdir), $(abs_cwd))) 39 #println("UNDER HORIZON: "$(abs_cwd)) 40 return $(dir $(HORIZON_ROOT)) 41 42 # Is there a sources directory in the project root? 43 subdir = $(removeprefix $(AROOT)\\sources\\, $(abs_cwd)) 44 if $(not $(equal $(subdir), $(abs_cwd))) 45 #println("SOURCES EXIST: "$(abs_cwd)) 46 return $(ROOT) 47 48 #println(subdir: $(subdir)) 49 # Output to current directory 50 return $(dir .) 51 52#------------------------------------------------------- 53# getModuleOutputSubDirectoryOf 54# 55# Overview 56# | 57# 58# Referenced global variables 59# | 60#------------------------------------------------------- 61getModuleOutputSubDirectoryOf(module_dir, sub_dir) = 62 if $(defined SOURCES_BASE_ROOT) 63 module_dir = $(SOURCES_BASE_ROOT) 64 export 65 66 abs_dir = $(absname $(module_dir)) 67 subpath = $(removeprefix $(AROOT)$(DIRSEP), $(abs_dir)) 68 subpath = $(removeprefix sources$(DIRSEP), $(subpath)) 69 70 # Is the project root HORIZON_ROOT? (SDK build?) 71 if $(equal $(AROOT), $(HORIZON_ROOT)) 72 return $(dir $(HORIZON_ROOT)/$(sub_dir)/$(subpath)) 73 74 # Is the current directory in HORIZON_ROOT? 75 subdir = $(removeprefix $(HORIZON_ROOT), $(abs_dir)) 76 if $(not $(equal $(subdir), $(abs_dir))) 77 return $(dir $(HORIZON_ROOT)/$(sub_dir)/$(subpath)) 78 79 # Is there a sources directory in the project root? 80 subdir = $(removeprefix $(AROOT)\\sources\\, $(abs_dir)) 81 if $(not $(equal $(subdir), $(abs_dir))) 82 return $(dir $(ROOT)/$(sub_dir)/$(subpath)) 83 84 # Output to target directory 85 return $(dir $(module_dir)$(DIRSEP)$(sub_dir)) 86 87#------------------------------------------------------- 88# getModuleImageSubDirectoryOf 89# 90# Overview 91# | 92# 93# Referenced global variables 94# | 95#------------------------------------------------------- 96getModuleImageSubDirectoryOf(module_dir) = 97 return $(getModuleOutputSubDirectoryOf $(module_dir), $(SUBDIR_IMAGES)) 98 99#------------------------------------------------------- 100# getModuleObjectsSubDirectoryOf 101# 102# Overview 103# | 104# 105# Referenced global variables 106# | 107#------------------------------------------------------- 108getModuleObjectsSubDirectoryOf(module_dir) = 109 return $(getModuleOutputSubDirectoryOf $(module_dir), $(SUBDIR_OBJECTS)) 110 111#------------------------------------------------------- 112# getModuleSubDirectory 113# 114# Overview 115# Get the subdirectory name where generated items are stored from the source path name 116# 117# Referenced global variables 118# | 119#------------------------------------------------------- 120getModuleSubDirectory() = 121 if $(defined SOURCES_BASE_ROOT) 122 basedir = $(SOURCES_BASE_ROOT) 123 export 124 else 125 basedir = $(CWD) 126 export 127 #println(basedir: $(basedir)) 128 if $(equal $(ROOT), $(basedir)) 129 return . 130 131 basedir = $(absname $(basedir)) 132 subpath = $(removeprefix $(AROOT)$(DIRSEP), $(basedir)) 133 subpath = $(removeprefix sources$(DIRSEP), $(subpath)) 134 return $(subpath) 135 136#------------------------------------------------------- 137# getObjectBaseDirectory 138# 139# Overview 140# | 141# 142# Referenced global variables 143# | 144#------------------------------------------------------- 145getObjectBaseDirectory() = 146 base_dir = $(getOutputBaseDirectory) 147 if $(equal ., $(base_dir)) 148 module_dir = 149 export 150 else 151 module_dir = $(getModuleSubDirectory)$(DIRSEP) 152 export 153 return $(base_dir)$(DIRSEP)$(SUBDIR_OBJECTS)$(DIRSEP)$(module_dir) 154 155 156 157 158#---------------------------------------------------------------------------- 159# Class definitions 160#---------------------------------------------------------------------------- 161 162TargetSpec. = 163 class TargetSpec 164 165 #---------------------------------------------------------------------------- 166 # Variable Definitions 167 #---------------------------------------------------------------------------- 168 169 this.processor = $(EMPTY) 170 this.platform = $(EMPTY) 171 this.hardware = $(EMPTY) 172 this.name = $(EMPTY) 173 174 175 #---------------------------------------------------------------------------- 176 # Function definitions 177 #---------------------------------------------------------------------------- 178 179 #------------------------------------------------------- 180 # New. 181 # 182 # Overview 183 # | 184 # 185 # Referenced global variables 186 # None. 187 #------------------------------------------------------- 188 new(name) = 189 this.name = $(name) 190 return $(this) 191 192 #------------------------------------------------------- 193 # dump 194 # 195 # Overview 196 # | 197 # 198 # Referenced global variables 199 # None. 200 #------------------------------------------------------- 201 dump() = 202 println($"name: "$(name)) 203 println($" platform: "$(platform)) 204 println($" hardware: "$(hardware)) 205 println($" processors: "$(processors)) 206 println($' ') 207 208 #------------------------------------------------------- 209 # getMacroFlags 210 # 211 # Overview 212 # | 213 # 214 # Referenced global variables 215 # None. 216 #------------------------------------------------------- 217 getMacroFlags(systemname, processor) = 218 return $(EMPTY) 219 220TargetConfig. = 221 class TargetConfig 222 223 #---------------------------------------------------------------------------- 224 # Variable Definitions 225 #---------------------------------------------------------------------------- 226 227 this.hardware = $(EMPTY) 228 this.systemname = $(EMPTY) 229 this.processor = $(EMPTY) 230 this.effort = $(EMPTY) 231 this.buildtype = $(EMPTY) 232 this.matched = true 233 234 235 236 #---------------------------------------------------------------------------- 237 # Function definitions 238 #---------------------------------------------------------------------------- 239 240 #------------------------------------------------------- 241 # New. 242 # 243 # Overview 244 # | 245 # 246 # Referenced global variables 247 # None. 248 #------------------------------------------------------- 249 new() = 250 return $(this) 251 252 #------------------------------------------------------- 253 # dump 254 # 255 # Overview 256 # | 257 # 258 # Referenced global variables 259 # None. 260 #------------------------------------------------------- 261 dump() = 262 println($"hardware: "$(hardware)) 263 println($" processor: "$(processor)) 264 println($' ') 265 266 #------------------------------------------------------- 267 # getFullname 268 # 269 # Overview 270 # | 271 # 272 # Referenced global variables 273 # None. 274 #------------------------------------------------------- 275 getFullname() = 276 return $(hardware).$(systemname).$(processor).$(effort) 277 278 #------------------------------------------------------- 279 # getFullnameWithSystem 280 # 281 # Overview 282 # | 283 # 284 # Referenced global variables 285 # | 286 #------------------------------------------------------- 287 getFullnameWithSystem(altsystemname) = 288 return $(hardware).$(altsystemname).$(processor).$(effort) 289 290 #------------------------------------------------------- 291 # getFullnameWithSystemAndEffort 292 # 293 # Overview 294 # | 295 # 296 # Referenced global variables 297 # None. 298 #------------------------------------------------------- 299 getFullnameWithSystemAndEffort(altsystemname, alteffort) = 300 return $(hardware).$(altsystemname).$(processor).$(alteffort) 301 302 #------------------------------------------------------- 303 # getScannerName 304 # 305 # Overview 306 # | 307 # 308 # Referenced global variables 309 # | 310 #------------------------------------------------------- 311 getScannerName() = 312 return $(getFullname)-$(buildtype) 313 314 #------------------------------------------------------- 315 # getObjectDirectory 316 # 317 # Overview 318 # | 319 # 320 # Referenced global variables 321 # | 322 #------------------------------------------------------- 323 getObjectDirectory() = 324 return $(getObjectDirectoryFeedback false) 325 326 #------------------------------------------------------- 327 # getObjectDirectoryFeedback 328 # 329 # Overview 330 # | 331 # 332 # Referenced global variables 333 # | 334 #------------------------------------------------------- 335 getObjectDirectoryFeedback(isFeedback) = 336 return $(makeDirectory $(getModuleObjectsSubDirectoryOf $(CWD))$(DIRSEP)$(getTargetSubDirectory false)) 337 338 #------------------------------------------------------- 339 # getLibraryDirectory 340 # 341 # Overview 342 # | 343 # 344 # Referenced global variables 345 # INSTALL_ROOT, INSTALL_ROOT_LIBRARIES, 346 # HORIZON_ROOT_LIBRARIES 347 #------------------------------------------------------- 348 getLibraryDirectory(isInstall) = 349 if $(and $(isInstall), $(defined INSTALL_ROOT)) 350 return $(makeDirectory $(INSTALL_ROOT_LIBRARIES)$(DIRSEP)$(getTargetSubDirectory true)) 351 else 352 return $(makeDirectory $(HORIZON_ROOT_LIBRARIES)$(DIRSEP)$(getTargetSubDirectory true)) 353 354 #------------------------------------------------------- 355 # isTestBuild 356 # 357 # Overview 358 # | 359 # 360 # Referenced global variables 361 # BUILD_TESTS 362 #------------------------------------------------------- 363 isTestBuild() = 364 if $(not $(defined BUILD_TESTS)) 365 return false 366 else 367 return $(BUILD_TESTS) 368 369 #------------------------------------------------------- 370 # getOutputBaseDirectory 371 # 372 # Overview 373 # | 374 # 375 # Referenced global variables 376 # None. 377 #------------------------------------------------------- 378 getOutputBaseDirectory() = 379 return $(getOutputBaseDirectory) 380 381 #------------------------------------------------------- 382 # getImageDirectory 383 # 384 # Overview 385 # | 386 # 387 # Referenced global variables 388 # INSTALL_ROOT_IMAGES, INSTALL_ROOT 389 #------------------------------------------------------- 390 getImageDirectory(isInstall) = 391 private.module_dir = $(getModuleSubDirectory)$(DIRSEP) 392 private.images_dir = $(EMPTY) 393 394 if $(and $(isInstall), $(defined INSTALL_ROOT)) 395 images_dir = $(INSTALL_ROOT_IMAGES) 396 export images_dir 397 else 398 export module_dir images_dir 399 private.base_dir = $(getOutputBaseDirectory) 400 if $(equal ., $(base_dir)) 401 module_dir = 402 images_dir = $(base_dir)$(DIRSEP)$(SUBDIR_IMAGES) 403 404 return $(makeDirectory $(images_dir)$(DIRSEP)$(module_dir)$(getTargetSubDirectory false)) 405 406 #------------------------------------------------------- 407 # getImageDirectoryOf 408 # 409 # Overview 410 # | 411 # 412 # Referenced global variables 413 # None. 414 #------------------------------------------------------- 415 getImageDirectoryOf(target_dir) = 416 private.images_dir = $(getModuleImageSubDirectoryOf $(target_dir)) 417 return $(dir $(images_dir)$(DIRSEP)$(getTargetSubDirectory false)) 418 419 #------------------------------------------------------- 420 # isSdkTool 421 # 422 # Overview 423 # | 424 # 425 # Referenced global variables 426 # INSTALL_SDK_TOOL 427 #------------------------------------------------------- 428 isSdkTool() = 429 return false 430 431 432 #------------------------------------------------------- 433 # getOptimizeType 434 # 435 # Overview 436 # | 437 # 438 # Referenced global variables 439 # None. 440 #------------------------------------------------------- 441 getOptimizeType() = 442 private.opttype = 443 switch($(buildtype)) 444 case Debug 445 value noopt 446 case Development 447 value verbose 448 case Release 449 value release 450 default 451 value etc 452 return $(opttype) 453 454 #------------------------------------------------------- 455 # getTargetSubDirectory 456 # 457 # Overview 458 # | 459 # 460 # Referenced global variables 461 # None. 462 #------------------------------------------------------- 463 getTargetSubDirectory(isLibrary) = 464 private.subdir = $(hardware).$(systemname).$(processor) 465 if $(isLibrary) 466 return $(subdir)$(DIRSEP)$(getOptimizeType) 467 else 468 return $(subdir).$(effort)$(DIRSEP)$(buildtype) 469 470 #------------------------------------------------------- 471 # getLibraryName 472 # 473 # Overview 474 # | 475 # 476 # Referenced global variables 477 # None. 478 #------------------------------------------------------- 479 getLibraryName(name) = 480 return $(name).$(effort)$(EXT_LIB) 481 482 #------------------------------------------------------- 483 # getStaticObjectName 484 # 485 # Overview 486 # | 487 # 488 # Referenced global variables 489 # None. 490 #------------------------------------------------------- 491 getStaticObjectName(name) = 492 return $(basename $(name)).$(effort)$(EXT_OBJ) 493 494 #------------------------------------------------------- 495 # getLdscriptPath 496 # 497 # Overview 498 # | 499 # 500 # Referenced global variables 501 # None. 502 #------------------------------------------------------- 503 getLdscriptPath(name) = 504 return $(getBinaryPath $(name), $(EXT_LDS)) 505 506 #------------------------------------------------------- 507 # getMapfilePath 508 # 509 # Overview 510 # | 511 # 512 # Referenced global variables 513 # None. 514 #------------------------------------------------------- 515 getMapfilePath(name) = 516 return $(getBinaryPath $(name), $(EXT_MAP)) 517 518 #------------------------------------------------------- 519 # getDefaultLdscriptPath 520 # 521 # Overview 522 # | 523 # 524 # Referenced global variables 525 # None. 526 #------------------------------------------------------- 527 getDefaultLdscriptPath() = 528 private.base = $(makePath $(ROOT_RESOURCES) specfiles linker $(platform).$(systemname).$(processor)) 529 return $(file $(base).ldscript) 530 531 #------------------------------------------------------- 532 # getFeedBackPath 533 # 534 # Overview 535 # | 536 # 537 # Referenced global variables 538 # None. 539 #------------------------------------------------------- 540 getFeedBackPath() = 541 return $(file $(getImageDirectory false)$(DIRSEP)$(getOutputFilename feedback, .dat)) 542 543 #------------------------------------------------------- 544 # getBinaryPath 545 # 546 # Overview 547 # | 548 # 549 # Referenced global variables 550 # None. 551 #------------------------------------------------------- 552 getBinaryPath(name, suffix) = 553 return $(file $(getImageDirectory false)$(DIRSEP)$(getOutputFilename $(name), $(suffix))) 554 555 #------------------------------------------------------- 556 # getBinaryPathOf 557 # 558 # Overview 559 # | 560 # 561 # Referenced global variables 562 # None. 563 #------------------------------------------------------- 564 getBinaryPathOf(target_dir, name, suffix) = 565 private.sub_dir = $(getModuleImageSubDirectoryOf $(target_dir)) 566 private.img_dir = $(dir $(sub_dir)$(DIRSEP)$(getTargetSubDirectory false)) 567 return $(file $(img_dir)$(DIRSEP)$(getOutputFilename $(name), $(suffix))) 568 569 #------------------------------------------------------- 570 # getDefaultDescriptorPath 571 # 572 # Overview 573 # | 574 # 575 # Referenced global variables 576 # None. 577 #------------------------------------------------------- 578 getDefaultDescriptorPath() = 579 return $(file $(ROOT_RESOURCES)$(DIRSEP)specfiles$(DIRSEP)Application.desc) 580 581 #------------------------------------------------------- 582 # getDefaultRomSpecFile 583 # 584 # Overview 585 # | 586 # 587 # Referenced global variables 588 # TARGET_MANAGER 589 #------------------------------------------------------- 590 getDefaultRomSpecFile() = 591 private.spec = $(TARGET_MANAGER.getSpecByHardware $(hardware)) 592 return $(file $(ROOT_RESOURCES)$(DIRSEP)specfiles$(DIRSEP)$(spec.getDefaultRomSpecFile $(hardware))) 593 594 #------------------------------------------------------- 595 # getDefaultBannerFile 596 # 597 # Overview 598 # | 599 # 600 # Referenced global variables 601 # None. 602 #------------------------------------------------------- 603 getDefaultBannerFile() = 604 return $(ROOT_RESOURCES)$(DIRSEP)banner$(DIRSEP)Default.bnr 605 606 #------------------------------------------------------- 607 # getDefaultIconFile 608 # 609 # Overview 610 # | 611 # 612 # Referenced global variables 613 # None. 614 #------------------------------------------------------- 615 getDefaultIconFile() = 616 return $(ROOT_RESOURCES)$(DIRSEP)banner$(DIRSEP)Default.icn 617 618 #------------------------------------------------------- 619 # getOutputFilename 620 # 621 # Overview 622 # | 623 # 624 # Referenced global variables 625 # None. 626 #------------------------------------------------------- 627 getOutputFilename(name, suffix) = 628 return $(name)$(suffix) 629 630 #------------------------------------------------------- 631 # getSystemCCFlags 632 # 633 # Overview 634 # | 635 # 636 # Referenced global variables 637 # TARGET_MANAGER 638 #------------------------------------------------------- 639 getSystemCCFlags() = 640 private.spec = $(TARGET_MANAGER.getSpecByHardware $(hardware)) 641 return $(spec.getSystemFlags $(systemname)) 642 643 #------------------------------------------------------- 644 # getMinimumLibraries 645 # 646 # Overview 647 # | 648 # 649 # Referenced global variables 650 # TARGET_MANAGER 651 #------------------------------------------------------- 652 getMinimumLibraries() = 653 private.spec = $(TARGET_MANAGER.getSpecByHardware $(hardware)) 654 return $(spec.getMinimumLibraries $(systemname), $(processor)) 655 656 #------------------------------------------------------- 657 # getDefaultLibraries 658 # 659 # Overview 660 # | 661 # 662 # Referenced global variables 663 # TARGET_MANAGER 664 #------------------------------------------------------- 665 getDefaultLibraries() = 666 private.spec = $(TARGET_MANAGER.getSpecByHardware $(hardware)) 667 return $(spec.getDefaultLibraries $(systemname), $(processor)) 668 669 #------------------------------------------------------- 670 # getHostIoLibraries 671 # 672 # Overview 673 # | 674 # 675 # Referenced global variables 676 # TARGET_MANAGER 677 #------------------------------------------------------- 678 getHostIoLibraries() = 679 private.spec = $(TARGET_MANAGER.getSpecByHardware $(hardware)) 680 return $(spec.getHostIoLibraries $(systemname), $(processor)) 681 682 #------------------------------------------------------- 683 # getMacroFlags 684 # 685 # Overview 686 # | 687 # 688 # Referenced global variables 689 # TARGET_MANAGER 690 #------------------------------------------------------- 691 getMacroFlags() = 692 private.spec = $(TARGET_MANAGER.getSpecByHardware $(hardware)) 693 return $(spec.getMacroFlags $(systemname), $(processor)) 694 695 #------------------------------------------------------- 696 # matches 697 # 698 # Overview 699 # | 700 # 701 # Referenced global variables 702 # None. 703 #------------------------------------------------------- 704 matches(varvalue, pattern) = 705 private.regex = compileToRegex($(pattern)) 706 match($(varvalue)) 707 case $(pattern) 708 return true 709 default 710 return false 711 712 #------------------------------------------------------- 713 # isHostIoEnable 714 # 715 # Overview 716 # | 717 # 718 # Referenced global variables 719 # HOST_IO_DEFAULT, HOST_IO 720 #------------------------------------------------------- 721 isHostIoEnable() = 722 if $(equal $(buildtype),Release) 723 HOST_IO_DEFAULT = false 724 export 725 else 726 HOST_IO_DEFAULT = true 727 export 728 729 if $,(HOST_IO) 730 return true 731 else 732 return false 733 734 #------------------------------------------------------- 735 # isFilterMatched 736 # 737 # Overview 738 # | 739 # 740 # Referenced global variables 741 # None. 742 #------------------------------------------------------- 743 isFilterMatched() = 744 return $(matched) 745 746HardwareTargetConfig. = 747 extends $(TargetConfig) 748 class HardwareTargetConfig 749 750 #---------------------------------------------------------------------------- 751 # Function definitions 752 #---------------------------------------------------------------------------- 753 754 #------------------------------------------------------- 755 # New. 756 # 757 # Overview 758 # | 759 # 760 # Referenced global variables 761 # None. 762 #------------------------------------------------------- 763 new() = 764 return $(this) 765 766 #------------------------------------------------------- 767 # getFullname 768 # 769 # Overview 770 # | 771 # 772 # Referenced global variables 773 # None. 774 #------------------------------------------------------- 775 getFullname() = 776 return $(hardware).$(effort) 777 778 #------------------------------------------------------- 779 # getFullnameDetailed 780 # 781 # Overview 782 # | 783 # 784 # Referenced global variables 785 # None. 786 #------------------------------------------------------- 787 getFullnameDetailed(altsystemname, altprocessor) = 788 return $(hardware).$(altsystemname).$(altprocessor).$(effort) 789 790 #------------------------------------------------------- 791 # getTargetSubDirectory 792 # 793 # Overview 794 # | 795 # 796 # Referenced global variables 797 # None. 798 #------------------------------------------------------- 799 getTargetSubDirectory(isLibrary) = 800 if $(isLibrary) 801 return $(hardware)$(DIRSEP)$(getOptimizeType) 802 else 803 return $(hardware).$(effort)$(DIRSEP)$(buildtype) 804 805TargetManager. = 806 class TargetManager 807 808 #---------------------------------------------------------------------------- 809 # Variable Definitions 810 #---------------------------------------------------------------------------- 811 812 this.tmap = $(EMPTY) 813 814 815 816 #---------------------------------------------------------------------------- 817 # Function definitions 818 #---------------------------------------------------------------------------- 819 820 #------------------------------------------------------- 821 # New. 822 # 823 # Overview 824 # | 825 # 826 # Referenced global variables 827 # None. 828 #------------------------------------------------------- 829 new() = 830 this.tmap = $(Map) 831 return $(this) 832 833 #------------------------------------------------------- 834 # register 835 # 836 # Overview 837 # | 838 # 839 # Referenced global variables 840 # None. 841 #------------------------------------------------------- 842 register(target) = 843 tmap = $(tmap.add $(target.hardware), $(target)) 844 return $(this) 845 846 #------------------------------------------------------- 847 # dump 848 # 849 # Overview 850 # | 851 # 852 # Referenced global variables 853 # None. 854 #------------------------------------------------------- 855 dump() = 856 tmap.foreach(k, v) 857 v.dump() 858 859 #------------------------------------------------------- 860 # getProcessors 861 # 862 # Overview 863 # | 864 # 865 # Referenced global variables 866 # None. 867 #------------------------------------------------------- 868 getProcessors(hardware) = 869 spec = $(getSpecByHardware $(hardware)) 870 return $(spec.processors) 871 872 #------------------------------------------------------- 873 # getHardwares 874 # 875 # Overview 876 # | 877 # 878 # Referenced global variables 879 # None. 880 #------------------------------------------------------- 881 getHardwares() = 882 return $(tmap.keys) 883 884 #------------------------------------------------------- 885 # getPlatform 886 # 887 # Overview 888 # | 889 # 890 # Referenced global variables 891 # None. 892 #------------------------------------------------------- 893 getPlatform(hardware) = 894 private.spec = $(getSpecByHardware $(hardware)) 895 return $(spec.platform) 896 897 #------------------------------------------------------- 898 # getSpecByHardware 899 # 900 # Overview 901 # | 902 # 903 # Referenced global variables 904 # None. 905 #------------------------------------------------------- 906 getSpecByHardware(hardware) = 907 return $(tmap.find $(hardware)) 908 909 #------------------------------------------------------- 910 # collectTargetValues 911 # 912 # Overview 913 # | 914 # 915 # Referenced global variables 916 # None. 917 #------------------------------------------------------- 918 collectTargetValues(getter) = 919 private.values = $(tmap.map $(fun k,V,$(apply $(getter), $(V)))) 920 return $(set $(values)) 921 922 #------------------------------------------------------- 923 # enumerateTargets 924 # 925 # Overview 926 # Add target build information from SUPPORTED_TARGETS(filterstrings) and TARGET_FILTER to TARGET_LIST. 927 # 928 # 929 # Referenced global variables 930 # TARGET_FILTER, TARGETS_LIST, TARGET_BUILDTYPES 931 # MATCHED_FAST 932 #------------------------------------------------------- 933 enumerateTargets(filterstrings, ignoreFastSmall, system_list) = 934 private.regex = $(compileToRegex $(filterstrings)) 935 private.regex_global = $(compileToRegex $(TARGET_FILTER)) 936 private.hardwares = $(getHardwares) 937 TARGETS_LIST = $(EMPTY) 938 939 foreach(buildtype, $(TARGET_BUILDTYPES)) 940 export TARGETS_LIST 941 942 foreach(hardware, $(hardwares)) 943 foreach(systemname, $(system_list)) 944 foreach(processor, $(getProcessors $(hardware))) 945 MATCHED_FAST = false 946 export MATCHED_FAST 947 948 foreach(effort, fast small) 949 private.full_name = $"$(hardware).$(systemname).$(processor).$(effort)" 950 951 if $(and $(isFilterMatch $(regex), $(full_name)), $(isFilterMatch $(regex_global), $(full_name))) 952 private.tgt = $(TargetConfig.new) 953 tgt.platform = $(getPlatform $(hardware)) 954 tgt.hardware = $(hardware) 955 tgt.systemname = $(systemname) 956 tgt.processor = $(processor) 957 tgt.effort = $(effort) 958 tgt.buildtype = $(buildtype) 959 960 TARGETS_LIST += $(tgt) 961 962 if $(equal $(effort), fast) 963 MATCHED_FAST = true 964 elseif $(and $(not $(MATCHED_FAST)), $(ignoreFastSmall)) 965 tgt.effort = fast 966 tgt.matched = false 967 968 TARGETS_LIST += $(tgt) 969 970 elseif $(and $(MATCHED_FAST), $(ignoreFastSmall)) 971 private.tgt = $(TargetConfig.new) 972 tgt.platform = $(getPlatform $(hardware)) 973 tgt.hardware = $(hardware) 974 tgt.systemname = $(systemname) 975 tgt.processor = $(processor) 976 tgt.effort = small 977 tgt.buildtype = $(buildtype) 978 tgt.matched = false 979 980 TARGETS_LIST += $(tgt) 981 return $(TARGETS_LIST) 982 983 #------------------------------------------------------- 984 # enumerateHardwareTargets 985 # 986 # Overview 987 # | 988 # 989 # Referenced global variables 990 # TARGETS_LIST 991 #------------------------------------------------------- 992 enumerateHardwareTargets(filterstrings) = 993 private.regex = $(compileToRegex $(filterstrings)) 994 private.regex_global = $(compileToRegex $(TARGET_FILTER)) 995 private.hardwares = $(getHardwares) 996 TARGETS_LIST = $(EMPTY) 997 998 foreach(buildtype, $(TARGET_BUILDTYPES)) 999 export TARGETS_LIST 1000 1001 foreach(hardware, $(hardwares)) 1002 foreach(effort, fast small) 1003 private.full_name = $"$(hardware).$(effort)" 1004 1005 if $(and $(isFilterMatch $(regex), $(full_name)), $(isFilterMatch $(regex_global), $(full_name))) 1006 private.tgt = $(HardwareTargetConfig.new) 1007 tgt.platform = $(getPlatform $(hardware)) 1008 tgt.hardware = $(hardware) 1009 tgt.effort = $(effort) 1010 tgt.buildtype = $(buildtype) 1011 1012 TARGETS_LIST += $(tgt) 1013 1014 return $(TARGETS_LIST) 1015 1016 #------------------------------------------------------- 1017 # isFilterMatch 1018 # 1019 # Overview 1020 # | 1021 # 1022 # Referenced global variables 1023 # None. 1024 #------------------------------------------------------- 1025 isFilterMatch(regex, full_name) = 1026 match $(full_name) 1027 case $(regex) 1028 return true 1029 default 1030 return false 1031 1032Builder. = 1033 class Builder 1034 1035 #---------------------------------------------------------------------------- 1036 # Variable Definitions 1037 #---------------------------------------------------------------------------- 1038 1039 this.manager = $(EMPTY) 1040 1041 1042 1043 #---------------------------------------------------------------------------- 1044 # Function definitions 1045 #---------------------------------------------------------------------------- 1046 1047 #------------------------------------------------------- 1048 # New. 1049 # 1050 # Overview 1051 # | 1052 # 1053 # Referenced global variables 1054 # None. 1055 #------------------------------------------------------- 1056 new(manager) = 1057 this.manager = $(manager) 1058 return $(this) 1059 1060 #------------------------------------------------------- 1061 # getTargets 1062 # 1063 # Overview 1064 # | 1065 # 1066 # Referenced global variables 1067 # None. 1068 #------------------------------------------------------- 1069 getTargets(targetfilters) = 1070 return $(manager.enumerateTargets $(targetfilters), false, Kernel Process) 1071 1072 #------------------------------------------------------- 1073 # getLibraryTargets 1074 # 1075 # Overview 1076 # | 1077 # 1078 # Referenced global variables 1079 # None. 1080 #------------------------------------------------------- 1081 getLibraryTargets(targetfilters) = 1082 return $(manager.enumerateTargets $(targetfilters), true, Kernel Process) 1083 1084 #------------------------------------------------------- 1085 # getHardwareTargets 1086 # 1087 # Overview 1088 # | 1089 # 1090 # Referenced global variables 1091 # None. 1092 #------------------------------------------------------- 1093 getHardwareTargets(targetfilters) = 1094 return $(manager.enumerateHardwareTargets $(targetfilters)) 1095 1096 #------------------------------------------------------- 1097 # getToolTargets 1098 # 1099 # Overview 1100 # | 1101 # 1102 # Referenced global variables 1103 # TARGET_FILTER 1104 #------------------------------------------------------- 1105 getToolTargets(targetfilters) = 1106 TARGET_FILTER = WIN-IA32.* 1107 SYSTEM_LIST = Tool 1108 return $(manager.enumerateTargets *) 1109 1110 #------------------------------------------------------- 1111 # go 1112 # 1113 # Overview 1114 # | 1115 # 1116 # Referenced global variables 1117 # TARGET 1118 #------------------------------------------------------- 1119 go(targetfilters, verb) = 1120 result = 1121 configs = $(getTargets $(targetfilters)) 1122 foreach(TARGET, $(configs)) 1123 result += $,(verb)) 1124 export 1125 return $(result) 1126 1127 #------------------------------------------------------- 1128 # dumpConfigList 1129 # 1130 # Overview 1131 # | 1132 # 1133 # Referenced global variables 1134 # None. 1135 #------------------------------------------------------- 1136 dumpConfigList(configs) = 1137 foreach(config, $(configs)) 1138 config.dump() 1139 1140 1141 1142#---------------------------------------------------------------------------- 1143# Variable Definitions 1144#---------------------------------------------------------------------------- 1145 1146global.TARGET_MANAGER = $(TargetManager.new) 1147 1148 1149 1150#---------------------------------------------------------------------------- 1151# Load target definitions 1152#---------------------------------------------------------------------------- 1153 1154# Load unlabeled first 1155foreach(om,$(ls $(ROOT_OMAKE)/platforms/$(TARGET_PLATFORM.Name)/$(TARGET_PLATFORM.Name).targetdefs.om)) 1156 include $(removesuffix $(om)) 1157 export 1158 1159# Load options next 1160foreach(om,$(ls i,$(ROOT_OMAKE)/platforms/$(TARGET_PLATFORM.Name)/$(TARGET_PLATFORM.Name).targetdefs.*.om)) 1161 include $(removesuffix $(om)) 1162 export 1163 1164global.BUILDER = $(Builder.new $(TARGET_MANAGER)) 1165 1166