Skip to content

Move profile logic to antrun tasks#93

Merged
tresf merged 14 commits intomasterfrom
ant-task
Jul 31, 2021
Merged

Move profile logic to antrun tasks#93
tresf merged 14 commits intomasterfrom
ant-task

Conversation

@tresf
Copy link

@tresf tresf commented Jul 29, 2021

Since #91 was merged, the profile logic for detecting and setting various build properties was failing in certain scenarios (e.g. One JVM or host OS may report os.arch=x86_64, another reports os.arch=arm64, etc)

The os-maven-plugin is designed to handle these exact scenarios, however it's properties are not available at profile-activation time.

This PR aims to fix that by moving maven's profile logic into dedicated antrun tasks, which are still quite hard to read (a nuance of ant in general), but now well organized much easier to read than the spiderwebs of profile rules we had previously.

This adds the following antrun tasks:

main-props

Calculates the target build system properties, specifically:

  • os.target.name
  • os.target.arch
  • os.target.bitness
  • os.target.classifier

These names were chosen to match the os-maven-plugin convention of os.detected.name, os.detected.arch, etc. If the target system isn't specified, it'll default to the detected system.

Other properties set by calculate-target

  • cmake.generator.nativelibdir
  • cmake.generator.arg (only if a toolchain file is provided)
  • maven.assembly.id

Last, this target is responsible for attaching a toolchain file to cmake, if needed.

msvc-props

  • Sets various cmake compiler options specific to the Microsoft Visual C compiler.
  • This is defaulted to ON for Windows, we don't yet support gcc, clang through like msys2 or cygwin yet. It would be relatively easy to support these down the road if needed.
  • Sets a special cmake.build.arg needed for MSVC-only (to trigger Release builds only, not Debug builds)

xcode-props

  • Sets various cmake compiler options specific to the Clang/LLVM compiler
  • This is defaulted to ON for MacOS. We don't yet support gcc or other compilers on Mac.

gcc-props

  • Sets various cmake compiler options specific to the GNU GCC compiler, assuming a Linux host.
  • This is defaulted to ON for all other OSs, which might cause issues with stuff like Solaris. We don't official support clang or other compilers on Linux, but historically these are drop-in replacements and should work. Note, clang is required for cross-compiling Windows ARM64 binaries from Linux, but this is handled through a dedicated toolchain file (see main-props)

test-props

  • This task is renamed, mostly unchanged, calculated and echos if tests will run by comparing os.target.classifier to os.detected.classifier and setting maven.test.skip appropriately.

show-file-info

  • This is a new task who's only job is to call file (e.g. file target/cmake/natives/macos_64/libjssc.dyllib) and echo the value returned to the screen. @GMKennedy and I used this command a lot testing Add aarch64 support #91 and I shimmed it in to save some time testing. If supported the file command should state the target architecture, which is especially useful for cross-compiling. The command will run on unix variants like MacOS and Linux as well as Windows using git's sh.exe as a shim.

Before merging:

  • @GMKennedy can you help test the various build profiles? I haven't tested mingw, ppc or armhf profiles yet.
  • If possible, I'd love to move these antrun tasks to a dedicated build.xml file, but when doing so, I couldn't get the properties to propagate back to Maven. Any help here is greatly appreciated.

@tresf
Copy link
Author

tresf commented Jul 30, 2021

  • If possible, I'd love to move these antrun tasks to a dedicated build.xml file, but when doing so, I couldn't get the properties to propagate back to Maven. Any help here is greatly appreciated.

Question posted: https://stackoverflow.com/questions/68594740

@tresf
Copy link
Author

tresf commented Jul 31, 2021

  • If possible, I'd love to move these antrun tasks to a dedicated build.xml file, but when doing so, I couldn't get the properties to propagate back to Maven. Any help here is greatly appreciated.

Question posted: https://stackoverflow.com/questions/68594740

I've filed an upstream bug report with maven-antrun-plugin: https://issues.apache.org/jira/browse/MANTRUN-231.

For now, I've created a workaround by writing a properties file and then picking it back up, which seems to do the trick. PR with this workaround is ready in #98.

@tresf tresf merged commit bea6c29 into master Jul 31, 2021
@tresf tresf deleted the ant-task branch July 31, 2021 03:29
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.

2 participants