普通网友 2016-03-05 06:51
浏览 109
已采纳

部分重用的makefile的模式

I am at this time creating more and more of small one-off projects in golang but I see many makefile tasks are literally copy&paste from across projects. For example, in every project I have a:

${APP_NAME}: $(SOURCES)
    go get ./...
    goimports -w $(SOURCES)
    go build -o ${APP_NAME}

I would like to know if anyone has experience of fragment extraction into a separate project and importing it. If so, how do you do it?

  • Just curl a file from raw.githubusercontent.com? Because that's what I'm about to do since I don't see any other easy way.

  • I also thought about using git submodules but that seems also a bit over the top for a couple of files.

  • 写回答

1条回答 默认 最新

  • douzhi2017 2016-03-27 08:08
    关注

    I have found a simple workaround: I include Makefiles which I made from the starting monolithic Makefile.

    I am putting split Makefiles in a separate git project, that contains only them.

    I am referring to those Makefiles from root project and I have them locally via git submodule. A bit more work - yes, but it allows me to have trivial "root" Makefile and all hard (quite often - repeating) logic in the separate project.

    Example of how I made this work:

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