github.com/rkt/rkt@v1.30.1-0.20200224141603-171c416fac02/makelib/build_go_bin.mk (about)

     1  # inputs cleared after including this file:
     2  # BGB_STAMP
     3  # BGB_BINARY
     4  # BGB_GO_FLAGS
     5  # BGB_PKG_IN_REPO
     6  # BGB_ADDITIONAL_GO_ENV
     7  
     8  # inputs left alone:
     9  # DEPSDIR
    10  # DEPSGENTOOL
    11  # GOPATH
    12  # GO_ENV
    13  # MAKEFILE_LIST
    14  # REPO_PATH
    15  
    16  _BGB_PATH_ := $(lastword $(MAKEFILE_LIST))
    17  
    18  $(call setup-stamp-file,_BGB_GO_DEPMK_STAMP_,$(BGB_BINARY)/bgb-go-depmk)
    19  $(call setup-stamp-file,_BGB_KV_DEPMK_STAMP_,$(BGB_BINARY)/bgb-kv-depmk)
    20  
    21  # the gopath symlink creation rule should be generated only once, even
    22  # if we include this file multiple times.
    23  ifeq ($(_BGB_RKT_SYMLINK_STAMP_),)
    24  
    25  # the symlink stamp wasn't yet generated, do it now.
    26  
    27  _BGB_RKT_BASE_SYMLINK_ := src/$(REPO_PATH)
    28  _BGB_RKT_SYMLINK_NAME_ := $(GOPATH_TO_CREATE)/$(_BGB_RKT_BASE_SYMLINK_)
    29  
    30  $(call setup-custom-stamp-file,_BGB_RKT_SYMLINK_STAMP_,$(_BGB_PATH_)/rkt-symlink)
    31  
    32  $(call generate-stamp-rule,$(_BGB_RKT_SYMLINK_STAMP_),,$(_BGB_RKT_SYMLINK_NAME_))
    33  
    34  INSTALL_SYMLINKS += $(MK_TOPLEVEL_ABS_SRCDIR):$(_BGB_RKT_SYMLINK_NAME_)
    35  CREATE_DIRS += $(call dir-chain,$(GOPATH_TO_CREATE),$(call to-dir,$(_BGB_RKT_BASE_SYMLINK_)))
    36  
    37  endif
    38  
    39  _BGB_PKG_NAME_ := $(REPO_PATH)/$(BGB_PKG_IN_REPO)
    40  
    41  $(call setup-dep-file,_BGB_GO_DEPMK,$(_BGB_PKG_NAME_))
    42  $(call setup-dep-file,_BGB_KV_DEPMK,$(_BGB_PKG_NAME_)/kv)
    43  
    44  $(call forward-vars,$(BGB_BINARY), \
    45  	BGB_ADDITIONAL_GO_ENV GO_ENV GO BGB_GO_FLAGS _BGB_PKG_NAME_)
    46  
    47  ifeq ($(INCREMENTAL_BUILD),yes)
    48  
    49  $(BGB_BINARY): $(_BGB_PATH_) $(_BGB_RKT_SYMLINK_STAMP_)
    50  	$(VQ) \
    51  	$(call vb,vt,GO,$(call vsg,$(_BGB_PKG_NAME_))) \
    52  	$(GO_ENV) $(BGB_ADDITIONAL_GO_ENV) GOBIN=$(dir $(@)) "$(GO)" install -pkgdir $(GOPATH)/pkg $(call v3,-v -x) $(BGB_GO_FLAGS) "$(_BGB_PKG_NAME_)"
    53  
    54  else
    55  
    56  $(BGB_BINARY): $(_BGB_PATH_) $(_BGB_RKT_SYMLINK_STAMP_)
    57  	$(VQ) \
    58  	$(call vb,vt,GO,$(call vsg,$(_BGB_PKG_NAME_))) \
    59  	$(GO_ENV) $(BGB_ADDITIONAL_GO_ENV) "$(GO)" build $(call v3,-v -x) -o "$@" $(BGB_GO_FLAGS) "$(_BGB_PKG_NAME_)"
    60  
    61  endif
    62  
    63  $(call generate-go-deps,$(_BGB_GO_DEPMK_STAMP_),$(BGB_BINARY),$(_BGB_GO_DEPMK),$(BGB_PKG_IN_REPO))
    64  $(call generate-kv-deps,$(_BGB_KV_DEPMK_STAMP_),$(BGB_BINARY),$(_BGB_KV_DEPMK),BGB_GO_FLAGS)
    65  
    66  $(BGB_STAMP): $(BGB_BINARY) $(_BGB_GO_DEPMK_STAMP_) $(_BGB_KV_DEPMK_STAMP_)
    67  
    68  # _BGB_RKT_SYMLINK_STAMP_ is deliberately not cleared - it needs to
    69  # stay defined to make sure that the gopath symlink rule is generated
    70  # only once.
    71  $(call undefine-namespaces,BGB _BGB,_BGB_RKT_SYMLINK_STAMP_)