| Elliott Hughes | d173c99 | 2019-01-10 14:51:35 -0800 | [diff] [blame] | 1 | -- |
| 2 | -- Requires: Premake 5 (https://premake.github.io/) |
| 3 | -- Usage: premake5 --file=premake5.lua [project / makefile format, refer to premake5 --help] --target=[target from below] |
| 4 | -- |
| 5 | |
| 6 | -- target option |
| 7 | tbl_target_values = |
| 8 | { |
| 9 | { "windows", "VS2015 projects targeting Windows 32/64 bits" }, |
| 10 | { "macosx", "Xcode4 projects targeting OS X" }, |
| 11 | } |
| 12 | |
| 13 | newoption |
| 14 | { |
| 15 | trigger = "target", |
| 16 | description = "Build environment and target to generate projects for.", |
| 17 | allowed = tbl_target_values |
| 18 | } |
| 19 | |
| 20 | -- validation |
| 21 | target_env = _OPTIONS["target"] |
| 22 | if not target_env then |
| 23 | print "Command-line option --target is required with one of the following values:" |
| 24 | for _, v in ipairs(tbl_target_values) do |
| 25 | print(v[1]) |
| 26 | end |
| 27 | os.exit(1) |
| 28 | end |
| 29 | |
| 30 | -- solution |
| 31 | workspace "tinyxml2" |
| 32 | |
| 33 | tbl_platforms = {} |
| 34 | if target_env == "windows" then |
| 35 | tbl_platforms = { |
| 36 | "x86", |
| 37 | "x64", |
| 38 | } |
| 39 | elseif target_env == "macosx" then |
| 40 | tbl_platforms = { |
| 41 | "Universal64" |
| 42 | } |
| 43 | end |
| 44 | platforms(tbl_platforms) |
| 45 | |
| 46 | tbl_configurations = { |
| 47 | "Debug", |
| 48 | "Release", |
| 49 | } |
| 50 | configurations(tbl_configurations) |
| 51 | |
| 52 | sln_location = ".projects/"..target_env |
| 53 | location(sln_location) |
| 54 | |
| 55 | bin_location = ".artifacts/"..target_env |
| 56 | obj_location = ".intermediate/"..target_env |
| 57 | |
| 58 | for _, p in ipairs(tbl_platforms) do |
| 59 | for _, c in ipairs(tbl_configurations) do |
| 60 | local pc = p.."-"..c |
| 61 | filter{ "platforms:"..p, c } |
| 62 | targetdir(bin_location.."/"..pc) |
| 63 | libdirs(bin_location.."/"..pc) |
| 64 | objdir(obj_location.."/"..pc) |
| 65 | end |
| 66 | end |
| 67 | |
| 68 | filter("not Release") |
| 69 | optimize "Debug" |
| 70 | symbols "On" |
| 71 | filter{ "Release" } |
| 72 | optimize "Full" |
| 73 | filter{} |
| 74 | |
| 75 | -- projects |
| 76 | project "tinyxml2" |
| 77 | |
| 78 | kind "staticlib" |
| 79 | |
| 80 | files { |
| 81 | "tinyxml2.h", |
| 82 | "tinyxml2.cpp" |
| 83 | } |
| 84 | |
| 85 | project "xmltest" |
| 86 | |
| 87 | kind "consoleapp" |
| 88 | |
| 89 | links { |
| 90 | "tinyxml2" |
| 91 | } |
| 92 | |
| 93 | files { |
| 94 | "xmltest.cpp" |
| 95 | } |