Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tricks for porting a large software project to tup build system

What is the best way to port a software project with thousands of .cpp files and associated headers in a fairly well structured source tree to the tup build system?

If the tree looks like:

colors/                                                                            
 primaries/
  red.cpp 
  green.cpp
  blue.cpp
 fruity/
  orange.cpp
  grape.cpp
 grayscale/
  white.cpp
  gray.cpp
  black.cpp
some/annoying/nesting/animals/
    horse.cpp
    bear.cpp

for tens of categories with tens of target files in each, it really seems like a rather inelegant solution to write one-time use shell scripts to dump out Tupfiles in each directory, even if they are ~mostly similar thanks to sharing a Tuprules.tup. What is the right, "best practice", hopefully portable way to do build projects like this with tup?

like image 962
Andrew Wagner Avatar asked Oct 19 '25 21:10

Andrew Wagner


1 Answers

With the recent addition of (still not well documented) LUA parser you can avoid having one Tupfile per directory. Take a look here http://gittup.org/tup/lua_parser.html read about Tupdefault.lua

Additionally - with recent change that allows output files in DIFFERENT folder you can simlify that even more. You can compile the files "somewhere", adding them to a global group(s), and then - when you need it, link/archive them all.

Simple Tuprules.tup:

TOP = $(TUP_CWD)
!cc = |> gcc $(CFLAGS) -c %f -o %o |> %B.o $(TOP)/<objects>

Simple Tupfile just for compilation (generic one, without modification to flags or sth):

include_rules

: foreach *.c |> !cc |>

Simple Tupfile for compilation and final linking (notes as above):

include_rules

: foreach *.c |> !cc |>
: $(TOP)/<objects> |> gcc %<objects> -o %o |> application.exe

Unfortunately I don't (yet) know how to use this particular feature (global groups) with LUA parser. I even asked about that on tup-users mailing list.

like image 183
Freddie Chopin Avatar answered Oct 27 '25 05:10

Freddie Chopin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!