摇:指出是否有任何事情必须重建 [英] Shake: Signal whether anything had to be rebuilt at all

查看:111
本文介绍了摇:指出是否有任何事情必须重建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用shake来构建一堆静态网页,然后使用sftp将其上传到远程主机。目前,cronjob运行

  git pull#获取可能的更新源
./my-shake-system
lftp ...#upload

我不想运行最后的命令实际上重建任何东西。有没有办法告诉摇晃运行命令 foo ,在所有其他情况之后,并且只有在您改变了某些东西!?

或者,也可以动摇报告它是否在进程退出代码中做了些什么?



我想我可以添加一个取决于所有可能生成的文件的规则,但这似乎是多余的和容易出错的。

解决方案

目前没有直接/简单的方法来确定是否构建了任何内容。对于更简单的构建系统,这也不是一个有用的概念,因为某些规则(特别是那些定义 storedValue 返回 Nothing )将总是重新运行,但是很快就会决定他们不需要运行依赖于它们的规则。摇动,这与重新运行一样。我可以考虑一些方法,哪一个最好取决于你的情况:

标记有趣的规则



您可以使用写入特定文件的函数来标记每个有趣的规则(其中一条产生需要上传的规则)。如果该特定文件存在,则需要上传。这可能会稍微好一些,就好像你做了多次Shake运行一样,在第一件事情发生变化但第二件事没有发生的情况下,该文件仍然存在。如果有意义,请使用 IORef 而不是文件。



使用分析

Shake具有相当先进的分析功能。如果你传递 shakeProfile = [output.json] ,它将产生一个JSON文件,详细说明什么是内建的和何时。运行由Int进行索引,最近一次运行的 0 ,并且排除任何不构建的运行。如果你有一个总是触发的规则(例如写入一个带有 alwaysRerun 的虚拟文件),那么如果同时触发了任何东西,它就会重建。



观看 .shake.database 文件大小

Shake有一个数据库,存储在 shakeFiles 下。每个不感兴趣的运行都会增长一个相当小的数量(〜100字节) - 但是给定系统的固定大小。如果它的尺寸变化较大,那么它做了一些有趣的事。

在这些方法中,标记有趣的规则可能是最简单和最直接的(尽管运行您忘记标记某些东西的风险)。

I use shake to build a bunch of static webpages, which I then have to upload to a remote host, using sftp. Currently, the cronjob runs

git pull # get possibly updated sources
./my-shake-system 
lftp ... # upload

I’d like to avoid running the final command if shake did not actually rebuild anything. Is there a way to tell shake "Run command foo, after everything else, and only if you changed something!"?

Or alternatively, have shake report whether it did something in the process exit code?

I guess I can add a rule that depends on all possibly generated file, but that seems to be redundant and error prone.

解决方案

Currently there is no direct/simple way to determine if anything built. It's also not such a useful concept as for simpler build systems, as certain rules (especially those that define storedValue to return Nothing) will always "rerun", but then very quickly decide they don't need to run the rules that depend on them. To Shake, that is the same as rerunning. I can think of a few approaches, which one is best probably depends on your situation:

Tag the interesting rules

You could tag each interesting rule (one that produces something that needs uploading) with a function that writes to a specific file. If that specific file exists, then you need to upload. This might work slightly better, as if you do multiple Shake runs, and in the first something changes but the second nothing does, the file will still be present. If it makes sense, use an IORef instead of a file.

Use profiling

Shake has quite advanced profiling. If you pass shakeProfile=["output.json"] it will produce a JSON file detailing what built and when. Runs are indexed by an Int, with 0 for the most recent run, and any runs that built nothing are excluded. If you have one rule that always fires (e.g. write to a dummy file with alwaysRerun) then if anything fired at the same time, it rebuilt.

Watch the .shake.database file size

Shake has a database, stored under shakeFiles. Each uninteresting run it will grow by a fairly small amount (~100 bytes) - but a fixed size given your system. If it changes in size by a greater amount, then it did something interesting.

Of these approaches, tagging the interesting rules is probably the simplest and most direct (although does run the risk of you forgetting to tag something).

这篇关于摇:指出是否有任何事情必须重建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