Browse Source

Fourth round at build and packaging scripts.

pull/585/head
Joao Matos 10 years ago
parent
commit
779ed9db71
  1. 1
      build/Helpers.lua
  2. 19
      build/LLVM.lua
  3. 8
      build/scripts/Build.lua
  4. 17
      build/scripts/Dependencies.lua
  5. 43
      build/scripts/LLVM.lua
  6. 17
      build/scripts/Provision.lua
  7. 1
      src/CppParser/premake4.lua

1
build/Helpers.lua

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
action = _ACTION or ""
basedir = path.getdirectory(_PREMAKE_COMMAND)
depsdir = path.getabsolute("../deps");
srcdir = path.getabsolute("../src");
incdir = path.getabsolute("../include");

19
build/LLVM.lua

@ -1,9 +1,22 @@ @@ -1,9 +1,22 @@
-- Setup the LLVM dependency directories
LLVMRootDir = "../../deps/llvm/"
LLVMBuildDir = "../../deps/llvm/build/"
LLVMRootDir = depsdir .. "/llvm/"
LLVMBuildDir = LLVMRootDir .. "llvm/build/"
-- TODO: Search for available system dependencies
require "scripts/LLVM"
function SearchLLVM()
local pkg_path = basedir .. "/scripts/" .. get_llvm_package_name()
print(path.getabsolute(pkg_path))
if os.isdir(pkg_path) then
LLVMRootDir = pkg_path
elseif os.isdir(LLVMRootDir) then
else
error("Error finding an LLVM build")
end
print("Using LLVM build: " .. LLVMRootDir)
end
function SetupLLVMIncludes()
local c = configuration()

8
build/scripts/Build.lua

