Archived
1
0

switch to make for build

This commit is contained in:
Jeff Becker 2017-04-04 09:01:32 -04:00
parent 665849e016
commit 08aaac492e
3 changed files with 39 additions and 236 deletions

39
Makefile Normal file
View File

@ -0,0 +1,39 @@
REPO=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
REPO_GOPATH=$(REPO)/go
MINIFY=$(REPO_GOPATH)/bin/minify
JS=$(REPO)/contrib/static/nntpchan.js
CONTRIB_JS=$(REPO)/contrib/js/contrib
LOCAL_JS=$(REPO)/contrib/js/nntpchan
VENDOR_JS=$(REPO)/contrib/js/vendor
SRND_DIR=$(REPO)/contrib/backends/srndv2
SRND=$(REPO)/srndv2
all: build
build: js srnd
js: $(JS)
srnd: $(SRND)
$(MINIFY):
GOPATH=$(REPO_GOPATH) go get -v github.com/tdewolff/minify/cmd/minify
js-deps: $(MINIFY)
$(JS): js-deps
for f in $(CONTRIB_JS)/*.js ; do $(MINIFY) --mime=text/javascript >> $(JS) < $$f ; done
$(MINIFY) --mime=text/javascript >> $(JS) < $(REPO)/contrib/js/entry.js
for f in $(LOCAL_JS)/*.js ; do $(MINIFY) --mime=text/javascript >> $(JS) < $$f ; done
for f in $(VENDOR_JS)/*.js ; do $(MINIFY) --mime=text/javascript >> $(JS) < $$f ; done
$(SRND):
make -C $(SRND_DIR)
cp $(SRND_DIR)/srndv2 $(SRND)
clean:
rm -f $(SRND) $(JS)
distclean: clean
rm -rf $(REPO_GOPATH)

View File

@ -1,118 +0,0 @@
#!/usr/bin/env bash
neochan="no"
if [ "$1" == "--enable-neochan" ] ; then
neochan="yes"
fi
root=$(readlink -e "$(dirname "$0")")
set -e
if [ "x" == "x$root" ] ; then
root=$PWD/${0##*}
fi
cd "$root"
if [ -z "$GOPATH" ]; then
export GOPATH=$root/go
mkdir -p "$GOPATH"
fi
if [ ! -f "$GOPATH/bin/minify" ]; then
echo "set up minifiy"
go get -v github.com/tdewolff/minify/cmd/minify
fi
outfile="$PWD/contrib/static/nntpchan.js"
neochan_js_outfile="$PWD/contrib/static/neochan.js"
neochan_css_outfile="$PWD/contrib/static/neochan.css"
mini() {
echo "minify $1"
echo "" >> $2
echo "/* begin $1 */" >> $2
"$GOPATH/bin/minify" --mime=text/javascript >> $2 < $1
echo "" >> $2
echo "/* end $1 */" >> $2
}
css() {
echo "minify $1"
echo "" >> $2
echo "/* begin $1 */" >> $2
lessc $1 >> $2
echo "" >> $2
echo "/* end $1 */" >> $2
}
initfile() {
rm -f "$1"
echo '/*' >> "$1"
echo ' * For source code and license information please check https://github.com/majestrate/nntpchan' >> "$1"
brandingfile=./contrib/branding.txt
if [ -e "$brandingfile" ] ; then
echo ' *' >> "$1"
while read line; do
echo -n ' * ' >> "$1";
echo $line >> "$1";
done < $brandingfile;
fi
echo ' */' >> "$1"
}
echo
echo "building nntpchan.js ..."
echo
initfile "$outfile"
for f in ./contrib/js/contrib/*.js ; do
mini "$f" "$outfile"
done
mini ./contrib/js/entry.js "$outfile"
# local js
for f in ./contrib/js/nntpchan/*.js ; do
mini "$f" "$outfile"
done
# vendor js
for f in ./contrib/js/vendor/*.js ; do
mini "$f" "$outfile"
done
if [ "$neochan" == "yes" ] ; then
set +e
for exe in lessc coffee ; do
which $exe &> /dev/null
if [ "$?" != "0" ] ; then
echo "$exe not installed";
exit 1
fi
done
echo
echo "building neochan.js ..."
echo
initfile "$neochan_js_outfile"
for f in ./contrib/js/neochan/*.coffee ; do
echo "compile $f"
coffee -cs < "$f" > "$f.js"
done
for f in ./contrib/js/neochan/*.js ; do
mini "$f" "$neochan_js_outfile"
done
echo
echo "building neochan.css ..."
echo
initfile "$neochan_css_outfile"
for f in ./contrib/js/neochan/*.less ; do
css "$f" "$neochan_css_outfile"
done
fi
echo
echo "ok"

118
build.sh
View File

@ -1,118 +0,0 @@
#!/usr/bin/env bash
root=$(readlink -e "$(dirname "$0")")
set -e
if [ "" == "$root" ] ; then
root=$PWD/${0##*}
fi
cd "$root"
tags=""
help_text="usage: $0 [--disable-neochan] [--enable-redis]"
# check for help flags first
for arg in "$@" ; do
case $arg in
-h|--help)
echo "$help_text"
exit 0
;;
esac
done
rev="QmPAqM7anxdr1ngPmJz9J9AAxDLinDz2Eh9aAzLF9T7LNa"
ipfs="no"
rebuildjs="yes"
_next=""
unstable="no"
neochan="no"
buildredis="no"
lua="no"
# check for build flags
for arg in "$@" ; do
case $arg in
"--enable-lua")
lua="yes"
;;
"--enable-redis")
buildredis="yes"
;;
"--enable-neochan")
neochan="yes"
;;
"--unstable")
unstable="yes"
;;
"--no-js")
rebuildjs="no"
;;
"--ipfs")
ipfs="yes"
;;
"--revision")
_next="rev"
;;
"--revision=*")
rev=$(echo "$arg" | cut -d'=' -f2)
;;
*)
if [ "x$_next" == "xrev" ] ; then
rev="$arg"
fi
esac
done
if [ "$buildredis" == "yes" ] ; then
tags="$tags -tags disable_redis"
fi
if [ "$lua" == "yes" ] ; then
tags="$tags -tags lua"
fi
if [ "$rev" == "" ] ; then
echo "revision not specified"
exit 1
fi
cd "$root"
if [ "$rebuildjs" == "yes" ] ; then
echo "rebuilding generated js..."
if [ "$neochan" == "no" ] ; then
./build-js.sh --disable-neochan
else
./build-js.sh
fi
fi
unset GOPATH
export GOPATH=$PWD/go
mkdir -p "$GOPATH"
if [ "$ipfs" == "yes" ] ; then
if [ ! -e "$GOPATH/bin/gx" ] ; then
echo "obtaining gx"
go get -u -v github.com/whyrusleeping/gx
fi
if [ ! -e "$GOPATH/bin/gx-go" ] ; then
echo "obtaining gx-go"
go get -u -v github.com/whyrusleeping/gx-go
fi
echo "building stable revision, this will take a bit. to speed this part up install and run ipfs locally"
mkdir -p "$GOPATH/src/gx/ipfs"
cd "$GOPATH/src/gx/ipfs"
"$GOPATH/bin/gx" get "$rev"
cd "$rev/srndv2"
echo "build..."
go build -v .
cp srndv2 "$root"
echo -e "Built\n"
echo "Now configure NNTPChan with ./srndv2 setup"
else
echo "building the daemon..."
echo
make -C contrib/backends/srndv2
cp contrib/backends/srndv2/srndv2 .
echo "built"
echo "now configure NNTPChan with ./srndv2 setup"
fi