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

Automated script to install Splashkit and native tools on MSYS/MinGW #506

Merged
merged 9 commits into from
May 26, 2024
52 changes: 52 additions & 0 deletions docs/Splashkit/Applications/mingw-automated installation/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Installation Script Documentation
omckeon marked this conversation as resolved.
Show resolved Hide resolved

## Purpose

This script automates the installation process for SplashKit, .net, C++ tools, and Visual Studio
Code (VS Code) on Windows systems using MSYS2. It ensures a seamless setup of development tools
required for software development.

## Script Details

The script is divided into several sections, each responsible for a specific task:

1. **Update package databases:** Ensures that package databases are up to date before proceeding
with installations.
2. **Install required packages:** Installs necessary packages such as git, curl, and unzip.
3. **Install C++ tools:** Installs essential C++ development tools using `pacman`.
4. **Install .net SDK:** Downloads and installs the .net SDK using PowerShell to handle the
installation process.
5. **Install VS Code:** Downloads and installs VS Code using PowerShell to handle the installation
process.
6. **Install SplashKit:** Downloads and installs SplashKit using the provided installation script.
7. **Install VS Code extensions:** Installs essential VS Code extensions for C++ and .net
development.

## Usage

To use the script, follow these steps:

1. Ensure that you have MSYS2 installed on your system.
2. Copy the script to your system or download it. Save it as `install.sh` inside your MSYS2 home
directory (`C:/msys64/home/{username}/install.sh`).
3. Open a MINGW64 bash terminal window.
4. Go to the directory containing the script:
```shell
cd ~
```
5. Run the script using the command:
```shell
bash install.sh
```
6. Follow the on-screen prompts and instructions to complete the installation process.
7. After installation, restart your terminal for the changes to take effect.

## Troubleshooting

If you encounter any issues during the installation process, consider the following troubleshooting
steps:

- Check your internet connection to ensure that downloads are not being interrupted.
- Verify that you have the necessary permissions to execute the script.
- Ensure that your system meets the minimum requirements for running the installed tools.
- Refer to the documentation of individual tools for troubleshooting specific issues.
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash

# Define variables
splashkit_url="https://raw.githubusercontent.com/splashkit/skm/master/install-scripts/skm-install.sh"
dotnet_sdk_url="https://download.visualstudio.microsoft.com/download/pr/90486d8a-fb5a-41be-bfe4-ad292c06153f/6673965085e00f5b305bbaa0b931cc96/dotnet-sdk-8.0.300-win-x64.exe"
vscode_installer_url="https://aka.ms/win32-x64-user-stable"

# Update package databases
echo "Updating package databases..."
pacman -Syy

# Install required packages
echo "Installing required packages..."
pacman -S --needed --noconfirm git curl unzip

# Install C++ tools (before SplashKit)
echo "Installing C++ tools..."
pacman -S --needed --noconfirm mingw-w64-x86_64-gcc mingw-w64-x86_64-gdb mingw-w64-x86_64-make mingw-w64-x86_64-toolchain

# Check if .NET SDK is installed
if ! command -v dotnet &> /dev/null
then
echo "Downloading .NET SDK installer..."
curl -L $dotnet_sdk_url -o dotnet-sdk-installer.exe

echo "Installing .NET SDK..."
powershell.exe -Command "Start-Process dotnet-sdk-installer.exe -ArgumentList '/quiet /norestart' -Wait"
if [ $? -ne 0 ]; then
echo ".NET SDK installation failed. Please try installing it manually."
exit 1
fi

if ! command -v dotnet &> /dev/null
then
echo ".NET SDK installation failed or .NET SDK is not in the PATH. Please check the installation and try again."
exit 1
fi
else
echo ".NET SDK is already installed."
fi

# Check if VS Code is installed
if ! command -v code &> /dev/null
then
echo "Downloading Visual Studio Code installer..."
curl -L $vscode_installer_url -o vscode-installer.exe

echo "Installing Visual Studio Code..."
powershell.exe -Command "Start-Process vscode-installer.exe -ArgumentList '/silent /mergetasks=!runcode' -Wait"
if [ $? -ne 0 ]; then
echo "Visual Studio Code installation failed. Please try installing it manually."
exit 1
fi

