jasonwhite / button

A build system that aims to be fast, correct, and elegantly simple.
http://jasonwhite.github.io/button/
MIT License
41 stars 5 forks source link

Parent build rebuilds resources of recursive one #21

Open mihails-strasuns opened 7 years ago

mihails-strasuns commented 7 years ago

Can be reproduced with https://projects.dicebot.lv/desktop/libmpcd :

$ cd build; button build
 > button-lua BUILD.lua -o button-lua.json
 > button convert -f button-lua.json build.sh
 > dmd example
 > button build -f button-lua.json
$ cd ..; button build
 - Warning: Output file `tests/.button.json.state` was changed externally and will be regenerated.
 - Warning: Output file `tests/.button-lua.json.state` was changed externally and will be regenerated.
 - Warning: Output file `tests/build.sh` was changed externally and will be regenerated.
 - Warning: Output file `tests/button-lua.json` was changed externally and will be regenerated.
 - Warning: Output file `tests/obj/unittests` was changed externally and will be regenerated.
 - Warning: Output file `tests/obj/unittests.stamp` was changed externally and will be regenerated.
 - Warning: Output file `build/.button-lua.json.state` was changed externally and will be regenerated.
 - Warning: Output file `build/.button.json.state` was changed externally and will be regenerated.
 - Warning: Output file `build/bin/example` was changed externally and will be regenerated.
 - Warning: Output file `build/build.sh` was changed externally and will be regenerated.
 - Warning: Output file `build/button-lua.json` was changed externally and will be regenerated.
 - Warning: Output file `.button-lua.json.state` was changed externally and will be regenerated.
 - Warning: Output file `build.sh` was changed externally and will be regenerated.
 - Warning: Output file `button-lua.json` was changed externally and will be regenerated.
 - Warning: Output file `bin/example` was changed externally and will be regenerated.
 > button-lua BUILD.lua -o button-lua.json
 > button convert -f button-lua.json build.sh
 > button-lua BUILD.lua -o button-lua.json
 - Warning: Output file `bin/example` was changed externally and will be regenerated.
 > button convert -f button-lua.json build.sh
 > dmd example
 > button build -f button-lua.json
 > button build -f build/button.json
 > dmd unittests
 > obj/unittests
 > button build -f button-lua.json
 > button build -f tests/button.json
$ cd build; button build 
 - Warning: Output file `.button-lua.json.state` was changed externally and will be regenerated.
 - Warning: Output file `build.sh` was changed externally and will be regenerated.
 - Warning: Output file `button-lua.json` was changed externally and will be regenerated.
 - Warning: Output file `bin/example` was changed externally and will be regenerated.
 > button-lua BUILD.lua -o button-lua.json
 > button convert -f button-lua.json build.sh
 - Warning: Output file `bin/example` was changed externally and will be regenerated.
 > dmd example
 > button build -f button-lua.json

I don't know what is really happening here but it looks wasteful that same resources keep being considered "changed externally" depending on root directory that triggers the build. Is this by design or a bug?

jasonwhite commented 7 years ago

It is wasteful and it has been on my TODO list for a long time. This code is the root of the problem.

The fix is to pass to each task a list of all the incoming resources that were modified and are causing it to be executed. Then, the parent build tells the child build which resources were modified so it doesn't have to recalculate (which can be very expensive). This will have to be implemented as part of the graph traversal algorithm in graph.d.