spicylord / clutils (public) (License: GPLv3) (since 2019-07-04) (hash sha1)
An assortment of new and rewritten preexisting tools written by me.
List of commits:
Subject Hash Author Date (UTC)
usefull for compiling c/c++. More info in README 73665a7d814e07970a0dce7a7b663d4ddf9217a4 spicylord 2019-08-26 02:55:56
hopefully delete ins.c b06e7258852b9ca1877b7c4fa78b6984e00a9b72 spicylord 2019-08-22 19:03:04
ins has been replaced with a shell script and clp has been fixed 35072ced804239e2f886fdf3b4dd995dfe6805f1 spicylord 2019-08-22 18:49:38
reverted sc because I cannot into memory management. ins is suffering from memory as well so use at your own risk. 1f24dcf261e3d779782a5e5ba2bd0c26da0fd928 spicylord 2019-08-17 19:10:51
im an idiot c6aa7a7fa124fb08422fb24de68ecb70ba066195 spicylord 2019-08-16 04:30:23
bug fixes 5ec9e0063dee0e8cb9b7c88a06535a1c13faa2af spicylord 2019-08-16 04:20:21
added free for previously unfreed malloc buffer fbuf ec2c9bbcb387a718d36bd861083ac2c40134c152 spicylord 2019-08-16 02:01:00
put all of the programs under the GPLv3 or later, also updated sc.c 77dbf20cedc357042ffc03e5da9a51690337a977 spicylord 2019-08-16 01:08:49
added ins to INSTALL script 6d58cd823d49a8ad4a32a57173d5d690ddb677c6 spicylord 2019-08-15 21:23:41
added ins, a program that takes standard input and inserts that into the beginning of a file c51d12a96e47c407a2e82980401556194b2c090e matt 2019-08-15 21:17:47
added exho, a program that runs a command and outputs that command to stdout 4c7b8d4998e747541c420256494cee40ff19fc12 spicylord 2019-07-12 02:29:35
allow for easy use of different c compilers in INSTALL a1bb4ec6cdbd070edb7955022f93ff33ca7255da spicylord 2019-07-11 16:16:46
made COPYING less cringe-inducing 8d1e9ca0093f143c25b919552b544db92c9f865d spicylord 2019-07-10 01:32:22
modified usage output and allowed for #,p 504ca7b3d8db60cb6d1f36a3fd48043ff62f78c0 spicylord 2019-07-06 15:49:16
spelling error in README 351dbee78173eef7ae94f9142c6a97452db0d208 spicylord 2019-07-04 20:30:33
added examples and instructions for clp, spng, and sc in the README 313a86755e40d909861bc95a11b75bbb109012c9 spicylord 2019-07-04 19:25:33
made regex slightly neater ac8eda8f7290e5f138edac12f789b1215de90719 spicylord 2019-07-04 18:31:55
fixed outputting garbled text into clipboard file a100287acf1993ae13130e036d7104bd2afe4585 spicylord 2019-07-04 18:30:34
fixed install script to compile clp.c instead of clb.c 54a54b5da1a122e69ed62bc0f030f11044a62fb9 spicylord 2019-07-04 13:47:33
added email a04151394c9a4b3afe23e8ebd11939fe7892737d spicylord 2019-07-04 02:58:00
Commit 73665a7d814e07970a0dce7a7b663d4ddf9217a4 - usefull for compiling c/c++. More info in README
Author: spicylord
Author date (UTC): 2019-08-26 02:55
Committer name: spicylord
Committer date (UTC): 2019-08-26 02:55
Parent(s): b06e7258852b9ca1877b7c4fa78b6984e00a9b72
Signing key:
Tree: 607bfa5a7881e92fbd9bb5495d617dbf3df5c58a
File Lines added Lines deleted
c 94 0
File c added (mode: 100755) (index 0000000..d027162)
1 #!/bin/sh
2
3 ###################################################################
4 # Wrapper around c compilers
5 # Makes compiling and writing c easier
6 # for people who write small programs (unfortunately not everyone).
7 # Mostly made for personal workflow.
8 # Inspired by the Go compiler.
9 ###################################################################
10
11 if [ "$1" = "" ]
12 then
13 echo "$0 [command] (file|foldername)" | sed "s|/.*/||g"
14 echo
15 echo "commands:"
16 echo
17 echo " build compiles all c files in a directory"
18 echo " mk compiles a single file using tcc"
19 echo " run compiles and runs the c file pointed to"
20 echo " clean removes the binary named after the directory"
21 echo
22
23 exit
24 fi
25
26 whatdo="$1"
27 file="$2" # optional
28
29 CC="clang"
30 while getopts ":c:" c; do
31 case "$c" in
32 c) CC="$OPTARG"; whatdo="$3"; file="$4"
33 ;;
34 esac
35 done
36 # add all the link options you can think of.
37 translate="s|math.h|-lm|; s|xcb/xcb.h|-lxcb|; s|xcb/xcb_util.h|-lxcb-util|;"
38
39 stdgone="s/assert.h|ctype.h|dirent.h|errno.h|fcntl.h|inttypes.h|limits.h|locale.h|setjmp.h|signal.h|stdarg.h|stdio.h|string.h|stdlib.h|time.h|unistd.h|sys\/types.h|sys\/wait.h|iostream//g;"
40
41 cfiletext="^//cfiles: " # uses grep regex
42
43
44 flags() {
45 incflangs=""
46 cflags=""
47 cfiles="$(grep -h "$cfiletext" *.c | cut -b 11-)"
48 include="$(grep -h "^#include <" *.c | uniq | sed "s/#include <//g;s/>//g;$translate;$stdgone")"
49
50 echo $cfiles $cflags $include $incflags
51 }
52
53 singleflags() {
54 incflangs=""
55 cflags=""
56 cfiles="$(grep "$cfiletext" "$file" | cut -c 11-)"
57 include="$(grep -h "^#include <" $file $cfiles | uniq | sed -E "s/#include <//g;s/>//g;$translate;$stdgone")"
58
59 echo $cfiles $cflags $include $incflags
60 }
61
62 build() {
63 [ "$file" != "" ] && [ -d "$file" ] && cd "$file"
64 arecfiles="$(ls -l | grep "\.c")"
65 [ "$arecfiles" = "" ] && echo "not a buildable directory" && exit
66 binname="$(pwd | sed "s|/.*/||g")" # The name of the working directory
67 allflags="$(flags)"
68 $CC $allflags -o "$binname" *.c
69 }
70
71
72
73 mak() {
74 [ ! -e "$file" ] || [ -d "$file" ] && echo "give one existing file name" && exit
75 filebase="${file%.*}"
76 allflags="$(singleflags)"
77 $CC -o "$filebase" $allflags "$file" -lfl
78 }
79
80
81 clean() {
82 [ "$file" != "" ] && [ -d "$file" ] && cd "$file"
83 binname="$(pwd | sed "s|/.*/||g")"
84 [ -f "$binname" ] && rm "$binname"
85 }
86
87 case "$whatdo" in
88 "build") build ;;
89 "debug") debugbuild ;;
90 "mk") mak ;;
91 "run") mak && "$(readlink -f $filebase)" ;;
92 "drun") debugonone ;;
93 "clean") clean ;;
94 esac
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/spicylord/clutils

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/spicylord/clutils

Clone this repository using git:
git clone git://git.rocketgit.com/user/spicylord/clutils

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main