Improve automatic version generation - fix #497
This commit is contained in:
parent
c7ea7e081e
commit
5138d04e5d
|
@ -20,9 +20,6 @@ callgrind.*
|
||||||
# GDB temp files
|
# GDB temp files
|
||||||
.gdb_history
|
.gdb_history
|
||||||
|
|
||||||
# Git hash file
|
|
||||||
githash.txt
|
|
||||||
|
|
||||||
# Test results
|
# Test results
|
||||||
tests/tc*/actual*.txt
|
tests/tc*/actual*.txt
|
||||||
stderr.txt
|
stderr.txt
|
||||||
|
|
15
build.bat
15
build.bat
|
@ -1,6 +1,20 @@
|
||||||
IF "%DC%"=="" SET DC="dmd"
|
IF "%DC%"=="" SET DC="dmd"
|
||||||
IF "%MFLAGS%"=="" SET MFLAGS="-m32"
|
IF "%MFLAGS%"=="" SET MFLAGS="-m32"
|
||||||
|
|
||||||
|
|
||||||
|
:: git might not be installed, so we provide 0.0.0 as a fallback or use
|
||||||
|
:: the existing githash file if existent
|
||||||
|
if not exist "bin" mkdir bin
|
||||||
|
git describe --tags > bin\githash_.txt
|
||||||
|
for /f %%i in ("bin\githash_.txt") do set githashsize=%%~zi
|
||||||
|
if %githashsize% == 0 (
|
||||||
|
if not exist "bin\githash.txt" (
|
||||||
|
echo v0.0.0 > bin\githash.txt
|
||||||
|
)
|
||||||
|
) else (
|
||||||
|
move /y bin\githash_.txt bin\githash.txt
|
||||||
|
)
|
||||||
|
|
||||||
set containers_modules=
|
set containers_modules=
|
||||||
for /r "containers/src" %%F in (*.d) do call set containers_modules=%%containers_modules%% "%%F"
|
for /r "containers/src" %%F in (*.d) do call set containers_modules=%%containers_modules%% "%%F"
|
||||||
|
|
||||||
|
@ -49,6 +63,7 @@ set server_name=bin\dcd-server
|
||||||
-Ilibdparse/src^
|
-Ilibdparse/src^
|
||||||
-Istdx-allocator/source^
|
-Istdx-allocator/source^
|
||||||
-wi -O -release^
|
-wi -O -release^
|
||||||
|
-Jbin^
|
||||||
%MFLAGS%^
|
%MFLAGS%^
|
||||||
-of%server_name%
|
-of%server_name%
|
||||||
|
|
||||||
|
|
6
dub.json
6
dub.json
|
@ -12,6 +12,9 @@
|
||||||
"msgpack-d": "~>1.0.0-beta.3",
|
"msgpack-d": "~>1.0.0-beta.3",
|
||||||
"stdx-allocator": "~>2.77.2"
|
"stdx-allocator": "~>2.77.2"
|
||||||
},
|
},
|
||||||
|
"stringImportPaths" : [
|
||||||
|
"bin"
|
||||||
|
],
|
||||||
"versions": ["built_with_dub"],
|
"versions": ["built_with_dub"],
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
|
@ -40,5 +43,8 @@
|
||||||
"src/dcd/client/*"
|
"src/dcd/client/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"preGenerateCommands" : [
|
||||||
|
"rdmd --eval=\"auto dir=environment.get(\\\"DUB_PACKAGE_DIR\\\"); dir.buildPath(\\\"bin\\\").mkdirRecurse; auto gitVer = (\\\"git -C \\\"~dir~\\\" describe --tags\\\").executeShell; (gitVer.status == 0 ? gitVer.output.strip : \\\"v\\\" ~ dir.dirName.baseName.findSplitAfter(environment.get(\\\"DUB_ROOT_PACKAGE\\\")~\\\"-\\\")[1]).ifThrown(\\\"0.0.0\\\").chain(newline).toFile(dir.buildPath(\\\"bin\\\", \\\"dubhash.txt\\\"));\""
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
17
makefile
17
makefile
|
@ -17,7 +17,8 @@ STDXALLOC_DIR := stdx-allocator
|
||||||
SHELL:=/bin/bash
|
SHELL:=/bin/bash
|
||||||
|
|
||||||
githash:
|
githash:
|
||||||
git log -1 --format="%H" > githash.txt
|
@mkdir -p bin
|
||||||
|
git describe --tags > bin/githash.txt
|
||||||
|
|
||||||
report:
|
report:
|
||||||
dscanner --report src > dscanner-report.json
|
dscanner --report src > dscanner-report.json
|
||||||
|
@ -36,21 +37,21 @@ CLIENT_SRC := \
|
||||||
|
|
||||||
DMD_CLIENT_FLAGS := -Imsgpack-d/src\
|
DMD_CLIENT_FLAGS := -Imsgpack-d/src\
|
||||||
-Imsgpack-d/src\
|
-Imsgpack-d/src\
|
||||||
-J.\
|
-Jbin\
|
||||||
-inline\
|
-inline\
|
||||||
-O\
|
-O\
|
||||||
-wi\
|
-wi\
|
||||||
-ofbin/dcd-client
|
-ofbin/dcd-client
|
||||||
|
|
||||||
GDC_CLIENT_FLAGS := -Imsgpack-d/src\
|
GDC_CLIENT_FLAGS := -Imsgpack-d/src\
|
||||||
-J.\
|
-Jbin\
|
||||||
-O3\
|
-O3\
|
||||||
-frelease\
|
-frelease\
|
||||||
-obin/dcd-client
|
-obin/dcd-client
|
||||||
|
|
||||||
LDC_CLIENT_FLAGS := -Imsgpack-d/src\
|
LDC_CLIENT_FLAGS := -Imsgpack-d/src\
|
||||||
-Imsgpack-d/src\
|
-Imsgpack-d/src\
|
||||||
-J=.\
|
-J=bin\
|
||||||
-release\
|
-release\
|
||||||
-O5\
|
-O5\
|
||||||
-oq\
|
-oq\
|
||||||
|
@ -87,7 +88,7 @@ DMD_SERVER_FLAGS := -Icontainers/src\
|
||||||
-I${DPARSE_DIR}/src\
|
-I${DPARSE_DIR}/src\
|
||||||
-I${DSYMBOL_DIR}/src\
|
-I${DSYMBOL_DIR}/src\
|
||||||
-I${STDXALLOC_DIR}/source\
|
-I${STDXALLOC_DIR}/source\
|
||||||
-J.\
|
-Jbin\
|
||||||
-wi\
|
-wi\
|
||||||
-O\
|
-O\
|
||||||
-release\
|
-release\
|
||||||
|
@ -101,13 +102,13 @@ DEBUG_SERVER_FLAGS := -Icontainers/src\
|
||||||
-wi\
|
-wi\
|
||||||
-g\
|
-g\
|
||||||
-ofbin/dcd-server\
|
-ofbin/dcd-server\
|
||||||
-J.
|
-Jbin
|
||||||
|
|
||||||
GDC_SERVER_FLAGS := -Icontainers/src\
|
GDC_SERVER_FLAGS := -Icontainers/src\
|
||||||
-Imsgpack-d/src\
|
-Imsgpack-d/src\
|
||||||
-I${DPARSE_DIR}/src\
|
-I${DPARSE_DIR}/src\
|
||||||
-I${DSYMBOL_DIR}/src\
|
-I${DSYMBOL_DIR}/src\
|
||||||
-J.\
|
-Jbin\
|
||||||
-O3\
|
-O3\
|
||||||
-frelease\
|
-frelease\
|
||||||
-obin/dcd-server
|
-obin/dcd-server
|
||||||
|
@ -117,7 +118,7 @@ LDC_SERVER_FLAGS := -Icontainers/src\
|
||||||
-I${DPARSE_DIR}/src\
|
-I${DPARSE_DIR}/src\
|
||||||
-I${DSYMBOL_DIR}/src\
|
-I${DSYMBOL_DIR}/src\
|
||||||
-Isrc\
|
-Isrc\
|
||||||
-J=.\
|
-J=bin\
|
||||||
-O5\
|
-O5\
|
||||||
-release
|
-release
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ fi
|
||||||
archiveName="dcd-$VERSION-$OS-$ARCH_SUFFIX.zip"
|
archiveName="dcd-$VERSION-$OS-$ARCH_SUFFIX.zip"
|
||||||
echo "Building $archiveName"
|
echo "Building $archiveName"
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
|
git describe --tags > bin/githash.txt # no git installed under Wine
|
||||||
DC="$DIR/dmd2/windows/bin/dmd.exe" wine cmd /C build.bat
|
DC="$DIR/dmd2/windows/bin/dmd.exe" wine cmd /C build.bat
|
||||||
|
|
||||||
cd bin
|
cd bin
|
||||||
|
|
|
@ -92,12 +92,7 @@ int main(string[] args)
|
||||||
|
|
||||||
if (printVersion)
|
if (printVersion)
|
||||||
{
|
{
|
||||||
version (Windows)
|
writeln(DCD_VERSION);
|
||||||
writeln(DCD_VERSION);
|
|
||||||
else version(built_with_dub)
|
|
||||||
writeln(DCD_VERSION);
|
|
||||||
else
|
|
||||||
write(DCD_VERSION, " ", GIT_HASH);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,17 +18,20 @@
|
||||||
|
|
||||||
module dcd.common.dcd_version;
|
module dcd.common.dcd_version;
|
||||||
|
|
||||||
|
import std.string : strip;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Human-readable version number
|
* Human-readable version number
|
||||||
*/
|
*/
|
||||||
enum DCD_VERSION = "v0.9.8";
|
|
||||||
|
|
||||||
version (Windows) {}
|
version (built_with_dub)
|
||||||
else version (built_with_dub) {}
|
{
|
||||||
|
enum DCD_VERSION = import("dubhash.txt").strip;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Current build's Git commit hash
|
* Current build's Git commit hash
|
||||||
*/
|
*/
|
||||||
enum GIT_HASH = import("githash.txt");
|
enum DCD_VERSION = import("githash.txt").strip;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,12 +81,7 @@ int main(string[] args)
|
||||||
|
|
||||||
if (printVersion)
|
if (printVersion)
|
||||||
{
|
{
|
||||||
version (Windows)
|
writeln(DCD_VERSION);
|
||||||
writeln(DCD_VERSION);
|
|
||||||
else version (built_with_dub)
|
|
||||||
writeln(DCD_VERSION);
|
|
||||||
else
|
|
||||||
write(DCD_VERSION, " ", GIT_HASH);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue