miracl / core

MIRACL Core
Apache License 2.0
206 stars 68 forks source link

refactor: have script return error code, add non-interactive build options, respect env variables #48

Closed kwvg closed 3 years ago

kwvg commented 3 years ago

The original behavior of ./config64.py and ./config64.py test have not been modified (with the exception of fast-failing being enabled by default now, presuming ./config64.py test is used in a CI environment)

What this PR implements

Usage: ./config64.py [OPTIONS] [ARGUMENTS]

Option              Long Option              Action
   -h, -?           --help                   Shows this message

Script Behaviour:
   -d               --disable-fastfail       Disable script termination if build fails (default: false)
   -i               --ignore-environment     Do not read environment variables, rely on shell instead (default: false)

Build Configuration:
   -o               --options=1 --options=64 Disable interactive mode and select specific options
   -r               --run-tests              Disable interactive mode, select all options, build and run tests
                                             (implies --disable-fastfail, --ignore-environment)

Cheers! 🍻

mcarrickscott commented 3 years ago

One minor issue with this - on my MinGW environment in Windows os.WEXITSTATUS is not recognised.

Mike

On Thu, Jun 24, 2021 at 6:36 PM Kittywhiskers Van Gogh < @.***> wrote:

The original behavior of ./config64.py and ./config64.py test have not been modified (with the exception of fast-failing being enabled by default now, presuming ./config64.py test is used in a CI environment) What this PR implements

  • Removing delete_file calls, I noticed it was added back but it came back to wreck my local repo's state and removing them didn't seem to affect builds
  • The C variant can now respect CFLAGSand CC and the C++ variant can now respect CXXFLAGSand CXX, there a flag to disable it
  • Introduction of fast-failing. If the compilation of a file fails, the whole script should fail. Previously the script would return 0 regardless of internal state, this has been rectified.
  • Introduction of non-interactive builds, so that it can be integrated into other build systems that use Miracl Core as a dependency
  • For those who want the laxer restrictions placed by ./config64.py test, you can now execute ./config64.py --run-tests

Usage: ./config64.py [OPTIONS] [ARGUMENTS]

Option Long Option Action

-h, -? --help Shows this message

Script Behaviour:

-d --disable-fastfail Disable script termination if build fails (default: false)

-i --ignore-environment Do not read environment variables, rely on shell instead (default: false)

Build Configuration:

-o --options=1 --options=64 Disable interactive mode and select specific options

-r --run-tests Disable interactive mode, select all options, build and run tests

                                         (implies --disable-fastfail, --ignore-environment)

Cheers! 🍻

You can view, comment on, or merge this pull request online at:

https://github.com/miracl/core/pull/48 Commit Summary

  • Remove excessive delete_file calls, only delete generated files
  • Move all indent 0 logic to dedicated main() function
  • Shift minimum core library files to tuple, use loop
  • Add new flag that terminates script if compile error found
  • Add the ability to accept CC and CFLAGS
  • Add the ability to build relatively silently, pass arguments

File Changes

Patch Links:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/miracl/core/pull/48, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAU3ZDWN2HRRO6VDPUJRSX3TUNULLANCNFSM47IKT62Q .

kwvg commented 3 years ago

A comment on an answer on Stack Exchange might explain that behavior.

In Windows the exit code of the process should be returned directly, but I'm afraid that you are getting the Linux exit code conversion anyway (cygwin, mingw, or something like that in the way).

According to the Python docs for os.waitstatus_to_exitcode, something that somewhat relies on WEXITSTATUS(), it appears to support Windows.

Also to note, while os.WEXITSTATUS is marked as "Availability: Unix", they add a disclaimer on this page about what that exactly means

An “Availability: Unix” note means that this function is commonly found on Unix systems. It does not make any claims about its existence on a specific operating system.