TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Polyglot Makefiles

153 点作者 sciencerobot大约 5 年前

8 条评论

brandmeyer大约 5 年前
That&#x27;s interesting.<p>Author probably wants to use `private` for those target-local variables, though.<p>For example,<p><pre><code> R: .SHELLFLAGS := -e R: SHELL := Rscript R: greeting = &quot;bonjour&quot; message(paste0(greeting, &quot;, R!&quot;)) </code></pre> Everything that target `R` depends on will also have SHELL and .SHELLFLAGS over-ridden. If `R` depends on some data generated by another program, it probably wants to be built and executed with the default SHELL (or another shell, perhaps).<p><pre><code> R: private .SHELLFLAGS := -e R: private SHELL := Rscript R: greeting = &quot;bonjour&quot; message(paste0(greeting, &quot;, R!&quot;)) </code></pre> Now, `R`&#x27;s dependencies will be generated with the makefile&#x27;s defaults.<p>Usually I prefer to build up richer stages like this using the system shell anyway, though. Build a target which in turn is executed by the shell normally to traverse the next edge in the graph. But I can see how this mechanism has its uses.<p>See also <a href="https:&#x2F;&#x2F;www.gnu.org&#x2F;software&#x2F;make&#x2F;manual&#x2F;html_node&#x2F;Target_002dspecific.html" rel="nofollow">https:&#x2F;&#x2F;www.gnu.org&#x2F;software&#x2F;make&#x2F;manual&#x2F;html_node&#x2F;Target_00...</a>
评论 #23195163 未加载
gregwebs大约 5 年前
Make was designed for building dependencies. I think it is always problematic to use it as a command runner (for example there is no standard way to list out the available commands).<p>[just](<a href="https:&#x2F;&#x2F;github.com&#x2F;casey&#x2F;just" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;casey&#x2F;just</a>) is a tool that feels similar to make but is designed explicitly for the purpose of running commands.<p>I think of this as a simple CLI for your project workflow. You still really want to avoid putting code into a Justfile and put it into scripts. But the Justfile helps provide a slightly nicer UX and automatically invoke dependencies.
评论 #23195500 未加载
评论 #23196032 未加载
评论 #23195393 未加载
评论 #23196297 未加载
epistasis大约 5 年前
For complicated pipelines that I want to reuse multiple times, I have turned Makefiles into executables by putting this at the top:<p><pre><code> #!&#x2F;usr&#x2F;bin&#x2F;make -f </code></pre> And then putting them in my $PATH. I run them with arguments like:<p><pre><code> $ process-data.mk INTSV=a.tsv DB=largefile.gz OUTDIR=finished </code></pre> This makes me feel like I&#x27;ve sold my soul to the devil, and that I&#x27;m just living on borrowed time until it all fails and falls apart. It hasn&#x27;t yet, however...
评论 #23196417 未加载
评论 #23197323 未加载
评论 #23194926 未加载
ainar-g大约 5 年前
Note that this article (like many, many others) assumes GNU Make. POSIX Make has neither .ONESHELL nor local macros. Neither do most built-in Make implementations in other OSes, like OpenBSD&#x27;s bmake.
评论 #23195328 未加载
评论 #23195846 未加载
IshKebab大约 5 年前
I wish someone would write a modern alternative to GNU Make. I&#x27;ve looked and there don&#x27;t seem to be any. The closest is Ninja but it doesn&#x27;t seem to be intended to be hand written.
评论 #23198195 未加载
评论 #23200738 未加载
评论 #23200981 未加载
adelarsq大约 5 年前
I added this to my list about Make at <a href="https:&#x2F;&#x2F;github.com&#x2F;adelarsq&#x2F;awesome-make" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;adelarsq&#x2F;awesome-make</a><p>Pull requests are welcome.
mehrdadn大约 5 年前
I think this might have repercussions? Like if you do &quot;make foo bash bar&quot; then can you predict what that SHELL is used for?
评论 #23195108 未加载
purplezooey大约 5 年前
loving the python3 makefiles