最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】gitbook的makefile根据当前用户是自己而自动开启代理

gitbook crifan 3698浏览 0评论
/Users/crifan/dev/dev_root/gitbook/GitbookTemplate/gitbook_template/common/gitbook_makefile.mk
# ENABLE_COMMIT_GITHUB_IO = false
ENABLE_COMMIT_GITHUB_IO = true


ifeq ($(ENABLE_COMMIT_GITHUB_IO), true)
# if need commit, enable and change to yours path
GITHUB_IO_PATH=/Users/crifan/dev/dev_root/github/github.io/crifan.github.io
# GITHUB_IO_PATH=/Users/xxx/dev/crifan/crifan.github.io


# ENABLE_UPDATE_GITHUB_IO_README = false
ENABLE_UPDATE_GITHUB_IO_README = true
endif


# ENABLE_RSYNC_PROXY = false
ENABLE_RSYNC_PROXY = true


ifeq ($(ENABLE_RSYNC_PROXY), true)
# for rsync use sock5 proxy
PROXY_SOCK5 = 127.0.0.1:51837
RSYNC_PROXY = -e "ssh -o 'ProxyCommand nc -X 5 -x $(PROXY_SOCK5) %h %p' -o ServerAliveInterval=30 -o ServerAliveCountMax=5"
else
# for rsync not use any proxy
RSYNC_PROXY = 
endif
改为:
根据当前用户 是否是我自己:
 crifan@licrifandeMacBook-Pro  ~/dev/dev_root/gitbook/GitbookTemplate/gitbook_template   master  whoami    
crifan
自动开启代理
makefile ifeq or
Makefile ifeq logical or – Stack Overflow
ifeq ($(GCC_MINOR),4)
    @echo Supported version
else ifeq ($(GCC_MINOR),5)
    @echo Supported version
else
    @echo Unsupported version
endif
可以用else
学习笔记:Makefile的ifeq逻辑或,逻辑与的变通实现_fanchenxinok的专栏-CSDN博客_ifeq
     2) 逻辑或变通实现,同样是上面的两个变量
         if( VALUE1 == V1 || VALUE2 == V2 ) {...} 可以用findstring函数做如下变通实现:
         #如果VALUE1或者VALUE2为V1或V2,则findstring 不会返回空。
         ifneq ($(findstring $(VALUE1)$(VALUE2),  V1  V2),)
            do something...
         endif
linux – Makefile OR condition – Stack Overflow
ifneq ($(filter on,$(TAG1) $(TAG2)),)
LD_FLAGS += -ltestlibrary
endif
用:
CURRENT_USER  := $(shell whoami)
$(info CURRENT_USER=$(CURRENT_USER))
ifeq ($(CURRENT_USER), "crifan")
ENABLE_COMMIT_GITHUB_IO = true
ENABLE_RSYNC_PROXY = true
else ifeq ($(CURRENT_USER), "xxx")
ENABLE_COMMIT_GITHUB_IO = true
ENABLE_RSYNC_PROXY = true
endif
$(info ENABLE_COMMIT_GITHUB_IO=$(ENABLE_COMMIT_GITHUB_IO))
$(info ENABLE_RSYNC_PROXY=$(ENABLE_RSYNC_PROXY))
结果:
CURRENT_USER=crifan
ENABLE_COMMIT_GITHUB_IO=false
ENABLE_RSYNC_PROXY=false
去掉引号
CURRENT_USER  := $(shell whoami)
$(info CURRENT_USER=$(CURRENT_USER))
ifeq ($(CURRENT_USER), crifan)
ENABLE_COMMIT_GITHUB_IO = true
ENABLE_RSYNC_PROXY = true
else ifeq ($(CURRENT_USER), xxx)
ENABLE_COMMIT_GITHUB_IO = true
ENABLE_RSYNC_PROXY = true
endif
结果
CURRENT_USER=crifan
ENABLE_COMMIT_GITHUB_IO=true
ENABLE_RSYNC_PROXY=true
可以的。
【总结】
最后代码:

ENABLE_COMMIT_GITHUB_IO = false
ENABLE_UPDATE_GITHUB_IO_README = false
ENABLE_RSYNC_PROXY = false


# default: rsync not use any proxy
RSYNC_PROXY = 


CURRENT_USER  := $(shell whoami)
$(info CURRENT_USER=$(CURRENT_USER))
ifeq ($(CURRENT_USER), crifan)
ENABLE_COMMIT_GITHUB_IO = true


# if need commit, enable and change to yours path
GITHUB_IO_PATH=/Users/crifan/dev/dev_root/github/github.io/crifan.github.io


ENABLE_UPDATE_GITHUB_IO_README = true


ENABLE_RSYNC_PROXY = true
else ifeq ($(CURRENT_USER), xxx)
ENABLE_COMMIT_GITHUB_IO = true


ENABLE_UPDATE_GITHUB_IO_README = true


# if need commit, enable and change to yours path
GITHUB_IO_PATH=/Users/xxx/dev/crifan/crifan.github.io


ENABLE_RSYNC_PROXY = true
endif
$(info ENABLE_COMMIT_GITHUB_IO=$(ENABLE_COMMIT_GITHUB_IO))
$(info ENABLE_RSYNC_PROXY=$(ENABLE_RSYNC_PROXY))


ifeq ($(ENABLE_RSYNC_PROXY), true)
# for rsync use sock5 proxy
PROXY_SOCK5 = 127.0.0.1:51837
RSYNC_PROXY = -e "ssh -o 'ProxyCommand nc -X 5 -x $(PROXY_SOCK5) %h %p' -o ServerAliveInterval=30 -o ServerAliveCountMax=5"
endif
。。。
最新代码详见:
https://github.com/crifan/gitbook_template/blob/master/common/gitbook_makefile.mk

转载请注明:在路上 » 【已解决】gitbook的makefile根据当前用户是自己而自动开启代理

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.234 seconds, using 22.08MB memory