author | Sam Lantinga <slouken@libsdl.org> |
Sun, 02 Feb 2014 00:53:27 -0800 | |
changeset 8149 | 681eb46b8ac4 |
parent 7925 | f090a47eb7f7 |
child 9619 | b94b6d0bff0f |
permissions | -rwxr-xr-x |
8149
681eb46b8ac4
Fixed bug 2374 - Update copyright for 2014...
Sam Lantinga <slouken@libsdl.org>
parents:
7925
diff
changeset
|
1 |
-- Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> |
7925
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
2 |
-- |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
3 |
-- This software is provided 'as-is', without any express or implied |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
4 |
-- warranty. In no event will the authors be held liable for any damages |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
5 |
-- arising from the use of this software. |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
6 |
-- |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
7 |
-- Permission is granted to anyone to use this software for any purpose, |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
8 |
-- including commercial applications, and to alter it and redistribute it |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
9 |
-- freely. |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
10 |
-- |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
11 |
-- Meta-build system using premake created and maintained by |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
12 |
-- Benjamin Henning <b.henning@digipen.edu> |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
13 |
|
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
14 |
-- This is kept just for windows because the other platforms use different means |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
15 |
-- for determining dependence or compatibility. |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
16 |
|
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
17 |
--[[ |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
18 |
sdl_depends.lua |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
19 |
|
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
20 |
This file simply contains a function for determining whether a dependency |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
21 |
exists on the Windows platform, given a possible environmental variable, |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
22 |
delimited search paths, and a main and/or sub-directory paths for more |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
23 |
elaborate pattern matching. |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
24 |
]] |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
25 |
|
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
26 |
-- find_dependency_dir_windows(env, main_search_path, main_dir_path) |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
27 |
-- Attempt to resolve a dependency (true or false) folder based on either an |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
28 |
-- environmental variable, start search path, or both. If both are present, |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
29 |
-- the environmental variable will be preferred. If neither are present, this |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
30 |
-- function returns false. |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
31 |
-- |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
32 |
-- Arguments: |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
33 |
-- env The name of the environmental variable to treat as a path |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
34 |
-- main_search_paths Paths to look for the main directory in |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
35 |
-- main_dir_path The a path that must be contained between main_search_path and sub_dir_path |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
36 |
-- sub_dir_path The path of the directories that should exist at the searched path |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
37 |
function find_dependency_dir_windows(env, main_search_paths, main_dir_path, sub_dir_path) |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
38 |
if not os.is("windows") then -- if not windows, then fail |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
39 |
return false |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
40 |
end |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
41 |
if env == nil and (main_search_paths == nil or #main_search_paths == 0) then |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
42 |
return false |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
43 |
end |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
44 |
local env_path = nil |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
45 |
local main_path = nil |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
46 |
if env ~= nil then env_path = os.getenv(env) end |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
47 |
local search_table = { n = 0 } |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
48 |
if main_search_paths ~= nil then |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
49 |
for k,main_search_path in ipairs(explode(main_search_paths, ";")) do |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
50 |
local directories = os.matchdirs(main_search_path .. "/**" .. main_dir_path .. "*") |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
51 |
for k,v in pairs(directories) do |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
52 |
table.insert(search_table, v) |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
53 |
end |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
54 |
end |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
55 |
end |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
56 |
if env_path ~= nil then table.insert(search_table, env_path) end |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
57 |
local search_path = table.concat(search_table, ";") |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
58 |
local result_path = os.dirpathsearch(sub_dir_path, search_path, ";") |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
59 |
if result_path == nil then |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
60 |
return false |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
61 |
end |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
62 |
local found_dir = os.isdir(result_path) |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
63 |
local abs_path = path.getabsolute(result_path) |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
64 |
if found_dir and env_path ~= nil then |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
65 |
abs_path = abs_path:gsub("\\", "/") |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
66 |
env_path = env_path:gsub("\\", "/") |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
67 |
local pos = abs_path:indexOf(env_path) |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
68 |
if pos ~= nil then |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
69 |
abs_path = abs_path:sub(1, pos - 1) .. "$(" .. env .. ")/" .. abs_path:sub(pos + #env_path) |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
70 |
end |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
71 |
end |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
72 |
-- we want the path in terms of '/' |
f090a47eb7f7
Added Ben Henning's GSoC2013 work: premake build system.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
73 |
return found_dir, abs_path |
8149
681eb46b8ac4
Fixed bug 2374 - Update copyright for 2014...
Sam Lantinga <slouken@libsdl.org>
parents:
7925
diff
changeset
|
74 |
end |