Browse Source

Allow passing a `-target-framework` option to `build.sh`

Closes https://github.com/mono/CppSharp/issues/1717.
pull/1718/head
Joao Matos 2 years ago
parent
commit
9c44f615da
  1. 17
      build/Helpers.lua
  2. 12
      build/build.sh
  3. 4
      docs/GettingStarted.md
  4. 1
      src/CLI/CppSharp.CLI.csproj

17
build/Helpers.lua

@ -43,6 +43,11 @@ newoption {
description = "Only generate configuration file", description = "Only generate configuration file",
} }
newoption {
trigger = "target-framework",
description = ".NET target framework version",
}
rootdir = path.getabsolute("../") rootdir = path.getabsolute("../")
srcdir = path.join(rootdir, "src"); srcdir = path.join(rootdir, "src");
incdir = path.join(rootdir, "include"); incdir = path.join(rootdir, "include");
@ -61,7 +66,17 @@ msvc_cpp_defines = { }
default_gcc_version = "9.0.0" default_gcc_version = "9.0.0"
generate_build_config = true generate_build_config = true
premake.path = premake.path .. ";" .. path.join(builddir, "modules") premake.path = premake.path .. ";" .. path.join(builddir, "modules")
targetframework = "net6.0"
function string.isempty(s)
return s == nil or s == ''
end
local function target_framework()
local value = _OPTIONS["target-framework"]
return string.isempty(value) and "net6.0" or value
end
targetframework = target_framework()
function string.starts(str, start) function string.starts(str, start)
if str == nil then return end if str == nil then return end

12
build/build.sh

@ -6,6 +6,7 @@ vs=vs2019
configuration=Release configuration=Release
build_only=false build_only=false
ci=false ci=false
target_framework=
verbosity=minimal verbosity=minimal
rootdir="$builddir/.." rootdir="$builddir/.."
bindir="$rootdir/bin" bindir="$rootdir/bin"
@ -46,7 +47,7 @@ build()
generate_config() generate_config()
{ {
"$builddir/premake.sh" --file="$builddir/premake5.lua" $vs --os=$os --arch=$platform --configuration=$configuration --config_only "$builddir/premake.sh" --file="$builddir/premake5.lua" $vs --os=$os --arch=$platform --configuration=$configuration --target-framework=$target_framework --config_only
} }
generate() generate()
@ -54,10 +55,10 @@ generate()
download_llvm download_llvm
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 "$@" "$builddir/premake.sh" --file="$builddir/premake5.lua" gmake2 --os=$os --arch=$platform --configuration=$configuration --target-framework=$target_framework "$@"
fi fi
"$builddir/premake.sh" --file="$builddir/premake5.lua" $vs --os=$os --arch=$platform --configuration=$configuration "$builddir/premake.sh" --file="$builddir/premake5.lua" $vs --os=$os --arch=$platform --configuration=$configuration --target-framework=$target_framework
} }
restore() restore()
@ -194,6 +195,11 @@ while [[ $# > 0 ]]; do
os=$2 os=$2
shift shift
;; ;;
-target-framework)
target_framework=$2
echo $target_framework
shift
;;
-ci) -ci)
ci=true ci=true
export CI=true export CI=true

4
docs/GettingStarted.md

@ -44,6 +44,8 @@ The following steps should be called from the VS developer command prompt.
<sh> build.sh generate -configuration Release -platform x64 <sh> build.sh generate -configuration Release -platform x64
``` ```
> :information_source: You can use the `-target-framework` option to target any valid .NET target framework.
2. Compile the VS projects 2. Compile the VS projects
You can open `CppSharp.sln` and hit F5 or compile via the command line: You can open `CppSharp.sln` and hit F5 or compile via the command line:
@ -82,6 +84,8 @@ When opening the solution for the first time on a more recent version than Visua
./build.sh generate -configuration Release -platform x64 ./build.sh generate -configuration Release -platform x64
``` ```
> :information_source: You can use the `-target-framework` option to target any valid .NET target framework.
2. Compile the csproj files and makefiles 2. Compile the csproj files and makefiles
``` ```

1
src/CLI/CppSharp.CLI.csproj

@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

Loading…
Cancel
Save