ar-lib.sh 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #! /bin/sh
  2. # Copyright (C) 2010-2017 Free Software Foundation, Inc.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Make sure 'ar-lib' wraps the Microsoft Library Manager (lib) correctly.
  17. am_create_testdir=empty
  18. required=xsi-lib-shell
  19. . test-init.sh
  20. get_shell_script ar-lib
  21. # Use a dummy lib, since lib isn't readily available on all systems.
  22. cat >lib <<'END'
  23. #! /bin/sh
  24. if test x"$2" = x-LIST && test x"$3" = xfake.lib; then
  25. echo fake.obj
  26. elif test x"$2" = x-LIST && test x"$3" = xfake2.lib; then
  27. printf "%s\n" "dir\\fake2.obj"
  28. else
  29. printf "%s\n" "lib $*"
  30. fi
  31. END
  32. chmod +x ./lib
  33. # Check if ar-lib can create an archive with "cr".
  34. opts=$(./ar-lib ./lib cr foo.lib foo.obj)
  35. test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.obj"
  36. # Check if ar-lib can update an existing archive with "r".
  37. touch foo.lib
  38. opts=$(./ar-lib ./lib r foo.lib foo.obj)
  39. test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib foo.obj"
  40. # Check if ar-lib can update an existing archive with "q".
  41. opts=$(./ar-lib ./lib q foo.lib foo.obj)
  42. test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib foo.obj"
  43. # Check if ar-lib accepts "u" as a modifier.
  44. # NOTE: "u" should have an effect, but currently doesn't.
  45. opts=$(./ar-lib ./lib ru foo.lib foo.obj)
  46. test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib foo.obj"
  47. # Check if ar-lib accepts "s" as a modifier.
  48. opts=$(./ar-lib ./lib rs foo.lib foo.obj)
  49. test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib foo.obj"
  50. # Check if ar-lib accepts "S" as a modifier.
  51. opts=$(./ar-lib ./lib rS foo.lib foo.obj)
  52. test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib foo.obj"
  53. # Check if ar-lib passes on @FILE with "r"
  54. opts=$(./ar-lib ./lib r foo.lib @list)
  55. test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib @list"
  56. # Check if ar-lib can delete a member from an archive with "d".
  57. opts=$(./ar-lib ./lib d foo.lib foo.obj)
  58. test x"$opts" = x"lib -NOLOGO -REMOVE:foo.obj foo.lib"
  59. # Check if ar-lib can delete members in an @FILE.
  60. echo foo.obj > foolist
  61. opts=$(./ar-lib ./lib d foo.lib @foolist)
  62. test x"$opts" = x"lib -NOLOGO -REMOVE:foo.obj foo.lib"
  63. # Check if ar-lib can list archive members with "t".
  64. opts=$(./ar-lib ./lib t foo.lib)
  65. test x"$opts" = x"lib -NOLOGO -LIST foo.lib"
  66. # Check if ar-lib accepts "v" as a modifier.
  67. # NOTE: "v" should have an effect, but currently doesn't.
  68. opts=$(./ar-lib ./lib tv foo.lib)
  69. test x"$opts" = x"lib -NOLOGO -LIST foo.lib"
  70. # Check if ar-lib can extract archive members with "x".
  71. touch fake.lib
  72. opts=$(./ar-lib ./lib x fake.lib)
  73. test x"$opts" = x"lib -NOLOGO -EXTRACT:fake.obj fake.lib"
  74. # Check if ar-lib can extract specified archive members with "x".
  75. opts=$(./ar-lib ./lib x foo.lib foo.obj)
  76. test x"$opts" = x"lib -NOLOGO -EXTRACT:foo.obj foo.lib"
  77. # Check if ar-lib can extract members in an @FILE.
  78. opts=$(./ar-lib ./lib x foo.lib @foolist)
  79. test x"$opts" = x"lib -NOLOGO -EXTRACT:foo.obj foo.lib"
  80. # Check if ar-lib passes -lib and -LTCG through to the wrappee.
  81. opts=$(./ar-lib ./lib -lib -LTCG x foo.lib foo.obj)
  82. test x"$opts" = x"lib -lib -LTCG -NOLOGO -EXTRACT:foo.obj foo.lib"
  83. # Check if ar-lib can extract backslashed members.
  84. touch fake2.lib
  85. opts=$(./ar-lib ./lib x fake2.lib)
  86. test x"$opts" = x"lib -NOLOGO -EXTRACT:dir\\fake2.obj fake2.lib"
  87. # Check if ar-lib accepts "s" as an action.
  88. opts=$(./ar-lib ./lib s foo.lib)
  89. test x"$opts" = x
  90. :