此makefile规则中的大括号是什么?

时间:2019-01-22 16:41:39

标签: makefile gnu-make makefile-project

我正在读取Qt创建的项目的makefile,该文件具有以下内容:

public Context mContext;
public List<Post> mPost;

private FirebaseUser firebaseUser;

public PostAdapter(Context mContext, List<Post> mPost) {
    this.mContext = mContext;
    this.mPost = mPost;
}

@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {

    View view = LayoutInflater.from(mContext).inflate(R.layout.post_item,viewGroup,false);

    return new PostAdapter.ViewHolder(view);
}

@Override
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int i) {

    firebaseUser = FirebaseAuth.getInstance().getCurrentUser();

    Post post = mPost.get(i);
    Glide.with(mContext).load(post.getPostimage()).into(viewHolder.post_image);

    if(post.getDescription().equals("")){
        viewHolder.description.setVisibility(View.GONE);
    }else {
        viewHolder.description.setVisibility(View.VISIBLE);
        viewHolder.description.setText(post.getDescription());
    }

    publisherInfo(viewHolder.image_profile,viewHolder.username,viewHolder.publisher,post.getPublisher());


}

@Override
public int getItemCount() {
    return mPost.size();
}

public class ViewHolder extends RecyclerView.ViewHolder{

    public ImageView image_profile, post_image, like, comment, save;

    public TextView username, likes, publisher, description, comments;


    public ViewHolder(@NonNull View itemView) {
        super(itemView);

        image_profile = itemView.findViewById(R.id.image_profile);
        post_image = itemView.findViewById(R.id.post_image);
        like = itemView.findViewById(R.id.like);
        comment = itemView.findViewById(R.id.comment);
        save = itemView.findViewById(R.id.save);
        username = itemView.findViewById(R.id.username);
        likes = itemView.findViewById(R.id.likes);
        publisher = itemView.findViewById(R.id.publisher);
        description = itemView.findViewById(R.id.description);
        comments = itemView.findViewById(R.id.comments);




    }
}

private void publisherInfo(final ImageView image_profile, final TextView username, final TextView publisher, final String userid){
    DatabaseReference reference = FirebaseDatabase.getInstance().getReference("Users").child(userid);
    reference.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {

            User user = dataSnapshot.getValue(User.class);
            Glide.with(mContext).load(user.getImageurl()).into(image_profile);
            username.setText(user.getUsername());
            publisher.setText(user.getUsername());

        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });
}}

(以上代码将\ t用于配方,并与makefile相同)

这条规则和食谱都使我困惑。

我将从规则中的{backend}.cpp{release\}.obj:: $(CXX) -c $(CXXFLAGS) $(INCPATH) -Forelease\ @<< $< << 开始。显然,{backend}也有同样的困惑。我假设这是对名为{release}的特定子目录的引用。我猜backend是否会被视为合法目标?但是 make 的哪一部分说这是合法的语法,这到底发生了什么?

FWIW:这是在一节中注释为:..\backend\release\bar.obj。 版本:##### implicit rules

奖励积分:

说明食谱中GNU Make 4.2.1 Built for x86_64-unknown-cygwin@<<的用法...(是的,我缺乏bash shell技巧... )。这是否引用了<<的第一个先决条件并以静默方式对其进行重定向?为什么不$<

谢谢。

1 个答案:

答案 0 :(得分:1)

这是NMAKE批处理模式规则

https://docs.microsoft.com/en-us/cpp/build/batch-mode-rules?view=vs-2017

等效的GNU Make规则类似于

backend/%.obj: release/%.cpp:

顾名思义,这些规则将只对所有有效目标调用一次其配方,并期望该规则通过$<宏一次创建所有目标。

<<语法是NMAKE的内联文件功能

https://docs.microsoft.com/en-us/cpp/build/inline-files-in-a-makefile?view=vs-2017

这将展开并捕获尖括号之间的所有内容,并将其保存到文件中,在这种情况下为临时文件,因为在括号后未指定文件名。然后通过@选项将该文件作为响应文件传递到编译器的第一行。