Skip to content

Commit

Permalink
Merge pull request #21 from driftregion/0.7.0
Browse files Browse the repository at this point in the history
0.7.1
  • Loading branch information
driftregion authored Jan 21, 2024
2 parents b20e908 + 8f09148 commit 8eaa0de
Show file tree
Hide file tree
Showing 127 changed files with 8,099 additions and 5,559 deletions.
25 changes: 25 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
build --strip=never
build --incompatible_enable_cc_toolchain_resolution

build --extra_toolchains //toolchain:arm_linux_gcc
build --extra_toolchains //toolchain:arm_none_gcc
build --extra_toolchains //toolchain:ppc_gcc
build --extra_toolchains //toolchain:ppc64_gcc
build --extra_toolchains //toolchain:ppc64le_gcc
build --extra_toolchains //toolchain:x86_64_clang

build:arm_linux --platforms=//platforms:arm_linux
build:s32k --platforms=//platforms:s32k_evb
build:ppc --platforms=//platforms:ppc
build:ppc64 --platforms=//platforms:ppc64
build:ppc64le --platforms=//platforms:ppc64le
build:x86_64_clang --platforms=//platforms:x86_64_clang

test:arm_linux --run_under="qemu-arm -L /usr/arm-linux-gnueabihf/ "
test:ppc --run_under="qemu-ppc -L /usr/powerpc-linux-gnu/ "
test:ppc64 --run_under="qemu-ppc64 -L /usr/powerpc64-linux-gnu/ "
test:ppc64le --run_under="qemu-ppc64le -L /usr/powerpc64le-linux-gnu/ "


# parallel tests break on a single vcan interface
test: --local_test_jobs=1 --test_output=all
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: unit tests

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v3

- name: lint
run: CHECK_FORMAT=1 ./run_clang_format.sh
continue-on-error: true

- name: run unit tests
run: bazel test //test:all --test_tag_filters=-vcan


25 changes: 25 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: release

