Giter Club home page Giter Club logo

Comments (7)

con-f-use avatar con-f-use commented on September 15, 2024

I'd put it in Makefile.example of esp82xx as well as in the top-level projects' main Makefiles. So someone creating a new project doesn't forget it as easily.

I'm thinking of something like this:

ifndef TARGET
# Fetch submodule if the user forgot to clone with `--recursive`
GETSUBMODS = all burn burnweb netweb netburn clean cleanall purge
.PHONY : $(GETSUBMODS)
$(GETSUBMODS) :
    $(warning Submodule esp82xx was not fetched. Trying it now.)
    git submodule update --init --recursive
    $(info Re-unning make...)
    make $@ $(MFLAGS) $(MAKEOVERRIDES)
endif

It gets run, when TARGET is not defined, a.k.a. including the esp82xx/main.mf fails. Make usually quits, when it can't include a file, so the lines:

include esp82xx/common.mf
include esp82xx/main.mf

needs to have a minus prepended

-include esp82xx/common.mf
-include esp82xx/main.mf

I will test that right away and make a pull request. By the way, don't know if git supports that, but can you give me access to the esp82xx repo and maybe colorchord and the others. It's getting annoying to fork and request a pull all the time. If you feel uncomfortable with that though, I understand.

Edit:
I think this can be closed now. Made the pull request in #11.

from esp82xx.

cnlohr avatar cnlohr commented on September 15, 2024

So, I was jump-happy and committed my small change in the projects now, but after reading this, I am having second thoughts. Leaving this issue open and will look into this later today to swap it around to your way.

from esp82xx.

con-f-use avatar con-f-use commented on September 15, 2024

Well, your's would only update an already pulled submodule. Since it's in the submodule, we can't use it in the top level-project, when the user forgot to git clone --recursive. Should be in both, the Makefile.example of the submodule and the Makefile of the top-level.

from esp82xx.

cnlohr avatar cnlohr commented on September 15, 2024

So... Why not do it like this:

-include esp82xx/common.mf
-include esp82xx/main.mf

ifndef TARGET
$(info Modules were not checked out... use git close --recursive in the future. Pulling now.)
$(shell git submodule update --init --recursive)
endif

EDIT: I'm just trying to get away from explicitly calling out targets.

from esp82xx.

con-f-use avatar con-f-use commented on September 15, 2024

I agree, it's ugly. I tried something similar to your code first. Make complained and refused to execute. Forgot why exactly, something like "recipe commences before first target". Maybe at least one rule has to be present or something, so this could work:

-include esp82xx/common.mf
-include esp82xx/main.mf

ifndef TARGET
$(info Modules were not checked out... use git clone --recursive in the future. Pulling now.)
$(shell git submodule update --init --recursive)
endif

.PHONY : empty_rule
empty_rule :
    @true

Still, even if this worked, if someone was trying make burn or any of the other targets, I think make would fail with an "No rule to make target 'burn'" error and worse, not pull the submodules. That would be rather cryptic behavior.

Maybe a match-all pattern rule, i.e. "%" instead of the empty_rule:

$(shell git submodule update --init --recursive)
endif

% : 
    $(warning This is the empty rule. Something went wrong.)
    @true

But not sure if it would overwrite the included Makefiles still, even when they are pulled and included. But I vaguely remember that specific rules overwrite pattern rules. This could actually work...

from esp82xx.

cnlohr avatar cnlohr commented on September 15, 2024

I don't know what version of Make you're using... I just tried 'make burn' with mine, and it did pull a new copy.

Modules were not checked out... use git close --recursive in the future.
Pulling now.
Cloning into 'embedded8266/esp82xx'...
remote: Counting objects: 119, done.
remote: Compressing objects: 100% (85/85), done.
remote: Total 119 (delta 51), reused 97 (delta 30), pack-reused 0
Receiving objects: 100% (119/119), 95.24 KiB | 0 bytes/s, done.
Resolving deltas: 100% (51/51), done.
Checking connectivity... done.
Makefile:8: *** multiple target patterns.  Stop.

I don't think it's necessary to define additional rules?

ifndef TARGET
$(info Modules were not checked out... use git close --recursive in the future.)
$(info Pulling now.)
$(shell git submodule update --init --recursive)
endif

Wow, I can't believe we're beating this "nice to have" so hard :(

from esp82xx.

cnlohr avatar cnlohr commented on September 15, 2024

Let's just call this discussion closed. Everything is fine now.

from esp82xx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.