ice icon indicating copy to clipboard operation
ice copied to clipboard

Generate improved depends file with slice2cpp

Open externl opened this issue 9 months ago • 8 comments

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

externl avatar Mar 07 '25 13:03 externl

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

pepone avatar Mar 12 '25 12:03 pepone

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.

externl avatar Mar 12 '25 14:03 externl

I think slice2cpp is correct here. What does it mean for a non target to have dependencies?

pepone avatar Mar 12 '25 14:03 pepone

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.

externl avatar Mar 12 '25 14:03 externl

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.

pepone avatar Mar 12 '25 14:03 pepone

I see what you mean now!

externl avatar Mar 12 '25 14:03 externl

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.

pepone avatar Mar 12 '25 14:03 pepone

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.

pepone avatar Jul 30 '25 15:07 pepone