test_gcc.lua 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. --
  2. -- tests/test_gcc.lua
  3. -- Automated test suite for the GCC toolset interface.
  4. -- Copyright (c) 2009-2011 Jason Perkins and the Premake project
  5. --
  6. T.gcc = { }
  7. local suite = T.gcc
  8. local cfg
  9. function suite.setup()
  10. cfg = { }
  11. cfg.basedir = "."
  12. cfg.location = "."
  13. cfg.language = "C++"
  14. cfg.project = { name = "MyProject" }
  15. cfg.flags = { }
  16. cfg.objectsdir = "obj"
  17. cfg.platform = "Native"
  18. cfg.links = { }
  19. cfg.libdirs = { }
  20. cfg.linktarget = { fullpath="libMyProject.a" }
  21. end
  22. --
  23. -- CPPFLAGS tests
  24. --
  25. function suite.cppflags_OnWindows()
  26. cfg.system = "windows"
  27. local r = premake.gcc.getcppflags(cfg)
  28. test.isequal("-MMD -MP", table.concat(r, " "))
  29. end
  30. --
  31. -- CFLAGS tests
  32. --
  33. function suite.cflags_SharedLib_Windows()
  34. cfg.kind = "SharedLib"
  35. cfg.system = "windows"
  36. local r = premake.gcc.getcflags(cfg)
  37. test.isequal('', table.concat(r,"|"))
  38. end
  39. function suite.cflags_OnFpFast()
  40. cfg.flags = { "FloatFast" }
  41. local r = premake.gcc.getcflags(cfg)
  42. test.isequal('-ffast-math', table.concat(r,"|"))
  43. end
  44. function suite.cflags_OnFpStrict()
  45. cfg.flags = { "FloatStrict" }
  46. local r = premake.gcc.getcflags(cfg)
  47. test.isequal('-ffloat-store', table.concat(r,"|"))
  48. end
  49. --
  50. -- LDFLAGS tests
  51. --
  52. function suite.ldflags_SharedLib_Windows()
  53. cfg.kind = "SharedLib"
  54. cfg.system = "windows"
  55. local r = premake.gcc.getldflags(cfg)
  56. test.isequal('-s|-shared|-Wl,--out-implib="libMyProject.a"', table.concat(r,"|"))
  57. end
  58. function suite.linkflags_OnFrameworks()
  59. cfg.links = { "Cocoa.framework" }
  60. local r = premake.gcc.getlinkflags(cfg)
  61. test.isequal('-framework Cocoa', table.concat(r,"|"))
  62. end