Advertisement
Guest User

Untitled

a guest
Feb 15th, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. function config_file_excludes( srcFolder, platforms )
  2. local curConf = configuration().current
  3. for plat, fold in pairs( platforms ) do
  4. configuration{ "not " .. plat, fold .. "/" .. plat .. "**" }
  5. flags { "ExcludeFromBuild" }
  6. end
  7. for _, fold in ipairs(os.matchdirs(srcFolder .. "/*")) do
  8. config_file_excludes( fold )
  9. end
  10. configuration( ).current = curConf
  11. end
  12.  
  13. function config_current_project( )
  14. local curConf = configuration().current
  15. local dirs = os.matchdirs( "*" )
  16. if path_list_contains_top( dirs, "inc" ) then
  17. files{ "inc/**.h", "inc/**.hpp" }
  18. includedirs{ "inc" }
  19. config_ext_includes( "inc" )
  20. end
  21. if path_list_contains_top( dirs, "inc_private" ) then
  22. files{ "inc_private/**.h", "inc_private/**.hpp" }
  23. includedirs{ "inc_private" }
  24. config_ext_includes( "inc_private" )
  25. end
  26. if path_list_contains_top( dirs, "src" ) then
  27. files{ "src/**.cpp", "src/**.c" }
  28. config_file_excludes( "src" )
  29. end
  30. configuration( ).current = curConf
  31. end
  32.  
  33. ...
  34.  
  35. local allProjs = {}
  36. for sln in premake.global.eachSolution() do -- Iterate over every solution
  37. solution( sln.name ) -- Activate it
  38. for _, prj in ipairs( sln.projects ) do -- Now iterate over every project within that solution
  39. if prj.solution == sln then -- Skip external projects ( possible to import the same project into multiple solutions )
  40. allProjs[#allProjs + 1] = prj
  41. project( prj.name )
  42. filter "kind:SharedLib or *App"
  43. targetdir( "bin/" .. prj.name ) -- All application variants should be output to the bin folder followed by the project name
  44. debugdir( "bin/" .. prj.name )
  45. end
  46. end
  47. for _, cfg in ipairs(sln.configurations) do -- Now lets cover all configurations{}
  48. for _, plat in ipairs(sln.platforms) do -- Combined with platforms{}
  49. for _, prj in ipairs(sln.projects) do -- We need to iterate at project level as well to activate the project
  50. if prj.solution == sln then -- Skip external projects
  51. local lib_path = path.join( "lib" , cfg .. plat )
  52. project( prj.name ) -- Activate project so that location() gives us the correct info
  53. flags { "StaticRuntime" }
  54. configuration { cfg, plat } -- Activate the config / platform combo
  55. libdirs { lib_path } -- And set the library search folder
  56. objdir( "obj/" .. prj.name .. "/" .. cfg .. plat ) -- Also create a folder inside that project for object files
  57. configuration { "StaticLib", cfg, plat }
  58. targetdir( lib_path ) -- Set the library output path
  59. end
  60. end
  61. end
  62. end
  63. end
  64. make_soltuion_from_common( "ALL" ) -- Create a solution file that imports all projects
  65. location "sln"
  66. for _, prj in ipairs( allProjs ) do
  67. importproject( prj )
  68. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement