mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-03-01 21:10:33 +00:00
[wip] first steps toward a Nim wrapper for github.com/catid/leopard
This commit is contained in:
parent
02727ba0dc
commit
9db836a9e8
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -7,7 +7,6 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
max-parallel: 20
|
max-parallel: 20
|
||||||
matrix:
|
matrix:
|
||||||
branch: [v1.4.6]
|
|
||||||
target:
|
target:
|
||||||
# Unit tests
|
# Unit tests
|
||||||
- os: linux
|
- os: linux
|
||||||
@ -35,7 +34,7 @@ jobs:
|
|||||||
- target:
|
- target:
|
||||||
os: windows
|
os: windows
|
||||||
builder: windows-2019
|
builder: windows-2019
|
||||||
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }} (${{ matrix.branch }})'
|
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}'
|
||||||
runs-on: ${{ matrix.builder }}
|
runs-on: ${{ matrix.builder }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout nim-dagger
|
- name: Checkout nim-dagger
|
||||||
@ -93,6 +92,7 @@ jobs:
|
|||||||
EOF
|
EOF
|
||||||
chmod 755 external/bin/gcc external/bin/g++
|
chmod 755 external/bin/gcc external/bin/g++
|
||||||
echo '${{ github.workspace }}/external/bin' >> $GITHUB_PATH
|
echo '${{ github.workspace }}/external/bin' >> $GITHUB_PATH
|
||||||
|
echo "LIBLEOPARD_CMAKE_FLAGS=-DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Restore MinGW-W64 (Windows) from cache
|
- name: Restore MinGW-W64 (Windows) from cache
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
|
61
Makefile
61
Makefile
@ -23,9 +23,12 @@ LINK_PCRE := 0
|
|||||||
all \
|
all \
|
||||||
deps \
|
deps \
|
||||||
update \
|
update \
|
||||||
|
leopard \
|
||||||
|
testAll \
|
||||||
test \
|
test \
|
||||||
clean \
|
libbacktrace \
|
||||||
libbacktrace
|
clean-leopard \
|
||||||
|
clean
|
||||||
|
|
||||||
ifeq ($(NIM_PARAMS),)
|
ifeq ($(NIM_PARAMS),)
|
||||||
# "variables.mk" was not included, so we update the submodules.
|
# "variables.mk" was not included, so we update the submodules.
|
||||||
@ -48,6 +51,16 @@ all: | test
|
|||||||
# must be included after the default target
|
# must be included after the default target
|
||||||
-include $(BUILD_SYSTEM_DIR)/makefiles/targets.mk
|
-include $(BUILD_SYSTEM_DIR)/makefiles/targets.mk
|
||||||
|
|
||||||
|
# detecting the os
|
||||||
|
ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10...
|
||||||
|
detected_OS := Windows
|
||||||
|
else ifeq ($(strip $(shell uname)),Darwin)
|
||||||
|
detected_OS := macOS
|
||||||
|
else
|
||||||
|
# e.g. Linux
|
||||||
|
detected_OS := $(strip $(shell uname))
|
||||||
|
endif
|
||||||
|
|
||||||
# "-d:release" implies "--stacktrace:off" and it cannot be added to config.nims
|
# "-d:release" implies "--stacktrace:off" and it cannot be added to config.nims
|
||||||
ifeq ($(USE_LIBBACKTRACE), 0)
|
ifeq ($(USE_LIBBACKTRACE), 0)
|
||||||
NIM_PARAMS := $(NIM_PARAMS) -d:debug -d:disable_libbacktrace
|
NIM_PARAMS := $(NIM_PARAMS) -d:debug -d:disable_libbacktrace
|
||||||
@ -55,7 +68,7 @@ else
|
|||||||
NIM_PARAMS := $(NIM_PARAMS) -d:release
|
NIM_PARAMS := $(NIM_PARAMS) -d:release
|
||||||
endif
|
endif
|
||||||
|
|
||||||
deps: | deps-common nat-libs dagger.nims
|
deps: | deps-common nat-libs dagger.nims leopard
|
||||||
ifneq ($(USE_LIBBACKTRACE), 0)
|
ifneq ($(USE_LIBBACKTRACE), 0)
|
||||||
deps: | libbacktrace
|
deps: | libbacktrace
|
||||||
endif
|
endif
|
||||||
@ -67,20 +80,37 @@ update: | update-common
|
|||||||
|
|
||||||
# a phony target, because teaching `make` how to do conditional recompilation of Nim projects is too complicated
|
# a phony target, because teaching `make` how to do conditional recompilation of Nim projects is too complicated
|
||||||
|
|
||||||
|
LIBLEOPARD := $(shell pwd)/vendor/leopard/build/liblibleopard.a
|
||||||
|
LIBLEOPARD_HEADER := $(shell pwd)/vendor/leopard/leopard.h
|
||||||
|
|
||||||
|
ifeq ($(detected_OS),Windows)
|
||||||
|
LIBLEOPARD_CMAKE_FLAGS ?= -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release
|
||||||
|
else
|
||||||
|
LIBLEOPARD_CMAKE_FLAGS ?= -DCMAKE_BUILD_TYPE=Release
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(detected_OS),Windows)
|
||||||
|
NIM_PARAMS += --passC:"-I$(shell cygpath -m $(shell dirname $(LIBLEOPARD_HEADER)))" --passL:"$(shell cygpath -m $(LIBLEOPARD))"
|
||||||
|
else
|
||||||
|
NIM_PARAMS += --passC:"-I$(shell dirname $(LIBLEOPARD_HEADER))" --passL:"$(LIBLEOPARD)"
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(detected_OS),macOS)
|
||||||
|
NIM_PARAMS += --passL:"-fopenmp"
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(LIBLEOPARD):
|
||||||
|
cd vendor/leopard && \
|
||||||
|
mkdir -p build && cd build && \
|
||||||
|
cmake .. $(LIBLEOPARD_CMAKE_FLAGS) && \
|
||||||
|
$(MAKE)
|
||||||
|
|
||||||
|
leopard: $(LIBLEOPARD)
|
||||||
|
|
||||||
testAll: | build deps
|
testAll: | build deps
|
||||||
echo -e $(BUILD_MSG) "build/$@" && \
|
echo -e $(BUILD_MSG) "build/$@" && \
|
||||||
$(ENV_SCRIPT) nim testAll $(NIM_PARAMS) dagger.nims
|
$(ENV_SCRIPT) nim testAll $(NIM_PARAMS) dagger.nims
|
||||||
|
|
||||||
# detecting the os
|
|
||||||
ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10...
|
|
||||||
detected_OS := Windows
|
|
||||||
else ifeq ($(strip $(shell uname)),Darwin)
|
|
||||||
detected_OS := macOS
|
|
||||||
else
|
|
||||||
# e.g. Linux
|
|
||||||
detected_OS := $(strip $(shell uname))
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Builds and run the test suite (Waku v1 + v2)
|
# Builds and run the test suite (Waku v1 + v2)
|
||||||
test: | testAll
|
test: | testAll
|
||||||
|
|
||||||
@ -92,8 +122,11 @@ dagger.nims:
|
|||||||
libbacktrace:
|
libbacktrace:
|
||||||
+ $(MAKE) -C vendor/nim-libbacktrace --no-print-directory BUILD_CXX_LIB=0
|
+ $(MAKE) -C vendor/nim-libbacktrace --no-print-directory BUILD_CXX_LIB=0
|
||||||
|
|
||||||
|
clean-leopard:
|
||||||
|
rm -rf $(shell dirname $(LIBLEOPARD))
|
||||||
|
|
||||||
# usual cleaning
|
# usual cleaning
|
||||||
clean: | clean-common
|
clean: | clean-common clean-leopard
|
||||||
rm -rf build
|
rm -rf build
|
||||||
ifneq ($(USE_LIBBACKTRACE), 0)
|
ifneq ($(USE_LIBBACKTRACE), 0)
|
||||||
+ $(MAKE) -C vendor/nim-libbacktrace clean $(HANDLE_OUTPUT)
|
+ $(MAKE) -C vendor/nim-libbacktrace clean $(HANDLE_OUTPUT)
|
||||||
|
5
dagger/leopard.nim
Normal file
5
dagger/leopard.nim
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
const header = "leopard.h"
|
||||||
|
|
||||||
|
{.pragma: leo, cdecl, header: header, importCpp.}
|
||||||
|
|
||||||
|
proc leo_init*(): cint {.leo.}
|
5
tests/dagger/testleopard.nim
Normal file
5
tests/dagger/testleopard.nim
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import pkg/dagger/leopard
|
||||||
|
|
||||||
|
let lin = leo_init()
|
||||||
|
|
||||||
|
echo "leo_init() return code: " & $lin
|
@ -4,5 +4,7 @@ import ./dagger/testasyncheapqueue
|
|||||||
import ./dagger/testchunking
|
import ./dagger/testchunking
|
||||||
import ./dagger/testmanifest
|
import ./dagger/testmanifest
|
||||||
import ./dagger/testnode
|
import ./dagger/testnode
|
||||||
|
import ./dagger/testleopard
|
||||||
|
|
||||||
|
|
||||||
{.warning[UnusedImport]: off.}
|
{.warning[UnusedImport]: off.}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user