-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 03c498e
Showing
4 changed files
with
232 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
A program to build software | ||
Copyright © 2018 Robert Underwood | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
1. Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY Robert Underwood ''AS IS'' AND ANY | ||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL Robert Underwood BE LIABLE FOR ANY | ||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
The views and conclusions contained in the software and documentation | ||
are those of the authors and should not be interpreted as representing | ||
official policies, either expressed or implied, of Robert Underwood. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
PREFIX?=$(DESTDIR)/usr/local | ||
BINDIR?=$(PREFIX)/bin | ||
.PHONY: install | ||
install: | ||
install -D bin/m $(BINDIR)/m | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# M - a software build tool | ||
|
||
## usage: | ||
|
||
```sh | ||
#Make the project using meson, cmake, or make/autotools | ||
m | ||
|
||
#Run the project modifiying compiler flags | ||
CXX=clang++ m | ||
|
||
#Run the project tests | ||
m t | ||
|
||
#Cleanup the project | ||
m c | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
#!/bin/bash | ||
|
||
|
||
function m_test() { | ||
local DIR_ROOT="$1" | ||
local BAIL=$2 | ||
shift 2 | ||
echo "testing in ${DIR_ROOT}" | ||
echo "args: $@" | ||
|
||
while true; | ||
do | ||
#bail if not in a repo | ||
if [ "${BAIL}" -eq "1" ]; then | ||
echo "Not in a Repository" >&2 | ||
break | ||
fi | ||
|
||
#meson | ||
if [ -f "${DIR_ROOT}/meson.build" ]; then | ||
if [ ! -d "${DIR_ROOT}/build" ]; then | ||
meson build | ||
fi | ||
cd build | ||
meson test $@ | ||
cd .. | ||
break | ||
fi | ||
|
||
#cmake | ||
if [ -f "${DIR_ROOT}/CMakeLists.txt" ]; then | ||
if [ ! -d "${DIR_ROOT}/build" ]; then | ||
mkdir build | ||
cd build | ||
cmake -G Ninja .. | ||
cd .. | ||
fi | ||
cmake --build build | ||
cd build | ||
ctest | ||
cd .. | ||
break | ||
fi | ||
|
||
#autotools; fall trough to make for actual build | ||
if [ -f "${DIR_ROOT}/autogen.sh" ] && [ ! -f "${DIR_ROOT}/configure" ]; then | ||
./autogen.sh | ||
fi | ||
|
||
if [ -f "${DIR_ROOT}/configure" ] && [ ! -f "${DIR_ROOT}/Makefile" ]; then | ||
./configure | ||
fi | ||
|
||
#make | ||
if [ -f "${DIR_ROOT}/Makefile" ]; then | ||
make -j $(nproc --all) check | ||
break | ||
fi | ||
|
||
done | ||
|
||
} | ||
|
||
function m_build() { | ||
local DIR_ROOT="$1" | ||
local BAIL=$2 | ||
shift 2 | ||
echo "building in ${DIR_ROOT}" | ||
echo "args: $@" | ||
|
||
while true; | ||
do | ||
#bail if not in a repo | ||
if [ "${BAIL}" -eq "1" ]; then | ||
echo "Not in a Repository" >&2 | ||
break | ||
fi | ||
|
||
#meson | ||
if [ -f "${DIR_ROOT}/meson.build" ]; then | ||
if [ ! -d "${DIR_ROOT}/build" ]; then | ||
meson build | ||
fi | ||
ninja -C build $@ | ||
break | ||
fi | ||
|
||
#cmake | ||
if [ -f "${DIR_ROOT}/CMakeLists.txt" ]; then | ||
if [ ! -d "${DIR_ROOT}/build" ]; then | ||
mkdir build | ||
cd build | ||
cmake -G Ninja .. | ||
cd .. | ||
fi | ||
cmake --build build $@ | ||
break | ||
fi | ||
|
||
#autotools; fall trough to make for actual build | ||
if [ -f "${DIR_ROOT}/autogen.sh" ] && [ ! -f "${DIR_ROOT}/configure" ]; then | ||
./autogen.sh | ||
fi | ||
|
||
if [ -f "${DIR_ROOT}/configure" ] && [ ! -f "${DIR_ROOT}/Makefile" ]; then | ||
./configure | ||
fi | ||
|
||
#make | ||
if [ -f "${DIR_ROOT}/Makefile" ]; then | ||
make -j $(nproc --all) $@ | ||
break | ||
fi | ||
|
||
echo "No Build System Detected" | ||
break | ||
done | ||
} | ||
|
||
function m_clean() { | ||
local DIR_ROOT="$1" | ||
local BAIL=$2 | ||
shift 2 | ||
local BUILD_DIR=0 | ||
echo "Cleaning" | ||
while true; | ||
do | ||
if [ "${BAIL}" -eq "1" ]; then | ||
echo "Not in a Repository" >&2 | ||
break | ||
fi | ||
|
||
if [ -f ${DIR_ROOT}/Makefile ]; then | ||
make -j $(nproc --all) clean | ||
break | ||
fi | ||
|
||
if [ -f ${DIR_ROOT}/build/Makefile ]; then | ||
make -C build -j $(nproc --all) clean | ||
break | ||
fi | ||
|
||
if [ -f ${DIR_ROOT}/build/build.ninja ]; then | ||
ninja -C build clean | ||
break | ||
fi | ||
|
||
break | ||
done | ||
} | ||
|
||
BAIL=0 | ||
DIR_ROOT="." | ||
OLD_DIR=$(pwd) | ||
|
||
#find root of repository | ||
while [ ! -d "${DIR_ROOT}/.git" ] && [ ! -f "${DIR_ROOT}/.mstop" ] | ||
do | ||
DIR_ROOT="$(dirname $(readlink -f ${DIR_ROOT}))" | ||
if [ "${DIR_ROOT}" = "/" ]; then | ||
BAIL=1 | ||
break | ||
fi | ||
done | ||
|
||
cd "${DIR_ROOT}" | ||
|
||
case "$1" in | ||
c*) | ||
m_clean "${DIR_ROOT}" "${BAIL}" | ||
;; | ||
t*) | ||
shift | ||
m_test "${DIR_ROOT}" "${BAIL}" $@ | ||
;; | ||
*) | ||
shift | ||
m_build "${DIR_ROOT}" "${BAIL}" $@ | ||
;; | ||
esac | ||
|
||
cd "${OLD_DIR}" |