Skip to content

Commit dbbcb6d

Browse files
committed
Upgrade to .NET Core 3.1 and improve build system
1 parent 65eaa3f commit dbbcb6d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+515
-20133
lines changed

.github/workflows/main.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,37 @@ jobs:
1111
config:
1212
- { os: ubuntu-20.04, platform: x64, cxx: g++-9, cc: gcc-9 }
1313
- { os: macos-10.15, platform: x64, cxx: clang++, cc: clang }
14-
- { os: windows-2019, platform: x86, vs: 2019 }
15-
- { os: windows-2019, platform: x64, vs: 2019 }
14+
- { os: windows-2019, platform: x86, vs: msvc }
15+
- { os: windows-2019, platform: x64, vs: msvc }
1616

1717
runs-on: ${{ matrix.config.os }}
1818

1919
env:
2020
CC: ${{ matrix.config.cc }}
2121
CXX: ${{ matrix.config.cxx }}
22-
VS_VERSION: ${{ matrix.config.vs }}
2322
PLATFORM: ${{ matrix.config.platform }}
2423

2524
steps:
2625
- uses: actions/checkout@v2
2726

2827
- name: Environment
29-
if: matrix.config.vs > 0
28+
if: matrix.config.vs
3029
shell: bash
31-
run: echo "/c/Program Files (x86)/Microsoft Visual Studio/$VS_VERSION/Enterprise/MSBuild/Current/Bin" >> $GITHUB_PATH
30+
run: echo "/c/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/MSBuild/Current/Bin" >> $GITHUB_PATH
3231

3332
- name: Fix intrin.h file
34-
if: matrix.config.vs > 0
33+
if: matrix.config.vs
3534
shell: powershell
3635
run: build/intrin.ps1
3736

3837
- name: Setup
3938
shell: bash
40-
run: build/Setup.sh
39+
run: build/build.sh download_llvm -platform $PLATFORM
4140

4241
- name: Build
4342
shell: bash
44-
run: build/Compile.sh
43+
run: build/build.sh -platform $PLATFORM
4544

4645
- name: Test
4746
shell: bash
48-
run: build/RunTests.sh
47+
run: build/test.sh -platform $PLATFORM

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ src/generator/generator
4343
/build/vs20*
4444
/build/gmake
4545
/build/headers
46-
/build/netcore
46+
/build/gen
4747
/deps/llvm
48-
/deps/NUnit*
4948
/extra
5049
/include/include
5150
/include/libc

Directory.Build.props

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project>
2+
<PropertyGroup>
3+
<RootDir>$(MSBuildThisFileDirectory)</RootDir>
4+
<Platforms>x86;x64</Platforms>
5+
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
6+
<BaseIntermediateOutputPath>$(RootDir)build\obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
7+
<TargetDir Condition="$(Configuration) != ''">$(RootDir)bin\$(Configuration)_$(Platform)</TargetDir>
8+
<LangVersion>7.3</LangVersion>
9+
</PropertyGroup>
10+
</Project>

build/Compile.sh

Lines changed: 0 additions & 50 deletions
This file was deleted.

build/Helpers.lua

Lines changed: 38 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
-- This module checks for the all the project dependencies.
2+
require('vstudio')
3+
require('premake/premake.fixes')
4+
require('premake/premake.extensions')
25

36
newoption {
47
trigger = "arch",
58
description = "Choose a particular architecture / bitness",
9+
default = "x64",
610
allowed = {
711
{ "x86", "x86 32-bits" },
812
{ "x64", "x64 64-bits" },
9-
{ "AnyCPU", "Any CPU (.NET)" },
1013
}
1114
}
1215

@@ -26,99 +29,34 @@ newoption {
2629
}
2730

2831
newoption {
29-
trigger = "debug",
30-
description = "enable debug mode"
32+
trigger = "configuration",
33+
description = "Choose a configuration",
34+
default = "Release",
35+
allowed = {
36+
{ "Release", "Release" },
37+
{ "Debug", "Debug" },
38+
}
3139
}
3240

33-
explicit_target_architecture = _OPTIONS["arch"]
34-
35-
function get_mono_path()
36-
local mono = "mono"
37-
local result, errorcode = os.outputof(mono .. " --version")
38-
if result == nil and os.ishost("macosx") then
39-
mono = "/Library/Frameworks/Mono.framework/Versions/Current/bin/" .. mono
40-
result, errorcode = os.outputof(mono .. " --version")
41-
end
42-
if result == nil then
43-
print("Could not find Mono executable, please make sure it is in PATH.")
44-
os.exit(1)
45-
end
46-
return mono
47-
end
48-
49-
function is_64_bits_mono_runtime()
50-
local result, errorcode = os.outputof(get_mono_path() .. " --version")
51-
local arch = string.match(result, "Architecture:%s*([%w]+)")
52-
return arch == "amd64"
53-
end
54-
default_gcc_version = "9.0.0"
55-
56-
function target_architecture()
57-
if _ACTION == "netcore" then
58-
return "AnyCPU"
59-
end
60-
61-
-- Default to 64-bit on Windows and Mono architecture otherwise.
62-
if explicit_target_architecture ~= nil then
63-
return explicit_target_architecture
64-
end
65-
if os.ishost("windows") then return "x64" end
66-
return is_64_bits_mono_runtime() and "x64" or "x86"
67-
end
68-
69-
if not _OPTIONS["arch"] then
70-
_OPTIONS["arch"] = target_architecture()
71-
end
72-
73-
-- Uncomment to enable Roslyn compiler.
74-
--[[
75-
premake.override(premake.tools.dotnet, "gettoolname", function(base, cfg, tool)
76-
if tool == "csc" then
77-
return "csc"
78-
end
79-
return base(cfg, tool)
80-
end)
81-
]]
82-
83-
basedir = path.getdirectory(_PREMAKE_COMMAND)
84-
premake.path = premake.path .. ";" .. path.join(basedir, "modules")
85-
86-
depsdir = path.getabsolute("../deps");
87-
srcdir = path.getabsolute("../src");
88-
incdir = path.getabsolute("../include");
89-
bindir = path.getabsolute("../bin");
90-
examplesdir = path.getabsolute("../examples");
91-
testsdir = path.getabsolute("../tests");
92-
93-
local function get_build_dir()
94-
if _ARGS[1] then
95-
return _ARGS[1]
96-
end
97-
98-
if not _ACTION then
99-
return ""
100-
end
101-
102-
return _ACTION == "gmake2" and "gmake" or _ACTION
103-
end
104-
105-
builddir = path.getabsolute("./" .. get_build_dir());
106-
107-
if _ACTION ~= "netcore" then
108-
objsdir = path.join(builddir, "obj", "%{cfg.buildcfg}_%{cfg.platform}");
109-
libdir = path.join(builddir, "lib", "%{cfg.buildcfg}_%{cfg.platform}");
110-
else
111-
objsdir = path.join(builddir, "obj", "%{cfg.buildcfg}");
112-
libdir = path.join(builddir, "lib", "%{cfg.buildcfg}");
113-
end
114-
41+
rootdir = path.getabsolute("../")
42+
depsdir = path.join(rootdir, "deps");
43+
srcdir = path.join(rootdir, "src");
44+
incdir = path.join(rootdir, "include");
45+
examplesdir = path.join(rootdir, "examples");
46+
testsdir = path.join(rootdir, "tests");
47+
builddir = path.join(rootdir, "build")
48+
bindir = path.join(rootdir, "bin")
49+
objsdir = path.join(builddir, "obj");
11550
gendir = path.join(builddir, "gen");
51+
actionbuilddir = path.join(builddir, _ACTION == "gmake2" and "gmake" or (_ACTION and _ACTION or ""));
52+
bindircfg = path.join(bindir, "%{cfg.buildcfg}_%{cfg.platform}");
53+
prjobjdir = path.join(objsdir, "%{prj.name}", "%{cfg.buildcfg}")
11654

11755
msvc_buildflags = { "/MP", "/wd4267" }
118-
11956
msvc_cpp_defines = { }
120-
57+
default_gcc_version = "9.0.0"
12158
generate_build_config = true
59+
premake.path = premake.path .. ";" .. path.join(builddir, "modules")
12260

12361
function string.starts(str, start)
12462
if str == nil then return end
@@ -129,8 +67,13 @@ function SafePath(path)
12967
return "\"" .. path .. "\""
13068
end
13169

70+
function target_architecture()
71+
return _OPTIONS["arch"]
72+
end
73+
13274
function SetupNativeProject()
13375
location ("%{wks.location}/projects")
76+
files { "*.lua" }
13477

13578
filter { "configurations:Debug" }
13679
defines { "DEBUG" }
@@ -177,21 +120,7 @@ end
177120

178121
function SetupManagedProject()
179122
language "C#"
180-
location ("%{wks.location}/projects")
181-
buildoptions {"/langversion:7.3"}
182-
buildoptions {"/platform:".._OPTIONS["arch"]}
183-
184-
dotnetframework "4.7.2"
185-
186-
if not os.istarget("macosx") then
187-
filter { "action:vs* or netcore" }
188-
location "."
189-
filter {}
190-
end
191-
192-
filter { "action:netcore" }
193-
dotnetframework "netstandard2.0"
194-
123+
location "."
195124
filter {}
196125
end
197126

@@ -271,15 +200,15 @@ function UseCxx11ABI()
271200
end
272201

273202
function EnableNativeProjects()
274-
if _ACTION == "netcore" then
275-
return false
276-
end
203+
return not (string.starts(_ACTION, "vs") and not os.ishost("windows"))
204+
end
277205

278-
if string.starts(_ACTION, "vs") and not os.ishost("windows") then
279-
return false
280-
end
206+
function EnabledManagedProjects()
207+
return string.starts(_ACTION, "vs")
208+
end
281209

282-
return true
210+
function EnabledCLIProjects()
211+
return EnabledManagedProjects() and os.istarget("windows")
283212
end
284213

285214
function AddPlatformSpecificFiles(folder, filename)

build/InstallMono.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

build/InstallNugets.sh

Lines changed: 0 additions & 9 deletions
This file was deleted.

build/LLVM.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ local LLVMRootDirRelease = ""
1010
require "scripts/LLVM"
1111

1212
function SearchLLVM()
13-
local basedir = path.getdirectory(_PREMAKE_COMMAND)
14-
LLVMRootDirDebug = basedir .. "/scripts/" .. get_llvm_package_name(nil, "Debug")
15-
LLVMRootDirRelease = basedir .. "/scripts/" .. get_llvm_package_name()
13+
LLVMRootDirDebug = builddir .. "/scripts/" .. get_llvm_package_name(nil, "Debug")
14+
LLVMRootDirRelease = builddir .. "/scripts/" .. get_llvm_package_name()
1615

1716
if os.isdir(LLVMRootDirDebug) or os.isdir(LLVMRootDirRelease) then
1817
LLVMDirPerConfiguration = true

build/RunTests.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

build/Setup.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)