@ -25,7 +25,7 @@ function msbuild(sln, conf) @@ -25,7 +25,7 @@ function msbuild(sln, conf)
execute(cmd)
end
function premake(file, action)
function run_premake(file, action)
-- search for file with extension Lua
if os.isfile(file .. ".lua") then
file = file .. ".lua"
@ -37,15 +37,15 @@ end @@ -37,15 +37,15 @@ end
function build_cppsharp()
-- install dependencies
premake("Provision", "provision")
run_premake("Provision", "provision")
-- if there is an llvm git clone then use it
-- otherwise download and extract llvm/clang build
premake("LLVM", "download_llvm")
run_premake("LLVM", "download_llvm")
-- generate project files
premake("../premake4", "gmake")
run_premake("../premake4", "gmake")
-- build cppsharp
--[[BUILD_CONF=release_x32;

17
build/scripts/Dependencies.lua

@ -1,17 +0,0 @@ @@ -1,17 +0,0 @@
require "Utils"
function nuget()
if not os.isfile("nuget.exe") then
http.download("https://nuget.org/nuget.exe")
end
local nugetexe = os.is("windows") and "NuGet.exe" or "mono ./NuGet.exe"
execute(nugetexe .. " restore packages.config -PackagesDirectory ../deps")
end
clone()
if _ACTION == "nuget" then
nuget()
os.exit()
end

43
build/scripts/LLVM.lua

@ -1,7 +1,8 @@ @@ -1,7 +1,8 @@
require "Build"
require "Utils"
require "../Helpers"
local llvm = "../../deps/llvm"
local llvm = basedir .. "/../../deps/llvm"
-- If we are inside vagrant then clone and build LLVM outside the shared folder,
-- otherwise file I/O performance will be terrible.
@ -11,11 +12,19 @@ end @@ -11,11 +12,19 @@ end
local llvm_build = llvm .. "/" .. os.get()
function get_llvm_rev()
return cat(basedir .. "/LLVM-commit")
end
function get_clang_rev()
return cat(basedir .. "/Clang-commit")
end
function clone_llvm()
local llvm_release = cat("../LLVM-commit")
local llvm_release = get_llvm_rev()
print("LLVM release: " .. llvm_release)
local clang_release = cat("../Clang-commit")
local clang_release = get_clang_rev()
print("Clang release: " .. clang_release)
if os.isdir(llvm) and not os.isdir(llvm .. "/.git") then
@ -42,18 +51,28 @@ function clone_llvm() @@ -42,18 +51,28 @@ function clone_llvm()
end
function get_llvm_package_name(rev, conf)
if not rev then
rev = get_llvm_rev()
end
if not conf then
conf = get_llvm_configuration_name()
end
rev = string.sub(rev, 0, 6)
return table.concat({"llvm", rev, os.get(), conf}, "-")
end
function get_llvm_configuration_name()
return os.is("windows") and "RelWithDebInfo" or "Release"
end
function extract_7z(archive, dest_dir)
return execute(string.format("7z x %s -o%s -y", archive, dest_dir), true)
end
function download_llvm()
local base = "https://dl.dropboxusercontent.com/u/194502/CppSharp/llvm/"
local conf = os.is("windows") and "RelWithDebInfo" or "Release"
local rev = string.sub(cat("../LLVM-commit"), 0, 6)
local pkg_name = get_llvm_package_name(rev, conf)
local pkg_name = get_llvm_package_name()
local archive = pkg_name .. ".7z"
-- check if we already have the file downloaded
@ -86,20 +105,21 @@ function clean_llvm(llvm_build) @@ -86,20 +105,21 @@ function clean_llvm(llvm_build)
end
function build_llvm(llvm_build)
local conf = get_llvm_configuration_name()
if os.is("windows") then
cmake("Visual Studio 12 2013", "RelWithDebInfo")
cmake("Visual Studio 12 2013", conf)
local llvm_sln = path.join(llvm_build, "LLVM.sln")
msbuild(llvm_sln, "RelWithDebInfo")
msbuild(llvm_sln, conf)
else
cmake("Ninja", "Release")
cmake("Ninja", conf)
execute("ninja")
execute("ninja clang-headers")
end
end
function package_llvm(conf, llvm, llvm_build)
local rev = string.sub(git.rev_parse(llvm, "HEAD"), 0, 6)
local rev = git.rev_parse(llvm, "HEAD")
local out = get_llvm_package_name(rev, conf)
if os.isdir(out) then os.rmdir(out) end
@ -159,7 +179,8 @@ if _ACTION == "build_llvm" then @@ -159,7 +179,8 @@ if _ACTION == "build_llvm" then
end
if _ACTION == "package_llvm" then
local pkg = package_llvm("RelWithDebInfo", llvm, llvm_build)
local conf = get_llvm_configuration_name()
local pkg = package_llvm(conf, llvm, llvm_build)
archive_llvm(pkg)
os.exit()
end

17
build/scripts/Provision.lua

@ -45,12 +45,23 @@ function download_cmake() @@ -45,12 +45,23 @@ function download_cmake()
end
end
function download_nuget()
if not os.isfile("nuget.exe") then
download("https://nuget.org/nuget.exe", "nuget.exe")
end
end
function restore_nuget_packages()
local nugetexe = os.is("windows") and "NuGet.exe" or "mono ./NuGet.exe"
execute(nugetexe .. " restore packages.config -PackagesDirectory " .. depsdir)
end
local compile_llvm = is_vagrant()
function provision_linux()
-- Add Repos
sudo("apt-key adv --keyserver http:////keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF")
sudo("echo \"deb http:////download.mono-project.com/repo/debian wheezy main\" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list")
sudo("apt-key adv --keyserver http://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF")
sudo("echo \"deb http://download.mono-project.com/repo/debian wheezy main\" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list")
if is_vagrant() then
sudo("add-apt-repository -y ppa:george-edison55/cmake-3.x")
@ -96,3 +107,5 @@ if _ACTION == "provision" then @@ -96,3 +107,5 @@ if _ACTION == "provision" then
end
os.exit()
end

1
src/CppParser/premake4.lua

@ -37,6 +37,7 @@ project "CppSharp.CppParser" @@ -37,6 +37,7 @@ project "CppSharp.CppParser"
"*.lua"
}
SearchLLVM()
SetupLLVMIncludes()
SetupLLVMLibs()

Loading…
Cancel
Save