爲了方便發佈tar,rebar3要適應relx遷移include目錄到src目錄

使用rebar3打tar包,十分方便。其中rebar3使用relx打包,relx裏面有下面的選項,能夠在打包的時候,不打包src目錄,方便在發佈的時候,不發佈src裏面的源碼文件:git

%% relx will include src files of your applications, if present, by default.
%% If you don't want to include the src files, set `include_src` to false.
{include_src, false}.

參考:relx Configurationgithub

但咱們使用rebar3生成項目的時候,src、include是處於相同等級的目錄下面,發佈的時候,使用上面的選項能夠不發佈src目錄,但include目錄會被髮布出去。這個不方便咱們發佈。app

那有沒有 include_include 選項呢?code

答案是沒有。參考:include_src ok but what about include_include ? #99get

但咱們能夠經過compile的選項來繞過這個問題。源碼

compile有個選項是{i,Dir},  它會在Dir目錄下面查找須要的編譯頭文件。it

rebar3能夠設置這個選項在erl_opts下面,參考:how to set include directory for rebario

{erl_opts, [{i, PathToIncludeFile}]}.

這樣,咱們就能夠把include目錄遷移到src目錄,這樣就能夠在發佈的時候,不拷貝include目錄了。編譯

注意,PathToIncludeFile是在rebar3當前目錄對應的目錄,要注意相對目錄。打包

相關文章
相關標籤/搜索