Makefile:有没有办法包含动态生成的文件?

时间:2019-05-09 20:59:48

标签: makefile

我有一个makefile,其中有两个目标,testsdisttests会生成一些csv文件,而dist会将指定的文件压缩为tar球。

由于生成的csv文件也应包含在tar球中,因此我使用了以下Makefile(部分)

.PHONY: tests # to make sure the target "tests" are not treated as files
DISTFILES=$(wildcard *.csv) # also some other files, omitted here
tests:
    chmod +x tests.sh 
    -./tests.sh # will generate some csv files
dist: tests
    tar cvzf dist.tar.gz $(DISTFILES)

我现在遇到的问题是,生成的csv文件未包含在tar球中,因为它们在调用make dist之前不在目录中。

所以我的问题是,有没有办法包含这些动态生成的文件?谢谢!

2 个答案:

答案 0 :(得分:0)

怎么样:

$query = App\User::leftJoin('tableX', 'tableX.user_id', 'users.id');

if ($some_condition) {
    foreach( $query->getQuery()->joins as $key => $join) {
        /** @var \Illuminate\Database\Query\JoinClause $join */
        if ($join->table == 'tableX') {
            unset($query->getQuery()->joins[$key]);
        }
    }
    $query->join('tableX', 'table.user_id', 'users.id');
}

答案 1 :(得分:0)

Beta的答案可能是最简单的。您还可以递归使用make,以便第二次调用看到生成的文件:

# This Doesn't Work.
import requests
url = 'https://ryanspressurewashing.com/wp-content/uploads/2017/06/metal-
roof-after-pressure-washing.jpg'

r = requests.get(url, stream=True)
with open('image3.jpg', 'wb') as my_file:
# Read by 4KB chunks
    for byte_chunk in r.iter_content(chunk_size=4096):
        my_file.write(byte_chunk)



#  This Works?

import requests
url = 'http://www.webscrapingfordatascience.com/files/kitten.jpg'
r = requests.get(url, stream=True)
with open('image.jpg', 'wb') as my_file:
# Read by 4KB chunks
    for byte_chunk in r.iter_content(chunk_size=4096):
        my_file.write(byte_chunk)