使用 bjam 进行简单安装
我是一个 boost.build 新手,虽然 bjam 对于大多数编译任务来说都很容易使用,但我不知道如何做一些应该非常简单的事情:在系统中安装我的应用程序。
假设我有一个非常简单的项目,树中有两个文件(除了 Jamroot 之外)。
hello.cpp :一个 C++ 程序说它打印 /etc/hello.conf 的内容
- 。 conf :默认的 hello.conf
我想要做的是:
- 能够编译和链接 hello.cpp,而无需在系统范围内安装任何内容
- 当使用安装目标调用时, (并且只有那时):
- 将可执行文件 hello 复制到 /usr/bin
- 将 hello.conf 复制到 /etc。
下面是我开始编写的 bjam:
exe hello : hello.cpp ;
alias install : install-bin install-etc ;
install install-bin : hello : <location>/usr/bin ;
install install-etc : hello.conf : <location>/etc ;
我的问题是,作为用户,我无法写入 /etc 或 /usr/bin,并且我希望仅在显式调用安装目标时执行此操作,而不是每次输入 bjam 时执行此操作。
对我来说,将安装和构建阶段分开非常重要,因为构建阶段应使用用户权限完成,安装阶段应使用管理员权限完成。
I'm a boost.build newby and while bjam is quite easy to use for most compiling tasks and I didn't figured out how to do something that should be really simple : installing my application in the system.
Say I have a very simple project with two files in tree (besides Jamroot).
hello.cpp : a C++ program say it prints the content of /etc/hello.conf
hello.conf : a default hello.conf
What I want to do is:
- be able to to compile and link hello.cpp without installing anything system wide
- when called with an install target (and only then) :
- copy executable hello to /usr/bin
- copy hello.conf to /etc.
Below is the bjam I started to write:
exe hello : hello.cpp ;
alias install : install-bin install-etc ;
install install-bin : hello : <location>/usr/bin ;
install install-etc : hello.conf : <location>/etc ;
My problem is that as a user I can't write to /etc nor /usr/bin and I want this to be done only when explicitely calling the install target, not everytime I type bjam.
It is quite important to me to separate the install and the building stages as building stage should be done using user rights and install stage using administrator rights.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你写的看起来不错,除了两个问题。首先,最后一行应为:
其次,
install
别名应同时引用install-bin
和install-etc
。当你做出这些改变时,事情有效吗?What you wrote seems fine, except for two issues. First, the last line should read:
Second, the
install
alias should refer to bothinstall-bin
andinstall-etc
. When you make those changes, do things work?