Skip to content

Commit

Permalink
Problems creating projects fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
drizzy committed Oct 9, 2022
1 parent 3cfcaee commit 313a7f0
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 25 deletions.
16 changes: 13 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# Change Log

All notable changes to the "code-make" extension will be documented in this file.
### [v1.0.1](https://github.com/drizzy/vscode-code-make/releases/tag/v1.0.1)

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
> 08 October 2022
## [Unreleased]
- Problems creating projects on windows fixed

- Brief documentation to be able to install `make`

- Brief documentation to be able to install the `C++ compiler`

- Modification of the `Makefile` for better compilation

### [v1.1.0](https://github.com/drizzy/vscode-code-make/releases/tag/v1.0.0)

> 04 October 2022
- Initial release
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Create projects in c++ Compile and run the program directly from the vscode inte

## Requirements

* You have to have `make` installed on your computer
* If you are on linux you must install `gcc `
* If you are on window you must install `mingw`
* If you are on mac os you must install `clang`
* You have to have `make` installed on your computer ([see instructions](docs/SETUP.md#make))
* If you are on linux you must install `gcc` ([see instructions](docs/ETUP.md#linux))
* If you are on window you must install `mingw` ([see instructions](docs/SETUP.md#windows))
* If you are on mac os you must install `clang` ([see instructions](docs/SETUP.md#mac))

## How to use

Expand Down
149 changes: 149 additions & 0 deletions docs/SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Install Make

## windows

- The easiest option is to use [Chocolatey](https://chocolatey.org/install) . First you need to install this package manager. Once installed,
you can install `make` (you may need to run it in a terminal as administrator)

Install chocolatey
```bash
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
```

Install make on windows
```bash
choco install make
```

## GNU/Linux

- Ensure `make` is installed
- It is probably already installed to check open a terminal and execute the following command:

```bash
make --version
```

- If it is not installed do the following

- Before installing the make package, it is better to update your already installed packages; otherwise you may encounter compatibility issues with some software. You can do it by typing.

### Ubuntu

Update packages
```bash
sudo apt update
```

Install make on ubuntu
```bash
sudo apt install build-essential
```
The command installs a bunch of new packages including `gcc`, `g++` and `make`.


### Arch Linux

Update packages
```bash
sudo pacman -Syu
```

Install make on Arch Linux
```bash
sudo pacman -S make
```

## Mac
- With Homebrew installed on your Mac it's super easy to install `make`, it may require root permissions.

- If you don't have [Homebrew](https://docs.brew.sh/Installation) installed, read the documentation on how to install it.

Install make on Mac
```bash
brew install make
```

# Install GCC

## Windows
- Go to [ Mingw-w64](https://sourceforge.net/projects/mingw/files/Installer/mingw-get-setup.exe/download " Mingw-w64")

- Look for **mingw-get-setup.exe** for downloading. Download it and launch the installer. Accept the terms and move on.

- You'll now see that the installer is connecting to the Internet and downloading a lot of tiny and small files. Wait till it ends.

- Right when it ends (which won't take long), you'll be presented a window with title **MinGW Installation Manager.** You should be in the 'Basic Setup' tab by default when it launches. If not, click on **Basic Setup.**

- Out of the numerous check boxes presented to you on the right side, tick "**mingw32-gcc-g++-bin**". If you are prompted with a menu, click on Mark for Install.

- Then on the top left corner click on **Installation > Apply Changes.** And wait while it downloads a billion files and installs them.

- Now you gotta edit your "Environment Variables" as well, so that gcc works in cmd no matter the file location.

- For that go to **Windows Explorer > Right click on This PC > Properties > Advanced system settings > Environment Variables** or you could just search for "Environment Variables" in Windows Search...

- At the bottom "System Variables" panel, look for a Variable named "Path" and double click on it. Some systems show a good UI for adding a New Path easily (by clicking New), else you just need to add ; at the end and add the following path

```bash
C:\MinGW\bin
```
`(This is assuming you didn't manually change any installation paths and went with just clicking 'Next' during installation)`

- Click on OK, and OK and close the other windows. Open a Command Prompt Terminal and try typing and press Enter. `gcc --version`

## GNU/Linux

- Ensure `gcc` is installed
- It is probably already installed to check open a terminal and execute the following command:

```bash
gcc --version
```

- If it is not installed do the following

### Ubuntu

Update packages
```bash
sudo apt update
```

Install gcc on ubuntu
```bash
sudo apt install build-essential
```
The command installs a bunch of new packages including `gcc`, `g++` and `make`.


### Arch Linux

Update packages
```bash
sudo pacman -Syu
```

Install gcc on Arch Linux
```bash
sudo pacman -S gcc
```

## Mac

- Ensure `Clang` is installed
- It is probably already installed to check open a terminal and execute the following command:

```bash
clang --version
```

- If it is not installed do the following

- Open "Terminal" (it is located in Applications/Utilities)
- In the terminal window, run the command
```bash
xcode-select --install
```
- In the windows that pops up, click , and agree to the Terms of Service. `Install`
Once the installation is complete, the command line utilities should be set up property.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "code-make",
"displayName": "Code Make",
"description": "Creates c++ projects with configured Makefile",
"version": "1.0.0",
"version": "1.0.1",
"publisher": "drizzy",
"license": "MIT",
"icon": "icons/logo.png",
Expand Down
18 changes: 15 additions & 3 deletions src/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,22 @@ let eventEmitter = events.EventEmitter;
let event = new eventEmitter();

/* Getting the path of the workspace folder. */
const folderPath = workspace.workspaceFolders[0].uri
.toString()
.split(':')[1];
let folderPath;
if (!workspace.workspaceFolders) {
folderPath = workspace.rootPath;
}
else {

let root;
if (workspace.workspaceFolders.length === 1) {
root = workspace.workspaceFolders[0];
}
else {
root = workspace.getWorkspaceFolder(resource);
}

folderPath = root.uri.fsPath;
}

/* Creating a new status bar item for each of the commands. */
let items = {
Expand Down
57 changes: 46 additions & 11 deletions src/template/makefile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,68 @@ else
endif

# define the color of the console text
COLOUR_GREEN = \033[0;32m
COLOUR_RED = \033[0;31m
COLOUR_BLUE = \033[0;34m
COLOUR_END = \033[0m
ifeq ($(OS),Windows_NT)
RED := $(tput setaf "1")
GREEN := $(tput setaf "2")
YELLOW := $(tput setaf "3")
BLUE := $(tput setaf "4")
PURPLE := $(tput setaf "5")
CYAN := $(tput setaf "6")
WHITE := $(tput setaf "7")
RESET := $(tput sgr0)
else
RED := $(shell echo -e "\033[031m")
GREEN := $(shell echo -e "\033[032m")
YELLOW := $(shell echo -e "\033[033m")
BLUE := $(shell echo -e "\033[034m")
PURPLE := $(shell echo -e "\033[035m")
CYAN := $(shell echo -e "\033[036m")
WHITE := $(shell echo -e "\033[037m")
RESET := $(shell echo -e "\033[0m")
endif

OBJS := $(patsubst %.cpp, $(OBJ)/%.o, $(notdir $(wildcard $(SRC)/*.cpp) $(wildcard $(LIB)/*.cpp)))

# Generate object files
$(OBJ)/%.o: %.cpp
@mkdir -p obj
@echo -e "$(COLOUR_BLUE)Generating object: $(@F)$(COLOUR_END)"
ifeq ($(OS),Windows_NT)
@IF NOT EXIST $(subst /,\,$(OBJ)) mkdir $(subst /,\,$(OBJ))
else
@mkdir -p $(OBJ)
endif
@echo $(CYAN)Compiling: $(RED)$(@F)$(RESET)
@$(CXX) -I $(INC) -c $< -o $@

# Generate executable
$(TARGET): $(OBJS)
ifeq ($(OS),Windows_NT)
@IF NOT EXIST $(subst /,\,$(BIN)) mkdir $(subst /,\,$(BIN))
else
@mkdir -p $(BIN)
@echo -e "$(COLOUR_GREEN)Generating executable: $(@F)$(COLOUR_END)"
@$(CXX) $(OBJS) -o $@
endif
@echo $(CYAN)Creating executable: $(GREEN)$(@F)$(RESET)
@$(CXX) $(OBJS) -o $@

.PHONY: run
run:
@$(TARGET)

.PHONY: clean
clean:
@rm -rf $(OBJ)/*.o $(BIN)/$(APPNAME) $(BIN)/$(APPNAME).exe

ifeq ($(OS),Windows_NT)
@if exist $(OBJ)\*.o @del /Q $(OBJ)\*.o
@if exist $(OBJ)\*.exe @del /Q $(BIN)\*.exe
else
@rm -f $(OBJ)/*.o
@rm -f $(BIN)/*
endif

.PHONY: delete
delete:
@rm -rf $(OBJ) $(BIN)
ifeq ($(OS),Windows_NT)
@if exist $(OBJ) @rd /Q /S $(OBJ)
@if exist $(BIN) @rd /Q /S $(BIN)
else
@rm -rf $(OBJ)
@rm -rf $(BIN)
endif
6 changes: 3 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const struct = async () => {

if (!fs.existsSync(path.join(folderPath, 'src'))){

fs.mkdirSync(path.join(folderPath, 'src'), err => {
fs.mkdirSync(path.join(folderPath, 'src'), {recursive: true}, err => {
if (err) {
console.error(err)
window.showErrorMessage('Failed to create folder')
Expand All @@ -50,7 +50,7 @@ const struct = async () => {

if(!fs.existsSync(path.join(folderPath, 'include'))){

fs.mkdirSync(path.join(folderPath, 'include'), err => {
fs.mkdirSync(path.join(folderPath, 'include'), {recursive: true}, err => {
if (err) {
console.error(err)
window.showErrorMessage('Failed to create folder')
Expand All @@ -60,7 +60,7 @@ const struct = async () => {

if(!fs.existsSync(path.join(folderPath, 'lib'))){

fs.mkdirSync(path.join(folderPath, 'lib'), err => {
fs.mkdirSync(path.join(folderPath, 'lib'), {recursive: true}, err => {
if (err) {
console.error(err)
window.showErrorMessage('Failed to create folder')
Expand Down

0 comments on commit 313a7f0

Please sign in to comment.