-
Notifications
You must be signed in to change notification settings - Fork 553
/
Makefile
160 lines (132 loc) · 6.43 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
THISDIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
DESTDIR ?= /opt/cosmos
IL2CPU_URL = https://github.com/CosmosOS/IL2CPU
XSHARP_URL = https://github.com/CosmosOS/XSharp
COMMON_URL = https://github.com/CosmosOS/Common
IL2CPU_BRANCH = master
XSHARP_BRANCH = master
COMMON_BRANCH = master
IL2CPU_DIR = $(THISDIR)/../IL2CPU
XSHARP_DIR = $(THISDIR)/../XSharp
COMMON_DIR = $(THISDIR)/../Common
GIT = git
DOTNET = dotnet
BUILDMODE=Release
GITFLAGS = clone --depth=1
DOTNETFLAGS = -nologo -v:q -c:$(BUILDMODE)
GREEN = \033[0;32m
YELLOW = \033[1;33m
DEFAULT = \033[0m
.PHONY: all
all: $(IL2CPU_DIR) $(XSHARP_DIR) $(COMMON_DIR)
@printf "${YELLOW}Cosmos${DEFAULT} DevKit Installer\n"
@# Elapsed time is stored in a temporary file, deleted post-install.
@date +%s > [email protected]
@$(MAKE) build
@$(MAKE) publish
@sudo $(MAKE) install
@$(MAKE) nuget-install
@$(MAKE) template-install
@printf "To create a Cosmos kernel, run \'dotnet new cosmosCSKernel -n \{name\}\'"
@printf "Build log file saved to ${GREEN}$(THISDIR)/build${date}.log${DEFAULT}\n"
@printf "============================================\n"
@printf "| ${YELLOW}Cosmos${DEFAULT} has been installed successfully! |\n"
@printf "============================================\n"
@printf "Took ${YELLOW}$$(($$(date +%s)-$$(cat [email protected])))s${DEFAULT} to build\n"
$(IL2CPU_DIR):
@printf "Cloning ${GREEN}Cosmos/IL2CPU${DEFAULT}\n"
@$(GIT) $(GITFLAGS) --branch=$(IL2CPU_BRANCH) $(IL2CPU_URL) $(IL2CPU_DIR)
$(XSHARP_DIR):
@printf "Cloning ${GREEN}Cosmos/XSharp${DEFAULT}\n"
@$(GIT) $(GITFLAGS) --branch=$(XSHARP_BRANCH) $(XSHARP_URL) $(XSHARP_DIR)
$(COMMON_DIR):
@printf "Cloning ${GREEN}Cosmos/Common${DEFAULT}\n"
@$(GIT) $(GITFLAGS) --branch=$(COMMON_BRANCH) $(COMMON_URL) $(COMMON_DIR)
.PHONY: build
build:
@printf "Building ${GREEN}IL2CPU${DEFAULT}\n"
@$(DOTNET) clean $(IL2CPU_DIR)
@$(DOTNET) build $(IL2CPU_DIR) $(DOTNETFLAGS)
@$(DOTNET) pack $(IL2CPU_DIR) $(DOTNETFLAGS)
@printf "Building ${GREEN}Cosmos${DEFAULT}\n"
@$(DOTNET) clean $(THISDIR)/source/Cosmos.Common
@$(DOTNET) clean $(THISDIR)/source/Cosmos.Debug.Kernel
@$(DOTNET) clean $(THISDIR)/source/Cosmos.Debug.Kernel.Plugs.Asm
@$(DOTNET) clean $(THISDIR)/source/Cosmos.Core
@$(DOTNET) clean $(THISDIR)/source/Cosmos.Core_Asm
@$(DOTNET) clean $(THISDIR)/source/Cosmos.Core_Plugs
@$(DOTNET) clean $(THISDIR)/source/Cosmos.HAL2
@$(DOTNET) clean $(THISDIR)/source/Cosmos.System2
@$(DOTNET) clean $(THISDIR)/source/Cosmos.System2_Plugs
@$(DOTNET) clean $(THISDIR)/source/Cosmos.Build.Tasks
@$(DOTNET) clean $(THISDIR)/source/Cosmos.Plugs
@$(DOTNET) pack $(THISDIR)/source/Cosmos.Common $(DOTNETFLAGS)
@$(DOTNET) pack $(THISDIR)/source/Cosmos.Debug.Kernel $(DOTNETFLAGS)
@$(DOTNET) pack $(THISDIR)/source/Cosmos.Debug.Kernel.Plugs.Asm $(DOTNETFLAGS)
@$(DOTNET) pack $(THISDIR)/source/Cosmos.Core $(DOTNETFLAGS)
@$(DOTNET) pack $(THISDIR)/source/Cosmos.Core_Asm $(DOTNETFLAGS)
@$(DOTNET) pack $(THISDIR)/source/Cosmos.Core_Plugs $(DOTNETFLAGS)
@$(DOTNET) pack $(THISDIR)/source/Cosmos.HAL2 $(DOTNETFLAGS)
@$(DOTNET) pack $(THISDIR)/source/Cosmos.System2 $(DOTNETFLAGS)
@$(DOTNET) pack $(THISDIR)/source/Cosmos.System2_Plugs $(DOTNETFLAGS)
@$(DOTNET) pack $(THISDIR)/source/Cosmos.Build.Tasks $(DOTNETFLAGS)
@$(DOTNET) pack $(THISDIR)/source/Cosmos.Plugs $(DOTNETFLAGS)
@printf "Building ${GREEN}X#${DEFAULT}\n"
@$(DOTNET) clean $(XSHARP_DIR)/source/XSharp/XSharp
@$(DOTNET) clean $(XSHARP_DIR)/source/Spruce
$(DOTNET) pack $(XSHARP_DIR)/source/XSharp/XSharp $(DOTNETFLAGS)
$(DOTNET) pack $(XSHARP_DIR)/source/Spruce $(DOTNETFLAGS)
.PHONY: publish
publish:
@printf "Publishing ${GREEN}IL2CPU${DEFAULT}\n"
$(DOTNET) publish $(IL2CPU_DIR)/source/IL2CPU -r linux-x64 --self-contained $(DOTNETFLAGS)
@printf "Publishing ${GREEN}Cosmos${DEFAULT}\n"
@$(DOTNET) publish $(THISDIR)/source/Cosmos.Core_Plugs $(DOTNETFLAGS)
@$(DOTNET) publish $(THISDIR)/source/Cosmos.Debug.Kernel.Plugs.Asm $(DOTNETFLAGS)
@$(DOTNET) publish $(THISDIR)/source/Cosmos.HAL2 $(DOTNETFLAGS)
@$(DOTNET) publish $(THISDIR)/source/Cosmos.System2_Plugs $(DOTNETFLAGS)
@$(DOTNET) publish $(THISDIR)/source/Cosmos.Plugs $(DOTNETFLAGS)
@printf "Publishing ${GREEN}X#${DEFAULT}\n"
@$(DOTNET) publish $(XSHARP_DIR)/source/XSharp/XSharp $(DOTNETFLAGS)
@$(DOTNET) publish $(XSHARP_DIR)/source/Spruce $(DOTNETFLAGS)
.PHONY: install
install:
@printf "Installing to ${YELLOW}$(DESTDIR)${DEFAULT}\n"
@mkdir -p $(DESTDIR)/Cosmos
@mkdir -p $(DESTDIR)/XSharp/DebugStub
@mkdir -p $(DESTDIR)/Build/ISO
@mkdir -p $(DESTDIR)/Build/IL2CPU
@mkdir -p $(DESTDIR)/Build/HyperV
@mkdir -p $(DESTDIR)/Build/VMware/Workstation
@mkdir -p $(DESTDIR)/Packages
@mkdir -p $(DESTDIR)/Kernel
@cp -r $(IL2CPU_DIR)/artifacts/$(BUILDMODE)/nupkg/*.nupkg $(DESTDIR)/Packages/
@cp -r $(THISDIR)/artifacts/$(BUILDMODE)/nupkg/*.nupkg $(DESTDIR)/Packages/
@cp -r $(XSHARP_DIR)/artifacts/$(BUILDMODE)/nupkg/*.nupkg $(DESTDIR)/Packages/
@cp -r $(IL2CPU_DIR)/source/Cosmos.Core.DebugStub/*.xs $(DESTDIR)/XSharp/DebugStub/
@cp -r $(THISDIR)/Artwork/XSharp/XSharp.ico $(DESTDIR)/XSharp/
@cp -r $(THISDIR)/Artwork/Cosmos.ico $(DESTDIR)/
@cp -r $(IL2CPU_DIR)/source/IL2CPU/bin/$(BUILDMODE)/*/linux-x64/publish/* $(DESTDIR)/Build/IL2CPU/
@cp -r $(THISDIR)/source/Cosmos.Core_Plugs/bin/$(BUILDMODE)/*/publish/*.dll $(DESTDIR)/Kernel/
@cp -r $(THISDIR)/source/Cosmos.System2_Plugs/bin/$(BUILDMODE)/*/publish/*.dll $(DESTDIR)/Kernel/
@cp -r $(THISDIR)/source/Cosmos.HAL2/bin/$(BUILDMODE)/*/publish/*.dll $(DESTDIR)/Kernel/
@cp -r $(THISDIR)/source/Cosmos.Debug.Kernel.Plugs.Asm/bin/$(BUILDMODE)/netstandard2.0/publish/*.dll $(DESTDIR)/Kernel/
@cp -r $(THISDIR)/Build/HyperV/*.vhdx $(DESTDIR)/Build/HyperV/
@cp -r $(THISDIR)/Build/VMWare/Workstation/* $(DESTDIR)/Build/VMware/Workstation/
@cp -r $(THISDIR)/Build/syslinux/* $(DESTDIR)/Build/ISO/
@printf $(DESTDIR) > /etc/CosmosUserKit.cfg
.PHONY: nuget-install
nuget-install:
@printf "Installing ${GREEN}Nuget packages${DEFAULT}\n"
@rm -r -f ~/.nuget/packages/cosmos.*/
@rm -r -f ~/.nuget/packages/il2cpu.*/
@$(DOTNET) nuget remove source "Cosmos Local Package Feed" || true
@$(DOTNET) nuget add source $(DESTDIR)/Packages/ -n "Cosmos Local Package Feed"
.PHONY: template-install
template-install:
@printf "Installing ${GREEN}C# Template packages${DEFAULT}\n"
@-dotnet new uninstall $(THISDIR)/source/templates/csharp/
@printf "If the template was not installed, you can ignore this\n"
@dotnet new -i $(THISDIR)/source/templates/csharp/
#TODO: Uninstall