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

Add the D %-flag for the dirname. #345

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add the D %-flag for the dirname. #345

wants to merge 1 commit into from

Conversation

vicencb
Copy link

@vicencb vicencb commented Feb 25, 2018

%D (dirname) is the counterpart of %b (basename)
It is useful for recreating the source directory structure inside the
build directory.

%D (dirname) is the counterpart of %b (basename)
It is useful for recreating the source directory structure inside the
build directory.
@gittup
Copy link
Owner

gittup commented Feb 27, 2018

Thanks for adding this! I'm curious what use-case you have that needs this flag? Also, do you mind signing the CLA since this adds new functionality?

@vicencb
Copy link
Author

vicencb commented Feb 27, 2018

Hi
for the use case, consider the following Tupfile:

# There can be several files with the same basename.
SOURCES+=src/dir1/*.c
SOURCES+=src/dir2/*.c
SOURCES+=src/dir2/dir3/*.c
SOURCES+=src/*.c

# Put all autogenerated files in the obj directory.

# This will not work, because several object files with the same basename will overwrite each other.
# foreach $(SOURCES) |> cc -c %f -o %o |> obj/%B.o {obj}

# With %D the same directory structure found in src will be inside obj.
: foreach $(SOURCES) |> cc -c %f -o %o |> obj/%D%B.o {obj}

: {obj} |> cc %f -o %o |> obj/program

For the CLA, I have read https://github.com/gittup/tup/blob/master/CONTRIBUTING.md but that page is not convincing me to sign anything.
Could you expand that page to try to convince potential contributors into signing it?
Some information I would like to see in that page:

  1. Why do you want contributors to sign it?
  2. Why a contributor is requested all that information? (e-mail address, personal address, ...)
  3. If my contribution is placed in the public domain, do I need to sign the CLA?

Regards,
  Vicenç.

@vicencb
Copy link
Author

vicencb commented Mar 12, 2018

Hello,
I have found http://gittup.org/tup/license.html which answers point no. 1.
A link could be added in CONTRIBUTING.md.
Please, can you answer 2 and 3? I am specially interested in 3.

Regards,
  Vicenç.

@s-ol
Copy link

s-ol commented Oct 19, 2018

I'm also needing this for the same reason. I am transpiling a directory tree of files to another destination directory and want to keep the directory structure intact. The two solutions I see are

app/*.moon app/nested/*.moon |> moonc -o %o %f |> %D%B.lua

app/*.moon app/nested/*.moon |> moonc -o %o %f |> %F.lua

where %F would be the whole path with the extension stripped (like %B is to %b).

Also bump since it seems like this perhaps got lost @gittup

@danielytics
Copy link

It looks like this isn't going to be added? I also need this :'(

@gittup is there any chance this feature be implemented?

@gittup
Copy link
Owner

gittup commented Oct 29, 2020

It looks like this isn't going to be added? I also need this :'(

@gittup is there any chance this feature be implemented?

Hi @danielytics, can you clarify what your use-case is? The initial suggestion of using it to re-create the source hierarchy inside a build directory would already be automatically handled by variants. Can you give an example Tupfile of what you're wanting to do?

@danielytics
Copy link

danielytics commented Oct 29, 2020

I guess I'm just trying to simplify the Tupfile for the case when the sources are spread between subdirectories (which I often do to keep large sources easier to manage) and I'm trying to figure out how to keep my Tupfile small and simple. Ideally, it would support both recursive directory globbing as well as this feature to really work though... But maybe I'm missing something and there's a simpler way?

Right now, I have a Tupfile that looks something like this:

: foreach src/*.cpp |> !compile-c++  |> build/B.o
: foreach src/core/*.cpp |> !compile-c++ |> build/core_%B.o
: foreach src/utils/*.cpp |> !compile-c++ |> build/utils_%B.o
# ...
: build/*.o |> !link-exe |> ../prog

It works, but its not ideal as I have to manually enumerate all subdirectories and then either prefix the object files, or again enumerate the subdirectories in the inputs for the link step.

EDIT: Ok, I'm still learning tup, but I guess as long as I restrict it to one level of nesting, I can do this:

:foreach src/foo/*.cpp |> !compile-c++ |> build/%d_%B.o
:foreach src/bar/*.cpp |> !compile-c++ |> build/%d_%B.o

@danielytics
Copy link

Ah, apologies @gittup for the noise. I think I can accomplish more or less what I want, using %d to name the outputs and groups as inputs so I don't need to list directories more than once. I guess I didn't understand tup's capabilities well enough, but after rereading the docs a few times, I think I've got it.

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

Successfully merging this pull request may close these issues.

None yet

4 participants