build system and package manager (spm) for C
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
LICENSE
README.md update README Aug 25, 2018
genMake.c
install.sh
installTermux.sh
make.sh update sheepy, add spm Sep 30, 2017

README.md

Warning: the tools in this repository are under development.

sheepy compiles and runs C programs without makefiles and it has the ability to run as a C script with a hashbang. GCC (minimum 4.9) has to be installed for a working system.

The build system is multiprocess by default and already built objects are reused.

sheepy depends on libsheepy, libsheepy is installed during the installation process.

libsheepy reference documentation is available at http://spartatek.se/libsheepy/.

The prefered C standard is C11 because libsheepy has many generics, C99 is supported but is much less convenient to use than C11 because there are thousands of functions in libsheepy (a function for each type and feature).

  • sheepy builds the executables and libraries.
  • spm is the package manager.

Install

Platforms:

  • Linux/GNU, Intel (Ivy Bridge or newer for DRNG RDRAND)
  • Linux/GNU, ARM (raspberry pi)
  • Android/Termux ARM
  • MacOS
  • FreeBSD

These commands install sheepy and spm:

git clone https://github.com/RemyNoulin/sheepy.git
cd sheepy

sudo -H ./install.sh

In Termux:

# Termux only
pkg install git clang curl gdb

git clone https://github.com/RemyNoulin/sheepy.git
cd sheepy

./installTermux.sh

Configuration

The user configuration is located at ~/.sheepy/config.yml.

If the configuration file doesn't already exist, it is created when sheepy is executed for the first time.

Settings:

  • system install location of the sheepy and spm commands and global packages
  • cflags flags for the C compiler
  • lflags flags for the linker
  • linkWithGold enable/disable gold linker (multithreaded linking)
  • 32bit generate a 32bit executable
  • parallelSheepy enable/disable multiprocess build
  • buildPath directory where the intermediary object files are stored
  • key secret key to log on the spm registry
  • testflags compile flags for tests

Dependencies

sheepy and spm have some external dependencies:

  • GCC 4.9 or clang
  • Optionally gold linker, this can be disabled in the configuration (~/.sheepy/config.yml)
  • curl (spm)
  • tar (spm)
  • gzip or pigz (spm)

Starting a new project

With sheepy:

sheepy -n example

# run:
./example.c

To create new packages with spm:

spm new example1 examples2

# run:
cd example1
./example1.c

Compilation

To get help, run:

sheepy -h

To run a program:

sheepy <C_SOURCE>

To run as a script, add a hashbang at the top of the main c file:

#! /usr/bin/env sheepy

libsheepy.a is always linked and pthread is always enabled.

minimal C source:

#! /usr/bin/env sheepy
int main(int ARGC, char** ARGV) {
}

Packages

To get help, run:

spm help

To install a package:

sudo spm -g install sheepyExamples
sudo spm -g install md

The searchReplace requires libpcre to compile successfully, to install pcre:

sudo apt-get install libpcre3-dev

To create a new package:

spm new packageName
cd packageName

Compiling multiple source files

sheepy doesn't use makefiles, it scans the #include lines in the source code to figure out what to compile.

When an include statement is found, sheepy searches for a C source file with the same name changing the extension from .h to .c. For includes in installed packages, the source files are already in the static library so the library is statically linked.

For example, main.c:

#include "libsheepyObject.h"
#include "test.h"
#include "shpPackages/apkg/apkg.h"
int main(int c, char **a) {
  XSUCCESS;
}

sheepy compiles main.c, test.c if it exists and statically link libapkg.a.

Creating classes

As seen in previously sheepy -n name generates a new main file. sheepy -C className generates the files for a class called className

In order to use the class, simply add #include "className.h" in a source file.

The class templates has the methods inherited from the baset class, all the sheepy classes inherit from the baset class. The template has TODO comments showing how to extend the class.

Unit tests and memcheck

sheepy and spm have commands for generating unit test and memcheck (valgrind) templates. The following is the instructions to generate and run the tests for :

Create and edit package.yml to enable the tests:

spm new <package name>
cd <package name>
vi package.yml

Uncomment: testBin, testCflags, testLflags, memcheckBin, memcheckCflags, memcheckLflags and add the compilation flags as necessary

Generate the test templates:

sheepy -T

Add the tests in test.c

Run the tests:

Unit tests:

spm test

Memcheck:

./test<Package name>Mem.sh