if ! command -v code &> /dev/null
then
echo "Visual Studio Code installation failed or VS Code is not in the PATH. Please check the installation and try again."
exit 1
fi
else
echo "Visual Studio Code is already installed."
fi

# Install SplashKit
echo "Installing SplashKit..."
bash <(curl -s $splashkit_url)
echo 'export PATH=$PATH:~/.splashkit' >> ~/.bashrc
export PATH=$PATH:~/.splashkit
if [ -d ~/.splashkit/global ]; then
echo "Installing SplashKit global"
skm global install
fi

# Add .NET environment variables
echo 'export DOTNET_ROOT=$HOME/.dotnet' >> ~/.bashrc
echo 'export PATH=$PATH:$HOME/.dotnet' >> ~/.bashrc

# Install VS Code extensions
echo "Installing VS Code extensions..."
code --install-extension ms-vscode.cpptools-extension-pack
code --install-extension ms-dotnettools.csharp
code --install-extension ms-dotnettools.csdevkit
code --install-extension ms-dotnettools.vscodeintellicode-csharp

echo "Installation complete. Please restart your terminal for changes to take effect."
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Detecting Operating System through MSYS2

MSYS, or Minimal SYStem, is a Windows software distribution and development platform that offers
package management, a bash shell, and a number of other tools and libraries in a manner reminiscent
of Unix. It is often used in conjunction with MinGW (Minimalist GNU for Windows) to create native
Windows applications using the GNU toolchain.

## Using Environment Variables

One common method for detecting the operating system is to leverage pre-defined environment
variables that contain information about the system. MSYS2 provides a variable called `$OSTYPE`,
which holds a string that identifies the operating system type. By checking the value of this
variable, scripts can determine whether they are running on Windows, Linux, macOS, or another
supported platform.

## Utilizing System Commands

Another approach involves using system commands that provide information about the current operating
system. The `uname` command, for example, can print various details about the system, including the
operating system name. By parsing the output of this command, scripts can identify the specific
operating system and take appropriate actions.

## Advantages and Limitations

Detecting the operating system through MSYS2 offers several advantages:

1. **Consistent Development Experience:** By using MSYS2, developers can work in a familiar
Unix-like environment, even on Windows, ensuring a consistent development experience across
platforms.

2. **Portability:** Scripts that detect the operating system through MSYS2 can be easily ported to
other Unix-like environments, as they rely on standard bash features and commands.

3. **Integration with MinGW:** MSYS2 is often used in conjunction with MinGW, allowing developers to
create native Windows applications using the GNU toolchain.

However, there are also some limitations to consider:

1. **Limited to MSYS2 Environment:** The techniques for detecting the operating system are specific
to the MSYS2 environment and may not work in other Windows environments, such as PowerShell or
the native Command Prompt.

2. **Potential Compatibility Issues:** While MSYS2 aims to provide a Unix-like environment, there
may be compatibility issues with certain Windows-specific tools or libraries.

3. **Learning Curve:** Developers who are unfamiliar with Unix-like environments or MSYS2 may face a
steeper learning curve when using these techniques.

## Conclusion

Detecting the operating system through MSYS2 is a valuable skill for developers working in a
Unix-like environment on Windows. By leveraging environment variables, system commands, and other
techniques, scripts can identify the underlying operating system and adapt their behaviour
accordingly. While there are some limitations to consider, the ability to work in a consistent
development environment across platforms makes MSYS2 a powerful tool for cross-platform development.
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Installing Visual Studio Code (VSCode) through MSYS2

Visual Studio Code (VSCode) is a popular and powerful code editor developed by Microsoft. While it
is primarily designed for Windows, Linux, and macOS, it can also be installed and used on Windows
through MSYS2, a collection of tools and libraries that provide a Unix-like environment for Windows.

## Understanding MSYS2

MSYS2 is a software distribution and building platform for Windows, providing a Unix-like
environment with a bash shell, a package manager (pacman), and a collection of tools and libraries.
It is particularly useful for developers who prefer working in a Unix-like environment or need to
build and run Unix-based applications on Windows.

MSYS2 includes MinGW, a minimalist development environment that allows you to use the GNU Compiler
Collection (GCC) and other GNU tools to create native Windows applications. This makes it an ideal
choice for installing and using VSCode, which is built on top of Electron, a framework that uses
Node.js and Chromium.

