|
396 | 396 | # GHCJS 8.10 does not have these
|
397 | 397 | "Cabal-syntax"
|
398 | 398 | "exceptions"
|
| 399 | + "file-io" |
399 | 400 | "ghc"
|
400 | 401 | "ghc-bignum"
|
401 | 402 | "ghc-experimental"
|
|
422 | 423 | evalPackages.jq
|
423 | 424 | ];
|
424 | 425 | } (let varname = x: builtins.replaceStrings ["-"] ["_"] x; in ''
|
| 426 | + PACKAGE_VERSION=${ghc.version} |
| 427 | + ProjectVersion=${ghc.version} |
| 428 | +
|
| 429 | + # The following logic is from GHC m4/setup_project_version.m4 |
| 430 | +
|
| 431 | + # Split PACKAGE_VERSION into (possibly empty) parts |
| 432 | + VERSION_MAJOR=`echo $PACKAGE_VERSION | sed 's/^\([^.]*\)\(\.\{0,1\}\(.*\)\)$/\1'/` |
| 433 | + VERSION_TMP=`echo $PACKAGE_VERSION | sed 's/^\([^.]*\)\(\.\{0,1\}\(.*\)\)$/\3'/` |
| 434 | + VERSION_MINOR=`echo $VERSION_TMP | sed 's/^\([^.]*\)\(\.\{0,1\}\(.*\)\)$/\1'/` |
| 435 | + ProjectPatchLevel=`echo $VERSION_TMP | sed 's/^\([^.]*\)\(\.\{0,1\}\(.*\)\)$/\3'/` |
| 436 | +
|
| 437 | + # Calculate project version as an integer, using 2 digits for minor version |
| 438 | + case $VERSION_MINOR in |
| 439 | + ?) ProjectVersionInt=''${VERSION_MAJOR}0''${VERSION_MINOR} ;; |
| 440 | + ??) ProjectVersionInt=''${VERSION_MAJOR}''${VERSION_MINOR} ;; |
| 441 | + *) echo bad minor version in $PACKAGE_VERSION; exit 1 ;; |
| 442 | + esac |
| 443 | + # AC_SUBST([ProjectVersionInt]) |
| 444 | +
|
| 445 | + # The project patchlevel is zero unless stated otherwise |
| 446 | + test -z "$ProjectPatchLevel" && ProjectPatchLevel=0 |
| 447 | +
|
| 448 | + # Save split version of ProjectPatchLevel |
| 449 | + ProjectPatchLevel1=`echo $ProjectPatchLevel | sed 's/^\([^.]*\)\(\.\{0,1\}\(.*\)\)$/\1/'` |
| 450 | + ProjectPatchLevel2=`echo $ProjectPatchLevel | sed 's/^\([^.]*\)\(\.\{0,1\}\(.*\)\)$/\3/'` |
| 451 | +
|
| 452 | + # The project patchlevel1/2 is zero unless stated otherwise |
| 453 | + test -z "$ProjectPatchLevel1" && ProjectPatchLevel1=0 |
| 454 | + test -z "$ProjectPatchLevel2" && ProjectPatchLevel2=0 |
| 455 | +
|
| 456 | + # AC_SUBST([ProjectPatchLevel1]) |
| 457 | + # AC_SUBST([ProjectPatchLevel2]) |
| 458 | +
|
| 459 | + # Remove dots from the patch level; this allows us to have versions like 6.4.1.20050508 |
| 460 | + ProjectPatchLevel=`echo $ProjectPatchLevel | sed 's/\.//'` |
| 461 | +
|
| 462 | + # AC_SUBST([ProjectPatchLevel]) |
| 463 | +
|
| 464 | + # The version of the GHC package changes every day, since the |
| 465 | + # patchlevel is the current date. We don't want to force |
| 466 | + # recompilation of the entire compiler when this happens, so for |
| 467 | + # GHC HEAD we omit the patchlevel from the package version number. |
| 468 | + # |
| 469 | + # The ProjectPatchLevel1 > 20000000 iff GHC HEAD. If it's for a stable |
| 470 | + # release like 7.10.1 or for a release candidate such as 7.10.1.20141224 |
| 471 | + # then we don't omit the patchlevel components. |
| 472 | +
|
| 473 | + ProjectVersionMunged="$ProjectVersion" |
| 474 | + if test "$ProjectPatchLevel1" -gt 20000000; then |
| 475 | + ProjectVersionMunged="''${VERSION_MAJOR}.''${VERSION_MINOR}" |
| 476 | + fi |
| 477 | + # AC_SUBST([ProjectVersionMunged]) |
| 478 | +
|
| 479 | + # The version used for libraries tightly coupled with GHC (e.g. |
| 480 | + # ghc-internal) which need a major version bump for every minor/patchlevel |
| 481 | + # GHC version. |
| 482 | + # Example: for GHC=9.10.1, ProjectVersionForLib=9.1001 |
| 483 | + # |
| 484 | + # Just like with project version munged, we don't want to use the |
| 485 | + # patchlevel version which changes every day, so if using GHC HEAD, the |
| 486 | + # patchlevel = 00. |
| 487 | + case $VERSION_MINOR in |
| 488 | + ?) ProjectVersionForLibUpperHalf=''${VERSION_MAJOR}.0''${VERSION_MINOR} ;; |
| 489 | + ??) ProjectVersionForLibUpperHalf=''${VERSION_MAJOR}.''${VERSION_MINOR} ;; |
| 490 | + *) echo bad minor version in $PACKAGE_VERSION; exit 1 ;; |
| 491 | + esac |
| 492 | + # GHC HEAD uses patch level version > 20000000 |
| 493 | + case $ProjectPatchLevel1 in |
| 494 | + ?) ProjectVersionForLib=''${ProjectVersionForLibUpperHalf}0''${ProjectPatchLevel1} ;; |
| 495 | + ??) ProjectVersionForLib=''${ProjectVersionForLibUpperHalf}''${ProjectPatchLevel1} ;; |
| 496 | + *) ProjectVersionForLib=''${ProjectVersionForLibUpperHalf}00 |
| 497 | + esac |
| 498 | +
|
425 | 499 | PKGS=""
|
426 | 500 | ${pkgs.lib.concatStrings
|
427 | 501 | (builtins.map (name: ''
|
|
441 | 515 | fi
|
442 | 516 | if [[ "$cabal_file" != "" ]]; then
|
443 | 517 | fixed_cabal_file=$(mktemp)
|
444 |
| - cat $cabal_file | sed -e 's/@ProjectVersionMunged@/${ghc.version}/g' -e 's/default: *@[A-Za-z0-9]*@/default: False/g' -e 's/@Suffix@//g' > $fixed_cabal_file |
| 518 | + cat $cabal_file | sed -e "s/@ProjectVersionMunged@/$ProjectVersionMunged/g" -e "s/@ProjectVersionForLib@/$ProjectVersionForLib/g" -e 's/default: *@[A-Za-z0-9]*@/default: False/g' -e 's/@Suffix@//g' > $fixed_cabal_file |
445 | 519 | json_cabal_file=$(mktemp)
|
446 | 520 | cabal2json $fixed_cabal_file > $json_cabal_file
|
447 | 521 |
|
|
0 commit comments