Browse Source

Auto-detect .NET target framework to use in `build.sh` (#1864)

* Auto-detect .NET target framework to use in `build.sh`.

* Remove some unused build code and files.
pull/1867/head
João Matos 10 months ago committed by GitHub
parent
commit
bf03942a92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 12
      build/build.sh
  2. 1
      build/premake5.lua
  3. 19
      build/scripts/ClangToolset.cmake
  4. 117
      build/scripts/Provision.lua
  5. 44
      build/scripts/Vagrantfile

12
build/build.sh

@ -54,6 +54,18 @@ generate()
{ {
download_llvm download_llvm
if [ "$target_framework" = "" ]; then
if command -v dotnet &> /dev/null
then
version=$(dotnet --version)
major_minor=$(echo $version | awk -F. '{print $1"."$2}')
target_framework="net$major_minor"
else
echo ".NET is not installed, cannot lookup up target framework version."
fi
fi
if [ "$os" = "linux" ] || [ "$os" = "macosx" ]; then if [ "$os" = "linux" ] || [ "$os" = "macosx" ]; then
"$builddir/premake.sh" --file="$builddir/premake5.lua" gmake2 --os=$os --arch=$platform --configuration=$configuration --target-framework=$target_framework "$@" "$builddir/premake.sh" --file="$builddir/premake5.lua" gmake2 --os=$os --arch=$platform --configuration=$configuration --target-framework=$target_framework "$@"
fi fi

1
build/premake5.lua

@ -53,7 +53,6 @@ workspace "CppSharp"
if EnabledManagedProjects() then if EnabledManagedProjects() then
include (srcdir .. "/Core") include (srcdir .. "/Core")
include (srcdir .. "/AST") include (srcdir .. "/AST")
--include (srcdir .. "/ASTViewer")
include (srcdir .. "/CppParser/Bindings") include (srcdir .. "/CppParser/Bindings")
include (srcdir .. "/CppParser/Bootstrap") include (srcdir .. "/CppParser/Bootstrap")
include (srcdir .. "/CppParser/ParserGen") include (srcdir .. "/CppParser/ParserGen")

19
build/scripts/ClangToolset.cmake

@ -1,19 +0,0 @@
SET (CMAKE_C_COMPILER "/usr/bin/clang")
SET (CMAKE_C_FLAGS "-Wall -std=c99")
SET (CMAKE_C_FLAGS_DEBUG "-glldb")
SET (CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG")
SET (CMAKE_C_FLAGS_RELEASE "-O4 -DNDEBUG")
SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -glldb")
SET (CMAKE_CXX_COMPILER "/usr/bin/clang++")
SET (CMAKE_CXX_FLAGS "-Wall")
SET (CMAKE_CXX_FLAGS_DEBUG "-glldb")
SET (CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
SET (CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG")
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -glldb")
SET (CMAKE_AR "/usr/bin/llvm-ar")
SET (CMAKE_LINKER "/usr/bin/llvm-ld")
SET (CMAKE_NM "/usr/bin/llvm-nm")
SET (CMAKE_OBJDUMP "/usr/bin/llvm-objdump")
SET (CMAKE_RANLIB "/usr/bin/llvm-ranlib")

117
build/scripts/Provision.lua

@ -1,117 +0,0 @@
require "Utils"
function download_ninja()
local system = "";
if os.ishost("windows") then
system = "win"
elseif os.ishost("macosx") then
system = "mac"
elseif os.ishost("linux") then
system = "linux"
else
error("Error downloading Ninja for unknown system")
end
local url = "https://github.com/ninja-build/ninja/releases/download/v1.6.0/ninja-" .. system .. ".zip"
local file = "ninja.zip"
if not os.isfile(file) then
download(url, file)
end
if os.isfile(file) then
print("Extracting file " .. file)
zip.extract(file, "ninja")
end
end
function download_cmake()
local system = "";
if os.ishost("windows") then
system = "win32-x86.zip"
elseif os.ishost("macosx") then
system = "Darwin-x86_64.dmg"
elseif os.ishost("linux") then
system = "Linux-x86_64.sh"
else
error("Error downloading CMake for unknown system")
end
local base = "cmake-3.8.2-"
local file = base .. system
local url = "https://cmake.org/files/v3.8/" .. file
if not os.isfile(file) then
download(url, file)
end
return file
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.ishost("windows") and "NuGet.exe" or "mono ./NuGet.exe"
execute(nugetexe .. " restore packages.config -PackagesDirectory " .. path.join(rootdir, "deps"))
end
local compile_llvm = is_vagrant()
function provision_linux()
-- Add Repos
sudo("apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF")
sudo("echo \"deb http://download.mono-project.com/repo/ubuntu xenial main\" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list")
sudo("apt-get update")
-- Build tools
sudo("apt-get install -y git build-essential clang")
-- Mono
sudo("apt-get install -y mono-devel")
-- LLVM/Clang build tools
if compile_llvm then
sudo("apt-get install -y ninja-build")
local file = download_cmake()
sudo("mkdir -p /opt/cmake")
sudo("bash " .. file .. " --prefix=/opt/cmake --skip-license")
sudo("ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake")
end
end
function brew_install(pkg)
-- check if package is already installed
local res = outputof("brew ls --versions " .. pkg)
if string.is_empty(res) then
execute("brew install " .. pkg)
end
end
function provision_osx()
if compile_llvm then
execute("brew cask install virtualbox vagrant")
end
download_cmake()
end
if _ACTION == "cmake" then
download_cmake()
os.exit()
end
if _ACTION == "provision" then
if os.ishost("linux") then
provision_linux()
elseif os.ishost("macosx") then
provision_osx()
end
os.exit()
end

44
build/scripts/Vagrantfile vendored

@ -1,44 +0,0 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<SCRIPT
SCRIPT
is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
Vagrant.configure(2) do |config|
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
config.vm.box = "geerlingguy/ubuntu1604"
#load external box config
config.vm.provider "virtualbox" do |vb|
vb.memory = 8192
vb.cpus = 4
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate//cppsharp","1"]
end
config.vm.network "private_network", type: "dhcp"
config.vm.synced_folder "../..", "/cppsharp", nfs: !is_windows
# this function fixes errors with ubuntu interactive shell
config.vm.provision "fix-no-tty", type: "shell" do |s|
s.privileged = false
s.inline = "sudo sed -i '/tty/!s/mesg n/tty -s \\&\\& mesg n/' /root/.profile"
end
#this section runs as root
config.vm.provision "shell", privileged: true , inline: <<-SHELL
cd /cppsharp/
cd build/scripts && ../premake5-linux-64 --file=Provision.lua provision
SHELL
#this section runs as normal user
config.vm.provision "shell", privileged: false , inline: <<-SHELL
SHELL
end
Loading…
Cancel
Save