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

Allows installdir, bindir and libdir to be configured via opt arguments #5634

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

A2va
Copy link
Contributor

@A2va A2va commented Sep 18, 2024

  • Before adding new features and new modules, please go to issues to submit the relevant feature description first.
  • Write good commit messages and use the same coding conventions as the rest of the project.
  • Please commit code to dev branch and we will merge into master branch in feature
  • Ensure your edited codes with four spaces instead of TAB.

  • 增加新特性和新模块之前,请先到issues提交相关特性说明,经过讨论评估确认后,再进行相应的代码提交,避免做无用工作。
  • 编写友好可读的提交信息,并使用与工程代码相同的代码规范,代码请用4个空格字符代替tab缩进。
  • 请提交代码到dev分支,如果通过,我们会在特定时间合并到master分支上。
  • 为了规范化提交日志的格式,commit消息,不要用中文,请用英文描述。

@@ -233,7 +243,8 @@ function _install_moduleonly(target, opt)
end

function main(target, opt)
local installdir = target:installdir()
opt = opt or {}
local installdir = opt.installdir and target:set("installdir", opt.installdir) or target:installdir()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not call target:set to modify target installdir configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if I could save the installdir of a target, then set it to the old value at the end of the function.
The other solution that comes to mind is to add an opt argument to installdir, libdir and bindir of target.

Which solution do you prefer?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use local installdir = opt.installdir and opt.installdir or target:installdir()?

Copy link
Contributor Author

@A2va A2va Sep 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because when target:installdir(opt.bindir) is called, installdir is not set in the target (or not the right value). One solution would be to join installdir and bindir each time, but as this is already what bindir does, I haven't considered this option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can add function _get_installdir(target, opt) to wrap it. then get them each time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like this

function _get_target_bindir(package, target)
local bindir = package:bindir()
local prefixdir = target:prefixdir()
if prefixdir then
bindir = path.join(package:installdir(), prefixdir, target:extraconf("prefixdir", prefixdir, "bindir") or "bin")
end
return path.normalize(bindir)
end
function _get_target_libdir(package, target)
local libdir = package:libdir()
local prefixdir = target:prefixdir()
if prefixdir then
libdir = path.join(package:installdir(), prefixdir, target:extraconf("prefixdir", prefixdir, "libdir") or "lib")
end
return path.normalize(libdir)
end
function _get_target_includedir(package, target)
local includedir = package:includedir()
local prefixdir = target:prefixdir()
if prefixdir then
includedir = path.join(package:installdir(), prefixdir, target:extraconf("prefixdir", prefixdir, "includedir") or "include")
end
return path.normalize(includedir)
end
function _get_target_installdir(package, target)
local installdir = package:installdir()
local prefixdir = target:prefixdir()
if prefixdir then
installdir = path.join(package:installdir(), prefixdir)
end
return path.normalize(installdir)
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants