diff options
| author | ruki <[email protected]> | 2019-11-17 23:38:54 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-11-17 23:38:54 +0800 |
| commit | cf984b4a0e9e4ea733f2c35deca3b714baa2a227 (patch) | |
| tree | a543106b0ceca6f81d7528749bc3812adbeefdc1 /xmake/core/project/project.lua | |
| parent | f5258628ba215481571ce1e957737b2ed97c45ab (diff) | |
add .xmakerc.lua
Diffstat (limited to 'xmake/core/project/project.lua')
| -rw-r--r-- | xmake/core/project/project.lua | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index 4baa8ab5c..0a6451b80 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -291,6 +291,16 @@ function project.file() return os.projectfile() end +-- get the global rcfile: ~/.xmakerc.lua +function project.rcfile() + local xmakerc = project._XMAKE_RCFILE + if xmakerc == nil then + xmakerc = os.getenv("XMAKE_RCFILE") or "~/.xmakerc.lua" + project._XMAKE_RCFILE = xmakerc + end + return xmakerc +end + -- get the project directory function project.directory() return os.projectdir() @@ -329,7 +339,16 @@ function project._load(force, disable_filter) local interp = project.interpreter() -- load script - local ok, errors = interp:load(project.file()) + local ok, errors = interp:load(project.file(), {on_load_data = function (data) + local xmakerc_file = project.rcfile() + if xmakerc_file and os.isfile(xmakerc_file) then + local rcdata = io.readfile(xmakerc_file) + if rcdata then + data = rcdata .. "\n" .. data + end + end + return data + end}) if not ok then return false, (errors or "load project file failed!") end |
