Changeset 688 in kBuild
- Timestamp:
- Dec 8, 2006 5:44:22 AM (18 years ago)
- Location:
- trunk/kBuild
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kBuild/footer.kmk
r682 r688 103 103 _UNPACKS := 104 104 _PATCHES := 105 _UNFETCHES:= 105 106 _BLDPROGS := 106 107 _LIBS := … … 603 604 604 605 605 # 606 # Fetching Tools, Sources and Similar. 607 # 606 ## @page pg_fetches Fetching Tools, Sources and Similar. 607 # 608 # The targets listed in the the FETCHES target list have the following attributes: 609 # SOURCES 610 # INST 611 # FETCHTOOL 612 # FETCHFLAGS 613 # FETCHDIR 614 # UNPACKTOOL 615 # UNPACKFLAGS 616 # 617 # As usual the target name is an alias for 'creating' the target. Other 618 # aliases are: 619 # pass_fetches 620 # fetch 621 # unfetch 622 # download 623 # unpack 624 # 625 # @remark 626 # 627 # This is a little bit complex because we must guarantee that if a source file 628 # changes only sligtly we must refetch it and to a proper unpacking of it. It 629 # is also a desire that fetched archives and unpacked files can be deleted to 630 # save space. 631 # 632 # Thus, we must be able to cleanup what we've unpacked should any of the 633 # sources be removed. We do this by maintaining a file listing the files 634 # and directories that was unpacked. This operation is named 'unfetch'. 635 # 636 # We make use of the SIZE and MD5 attributes for each of the sources to 637 # construct a primary goal. Should any sources change only sligtly this 638 # name will change and we'll have to remake it. Upon remaking we will 639 # perform an 'unfetch' to remove old unpacked files. 640 # 641 # By not depending directly on the archives (nor on any unpacked files) 642 # but on a goal made up from the archive name, size and md5, we allow 643 # the user to delete the archives. Naturally, this means we'll have to 644 # check and fetch missing archives before attempting to unpack them. 645 # 646 # TODOs: 647 # 1. Port md5sum or some equivalent tool and include it in kBuild. 648 # 2. Download corruption / continuation. 649 # 3. It's quite possible that there is one too many indirect dependency now... 650 # 651 652 ## @todo move this! 608 653 MD5SUM := md5sum 609 654 … … 613 658 .PRECIOUS: $(out) 614 659 $(out) $($(target)_$(srcname)_FETCH_OUTPUT_): | $($(target)_$(srcname)_FETCH_DEPORD_) 615 @$(ECHO) Downloading $(source)... 616 $$(RM) -f $(out) $(out).md5 ## @todo fancy stuff like download continuation 660 @$$(ECHO) Downloading $(source)... 661 ## @todo do fancy stuff like download continuation. 662 $$(RM) -f $(out) $(out).md5 617 663 $($(target)_$(srcname)_FETCH_CMDS_) 618 664 @$(if $(md5),$$(APPEND) $(out).md5 "$(md5) *$(out)") … … 623 669 # Intermediate goal for making sure the md5 and size matches. it will (re) fetch the archive if necessary. 624 670 $(out).checked_$(md5)_$(size): $($(target)_$(srcname)_FETCH_DEPEND_) | $($(target)_$(srcname)_FETCH_DEPORD_) 625 @$ (ECHO) Checking $(out) ($(source))...671 @$$(ECHO) Checking $(out) ($(source))... 626 672 $$(RM) -f $$@ $(out).md5 627 673 @# creates the .md5 we pass to md5sum. 628 @$(if $(md5),$(APPEND) $(out).md5 "$(md5) *$(out)") 629 @# if the file exists, perform md5sum, otherwise just fetch it. 630 $(if $(wildcard $(out)),\ 631 $(MD5SUM) -c $(out).md5 || ( $(RM_EXT) -f $(out) && $(MAKE) -f $(MAKEFILE) $(out) ),\ 632 $(MAKE) -f $(MAKEFILE) $(out) ) 633 @$(APPEND) $$@ 634 635 _TARGET_$(target)_FETCHED += $(out).checked_$(md5)_$(size) 674 @$(if $(md5),$$(APPEND) $(out).md5 "$(md5) *$(out)") 675 @# (re)fetch the file if it doesn't exist or if it doesn't matches the md5. 676 ## @todo do fancy stuff like download continuation. 677 ( test -f $(out) && $(if $(md5),$$(MD5SUM) -c $(out).md5, true) ) \ 678 || ( $$(RM_EXT) -f $(out) \ 679 && $$(MAKE) $(out) -f $(MAKEFILE) ) 680 @$$(APPEND) $$@ 681 682 _TARGET_$(target)_FETCHED += $(out) $(out).checked_$(md5)_$(size) 683 684 # Just a little precaution. 685 .NOTPARALLEL: $(out) $(out).checked_$(md5)_$(size) 636 686 637 687 endef … … 639 689 ## generates the unpack rule 640 690 define def_fetch_src_unpack_rule 641 #$ (warning def_fetch_src_unpack_rule: source=$(source))642 643 691 # This is the unpack rule. it has an order-only dependency on the download check. 644 692 $(out) $($(target)_$(srcname)_UNPACK_OUTPUT_): $($(target)_$(srcname)_UNPACK_DEPEND_) \ 645 693 | $($(target)_$(srcname)_UNPACK_DEPORD_) $(archive).checked_$(md5)_$(size) 646 @$ (ECHO) Unpacking $(source) into $(inst)...694 @$$(ECHO) Unpacking $(source) into $(inst)... 647 695 $$(RM) -f $(out) 696 @# if the source archive doesn't exist fetch it (can have been deleted to save space). 697 test -f $(archive) \ 698 || ( $$(RM_EXT) -f $(archive).checked_$(md5)_$(size) \ 699 && $$(MAKE) $(archive).checked_$(md5)_$(size) -f $(MAKEFILE) ) 648 700 $($(target)_$(srcname)_UNPACK_CMDS_) 649 @$ (APPEND) $(out) $(out)650 @$ (APPEND) $(out) $(out).check_$(md5)_$(size)701 @$$(APPEND) $(out) $(notdir $(archive).checked_$(md5)_$(size)) 702 @$$(APPEND) $(out) $(notdir $(out)) 651 703 652 704 $(eval _TARGET_$(target)_UNPACKED += $(out)) 653 705 _TARGET_$(target)_DIGEST := $(_TARGET_$(target)_DIGEST)-$(srcname)_$(md5)_$(size) 706 707 .NOTPARALLEL: $(out) 654 708 655 709 endef … … 827 881 # @param out 828 882 # @param inst 829 # @param _TARGET_$(target)_FETCHED... 883 # @param _TARGET_$(target)_UNPACKED 884 # @param _TARGET_$(target)_DIGEST 830 885 # @param bld_trg 831 886 # @param bld_trg_arch … … 833 888 834 889 $(out): $(_TARGET_$(target)_UNPACKED) | $(call DIRDEP,$(inst)) 835 @$ (ECHO) Successfully fetched $(target)836 $ (RM) -f $$@ [email protected]837 @$ (APPEND) [email protected] ""838 $(if $(_TARGET_$(target)_UNPACKED),$ (CAT_EXT) $(_TARGET_$(target)_UNPACKED) >> [email protected])839 $ (MV) -f [email protected] $$@890 @$$(ECHO) Successfully fetched $(target) 891 $$(RM) -f $$@ [email protected] 892 @$$(APPEND) [email protected] "$(notdir $(out).$(_TARGET_$(target)_DIGEST))" 893 $(if $(_TARGET_$(target)_UNPACKED),$$(CAT_EXT) $(_TARGET_$(target)_UNPACKED) >> [email protected]) 894 $$(MV) -f [email protected] $$@ 840 895 841 896 $(out)_unfetched: 842 @$(ECHO) Unfetching $(target)... 843 $(RM) -f $$(shell $$(CAT_EXT) $(out) 2> /dev/null) 844 # figure out how to make this quiet... 845 -$(RMDIR) -p $(dir $(out)) $$(sort $$(dir $$(shell $$(CAT_EXT) $(out) 2> /dev/null))) 846 $(RM) -f $(out) 847 -$(RMDIR) -p $(dir $(out)) 897 @$$(ECHO) Unfetching $(target)... 898 $$(RM) -f $$(addprefix $(inst),$$(shell $$(CAT_EXT) $(out) 2> /dev/null | $$(SED) -e '/\/$$$$/d')) 899 $$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $$(dir $(out)) \ 900 $$(addprefix $(inst),$$(sort $$(dir $$(shell $$(CAT_EXT) $(out) 2> /dev/null)))) 901 $$(RM) -f $(out) 902 $$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $$(dir $(out)) 903 904 $(out).$(_TARGET_$(target)_DIGEST): | $(call DIRDEP,$(inst)) 905 @$$(RM) -f $(out).$(_TARGET_$(target)_DIGEST) 906 @$$(ECHO) $$(if $$(wildcard $(out)),Re-fetching,Fetching) $(target)... 907 $$(if $$(wildcard $(out)),$$(MAKE) -f $(MAKEFILE) $(out)_unfetched) 908 $$(MAKE) -f $(MAKEFILE) $(out) 909 $$(APPEND) $$@ "" 910 911 $(target):: $(out).$(_TARGET_$(target)_DIGEST) 912 913 .NOTPARALLEL: $(out) $(out)_unfetched $(out).$(_TARGET_$(target)_DIGEST) 848 914 849 915 endef … … 878 944 $(eval $(def_fetch_rules)) 879 945 880 _FETCHES += $(out) 946 _FETCHES += $(out).$(_TARGET_$(target)_DIGEST) 881 947 _DOWNLOADS += $(_TARGET_$(target)_FETCHED) 882 948 _UNPACKS += $(_TARGET_$(target)_UNPACKED) … … 894 960 # some aliases. 895 961 download: $(_DOWNLOADS) 896 unpack: $(_UNPACK )897 fetch es: $(_FETCHES)898 unfetch es: $(_UNFETCHES)962 unpack: $(_UNPACKS) 963 fetch: $(_FETCHES) 964 unfetch: $(_UNFETCHES) 899 965 900 966 … … 904 970 ## 905 971 ## 906 #define def_ fetch_src972 #define def_patch_src 907 973 # 908 974 #endef … … 913 979 # 914 980 #$(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),\ 915 # $(eval $(value def_patch_ one)))981 # $(eval $(value def_patch_src))) 916 982 # 917 983 #_PATCHES += -
trunk/kBuild/tools/TAR.kmk
r667 r688 52 52 define TOOL_TAR_UNPACK_CMDS 53 53 $(TOOL_TAR_UNPACK) -x $(flags) -C $(subst G:,,$(inst)) -f $(archive) 54 $(TOOL_TAR_UNPACK) -t $(flags) -f $(archive) | $(SED) -e 's|^|$(inst)|g'> $(out)54 $(TOOL_TAR_UNPACK) -t $(flags) -f $(archive) > $(out) 55 55 endef 56 56 else 57 57 define TOOL_TAR_UNPACK_CMDS 58 58 $(TOOL_TAR_UNPACK) -x $(flags) -C $(inst) -f $(archive) 59 $(TOOL_TAR_UNPACK) -t $(flags) -f $(archive) | $(SED) -e 's|^|$(inst)|g'> $(out)59 $(TOOL_TAR_UNPACK) -t $(flags) -f $(archive) > $(out) 60 60 endef 61 61 endif -
trunk/kBuild/tools/TARGZ.kmk
r667 r688 51 51 define TOOL_TARGZ_UNPACK_CMDS 52 52 $(TOOL_TARGZ_UNPACK) -x $(flags) -C $(inst) -f $(archive) 53 $(TOOL_TARGZ_UNPACK) -t $(flags) -f $(archive) | $(SED) -e 's|^|$(inst)|g'> $(out)53 $(TOOL_TARGZ_UNPACK) -t $(flags) -f $(archive) > $(out) 54 54 endef 55 55 -
trunk/kBuild/tools/ZIP.kmk
r681 r688 54 54 -e '/ [0-2][0-9]:[0-6][0-9]/!d' \ 55 55 -e 's/^.* [0-2][0-9]:[0-6][0-9] //' \ 56 -e 's|^|$(inst)|' \57 56 > $(out) 58 57 endef
Note:
See TracChangeset
for help on using the changeset viewer.