util,scons: improve compareVersions function
authorHoa Nguyen <hoanguyen@ucdavis.edu>
Thu, 30 Jul 2020 22:30:57 +0000 (15:30 -0700)
committerHoa Nguyen <hoanguyen@ucdavis.edu>
Fri, 31 Jul 2020 18:40:30 +0000 (18:40 +0000)
commit5bf345f77a31c16a0f500cdaaef2749565068fe5
tree9534b60d56c97897ee12c5bb09db4805e2f2fce5
parentbd25fc971df317f17ea39f46e3f515a26b43ddaa
util,scons: improve compareVersions function

Current compareVersions() fails in this case:
compareVersions("10", "10.0") return -1 while it should be 0.
This at least is causing a systemc compiling issue.

This problem causes by the comparison algorithm. The algorithm
turns the versions in two lists, and compares the corresponding
elements of the two lists up to the last element of the shorter
list. If all elements are equal, the longer list will be
determined to be the more recent version. Hence, this algorithm
determines "10.0" to be more recent to "10".

This commit addresses this issue by making the version lists
have the same length by adding 0 to the shorter list.

JIRA: https://gem5.atlassian.net/browse/GEM5-715

Change-Id: I859679185ac67e1b4d327d8803699cc5e399fa8c
Signed-off-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/32014
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/python/m5/util/__init__.py