on:
push:
tags: [ "v*" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v3

- name: build release
run: bazel build //:release

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
run: >-
gh release create ${{ github.ref_name }}
"bazel-bin/iso14229.zip#iso14229.zip"
--generate-notes
--title "${{ github.ref_name }}"
18 changes: 0 additions & 18 deletions .github/workflows/runtests.yml

This file was deleted.

13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
bazel-*
bazel-out/k8-fastbuild/bin
.rsync-filter
test_iso14229
client
Expand All @@ -7,4 +8,14 @@ corpus
*.profdata
*.profraw
.gdb_history
fuzzer
fuzzer
*.o
.vscode
**/*.cache
**/build
**/sdkconfig*
release/
examples/**/iso14229.c
examples/**/iso14229.h
*.pem
*.der
3 changes: 0 additions & 3 deletions .tests.gdbinit

This file was deleted.

2 changes: 2 additions & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Nick James Kirkby <iso14229dev@gmail.com>
Mark Corbin <mcorbin@lunarenergy.com>
74 changes: 38 additions & 36 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,55 +1,57 @@
load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands")
package(default_visibility = ["//visibility:public"])

filegroup(
name = "srcs",
srcs = [
"iso14229.c",
"iso14229.h",
"iso14229serverbufferedwriter.h",
],
)

cc_test(
name="test",
srcs=[
":srcs",
"test_iso14229.c",
],
copts=[
"-Wall",
"-Wextra",
"-Wno-missing-field-initializers",
"-Werror",
"-Wno-unused-parameter",
],
defines=[
"UDS_TP=UDS_TP_CUSTOM",
"UDS_CUSTOM_MILLIS",
cc_library(
name="iso14229",
srcs = [
"iso14229.c",
"iso14229.h",
],
)

cc_test(
name = "test_server_bufferedwriter",
srcs = [
"udsserverbufferedwriter.h",
"test_udsserverbufferedwriter.c",
],
cc_library(
name="iso14229_2",
srcs=glob(["src/**/*.c", "src/**/*.h"]),
copts=['-Isrc'],
)

refresh_compile_commands(
name = "s32k_refresh_compile_commands",
targets = {
"//examples/s32k144/...": "--config=s32k",
}
)

filegroup(
name="isotp_c_srcs",
srcs=[
"isotp-c/isotp.c",
"isotp-c/isotp.h",
"isotp-c/isotp_config.h",
"isotp-c/isotp_defines.h",
"isotp-c/isotp_user.h",
],
py_binary(
name="amalgamate",
srcs=["amalgamate.py"],
)

cc_library(
name="isotp_c",
srcs=[":isotp_c_srcs"],
copts=["-Wno-unused-parameter"],
genrule(
name="amalgamated",
srcs=glob(["src/**/*.c", "src/**/*.h"]),
outs=["iso14229.c", "iso14229.h"],
cmd="$(location //:amalgamate) --out_c $(location //:iso14229.c) --out_h $(location //:iso14229.h) $(SRCS)",
tools=["//:amalgamate"],
)

genrule(
name="release",
srcs=[
"iso14229.c",
"iso14229.h",
"README.md",
"LICENSE",
"AUTHORS.txt",
],
outs = ["iso14229.zip"],
cmd = "mkdir iso14229 && cp -L $(SRCS) iso14229/ && zip -r $(OUTS) iso14229",
)
53 changes: 14 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,45 +1,20 @@
ifeq "$(TP)" "ISOTP_C"
SRCS += isotp-c/isotp.c examples/isotp-c_on_socketcan.c
CFLAGS += -DUDS_TP=UDS_TP_ISOTP_C
endif
all: iso14229.c iso14229.h
mkdir -p release
cp iso14229.c iso14229.h release/

cxx: CFLAGS+=-DUDS_TP=UDS_TP_CUSTOM
cxx: Makefile iso14229.c iso14229.h
$(CXX) iso14229.c $(CFLAGS) -c

unit_test: CFLAGS+=-DUDS_TP=UDS_TP_CUSTOM -DUDS_CUSTOM_MILLIS
unit_test: Makefile iso14229.h iso14229.c test_iso14229.c
$(CC) iso14229.c test_iso14229.c $(CFLAGS) $(LDFLAGS) -o test_iso14229
$(RUN) ./test_iso14229

client: CFLAGS+=-g -DUDS_DBG_PRINT=printf
client: examples/client.c examples/uds_params.h iso14229.h iso14229.c Makefile $(SRCS)
$(CC) iso14229.c $(SRCS) $< $(CFLAGS) -o $@

server: CFLAGS+=-g -DUDS_DBG_PRINT=printf
server: examples/server.c examples/uds_params.h iso14229.h iso14229.c Makefile $(SRCS)
$(CC) iso14229.c $(SRCS) $< $(CFLAGS) -o $@

test_examples: test_examples.py
$(RUN) ./test_examples.py

uds_prefix: CFLAGS+=-DUDS_TP=UDS_TP_CUSTOM -DUDS_CUSTOM_MILLIS
uds_prefix: iso14229.c iso14229.h
$(CC) iso14229.c $(CFLAGS) -c -o /tmp/x.o && nm /tmp/x.o | grep ' T ' | grep -v 'UDS' ; test $$? = 1
clean:
rm -rf isotp_c_wrapped.c isotp_c_wrapped.h iso14229.c iso14229.h release/

test_qemu: Makefile iso14229.h iso14229.c test_iso14229.c test_qemu.py
$(RUN) ./test_qemu.py
isotp_c_wrapped.c: $(shell find src/tp/isotp-c -name '*.c')
echo '#if defined(UDS_ISOTP_C)' >> $@ ; for f in $^; do cat $$f >> $@; done ; echo '#endif' >> $@

test: cxx unit_test test_examples uds_prefix test_qemu
isotp_c_wrapped.h: $(shell find src/tp/isotp-c -name '*.h')
echo '#if defined(UDS_ISOTP_C)' >> $@ ; for f in $^; do cat $$f >> $@; done ; echo '#endif' >> $@

fuzz: CC=clang-14
fuzz: ASAN = -fsanitize=fuzzer,signed-integer-overflow,address,undefined -fprofile-instr-generate -fcoverage-mapping
fuzz: OPTS = -g -DUDS_TP=UDS_TP_CUSTOM -DUDS_CUSTOM_MILLIS
fuzz: iso14229.c iso14229.h fuzz_server.c Makefile
$(CC) $(OPTS) $(WARN) $(INCS) $(TFLAGS) $(ASAN) fuzz_server.c iso14229.c -o fuzzer
$(RUN) ./fuzzer corpus
iso14229.c: $(shell find src -name '*.c') isotp_c_wrapped.c
echo '#include "iso14229.h"' > $@ ; for f in $^; do echo; echo '#ifdef UDS_LINES'; echo "#line 1 \"$$f\""; echo '#endif'; cat $$f | sed -e 's,#include ".*,,'; done >> $@

clean:
rm -f client server test_iso14229 iso14229.o
iso14229.h: $(shell find src -name '*.h') isotp_c_wrapped.h
( echo '#ifndef ISO14229_H'; echo '#define ISO14229_H'; echo; echo '#ifdef __cplusplus'; echo 'extern "C" {'; echo '#endif'; cat src/version.h src/sys.h src/sys_arduino.h src/sys_unix.h src/sys_win32.h src/sys_esp32.h src/config.h src/util.h src/tp.h src/uds.h src/client.h src/server.h isotp_c_wrapped.h src/tp/*.h |sed -e 's,#include ".*,,' -e 's,^#pragma once,,' ; echo '#endif'; echo '#ifdef __cplusplus'; echo '}'; echo '#endif';) > $@

.phony: clean test_examples
.phony: clean
Loading

0 comments on commit 8eaa0de

Please sign in to comment.