## Prerequisites

Before proceeding with the installation, ensure that you have the following prerequisites:

1. **MSYS2:** Install MSYS2 on your Windows system. You can download the installer from the
[official MSYS2 website](https://www.msys2.org/).

2. **Updated Package Databases:** After installing MSYS2, open the MSYS2 MinGW 64-bit terminal and
run the following command to update the package databases:

```
pacman -Syu
```

This command will update the core package databases and install any necessary updates.

## Installing VSCode through MSYS2

Follow these steps to install VSCode through MSYS2:

1. **Install Dependencies:** In the MSYS2 MinGW 64-bit terminal, install the required dependencies
by running the following command:

```
pacman -S --needed base-devel mingw-w64-x86_64-toolchain
```

This command will install the base development tools and the MinGW toolchain, which are necessary
for building and running VSCode.

2. **Install Node.js:** VSCode is built on top of Electron, which requires Node.js. Install Node.js
by running the following command:

```
pacman -S mingw-w64-x86_64-nodejs
```

3. **Install Git:** Git is a version control system used by VSCode for various purposes, such as
managing extensions and updates. Install Git by running the following command:

```
pacman -S git
```

4. **Install VSCode:** Finally, install VSCode by running the following command:

```
pacman -S code
```

This command will download and install the latest version of VSCode from the MSYS2 repository.

5. **Launch VSCode:** After the installation is complete, you can launch VSCode by running the
following command in the MSYS2 MinGW 64-bit terminal:

```
code
```

Alternatively, you can search for "Visual Studio Code" in the Windows Start menu and launch it
from there.

## Configuring VSCode with MSYS2

Once VSCode is installed and launched, you may need to configure it to work seamlessly with MSYS2.
Here are a few steps to consider:

1. **Set the Integrated Terminal:** VSCode has an integrated terminal that can be configured to use
the MSYS2 bash shell. To do this, go to File > Preferences > Settings (or press Ctrl+,) and
search for "terminal.integrated.shell.windows". Set the value to the path of your MSYS2 bash
shell (e.g., "C:\msys64\usr\bin\bash.exe").

2. **Configure Build Tasks:** If you plan to use VSCode for building and compiling projects, you may
need to configure the build tasks to use the MSYS2 environment. This can be done by creating a
`tasks.json` file in the `.vscode` folder of your project and specifying the appropriate commands
and environment variables.

3. **Install Extensions:** VSCode has a rich ecosystem of extensions that can enhance your
development experience. You can install extensions directly from the VSCode Marketplace or
through the MSYS2 package manager. For example, to install the C/C++ extension, run the following
command in the MSYS2 MinGW 64-bit terminal:

```
pacman -S mingw-w64-x86_64-code-cpp
```

## Advantages and Limitations

Installing VSCode through MSYS2 offers several advantages:

- **Unix-like Environment:** Developers who are more comfortable working in a Unix-like environment
can benefit from the familiar tools and utilities provided by MSYS2.
- **Consistent Development Experience:** By using MSYS2, you can ensure a consistent development
experience across different platforms, as MSYS2 provides a Unix-like environment on Windows.
- **Access to MSYS2 Packages:** MSYS2 offers a vast collection of packages that can be easily
installed and integrated with VSCode, enhancing its functionality and capabilities.

However, there are also some limitations to consider:

- **Performance:** Running VSCode through MSYS2 may introduce some performance overhead, as it adds
an additional layer of abstraction.
- **Compatibility Issues:** While MSYS2 aims to provide a Unix-like environment, there may be
compatibility issues with certain Windows-specific tools or libraries.
- **Learning Curve:** Developers who are unfamiliar with Unix-like environments or MSYS2 may face a
steeper learning curve when using VSCode through MSYS2.

## Conclusion

Installing Visual Studio Code (VSCode) through MSYS2 on Windows provides developers with a powerful
code editor in a familiar Unix-like environment. By following the steps outlined in this report, you
can successfully install and configure VSCode to work seamlessly with MSYS2, taking advantage of its
rich ecosystem of tools, libraries, and extensions. While there are some limitations to consider,
the benefits of a consistent development experience and access to MSYS2 packages make this approach
a viable option for developers who prefer working in a Unix-like environment on Windows.
Loading
Loading