77 lines
1.7 KiB
Makefile
Raw Normal View History

2023-03-30 16:34:55 -05:00
# For a less verbose yarn
2023-03-28 11:01:07 -05:00
YARN = yarn --silent
2022-11-04 12:06:06 -07:00
2023-03-28 11:01:07 -05:00
.PHONY: all
all: format build test bundle
# Cleans native dependency, bindings and typescript artifacts
.PHONY: clean
clean:
2023-03-28 11:01:07 -05:00
@rm -rf build
@rm -rf dist
@rm -rf deps
@rm -f *.node
@rm -f *.a
@rm -f *.o
@rm -rf ref-tests
# Cleans typescript dependencies
.PHONY: clean-install
clean-install:
@rm -rf node_modules
# Installs typescript dependencies
.PHONY: install
install:
@$(YARN) install --ignore-scripts
# Cleans and rebuilds native dependencies, bindings and typescript wrapper
.PHONY: build
build: install clean
@# Prepare the dependencies directory
@mkdir -p deps/c-kzg
@cp -r ../../blst deps
@cp ../../src/c_kzg_4844.c deps/c-kzg
@cp ../../src/c_kzg_4844.h deps/c-kzg
@# Build the bindings
@$(YARN) node-gyp --loglevel=warn configure
@$(YARN) node-gyp --loglevel=warn build
# Bundle the distribution, also helpful for cross compatibility checks
.PHONY: bundle
bundle: build
@mkdir dist
2023-03-28 11:01:07 -05:00
@mv deps dist
@cp -r lib dist/lib
2023-03-28 11:01:07 -05:00
@cp -r src dist/src
@cp README.md dist/README.md
@cp package.json dist/package.json
@cp binding.gyp dist/binding.gyp
# Run unit tests and ref-tests
.PHONY: test
test: install
@echo
@$(YARN) jest
# Lint js/ts code
.PHONY: format
format: install
@$(YARN) eslint --quiet --color --ext .ts lib/ test/
@clang-format -i src/kzg.cxx
2023-03-28 11:01:07 -05:00
# Publish package to npm (requires an auth token)
.PHONY: publish
2023-03-30 12:05:22 -04:00
publish: build bundle
2023-03-28 11:01:07 -05:00
@cd dist
@npm publish
# Run ref-tests in linux environment for cross-compatability check
.PHONY: linux-test
2023-05-09 08:40:36 -05:00
linux-test: bundle
2023-03-30 16:34:55 -05:00
@# Docker cannot copy from outside this dir
2023-03-28 11:01:07 -05:00
@cp -r ../../tests ref-tests
@docker build -t "linux-test" .
@docker logs --follow `docker run -d linux-test`
@rm -rf ref-tests