Generate improved depends file with slice2cpp
When generating a BNF style depends file with --depend, the slice2cpp compiler currently (as of 3.7) generates:
> slice2cpp Foo.ice --depend
Foo.: \
Foo.ice \
<dependencies of foo>
If you specify an extension using metadata or on the command line we'll generate Foo.<ext>: instead.
This default output isn't really usable as the file Foo. does not exist. I think it would be preferable if the target was the slice file itself:
Foo.ice: \
<dependencies>
Note that in our C++ Makefiles we modify the output to make it usable.
https://github.com/zeroc-ice/ice/blob/089da7b29ffee6332727a78976f31ceb1035ea85/config/Make.project.rules#L179-L185
Fixing this would make the generated depends file usable out of the box by our new CMake support files.
[!NOTE] This does not affect --depend-xml
Compilers are not consistent with each other here:
jose@mac ice % ./cpp/bin/slice2cpp --depend slice/Ice/Locator.ice
Locator.h: \
slice/Ice/Locator.ice \
/Users/jose/Documents/3.8/ice/slice/Ice/Identity.ice
jose@mac ice % ./cpp/bin/slice2cs --depend slice/Ice/Locator.ice
Locator.cs: \
slice/Ice/Locator.ice \
/Users/jose/Documents/3.8/ice/slice/Ice/Identity.ice
jose@mac ice % ./cpp/bin/slice2java --depend slice/Ice/Locator.ice
slice/Ice/Locator.ice: \
/Users/jose/Documents/3.8/ice/slice/Ice/Identity.ice
jose@mac ice % ./cpp/bin/slice2js --depend slice/Ice/Locator.ice
Locator.js: \
slice/Ice/Locator.ice \
/Users/jose/Documents/3.8/ice/slice/Ice/Identity.ice
jose@mac ice % ./cpp/bin/slice2matlab --depend slice/Ice/Locator.ice
slice/Ice/Locator.ice: \
/Users/jose/Documents/3.8/ice/slice/Ice/Identity.ice
jose@mac ice % ./cpp/bin/slice2php --depend slice/Ice/Locator.ice
Locator.php: \
slice/Ice/Locator.ice \
/Users/jose/Documents/3.8/ice/slice/Ice/Identity.ice
jose@mac ice % ./cpp/bin/slice2py --depend slice/Ice/Locator.ice
Locator_ice.py: \
slice/Ice/Locator.ice \
/Users/jose/Documents/3.8/ice/slice/Ice/Identity.ice
jose@mac ice % ./cpp/bin/slice2rb --depend slice/Ice/Locator.ice
Locator.rb: \
slice/Ice/Locator.ice \
/Users/jose/Documents/3.8/ice/slice/Ice/Identity.ice
jose@mac ice % ./cpp/bin/slice2swift --depend slice/Ice/Locator.ice
Locator.swift: \
slice/Ice/Locator.ice \
/Users/jose/Documents/3.8/ice/slice/Ice/Identity.ice
Aside from the C++ issue of Foo.:, I'm not sure which one is most correct. ie. should the target be the output file or the input slice file.
I think slice2cpp is correct here. What does it mean for a non target to have dependencies?
I mean:
jose@mac ice % ./cpp/bin/slice2matlab --depend slice/Ice/Locator.ice
slice/Ice/Locator.ice: \
/Users/jose/Documents/3.8/ice/slice/Ice/Identity.ice
vs
jose@mac ice % ./cpp/bin/slice2swift --depend slice/Ice/Locator.ice
Locator.swift: \
slice/Ice/Locator.ice \
/Users/jose/Documents/3.8/ice/slice/Ice/Identity.ice
With slice2matlab the target is the input slice file, with slice2swift it's the generated Swift file.
Yes. I understand. I think the slice2matlab, slice2java version doesn't make much sense. At least not as Makefile dependencies which is what --depend is supposed to output.
You will not have a a rule to build Locator.ice, so adding dependencies to it seems pointless.
I see what you mean now!
I think we should remove the option from slice2java
- Nobody would ever use Makefiles to build Java.
- The Ice Builder and the new Slice tools use --depend-xml
- If you wanted to use the dependencies you would also need the list of generated files, which are only provided as XML using --list-generated.
Is there anything specific to CMake we can do to improve the generated dependencies? If so we can update the new DependencyVisitor to handle it otherwise close it. I going to assign this to @externl as he knows the CMake stuff and can look at it when he is back.