calc

Simple math expression parser.
git clone git://git.amin.space/calc.git
Log | Files | Refs | LICENSE

commit b2a64e2fba3f7ad8b9ad55fcb0c718d4eb9c7859
Author: amin <dev@aminmesbah.com>
Date:   Sat, 27 Oct 2018 03:25:13 +0000

Hello world

FossilOrigin-Name: 676e888ea329ec8723aff2dcdda5282c0bf9e95bf5cb3ca301f0eb6a93bc5f22
Diffstat:
A.gitignore | 1+
Abuild.sh | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
Acalc.c | 6++++++
3 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1 @@ +calc diff --git a/build.sh b/build.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +set -e # fail if any command has a non-zero exit status +set -u # fail if any undefined variable is referenced +set -o pipefail # propagate failure exit status through a pipeline +shopt -s globstar nullglob # enable recursive and null globbing + +exe_name="calc" +build_dir="." + +cc=clang +source_files=("calc.c") +cflags=("-std=c99" "-Wall" "-Wextra" "-Wshadow" "-Wsign-compare" "-Wswitch-enum" "-Wno-missing-braces") +debug_flags=("-g" "-Og" "-Werror") +# shellcheck disable=SC2207 +ldflags=() + +build_debug() { + debug_dir="${build_dir}" + debug_path="${debug_dir}/${exe_name}" + mkdir -p "$debug_dir" + ( + set -x; + "$cc" "${cflags[@]}" "${debug_flags[@]}" "${source_files[@]}" -o "$debug_path" "${ldflags[@]}" + ) +} + +usage() { + echo "build.sh - Build ${exe_name}" + echo " " + echo "build.sh [options]" + echo " " + echo "options:" + echo "-h, --help show help" +} + +while [[ $# -gt 0 ]]; do + case "$1" in + -h|--help) + usage + exit 0 + ;; + *) + break + ;; + esac +done + +build_debug + +exit 0 diff --git a/calc.c b/calc.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +int main(void) +{ + printf("Hello, world"); +}