简体   繁体   English

运行部分生成的Makefile

[英]Run partially build of Makefile

I've the following makefile which is look like following 我有以下makefile ,如下所示

PROJ_DIR := $(CURDIR)
all: pre app app1 app2 app3
apps = app app1 app2 app3 
pre:
  mkdir temp
app:
    cd PROJ_DIR/app ; npm install

app1:
    cd PROJ_DIR/app1 ; npm install
...
#Need to wait to app1...n to finish the install process in order to proceed and zip all the app installed artifacts
build:$(apps)
     #zip all the apps artifacts

clean:build
    rm -rf test

Now when I run this with make everything is working as expected . 现在,当我使用make运行此命令时, 一切都会按预期进行 The problem is that I want to run partial build like 问题是我想像

make -j1 pre app1 build clean (in the sequence only app1 should run and not app2 app3 etc ) here I've a problem since I've the apps pre-requestie(hint from Renaud ) which helps to wait when I execute the whole the make with make but if I want to run it partially it still run them all (all the apps) , is there a trick which can help in both for the execution type ? make -j1 pre app1 build clean (按顺序只应运行app1不应运行app2 app3等),这是一个问题,因为我已经对apps pre-requestie(来自Renaud的提示),这有助于在我执行整个程序时等待用make进行make但是如果我要部分运行它,仍然可以全部运行它们(所有应用程序),是否有一个技巧可以对两种执行类型都有帮助?

Not sure I understand all details but there is one important thing to consider: make does exactly what you tell it to do, no more, no less (hopefully). 不确定我是否了解所有细节,但有一件重要的事情要考虑:make完全按照您的要求去做,不要多做(希望如此)。 So, if you tell it that build depends on all your apps you cannot expect make to do build before it also did all apps. 因此,如果您告诉它build取决于您的所有应用程序,那么您就无法期望make在build所有应用程序之前先build它。 It's that simple. 就这么简单。 It's what 它是什么

build: $(apps)

says: build depends on $(apps) or, in other words, it is impossible to do build before having done $(apps) . 说: build取决于$(apps) ,换句话说,在完成$(apps)之前不可能进行build

If you want to build with only one app, you need another target than build ... or you need to change the definition of the apps make variable. 如果要仅使用一个应用程序进行构建,则除了build ...之外还需要其他目标,或者需要更改apps make变量的定义。 And guess what, it's probably the easiest thing to do because make let's you do this on the command line: 猜猜是什么,这可能是最简单的事情,因为make让您在命令行上执行此操作:

$ make apps='app1' pre build clean

or, if you want to build and pack only app1 and app2 : 或者,如果您只想构建和打包app1app2

$ make apps='app1 app2' pre build clean

By default the variables that are assigned on the command line take precedence over the definitions from inside the Makefile. 默认情况下,在命令行上分配的变量优先于Makefile内部的定义。 Executing make apps='app1' pre build clean will do exactly the same as if you edit the Makefile to change the definition of apps and then execute make pre build clean . 执行make apps='app1' pre build clean将执行完全相同的操作,就像您编辑Makefile更改apps的定义然后执行make pre build clean

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM