From bf03942a92f7ed12088cdfae8173eafbf465c357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Matos?= Date: Sun, 1 Sep 2024 15:47:23 +0100 Subject: [PATCH] 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. --- build/build.sh | 12 ++++ build/premake5.lua | 1 - build/scripts/ClangToolset.cmake | 19 ----- build/scripts/Provision.lua | 117 ------------------------------- build/scripts/Vagrantfile | 44 ------------ 5 files changed, 12 insertions(+), 181 deletions(-) delete mode 100644 build/scripts/ClangToolset.cmake delete mode 100644 build/scripts/Provision.lua delete mode 100644 build/scripts/Vagrantfile diff --git a/build/build.sh b/build/build.sh index 5cd81557a2..2255b02e70 100755 --- a/build/build.sh +++ b/build/build.sh @@ -54,6 +54,18 @@ generate() { 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 "$builddir/premake.sh" --file="$builddir/premake5.lua" gmake2 --os=$os --arch=$platform --configuration=$configuration --target-framework=$target_framework "$@" fi diff --git a/build/premake5.lua b/build/premake5.lua index f7b10fc24d..e132ae1cdb 100644 --- a/build/premake5.lua +++ b/build/premake5.lua @@ -53,7 +53,6 @@ workspace "CppSharp" if EnabledManagedProjects() then include (srcdir .. "/Core") include (srcdir .. "/AST") - --include (srcdir .. "/ASTViewer") include (srcdir .. "/CppParser/Bindings") include (srcdir .. "/CppParser/Bootstrap") include (srcdir .. "/CppParser/ParserGen") diff --git a/build/scripts/ClangToolset.cmake b/build/scripts/ClangToolset.cmake deleted file mode 100644 index c8153243fc..0000000000 --- a/build/scripts/ClangToolset.cmake +++ /dev/null @@ -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") \ No newline at end of file diff --git a/build/scripts/Provision.lua b/build/scripts/Provision.lua deleted file mode 100644 index 4dfaa72663..0000000000 --- a/build/scripts/Provision.lua +++ /dev/null @@ -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 - - diff --git a/build/scripts/Vagrantfile b/build/scripts/Vagrantfile deleted file mode 100644 index 8817e4a53f..0000000000 --- a/build/scripts/Vagrantfile +++ /dev/null @@ -1,44 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -$script = <