`make` inits submodule & builds blst (#250)

* Make inits submodule & builds blst

* Update the README

* Clean up C workflow
This commit is contained in:
Justin Traglia 2023-03-28 08:26:51 -05:00 committed by GitHub
parent 8de0aa54ce
commit 3c6b9346b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 44 deletions

View File

@ -15,33 +15,24 @@ jobs:
with: with:
submodules: recursive submodules: recursive
- name: Check formatting - name: Check formatting
working-directory: src
run: | run: |
cd src
make format make format
git diff --exit-code git diff --exit-code
- name: Build - name: Build/Test
run: | working-directory: src
cd src run: make
make blst
make
- name: Test
run: |
cd src
make test
- name: Clang Sanitizers - name: Clang Sanitizers
run: | working-directory: src
cd src run: make sanitize
make sanitize
- name: Clang Static Analyzer - name: Clang Static Analyzer
run: | working-directory: src
cd src run: make analyze
make analyze
- name: Install LLVM - name: Install LLVM
uses: egor-tensin/setup-clang@v1 uses: egor-tensin/setup-clang@v1
- name: Generate coverage report - name: Generate coverage report
run: | working-directory: src
cd src run: make coverage
make coverage
- name: Save coverage report - name: Save coverage report
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:

View File

@ -39,22 +39,21 @@ There are bindings for the following languages:
## Installation ## Installation
Initialize the blst submodule: ### Prerequisites
The following must be installed:
* `git`
* `make`
* `clang`
### Build & test
To build `c_kzg_4844.o`, the object file that the bindings use, run `make` in
the `src` directory. This will ensure the `blst` submodule has been initialized,
build `blst`, build `c_kzg_4844`, and run the tests. From the project root, run
this:
``` ```
git submodule update --init cd src && make
```
Build the blst library:
```
cd src
make blst
```
Build/test the C-KZG-4844 library:
```
cd src
make
``` ```

View File

@ -16,7 +16,9 @@ CFLAGS += -DFIELD_ELEMENTS_PER_BLOB=$(FIELD_ELEMENTS_PER_BLOB)
# Disable optimizations. Put after $CFLAGS. # Disable optimizations. Put after $CFLAGS.
NO_OPTIMIZE = -O0 NO_OPTIMIZE = -O0
# Compiler flags for including blst. Put after source files. # Settings for blst.
BLST_LIBRARY = ../lib/libblst.a
BLST_BUILDSCRIPT = ../blst/build.sh
BLST = -L../lib -lblst BLST = -L../lib -lblst
# Compiler flags for generating coverage data. # Compiler flags for generating coverage data.
@ -44,7 +46,19 @@ endif
all: c_kzg_4844.o test all: c_kzg_4844.o test
%.o: %.c $(BLST_BUILDSCRIPT):
@git submodule update --init
$(BLST_LIBRARY): $(BLST_BUILDSCRIPT)
@cd $(dir $(BLST_BUILDSCRIPT)) && \
./$(notdir $(BLST_BUILDSCRIPT)) && \
cp $(notdir $(BLST_LIBRARY)) ../lib && \
cp bindings/*.h ../inc
.PHONY: blst
blst: $(BLST_LIBRARY)
c_kzg_4844.o: c_kzg_4844.c $(BLST_LIBRARY)
@$(CC) $(CFLAGS) -c $< @$(CC) $(CFLAGS) -c $<
test_c_kzg_4844: test_c_kzg_4844.c c_kzg_4844.c test_c_kzg_4844: test_c_kzg_4844.c c_kzg_4844.c
@ -56,13 +70,6 @@ test_c_kzg_4844_cov: test_c_kzg_4844.c c_kzg_4844.c
test_c_kzg_4844_prof: test_c_kzg_4844.c c_kzg_4844.c test_c_kzg_4844_prof: test_c_kzg_4844.c c_kzg_4844.c
@$(CC) $(CFLAGS) $(NO_OPTIMIZE) $(PROFILE) -o $@ $< $(BLST) $(PROFILER) @$(CC) $(CFLAGS) $(NO_OPTIMIZE) $(PROFILE) -o $@ $< $(BLST) $(PROFILER)
.PHONY: blst
blst:
@cd ../blst && \
./build.sh && \
cp libblst.a ../lib && \
cp bindings/*.h ../inc
.PHONY: test .PHONY: test
test: test_c_kzg_4844 test: test_c_kzg_4844
@./test_c_kzg_4844 @./test_c_kzg_4844