Restructure to SCons with empty Vector lib

This commit is contained in:
karl 2021-03-04 19:37:40 +01:00
parent c10e35d940
commit d0a7f73512
10 changed files with 59 additions and 32 deletions

4
.gitignore vendored
View File

@ -32,3 +32,7 @@
*.out
*.app
# SConstruct
**/.sconsign.dblite
compile_commands.json
.cache/

17
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "gdb",
"request": "launch",
"target": "./vector.out",
"cwd": "${workspaceRoot}",
"valuesFormatting": "parseText",
"preLaunchTask": "build"
}
]
}

11
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "scons",
"problemMatcher": []
}
]
}

View File

@ -1,11 +0,0 @@
CXX = g++
CXXFLAGS = -Wall -O3
program: main.o
$(CXX) $(CXXFLAGS) -o program.out main.o
main.o: main.cpp
$(CXX) $(CXXFLAGS) -c main.cpp
clean :
-rm *.o *.out

View File

@ -1,7 +1,9 @@
# cpp-template
# Vector Library
## Instructions
## Building
Run `scons` in the root directory.
- Formatting: `./format.sh`
- Building: `make`
- Running: `./program.out`
## Developing
The `scons` command also generates a `compile_commands.json` which can be used by the VSCodium extension `clangd` for autocompletion, debugging, etc.
Build and run scripts for VSCodium are provided as well.

8
SConstruct Normal file
View File

@ -0,0 +1,8 @@
#!python
# Create the environment and create a Compilation Database for use in VSCodium
env = DefaultEnvironment(tools=['default', 'compilation_db'])
env.CompilationDatabase()
# Build the output program
Program('vector.out', Glob('*.cpp'))

6
Vector.cpp Normal file
View File

@ -0,0 +1,6 @@
#include "Vector.h"
#include <iostream>
Vector::Vector() {
std::cout << "Vector created" << std::endl;
}

4
Vector.h Normal file
View File

@ -0,0 +1,4 @@
class Vector {
public:
Vector();
};

View File

@ -1,7 +1,6 @@
#include "Vector.h"
#include <iostream>
int main() {
std::cout << "Hello World!" << std::endl;
return 0;
Vector vector;
}

View File

@ -1,13 +0,0 @@
#!/bin/bash
if [[ "$OSTYPE" == "darwin"* ]]; then
clang_format_command="clang-format"
clang_tidy_command="run-clang-tidy"
fi
if [[ "$OSTYPE" == "linux"* ]]; then
clang_format_command="clang-format-11"
clang_tidy_command="run-clang-tidy-11"
fi
eval "$clang_format_command -i *.h *.cpp -style=file"
eval "$clang_tidy_command -fix"