xmake.lua 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. add_rules("mode.debug", "mode.release")
  2. set_languages("c11")
  3. root_dir = "../"
  4. -- Include directories
  5. add_includedirs(root_dir .. "include")
  6. -- Define the shared library target for pocketpy
  7. target("pocketpy")
  8. set_kind("shared")
  9. add_files(root_dir .. "src2/pocketpy_c.c")
  10. -- Define the shared library target
  11. target("test")
  12. set_kind("shared")
  13. add_files("src/test.c")
  14. add_deps("pocketpy")
  15. --
  16. -- If you want to known more usage about xmake, please see https://xmake.io
  17. --
  18. -- ## FAQ
  19. --
  20. -- You can enter the project directory firstly before building project.
  21. --
  22. -- $ cd projectdir
  23. --
  24. -- 1. How to build project?
  25. --
  26. -- $ xmake
  27. --
  28. -- 2. How to configure project?
  29. --
  30. -- $ xmake f -p [macosx|linux|iphoneos ..] -a [x86_64|i386|arm64 ..] -m [debug|release]
  31. --
  32. -- 3. Where is the build output directory?
  33. --
  34. -- The default output directory is `./build` and you can configure the output directory.
  35. --
  36. -- $ xmake f -o outputdir
  37. -- $ xmake
  38. --
  39. -- 4. How to run and debug target after building project?
  40. --
  41. -- $ xmake run [targetname]
  42. -- $ xmake run -d [targetname]
  43. --
  44. -- 5. How to install target to the system directory or other output directory?
  45. --
  46. -- $ xmake install
  47. -- $ xmake install -o installdir
  48. --
  49. -- 6. Add some frequently-used compilation flags in xmake.lua
  50. --
  51. -- @code
  52. -- -- add debug and release modes
  53. -- add_rules("mode.debug", "mode.release")
  54. --
  55. -- -- add macro definition
  56. -- add_defines("NDEBUG", "_GNU_SOURCE=1")
  57. --
  58. -- -- set warning all as error
  59. -- set_warnings("all", "error")
  60. --
  61. -- -- set language: c99, c++11
  62. -- set_languages("c99", "c++11")
  63. --
  64. -- -- set optimization: none, faster, fastest, smallest
  65. -- set_optimize("fastest")
  66. --
  67. -- -- add include search directories
  68. -- add_includedirs("/usr/include", "/usr/local/include")
  69. --
  70. -- -- add link libraries and search directories
  71. -- add_links("tbox")
  72. -- add_linkdirs("/usr/local/lib", "/usr/lib")
  73. --
  74. -- -- add system link libraries
  75. -- add_syslinks("z", "pthread")
  76. --
  77. -- -- add compilation and link flags
  78. -- add_cxflags("-stdnolib", "-fno-strict-aliasing")
  79. -- add_ldflags("-L/usr/local/lib", "-lpthread", {force = true})
  80. --
  81. -- @endcode
  82. --