Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🩹 MakeFile various tweaks #2897

Merged
merged 11 commits into from
Apr 30, 2024
8 changes: 6 additions & 2 deletions Docs/articles/Installation/DevKit.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

* Source code of Development Kit from [Cosmos on GitHub](https://github.com/CosmosOS/Cosmos)
* You must clone the repository using Git. For a detailed walkthrough, [see here](https://help.github.com/articles/fork-a-repo/).

* [Visual Studio 2022 Community](https://visualstudio.microsoft.com/vs/)
* [InnoSetup](http://www.jrsoftware.org/isdl.php#qsp)

* This is required to build the setup kit which is used to build and install the Visual Studio integration libaries for Cosmos.
* During install it will ask you about optional components to install. Be sure you check "Install Inno Setup Preprocessor".

Expand Down Expand Up @@ -55,7 +57,7 @@ This will take a while. If there is no error, you successfully installed Cosmos

If you are using custom Cosmos repos, you will need to clone them all manually, as the installer script will only pull from https://github.com/CosmosOS/

A tree diagram of the source should look like the following:
A tree diagram of the source should look like the following:

<img src="https://raw.githubusercontent.com/CosmosOS/Cosmos/master/Docs/images/Dir.png" width="200">

Expand All @@ -73,7 +75,9 @@ Although Cosmos typically uninstalls previous kits before installing a new one;
If you have more than 1 version of Visual Studio *(such as both 2022 and 2019)*, this bug can occur. Try running `dotnet Project Templates` to get them back.

### dotnet Project Templates

If you are using Linux, or prefer not using Visual Studio for your projects, you can install the dotnet project template using `dotnet new --install ./source/templates/csharp/` assuming you are currently in the Cosmos base directory. After installing the template, use `dotnet new cosmosCSKernel -n {name}` to create a new Cosmos Kernel project.
The dotnet template can be removed at a later time using `dotnet new --uninstall ./source/templates/csharp/`.

*Last updated on 24 March 2024.*
*Last updated on 20 April 2024.*

77 changes: 49 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,52 @@ COMMON_DIR = $(THISDIR)/../Common
GIT = git
DOTNET = dotnet

BUILDMODE=Release
GITFLAGS = clone --depth=1
DOTNETFLAGS = -v:q -nologo
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 > _time_$@.txt
@$(MAKE) build
@$(MAKE) publish
@sudo $(MAKE) install
@$(MAKE) nuget-install
@echo "============================================"
@echo "| Cosmos has been installed successfully! |"
@echo "============================================"
@$(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 _time_$@.txt)))s${DEFAULT} to build\n"
@rm _time_$@.txt

$(IL2CPU_DIR):
@echo "Cloning Cosmos/IL2CPU"
@$(GIT) $(GITFLAGS) --branch=$(IL2CPU_BRANCH) $(IL2CPU_URL) $(THISDIR)/../IL2CPU
@printf "Cloning ${GREEN}Cosmos/IL2CPU${DEFAULT}\n"
@$(GIT) $(GITFLAGS) --branch=$(IL2CPU_BRANCH) $(IL2CPU_URL) $(IL2CPU_DIR)

$(XSHARP_DIR):
@echo "Cloning Cosmos/XSharp"
@$(GIT) $(GITFLAGS) --branch=$(XSHARP_BRANCH) $(XSHARP_URL) $(THISDIR)/../XSharp
@printf "Cloning ${GREEN}Cosmos/XSharp${DEFAULT}\n"
@$(GIT) $(GITFLAGS) --branch=$(XSHARP_BRANCH) $(XSHARP_URL) $(XSHARP_DIR)

$(COMMON_DIR):
@echo "Cloning Cosmos/Common"
@$(GIT) $(GITFLAGS) --branch=$(COMMON_BRANCH) $(COMMON_URL) $(THISDIR)/../Common
@printf "Cloning ${GREEN}Cosmos/Common${DEFAULT}\n"
@$(GIT) $(GITFLAGS) --branch=$(COMMON_BRANCH) $(COMMON_URL) $(COMMON_DIR)


.PHONY: build
build:
@echo "Building IL2CPU"
@printf "Building ${GREEN}IL2CPU${DEFAULT}\n"
@$(DOTNET) clean $(IL2CPU_DIR)
@$(DOTNET) build $(IL2CPU_DIR) $(DOTNETFLAGS)
@$(DOTNET) pack $(IL2CPU_DIR) $(DOTNETFLAGS)

@echo "Building Cosmos"
@printf "Building ${GREEN}Cosmos${DEFAULT}\n"

@$(DOTNET) clean $(THISDIR)/source/Cosmos.Common
@$(DOTNET) clean $(THISDIR)/source/Cosmos.Debug.Kernel
Expand All @@ -74,7 +87,7 @@ build:
@$(DOTNET) pack $(THISDIR)/source/Cosmos.Build.Tasks $(DOTNETFLAGS)
@$(DOTNET) pack $(THISDIR)/source/Cosmos.Plugs $(DOTNETFLAGS)

@echo "Building X#"
@printf "Building ${GREEN}X#${DEFAULT}\n"
@$(DOTNET) clean $(XSHARP_DIR)/source/XSharp/XSharp
@$(DOTNET) clean $(XSHARP_DIR)/source/Spruce

Expand All @@ -84,23 +97,23 @@ build:

.PHONY: publish
publish:
@echo "Publishing IL2CPU"
@printf "Publishing ${GREEN}IL2CPU${DEFAULT}\n"
$(DOTNET) publish $(IL2CPU_DIR)/source/IL2CPU -r linux-x64 --self-contained $(DOTNETFLAGS)

@echo "Publishing Cosmos"
@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)

@echo "Publishing X#"
@printf "Publishing ${GREEN}X#${DEFAULT}\n"
@$(DOTNET) publish $(XSHARP_DIR)/source/XSharp/XSharp $(DOTNETFLAGS)
@$(DOTNET) publish $(XSHARP_DIR)/source/Spruce $(DOTNETFLAGS)

.PHONY: install
install:
@echo "Installing to" $(DESTDIR)
@printf "Installing to ${YELLOW}$(DESTDIR)${DEFAULT}\n"
@mkdir -p $(DESTDIR)/Cosmos
@mkdir -p $(DESTDIR)/XSharp/DebugStub
@mkdir -p $(DESTDIR)/Build/ISO
Expand All @@ -109,31 +122,39 @@ install:
@mkdir -p $(DESTDIR)/Build/VMware/Workstation
@mkdir -p $(DESTDIR)/Packages
@mkdir -p $(DESTDIR)/Kernel
@cp -r $(IL2CPU_DIR)/artifacts/Release/nupkg/*.nupkg $(DESTDIR)/Packages/
@cp -r $(THISDIR)/artifacts/Release/nupkg/*.nupkg $(DESTDIR)/Packages/
@cp -r $(XSHARP_DIR)/artifacts/Release/nupkg/*.nupkg $(DESTDIR)/Packages/
@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/Debug/*/linux-x64/publish/* $(DESTDIR)/Build/IL2CPU/
@cp -r $(THISDIR)/source/Cosmos.Core_Plugs/bin/Debug/*/publish/*.dll $(DESTDIR)/Kernel/
@cp -r $(THISDIR)/source/Cosmos.System2_Plugs/bin/Debug/*/publish/*.dll $(DESTDIR)/Kernel/
@cp -r $(THISDIR)/source/Cosmos.HAL2/bin/Debug/*/publish/*.dll $(DESTDIR)/Kernel/
@cp -r $(THISDIR)/source/Cosmos.Debug.Kernel.Plugs.Asm/bin/Debug/netstandard2.0/publish/*.dll $(DESTDIR)/Kernel/
@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/
@echo $(DESTDIR) > /etc/CosmosUserKit.cfg
@printf $(DESTDIR) > /etc/CosmosUserKit.cfg

.PHONY: nuget-install
nuget-install:
@echo "Installing Nuget packages"
@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"
@$(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"
@dotnet new install $(THISDIR)/source/templates/csharp/
#TODO: Uninstall