亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

將參數傳遞給“ make run”

將參數傳遞給“ make run”

開心每一天1111 2020-02-04 15:36:02
我使用Makefiles。我有一個run運行該構建目標的目標。簡化后,它看起來如下所示:prog: ....  ...run: prog  ./prog坐下來 我知道這很巧妙,但不需要站著鼓掌?,F在,我的問題是-有什么方法可以傳遞參數?以便make run asdf --> ./prog asdfmake run the dog kicked the cat --> ./prog the dog kicked the cat謝謝!
查看完整描述

3 回答

?
嗶嗶one

TA貢獻1854條經驗 獲得超8個贊

我不知道完全按照自己的意愿做事的方法,但是一種解決方法可能是:


run: ./prog

    ./prog ${ARGS}

然后:


make ARGS="asdf" run


查看完整回答
反對 回復 2020-02-04
?
千巷貓影

TA貢獻1829條經驗 獲得超7個贊

您可以將變量傳遞給Makefile,如下所示:


run:

    @echo ./prog $$FOO

用法:


$ make run FOO="the dog kicked the cat"

./prog the dog kicked the cat

要么:


$ FOO="the dog kicked the cat" make run

./prog the dog kicked the cat

或者使用Beta提供的解決方案:


run:

    @echo ./prog $(filter-out $@,$(MAKECMDGOALS))

%:

    @:

%:-與任何任務名稱匹配的規則; @:-空配方=不執行任何操作


用法:


$ make run the dog kicked the cat

./prog the dog kicked the cat


查看完整回答
反對 回復 2020-02-04
  • 3 回答
  • 0 關注
  • 966 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號