将make目标添加到default.nix

时间:2018-11-13 18:14:42

标签: makefile nix

我有一个default.nix文件,如下所示:

with import <nixpkgs> {};
stdenv.mkDerivation {
name = "tsm";
src = ./.;
enableParallelBuilding = true;

cmakeFlags = ["-DGTEST_INCLUDE_DIR=${gtest}/include -DBUILD_COVERAGE=ON"];

buildInputs = [gcc cmake gtest glog lcov graphviz doxygen];

构建时,我还需要调用make doc coverage。如何make其他目标?

在搜索google之后,我尝试了makeFlagsArray = ("doc" "coverage")makeFlagsArray = ("doc coverage"). Neither worked. doc and coverage`并非每次都构建。这就是为什么我让它们仅基于make的显式调用的原因。

1 个答案:

答案 0 :(得分:1)

添加

import os
import struct

def get_umask():
    pipe = os.pipe()
    pid = os.fork()
    if pid == 0:
        os.close(pipe[0])
        umask = os.umask(0)
        os.write(pipe[1], struct.pack('H', umask))
        os.close(pipe[1])
        os._exit(0)
    else:
        os.close(pipe[1])
        value = os.read(pipe[0], 2)
        os.close(pipe[0])
        os.waitpid(pid, 0)
        return struct.unpack('H', value)[0]

print("umask {:03o}".format(get_umask()))

可以解决问题。不确定这是否是理想的方法。