考虑以下简单的makefile:
- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type {
// Process the received push
NSString *uuidString = payload.dictionaryPayload[@"UUID"];
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:uuidString];
NSString *handle = payload.dictionaryPayload[@"handle"];
bool hasVideo = payload.dictionaryPayload[@"hasVideo"];
if (uuid) {
UIApplication *app = [UIApplication sharedApplication];
UIBackgroundTaskIdentifier task = [app beginBackgroundTaskWithExpirationHandler:^{
[app endBackgroundTask:task];
}];
[self displayIncomingCall:uuid handle:handle hasVideo:false withCompletion:^(NSError *error) {
[[UIApplication sharedApplication] endBackgroundTask:task];
}];
}
}
- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type {
// Register VoIP push token (a property of PKPushCredentials) with server
if([credentials.token length] == 0) {
NSLog(@"voip token NULL");
return;
}
}
define cat_deps
$(shell cat $(1).dep)
endef
TARGET := main.o
all:$(TARGET)
@echo Done...!
%.o:$(call cat_deps,$*)
@echo $*
中的目标main.o
变量$(1)
必须为cat_desp
但它是空字符串。 main
也不起作用
在这种情况下,变量$(call cat_deps,%)
变为$(1)
。注意
该文件%
存在。请帮帮我。
答案 0 :(得分:1)
如果您将
main.o
中的目标$(1)
变量cat_desp
必须为main
,但它是空字符串。
$1
传递给函数cat_deps
,main
中的 main
实际会扩展为cat_deps
。但是,您传递的是一个空字符串。在你的规则中:
%.o: $(call cat_deps,$*)
@echo $*
上面的$*
在匹配规则之前展开,在匹配该规则之前,自动变量$*
实际上是空的。
在匹配规则后,您需要使用secondary expansion以扩展对cat_deps
的函数调用和自动变量$*
,即:
.SECONDEXPANSION:
%.o: $$(call cat_deps,$$*)
@echo $*
请注意$
和call
的其他$*
。
请注意,您还需要以下没有食谱的规则:
%: %.o
为了压制隐含规则。否则,上面的新%.o
规则的先决条件可以匹配那个(未抑制的)隐式规则,该规则具有.o
文件作为先决条件,并且将依次与新{{1}匹配再次统治。