On 09/10/18 15:11, Stuart Henderson wrote:
On 2018/05/01 00:10, Brian Callahan wrote:
Hi ports --
Attached is a new port, devel/samurai. Samurai is a ninja-compatible build
tool written in C.
---
pkg/DESCR:
samurai is a ninja-compatible build tool written in C99 with a focus on
simplicity, speed, and portability.
samurai implements the ninja build language through version 1.8.2. It
uses the same format for .ninja_log and .ninja_deps as ninja, currently
version 5 and 3 respectively.
It is largely feature-complete and supports most of the same options as
ninja.
---
Samurai can be used as a drop-in replacement for Ninja with CMake. Notably,
samurai does not do the random build order thing that ninja does, but
samurai has built everything I have thrown at it without issue. To make
testing easy, I'm including a patch for cmake.port.mk -- then all you have
to do is go to a port that uses cmake and add USE_SAMURAI=Yes to the port
Makefile. Note that I am not seriously proposing to commit the cmake.port.mk
change, unless people think that it'd be useful to have a backup to ninja.
OK?
~Brian
Here's an updated tgz for samurai 0.4, which has a proper tarball,
changelog is as follows:
New features
- Add support for --version option for compatibility with existing
higher-level build tools like cmake and meson.
- Now builds on macOS, which does not support the POSIX O_DIRECTORY or
st_mtim member of struct stat.
- Better messages from -d explain for missing/invalid dependencies or
build log entry.
Bug fixes
- Generator action with no entry in build log was incorrectly considered
dirty, causing a re-run of the ninja generation (cmake, meson, etc) on
the first build.
- Avoid large stack allocations during .ninja_deps processing and when
user specified a large maximum number of jobs.
- Fix -k maxfail handling when multiple jobs fail at the same time
(regression in 0.3).
Cleanups
- Prefer C99 functions/types over POSIX in some cases.
- Store modification time internally as int64_t for compatibility with
future ninja release and to avoid struct timespec requirement.
- Remove redundant call to stat when recording dependencies.
- Mark lexing keyword table as const to move to read-only section of
executable.
And here's a simpler cmake.port.mk diff using "USE_NINJA=samurai"
rather than a separate variable (though I am rather tempted to just
switch the cmake module to using samurai if it works in bulk build,
diffable build logs is a BIG improvement).
Index: cmake.port.mk
===================================================================
RCS file: /cvs/ports/devel/cmake/cmake.port.mk,v
retrieving revision 1.63
diff -u -p -r1.63 cmake.port.mk
--- cmake.port.mk 26 Jan 2018 13:11:14 -0000 1.63
+++ cmake.port.mk 10 Sep 2018 19:03:50 -0000
@@ -16,9 +16,16 @@ USE_NINJA = No
.if ${USE_NINJA:L} == "yes"
BUILD_DEPENDS += devel/ninja>=1.5.1
-_MODCMAKE_GEN = Ninja
NINJA ?= ninja
NINJA_FLAGS ?= -v -j ${MAKE_JOBS}
+.elif ${USE_NINJA:L} == "samurai"
+BUILD_DEPENDS += devel/samurai
+NINJA ?= samu
+NINJA_FLAGS ?= -v -j ${MAKE_JOBS}
+.endif
+
+.if ${USE_NINJA:L} == "yes" || ${USE_NINJA:L} == "samurai"
+_MODCMAKE_GEN = Ninja
MODCMAKE_BUILD_TARGET = cd ${WRKBUILD} && exec ${SETENV} ${MAKE_ENV} \
${NINJA} ${NINJA_FLAGS} ${ALL_TARGET}
MODCMAKE_INSTALL_TARGET = cd ${WRKBUILD} && exec ${SETENV} ${MAKE_ENV} \
Now that I think about it, we might need this version of a cmake.port.mk
diff, otherwise cmake will use Ninja for generating and Samurai for
building. Samurai can do both though.
~Brian
# $OpenBSD: cmake.port.mk,v 1.63 2018/01/26 13:11:14 jca Exp $
BUILD_DEPENDS+= devel/cmake
.for _n _v in ${SHARED_LIBS}
CONFIGURE_ENV+=LIB${_n}_VERSION=${_v}
MAKE_ENV+=LIB${_n}_VERSION=${_v}
.endfor
USE_NINJA ?= Yes
# XXX: Ninja is broken on m88k
.if ${MACHINE_ARCH} == "m88k"
USE_NINJA = No
.endif
.if ${USE_NINJA:L} == "yes"
BUILD_DEPENDS += devel/ninja>=1.5.1
NINJA ?= ninja
NINJA_FLAGS ?= -v -j ${MAKE_JOBS}
.elif ${USE_NINJA:L} == "samurai"
BUILD_DEPENDS += devel/samurai
NINJA ?= samu
NINJA_FLAGS ?= -v -j ${MAKE_JOBS}
CONFIGURE_ARGS += -DCMAKE_MAKE_PROGRAM=${NINJA}
.endif
.if ${USE_NINJA:L} == "yes" || ${USE_NINJA:L} == "samurai"
_MODCMAKE_GEN = Ninja
MODCMAKE_BUILD_TARGET = cd ${WRKBUILD} && exec ${SETENV} ${MAKE_ENV} \
${NINJA} ${NINJA_FLAGS} ${ALL_TARGET}
MODCMAKE_INSTALL_TARGET = cd ${WRKBUILD} && exec ${SETENV} ${MAKE_ENV} \
${FAKE_SETUP} ${NINJA} ${NINJA_FLAGS} ${FAKE_TARGET}
MODCMAKE_TEST_TARGET = cd ${WRKBUILD} && exec ${SETENV} ${ALL_TEST_ENV} \
${NINJA} ${NINJA_FLAGS} ${TEST_FLAGS} ${TEST_TARGET}
.if !target(do-build)
do-build:
@${MODCMAKE_BUILD_TARGET}
.endif
.if !target(do-install)
do-install:
@${MODCMAKE_INSTALL_TARGET}
.endif
.if !target(do-test)
do-test:
@${MODCMAKE_TEST_TARGET}
.endif
.else
_MODCMAKE_GEN = "Unix Makefiles"
# XXX cmake include parser is bogus
DPB_PROPERTIES += nojunk
.endif
CONFIGURE_ENV += MODJAVA_VER=${MODJAVA_VER} \
MODLUA_VERSION=${MODLUA_VERSION} \
MODLUA_BIN=${MODLUA_BIN} \
MODLUA_INCL_DIR=${MODLUA_INCL_DIR} \
MODPY_VERSION=${MODPY_VERSION} \
MODPY_BIN=${MODPY_BIN} \
MODPY_INCDIR=${MODPY_INCDIR} \
MODPY_LIBDIR=${MODPY_LIBDIR} \
MODRUBY_REV=${MODRUBY_REV} \
MODTCL_VERSION=${MODTCL_VERSION} \
MODTK_VERSION=${MODTK_VERSION} \
MODTCL_INCDIR=${MODTCL_INCDIR} \
MODTK_INCDIR=${MODTK_INCDIR} \
MODTCL_LIBDIR=${MODTCL_LIBDIR} \
MODTK_LIBDIR=${MODTK_LIBDIR} \
MODTCL_LIB=${MODTCL_LIB} \
MODTK_LIB=${MODTK_LIB}
MODCMAKE_DEBUG ?= No
.if empty(CONFIGURE_STYLE)
CONFIGURE_STYLE= cmake
.endif
MODCMAKE_configure= cd ${WRKBUILD} && ${SETENV} \
CC="${CC}" CFLAGS="${CFLAGS}" \
CXX="${CXX}" CXXFLAGS="${CXXFLAGS}" \
${CONFIGURE_ENV} ${LOCALBASE}/bin/cmake \
-DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY:Bool=True \
-G ${_MODCMAKE_GEN} ${CONFIGURE_ARGS} ${WRKSRC}
.if !defined(CONFIGURE_ARGS) || ! ${CONFIGURE_ARGS:M*CMAKE_BUILD_TYPE*}
. if ${MODCMAKE_DEBUG:L} == "yes"
CONFIGURE_ARGS += -DCMAKE_BUILD_TYPE:String=Debug
MODCMAKE_BUILD_SUFFIX = -debug.cmake
. else
CONFIGURE_ARGS += -DCMAKE_BUILD_TYPE:String=Release
MODCMAKE_BUILD_SUFFIX = -release.cmake
. endif
.endif
SUBST_VARS += MODCMAKE_BUILD_SUFFIX
SEPARATE_BUILD ?= Yes
TEST_TARGET ?= test
MODCMAKE_WANTCOLOR ?= No
MODCMAKE_VERBOSE ?= Yes
.if ${MODCMAKE_WANTCOLOR:L} == "yes" && defined(TERM)
MAKE_ENV += TERM=${TERM}
.endif
.if ${MODCMAKE_VERBOSE:L} == "yes"
MAKE_ENV += VERBOSE=1
.endif