Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: abbreviated qualified path to phony targets #133

Open
jhwoodyatt opened this issue Feb 21, 2020 · 4 comments
Open

feature: abbreviated qualified path to phony targets #133

jhwoodyatt opened this issue Feb 21, 2020 · 4 comments

Comments

@jhwoodyatt
Copy link

jhwoodyatt commented Feb 21, 2020

In my day job, we are using Bazel for software construction. (It's a living, shrug.)

One thing Bazel offers that I miss when I'm using OMake is the hierarchical structure of target names, and I've been thinking about what it would take to extend OMake to be more like Bazel in this regard. I think I've got an idea...

OMake today has .PHONY targets that are almost but not quite the right thing. To make them more friendly, it would be nice if there were a bit of reserved syntax for targets that expanded automatically to hierarchical "phony target" names in the same way that Bazel target names have a hierarchical structure.

I don't have a strong preference for a specific proposal for how that syntax would work, but I could throw one up if it would help:

  • Command line target arguments that begin with ^/ would have the ^ replaced with /.PHONY. Example: $ omake ^/foo/bar/baz at the root directory would be equivalent to $ (cd foo/bar && omake baz).
  • Command line target that have a suffix that starts with : would have the part of the suffix following the : interpreted as a regular expression that matches targets in the /.PHONY/ namespace corresponding to their relative location. Example: $ omake ':test-.+' would invoke all the phony targets in the current subdirectory tree that match the test-.+ regex.

One could also imagine some logic that provide for handling the combination of both the above the rules in a way that would seem familiar to Bazel users.

@ANogin
Copy link

ANogin commented Feb 21, 2020

Are you aware that .PHONY targets already form a hierarchy that you can use? Or are you just asking for a uniform syntax that does not require knowing whether the target is .PHONY + regexp capability?

% cat OMakeroot
.PHONY: do_it
.SUBDIRS: . a b
    do_it:
        echo $(in $(ROOT), $(dir .))
% omake --output-normal -s do_it
a
b
.
% omake --output-normal -s .PHONY/a/do_it
a
% omake --output-normal -s .PHONY/b/do_it
b
% omake --output-normal -s .PHONY/do_it
a
b
.

@jhwoodyatt
Copy link
Author

Are you aware that .PHONY targets already form a hierarchy that you can use?

Yes! I am, in fact, suggesting it would be nice to have a more compact syntax for referencing .PHONY targets. I would use this in my alternative Conjury library so that it would be easier to build a specific subproject from the command line at the root directory of a project.

I suppose it would be fair to think about this feature request in the context of looking at all the innovative features of Bazel (and its cognates, e.g. Buck, Pants, Please, et cetera), and coming up with new features of OMake to make it better compare with those tools.

@cspiel
Copy link
Collaborator

cspiel commented Feb 24, 2020

Having a strong (GNU-) Make background, I see .PHONY (and .FORCE, .PRECIOUS, etc.)
as an attribute of a target, not part of a target's name. So, I'd prefer omake's .PHONY being
optional at the command line; from the user's perspective it introduces just a target like any
other. Aleksey's example then reduces to something like this

% omake --output-normal -s a/do_it

Wrt to the second part of your suggestion, @jhwoodyatt, I'd even extend its reach: what if
every target mentioned at the command line always undergoes the same expansions?
Every (POSIX-) shell does e.g. "filename expansion" and "brace expansion". As the targets
of a whatever Make program often are filenames it seems only natural to provide a similar
expansion mechanism to the one implemented in our UN*X shells.

My preferred syntax would be close to shell globs, not regexps, though.

$ omake 'test/suite-{alpha,production}' # build test/suite-alpha and
                    # test/suite-production
$ omake 'test/suite-alpha/semantics4[0-9][0-9].log' # build (test-)log files in the
                    # "alpha" suite which are in the 400-group of semantics tests

@jhwoodyatt
Copy link
Author

My preferred syntax would be close to shell globs, not regexps, though.

Sure. That works for me. The target expansion that Bazel provides is really really limited. Wouldn't take much to do better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants