A simple and convenient build-and-run system for C and C++.

Overview

smake

Smake is a simple and convenient build-and-run system for C and C++ projects.

Why make another build system?

CMake and GNU Make are great build systems. However, as the project gets larger, and as there are increasingly many types of builds (e.g. a builds for debugging), it becomes tedious to add duplicate code.

Smake solves this problem with its target-mode-build hierarchy. In this system, every project has a set of targets, and each target has a set of build modes. When smake is run on a target with a specific build mode, it will run the build corresponding to that mode.

pictures/smake.png

Each mode also has a post-build script that can be run. For most builds, this will simply be executing the target object file, but in some cases, the user may want to run a different command (i.e. gdb or valgrind) with the object file.

Install

Smake can be installed easily with pip install smake.

One can also simply clone the source and link the smake executable.

How does it work?

Smake searches for a smake.yaml file in the current directory and creates configurations for each target, including all modes and their corresponding builds and post-build scripts, etc.

The structure of an smake configuration file is as follows (in no strict order):

# Variables that can be referenced in builds
definitions:
  - gsourceA: fileA.c, fileB.c

# List of builds that will be used by the targets
builds:
  - buildA:
    - sources: gsourceA     # Reference a group of sources defined
                            # in the sources section
  - buildB:
    - sources: main.c       # Sources can be specified in the build as well
    - flags: -Wall, -Wextra # Flags are specified here, can be comma
                            # separated or specified as a list  
  - buildC:
    - sources: main.c
    - flags:  -Wall, -Wextra, -g

# List of all targets
targets:
 - targetA:
  - modes: default          # Specifiy modes here (default mode does
                            # not really need to be specified)
  - builds:
    - default: buildA       # Must specify builds as a pair of `mode: build`
  
  # Note that post-build scripts do not need to be specified:
  #   if nothing is specified, then there is no post-build script
  - targetB:
    - modes: default, debug # Comma separated modes
    - builds:               # Modes are selected using the -m option of smake
      - default: buildB     #   for example: smake targetB -m debug
      - debug: buildC       # the default mode is used if no mode is specified
    - postbuild:            # Post-build scripts, specified per mode (optional)
      - debug: 'gdb {}'     # The {} is replaced by the target object file

This configuration allows for the following commands:

$ smake targetA
$ smake targetB
$ smake targetB -m debug

As one can imagine, this build system is quite simple, yet powerful.

Another example of smake file can be found inside the example directory. Clone this repository and run smake to get started (available targets are smake basic and smake multisource).

Future features

  • Pre-build scripts, for cases where source code needs to be auto-generated
  • Add options for parallelizing builds
  • Easier way to define macro arguments for the compilers
  • Detect changes in included headers, and the config in general
You might also like...
A python script to run any executable and pass test cases to it's stdin and compare stdout with correct output.

quera_testcase_checker A python script to run any executable and pass test cases to it's stdin and compare stdout with correct output. proper way to u

Run python scripts and pass data between multiple python and node processes using this npm module

Run python scripts and pass data between multiple python and node processes using this npm module. process-communication has a event based architecture for interacting with python data and errors inside nodejs.

This is a multi-app executor that it used when we have some different task in a our applications and want to run them at the same time

This is a multi-app executor that it used when we have some different task in a our applications and want to run them at the same time. It uses SQLAlchemy for ORM and Alembic for database migrations.

Exercise to teach a newcomer to the CLSP grid to set up their environment and run jobs

Exercise to teach a newcomer to the CLSP grid to set up their environment and run jobs

Nuclei - Burp Extension allows to run nuclei scanner directly from burp and transforms json results into the issues
Nuclei - Burp Extension allows to run nuclei scanner directly from burp and transforms json results into the issues

Nuclei - Burp Extension Simple extension that allows to run nuclei scanner directly from burp and transforms json results into the issues. Installatio

Run-Your-Own Firefox Sync Server

Run-Your-Own Firefox Sync Server This is an all-in-one package for running a self-hosted Firefox Sync server. It bundles the "tokenserver" project for

Run unpatched binaries on Nix/NixOS

Run unpatched binaries on Nix/NixOS

Run Python code right in your Telegram messages
Run Python code right in your Telegram messages

Run Python code right in your Telegram messages Made with Telethon library, TGPy is a tool for evaluating expressions and Telegram API scripts. Instal

This repo is for scripts to run various clients at the merge f2f

merge-f2f This repo is for scripts to run various clients at the merge f2f. Tested with Lighthouse! Tested with Geth! General dependecies sudo apt-get

