Skip to content

Commit

Permalink
update to version 0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
teras committed May 11, 2020
1 parent 2117dad commit 9c79956
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 42 deletions.
122 changes: 83 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
.PHONY: clean all desktop osx linux pi windows current install run preosx prelinux prepi prewindows
.PHONY: clean all desktop posix osx linux pi windows win32 win64 local install install-only run docker xclean

# needs to be defined before include
default:current
default:local

include config.mk

DEST:=~/Works/System/arch
DEST:=~/Works/System/bin/arch

ALLNIMOPTS=-d:release -d:VERSION=$(VERSION) --opt:size $(NIMOPTS)
ifeq ($(DEBUG),true)
BASENIMOPTS=-d:VERSION=$(VERSION) --opt:size $(NIMOPTS)
else
ifeq ($(DEBUG),full)
BASENIMOPTS=-d:VERSION=$(VERSION) --debuginfo --linedir:on $(NIMOPTS)
else
BASENIMOPTS=-d:release -d:VERSION=$(VERSION) --opt:size $(NIMOPTS)
endif
endif

ifeq ($(EXECNAME),)
EXECNAME:=$(NAME)
Expand All @@ -25,8 +33,15 @@ ifeq ($(WINAPP),)
WINAPP:=console
endif

ifeq ($(ALLTARGETS),)
ALLTARGETS:=desktop pi
endif

ifneq ($(NIMBLE),)
NIMBLE:=nimble -y install $(NIMBLE);
NIMBLE:=nimble refresh ; nimble -y install $(NIMBLE);
DOCKERNAME:=teras/nimcross:${NAME}
else
DOCKERNAME:=teras/nimcross
endif

ifneq ($(NIMVER),)
Expand All @@ -35,68 +50,97 @@ endif

DOCOMPRESS:=$(shell echo $(COMPRESS) | tr A-Z a-z | cut -c1-1)

BUILDDEP:=$(wildcard *.nim *.c Makefile config.mk)
BUILDDEP:=$(wildcard *.nim *.c *.m Makefile config.mk)

current:target/${EXECNAME}

all:desktop pi
initlocal:
${NIMVER} ${NIMBLE}

local:target/${EXECNAME}

all:$(ALLTARGETS)

desktop:osx linux windows

pi:target/${EXECNAME}.arm64.linux
posix:osx linux pi

pi:target/${EXECNAME}.aarch64.linux

osx:target/${EXECNAME}.osx

linux:target/${EXECNAME}.linux

windows:target/${EXECNAME}.64.exe
windows:win32 win64

clean:
rm -rf target nimcache ${NAME} ${NAME}.exe
win32:target/${EXECNAME}.32.exe

win64:target/${EXECNAME}.64.exe

clean:xclean
rm -rf target docker.tmp nimcache ${NAME} ${NAME}.exe

docker:
@if [ "${NIMBLE}" != "" ] ; then \
rm -rf docker.tmp && \
mkdir docker.tmp && \
echo >docker.tmp/Dockerfile "FROM teras/nimcross" && \
echo >>docker.tmp/Dockerfile "RUN ${NIMBLE}" && \
cd docker.tmp ; docker build -t ${DOCKERNAME} . && \
rm -rf docker.tmp ; \
fi

target/${EXECNAME}:${BUILDDEP}
${NIMVER} nim ${COMPILER} ${ALLNIMOPTS} ${NAME}
nim ${COMPILER} ${BASENIMOPTS} ${OSXNIMOPTS} ${NAME}
mkdir -p target
mv ${NAME} target/${EXECNAME}
if [ "$(DOCOMPRESS)" = "y" ] ; then upx --best target/${EXECNAME} ; fi
if [ "$(DOCOMPRESS)" = "t" ] ; then upx --best target/${EXECNAME} ; fi
cp target/${EXECNAME} target/${EXECNAME}.osx

target/${EXECNAME}.osx:${BUILDDEP} preosx
target/${EXECNAME}.osx:${BUILDDEP}
mkdir -p target
docker run --rm -v `pwd`:/usr/src/app -w /usr/src/app teras/nimcross bash -c "${NIMVER} ${NIMBLE} nim ${COMPILER} ${ALLNIMOPTS} --os:macosx --passC:'-mmacosx-version-min=10.7 -gfull' --passL:'-mmacosx-version-min=10.7 -dead_strip' ${NAME} && x86_64-apple-darwin19-strip ${NAME}"
docker run --rm -v `pwd`:/usr/src/app -w /usr/src/app ${DOCKERNAME} bash -c "${NIMVER} nim ${COMPILER} ${BASENIMOPTS} ${OSXNIMOPTS} --os:macosx --passC:'-mmacosx-version-min=10.7 -gfull' --passL:'-mmacosx-version-min=10.7 -dead_strip' ${NAME} && x86_64-apple-darwin19-strip ${NAME}"
mv ${NAME} target/${EXECNAME}.osx
if [ "$(DOCOMPRESS)" = "y" ] ; then upx --best target/${EXECNAME}.osx ; fi
if [ "$(DOCOMPRESS)" = "t" ] ; then upx --best target/${EXECNAME}.osx ; fi

