Coder Social home page Coder Social logo

dtep's Introduction

dtep (duomi's template program)

Create simple c and c++ projecs using make

I made this program while reading learncpp.com because i wanted to be able to quicly create simple c++ projects. It is not meant for making "production" makefiles so keep that in mind.

If you are an a linux system use "make install" to install the program. Then use "dtep -h" to see available options

Testing

Testing is done using the robot framework library for python and are found in the folder named "test". To run tests use the following command to run the tests:

robot TestSuite.robot

You have to have the robot framework installed. The tests also expect there to be a python virtual environment folder named venv. This is because the tests call the python program located in venv/bin/python.

Project

A default project generated by dtep using

dtep new project-name c

would look something like this:

project-name
| - makefile
| - src
|   | - main.c
|   | - headers
# file: project-name/makefile
# made with dtep version 0.8
FLAGS += -Wall -Wextra -Werror -Wshadow -Wconversion -Wsign-conversion -pedantic-errors -std=c99
LDFLAGS +=

OBJ_DIR = obj
SRC_DIR = src
OUT_DIR = out

EXTENSION = .c
SRCS = $(wildcard $(SRC_DIR)/*$(EXTENSION))
OBJS = $(patsubst $(SRC_DIR)/%$(EXTENSION), $(OBJ_DIR)/%.o, $(SRCS))
NAME = $(OUT_DIR)/jarkko

.PHONY: debug release

debug: FLAGS += -g
debug: $(OUT_DIR) $(OBJ_DIR) $(NAME)

release: FLAGS += -march=native -O3 -DNDEBUG
release: $(OUT_DIR) $(OBJ_DIR) $(NAME)

$(NAME): $(OBJS)
    $(CC) -o $(NAME) $(OBJS) $(LDFLAGS)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%$(EXTENSION)
    $(CC) -c $< -o $@ $(FLAGS)

clean:
    rm -f $(OBJS) $(NAME)

$(OUT_DIR):
    mkdir $(OUT_DIR)

$(OBJ_DIR):
    mkdir $(OBJ_DIR)
/* file: project-name/src/main.c */
#include <stdio.h>

int main(void) {
    printf("hello world\n");
    return 0;
}

As you run make for the first time it will create folders named "obj" and "out" to house the object and executable files

How does the makefile work

The make file has two targets: "debug" and "release". Debug is meant for debuggin the program so it has the "-g" option. Release is meant to be the program to actually use it has optimisations turned to level 3 and the cpu optimisations set to native. Also the NDEBUG preprocessor macro is defined.

Command line options

The bare minimum is "dtep mode(new, init) name(name for the project) language(cpp, c++, c)"

Some other options are:

  • -h shows a help page
  • -e allows you to set the file extension for source files (for c++ projects it is .cc by default)
  • --std allows you to set the language standard for the project (example c99 or c++20)
  • -g adds a .gitignore file if you plan on using git
  • -s allows you tha change the name of the source directory
  • --object-dir and --output-dir allow you to change the names of the directories where .obj files and executables are stored

dtep's People

Contributors

duom1 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.