Comments
  • Smake vs CMake?

    Smake vs CMake?

    You realize everything you are doing with smake can be done with -D CMAKE_BUILD_TYPE=Release right? or =Debug. And there's Ninja Multi-config too. Your cmakelists shouldn't specify compiler flags.

    opened by arnavkartikeya 0
Releases(v1.2.0)
  • v1.2.0(Jan 2, 2022)

    Features

    • More flexible libraries (i.e. adding -pthread to the list will not be overriden as -l-pthread)
    • Generating compile_commands.json file for clangd

    Install

    pip install smake or clone the executable from the source.

    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Dec 9, 2021)

    Features

    • Parallelizing builds: set number of threads with smake -j [threads]
    • New section installs for specifying install processes (using smake --install [install-target]): these targes are not the same as those specified in targets
    • New section ldirs for specifying libraries directories (which are specified to the compiler with the -L flag)
    • Refactoring includes directory to idirs
    • Updated recompilation check which uses the modification dates of all header dependencies (this is the reason for the slight delay in the smake command)

    Install

    pip install smake or clone the executable from the source.

    Source code(tar.gz)
    Source code(zip)
    smake(21.13 KB)
  • v1.0.1(Dec 7, 2021)

    Fixes

    • Removed recursive config searching, takes too long on very large directories
    • Added error handling for missing builds and targets specifications
    • Refactored variable definition section from sources to definitions, and fixed related bugs to proper substitution

    Install

    pip install smake or clone the executable from the source.

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Dec 7, 2021)

    Features

    • Recursive build-and-run system
    • Easy build and target specification
    • Post-build scripts, useful for build-and-run or build-and-debug workflows

    Install

    pip install smake or clone the executable from the source.

    Source code(tar.gz)
    Source code(zip)
    smake(13.55 KB)
Owner
Venkataram Edavamadathil Sivaram
Venkataram Edavamadathil Sivaram
A collection of convenient parsers for Advent of Code problems.

Advent of Code Parsers A collection of convenient Python parsers for Advent of Code problems. Installation pip install aocp Quickstart You can import

Miguel Blanco Marcos 3 Dec 13, 2021
It is convenient to quickly import Python packages from the network.

It is convenient to quickly import Python packages from the network.

zmaplex 1 Jan 18, 2022
MiniJVM is simple java virtual machine written by python language, it can load class file from file system and run it.

MiniJVM MiniJVM是一款使用python编写的简易JVM,能够从本地加载class文件并且执行绝大多数指令。 支持的功能 1.从本地磁盘加载class并解析 2.支持绝大多数指令集的执行 3.支持虚拟机内存分区以及对象的创建 4.支持方法的调用和参数传递 5.支持静态代码块的初始化 不支

keguoyu 60 Apr 1, 2022
A simple service that allows you to run commands on the server using text

Server Text A simple flask service that allows you to run commands on the server/computer over sms. Think of it as a shell where you run commands over

MT Devs 49 Nov 9, 2021
A simple program to run through inputs for a 3n+1 problem

Author Tyler Windemuth Collatz_Conjecture A simple program to run through inputs for a 3n+1 problem Purpose: doesn't really have a purpose, did this t

null 0 Apr 22, 2022
Simple Python script I use to manage and build my Reflux themes.

Simple Python script I use to manage and build my Reflux themes. Built for personal use, but anyone can easily fork and tweak to suit thier needs.

Ire 3 Jan 25, 2022
A free and powerful system for awareness and research of the American judicial system.

CourtListener Started in 2009, CourtListener.com is the main initiative of Free Law Project. The goal of CourtListener.com is to provide high quality

Free Law Project 332 Dec 25, 2022
Waydroid is a container-based approach to boot a full Android system on a regular GNU/Linux system like Ubuntu.

Waydroid is a container-based approach to boot a full Android system on a regular GNU/Linux system like Ubuntu.

WayDroid 4.7k Jan 8, 2023
System Design Assignments as part of Arpit's System Design Masterclass

System Design Assignments The repository contains a set of problem statements around Software Architecture and System Design as conducted by Arpit's S

Relog 1.1k Jan 9, 2023
BloodCheck enables Red and Blue Teams to manage multiple Neo4j databases and run Cypher queries against a BloodHound dataset.

BloodCheck BloodCheck enables Red and Blue Teams to manage multiple Neo4j databases and run Cypher queries against a BloodHound dataset. Installation

Mr B0b 16 Nov 5, 2021