target/${EXECNAME}.linux:${BUILDDEP} prelinux
target/${EXECNAME}.linux:${BUILDDEP}
mkdir -p target
docker run --rm -v `pwd`:/usr/src/app -w /usr/src/app teras/nimcross bash -c "${NIMVER} ${NIMBLE} nim ${COMPILER} ${ALLNIMOPTS} ${NAME} && strip ${NAME}"
docker run --rm -v `pwd`:/usr/src/app -w /usr/src/app ${DOCKERNAME} bash -c "${NIMVER} nim ${COMPILER} ${BASENIMOPTS} ${LINUXNIMOPTS} ${NAME} && strip ${NAME}"
mv ${NAME} target/${EXECNAME}.linux
if [ "$(DOCOMPRESS)" = "y" ] ; then upx --best target/${EXECNAME}.linux ; fi
if [ "$(DOCOMPRESS)" = "t" ] ; then upx --best target/${EXECNAME}.linux ; fi

target/${EXECNAME}.arm64.linux:${BUILDDEP} prepi
target/${EXECNAME}.aarch64.linux:${BUILDDEP}
mkdir -p target
docker run --rm -v `pwd`:/usr/src/app -w /usr/src/app teras/nimcross bash -c "${NIMVER} ${NIMBLE} nim ${COMPILER} ${ALLNIMOPTS} --cpu:arm --os:linux ${NAME} && arm-linux-gnueabi-strip ${NAME}"
docker run --rm -v `pwd`:/usr/src/app -w /usr/src/app ${DOCKERNAME} bash -c "${NIMVER} nim ${COMPILER} ${BASENIMOPTS} ${PINIMOPTS} --cpu:arm --os:linux ${NAME} && arm-linux-gnueabi-strip ${NAME}"
mv ${NAME} target/${EXECNAME}.arm.linux
if [ "$(DOCOMPRESS)" = "y" ] ; then upx --best target/${EXECNAME}.arm.linux ; fi
docker run --rm -v `pwd`:/usr/src/app -w /usr/src/app teras/nimcross bash -c "${NIMVER} ${NIMBLE} nim ${COMPILER} ${ALLNIMOPTS} --cpu:arm64 --os:linux ${NAME} && aarch64-linux-gnu-strip ${NAME}"
mv ${NAME} target/${EXECNAME}.arm64.linux
if [ "$(DOCOMPRESS)" = "y" ] ; then upx --best target/${EXECNAME}.arm64.linux ; fi
#if [ "$(DOCOMPRESS)" = "t" ] ; then upx --best target/${EXECNAME}.arm.linux ; fi
docker run --rm -v `pwd`:/usr/src/app -w /usr/src/app ${DOCKERNAME} bash -c "${NIMVER} nim ${COMPILER} ${BASENIMOPTS} ${PINIMOPTS} --cpu:arm64 --os:linux ${NAME} && aarch64-linux-gnu-strip ${NAME}"
mv ${NAME} target/${EXECNAME}.aarch64.linux
if [ "$(DOCOMPRESS)" = "t" ] ; then upx --best target/${EXECNAME}.aarch64.linux ; fi

target/${EXECNAME}.64.exe:${BUILDDEP} prewindows
target/${EXECNAME}.32.exe:${BUILDDEP}
mkdir -p target
docker run --rm -v `pwd`:/usr/src/app -w /usr/src/app teras/nimcross bash -c "${NIMVER} ${NIMBLE} nim ${COMPILER} ${ALLNIMOPTS} -d:mingw --cpu:i386 --app:${WINAPP} ${NAME} && i686-w64-mingw32-strip ${NAME}.exe"
docker run --rm -v `pwd`:/usr/src/app -w /usr/src/app ${DOCKERNAME} bash -c "${NIMVER} nim ${COMPILER} ${BASENIMOPTS} ${WINDOWSNIMOPTS} -d:mingw --cpu:i386 --app:${WINAPP} ${NAME} && i686-w64-mingw32-strip ${NAME}.exe"
mv ${NAME}.exe target/${EXECNAME}.32.exe
if [ "$(DOCOMPRESS)" = "y" ] ; then upx --best target/${EXECNAME}.32.exe ; fi
docker run --rm -v `pwd`:/usr/src/app -w /usr/src/app teras/nimcross bash -c "${NIMVER} ${NIMBLE} nim ${COMPILER} ${ALLNIMOPTS} -d:mingw --cpu:amd64 --app:${WINAPP} ${NAME} && x86_64-w64-mingw32-strip ${NAME}.exe"
if [ "$(DOCOMPRESS)" = "t" ] ; then upx --best target/${EXECNAME}.32.exe ; fi

