Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracts target dir compute from config.buildtargetinfo into config.targetdir #2258

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions src/base/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@
local project = p.project
local config = p.config

---
-- Helper function to get the target directory for a config or project.
--
-- @param cfg
-- The configuration object or project being queried.
function config.targetdir(cfg)
if cfg.targetdir then
return cfg.targetdir
end

local basedir = cfg.location

local targetdir
if cfg.platform then
targetdir = path.join(basedir, 'bin', cfg.platform, cfg.buildcfg)
else
targetdir = path.join(basedir, 'bin', cfg.buildcfg)
end

return targetdir
end

---
-- Helper function for getlinkinfo() and gettargetinfo(); builds the
Expand All @@ -29,16 +50,8 @@
---

function config.buildtargetinfo(cfg, kind, field)
local basedir = cfg.project.location

local targetdir
if cfg.platform then
targetdir = path.join(basedir, 'bin', cfg.platform, cfg.buildcfg)
else
targetdir = path.join(basedir, 'bin', cfg.buildcfg)
end

local directory = cfg[field.."dir"] or cfg.targetdir or targetdir
local targetdir = config.targetdir(cfg)
local directory = cfg[field.."dir"] or targetdir
local basename = cfg[field.."name"] or cfg.targetname or cfg.project.name

local prefix = cfg[field.."prefix"] or cfg.targetprefix or ""
Expand Down