zoukankan      html  css  js  c++  java
  • make 学习笔记

    makefile

    makefile是一个"自动化编译器",你只需要写好一个makefile, 然后执行一个make命令 , 整个工程就会自动按照规则编译了,极大提高了我们程序猿的效率。

    R也只支持makefile的

    参考 https://github.com/pavopax/gists/blob/master/assets/makefile-example-1.bash

    Makefile quick start

    Makefiles are a simple way to organize code execution/compilation.

    It's like a recipe for your code repo.

    Makefile is a single file that can run all analysis code, or do other tasks. It is self-documenting, and helps in "reproducibility."

    You run it from command line, as follows.

    Hello, world!

    Here's a simple example.

    Make a file Makefile (no extension!) and put this in it:

    all: data process output
    
    data:
    		Rscript get_datasets.R
    		Rscript get_extra_files.R
    	
    process:
    		Rscript process.R
    
    output:
    		Rscript write_plots.R
    		Rscript write_tables.R
    		python app.py
    

    Now, from command line, you can:

    • type make data to run your "get data" scripts
    • type make output to only run your "output" script(s)
    • type make all to rerun the entire analysis, which consists of the pieces specified in the first line (data, process, output)

    all, data, process, output, etc are called "targets"

    Advantages

    Reproducibility.

    Rerun the whole thing with make all.

    Speed: Rerun only specific pieces of your analysis with make data, make process, etc

    Can be self-documenting.

    Examples

    Example 1

    Example 2

    Tips

    Add a target clean to remove data and start from scratch (reproducibility, FTW!)

    clean:
    	rm -rf data
    

    (Consider adding mkdir -p data in your make data target to create this folder automatically)

    If you already have a /data folder, then running make data may give you error. There are reasons for this. To alleviate this, run it as make -B data or declare it as .PHONY in Makefile like:

    all: process data
    
    .PHONY: data
    data:
        Rscript get_datasets.R
    

    More on .PHONY

  • 相关阅读:
    网摘习惯
    关于Application.DoEvents()
    五句话足以改变一生
    ActionForm中reset()的用法
    Java的MD5加密和解密类
    ibatis主键自动生成
    Parameter index out of range (3 > number of parameters
    ibatis 2.0 3.0 DTD
    SmartUpload在servlet中使用方法
    The prefix "tx" for element "tx:annotationdriven" is not bound.
  • 原文地址:https://www.cnblogs.com/gaowenxingxing/p/12863999.html
Copyright © 2011-2022 走看看