target/${EXECNAME}.64.exe:${BUILDDEP}
mkdir -p target
docker run --rm -v `pwd`:/usr/src/app -w /usr/src/app ${DOCKERNAME} bash -c "${NIMVER} nim ${COMPILER} ${BASENIMOPTS} ${WINDOWSNIMOPTS} -d:mingw --cpu:amd64 --app:${WINAPP} ${NAME} && x86_64-w64-mingw32-strip ${NAME}.exe"
mv ${NAME}.exe target/${EXECNAME}.64.exe
if [ "$(DOCOMPRESS)" = "y" ] ; then upx --best target/${EXECNAME}.64.exe ; fi
if [ "$(DOCOMPRESS)" = "t" ] ; then upx --best target/${EXECNAME}.64.exe ; fi


install: | all install-only

install:all
mkdir -p ${DEST}/darwin-x86_64/ && cp target/${EXECNAME}.osx ${DEST}/darwin-x86_64/${EXECNAME}
mkdir -p ${DEST}/linux-x86_64/ && cp target/${EXECNAME}.linux ${DEST}/linux-x86_64/${EXECNAME}
mkdir -p ${DEST}/linux-arm && cp target/${EXECNAME}.arm.linux ${DEST}/linux-arm/${EXECNAME}
mkdir -p ${DEST}/linux-arm64 && cp target/${EXECNAME}.arm64.linux ${DEST}/linux-arm64/${EXECNAME}
mkdir -p ${DEST}/windows-x86_64 && cp target/${EXECNAME}.64.exe ${DEST}/windows-x86_64/${EXECNAME}.exe
mkdir -p ${DEST}/windows-i686 && cp target/${EXECNAME}.32.exe ${DEST}/windows-i686/${EXECNAME}.exe
install-only:
set -e ; mkdir -p ${DEST}/all
set -e ; rm -rf ${DEST}/all/${EXECNAME}.* ; rm -f ${DEST}/darwin-x86_64/${EXECNAME} ${DEST}/linux-x86_64/${EXECNAME} ${DEST}/linux-arm/${EXECNAME} ${DEST}/linux-aarch64/${EXECNAME} ${DEST}/windows-x86_64/${EXECNAME}.exe ${DEST}/windows-i686/${EXECNAME}.exe
set -e ; if [ -f target/${EXECNAME}.osx ] ; then mkdir -p ${DEST}/darwin-x86_64 && cp target/${EXECNAME}.osx ${DEST}/all/ && ln -s ../all/${EXECNAME}.osx ${DEST}/darwin-x86_64/${EXECNAME} ; fi
set -e ; if [ -f target/${EXECNAME}.linux ] ; then mkdir -p ${DEST}/linux-x86_64 && cp target/${EXECNAME}.linux ${DEST}/all/ && ln -s ../all/${EXECNAME}.linux ${DEST}/linux-x86_64/${EXECNAME} ; fi
set -e ; if [ -f target/${EXECNAME}.arm.linux ] ; then mkdir -p ${DEST}/linux-arm && cp target/${EXECNAME}.arm.linux ${DEST}/all/ && ln -s ../all/${EXECNAME}.arm.linux ${DEST}/linux-arm/${EXECNAME} ; fi
set -e ; if [ -f target/${EXECNAME}.aarch64.linux ] ; then mkdir -p ${DEST}/linux-aarch64 && cp target/${EXECNAME}.aarch64.linux ${DEST}/all/ && ln -s ../all/${EXECNAME}.aarch64.linux ${DEST}/linux-aarch64/${EXECNAME} ; fi
set -e ; if [ -f target/${EXECNAME}.64.exe ] ; then mkdir -p ${DEST}/windows-x86_64 && cp target/${EXECNAME}.64.exe ${DEST}/all/ && ln -s ../all/${EXECNAME}.64.exe ${DEST}/windows-x86_64/${EXECNAME}.exe ; fi
set -e ; if [ -f target/${EXECNAME}.32.exe ] ; then mkdir -p ${DEST}/windows-i686 && cp target/${EXECNAME}.32.exe ${DEST}/all/ && ln -s ../all/${EXECNAME}.32.exe ${DEST}/windows-i686/${EXECNAME}.exe ; fi

run:current
run:local
./target/${EXECNAME} ${RUNARGS}
4 changes: 2 additions & 2 deletions config.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAME=dpacker
VERSION=0.1.1
VERSION=0.2

NIMOPTS=--multimethods:on
COMPILER=c
Expand All @@ -11,4 +11,4 @@ EXECNAME=dpr

RUNARGS=--dpacker-help

COMPRESS=yes
COMPRESS=true
15 changes: 14 additions & 1 deletion dpackeropts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ proc hasArg*(args:var seq[string], a:string, position:int = -1) : bool =
return true
false

const dpackerCmd = """ info
install
list
remove|uninstall
search
where|file|files
update
upgrade"""

const facesList* = """ --apt-face
--brew-face
--choco-face
Expand Down Expand Up @@ -47,4 +56,8 @@ List of valid --FACE options:
List of valid --TARGET options:
""" & targetsList
""" & targetsList & """
List of possible commands, with dpacker as target:
""" & dpackerCmd

0 comments on commit 9c79956

Please sign in to comment.