Skip to content

Commit

Permalink
Merge pull request #35 from iyourshaw/update-j2735-to-2024
Browse files Browse the repository at this point in the history
Update j2735 version to 2024
  • Loading branch information
payneBrandon authored Dec 11, 2024
2 parents 6a0c8d6 + 288f5f8 commit 73ca21f
Show file tree
Hide file tree
Showing 25 changed files with 1,802 additions and 54 deletions.
25 changes: 14 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# === BUILDER IMAGE ===
FROM alpine:3.12 as builder
FROM alpine:3.18 as builder
USER root
WORKDIR /asn1_codec
VOLUME ["/asn1_codec_share"]
Expand All @@ -10,21 +10,24 @@ RUN apk add --upgrade --no-cache --virtual .build-deps \
g++ \
make \
bash \
automake \
libtool \
autoconf \
librdkafka \
librdkafka-dev \
flex \
bison
librdkafka-dev

# Dependencies that are not needed if asn1c is not installed in the build container:
# libtool
# automake
# autoconf
# bison
# flex

# Install pugixml
ADD ./pugixml /asn1_codec/pugixml
RUN cd /asn1_codec/pugixml && mkdir -p build && cd build && cmake .. && make && make install

# Build and install asn1c submodule
ADD ./usdot-asn1c /asn1_codec/asn1c
RUN cd asn1c && test -f configure || autoreconf -iv && ./configure && make && make install
# The codec C files are pre-generated manually so it isn't necessary to build asn1c in the container
# # Build and install asn1c submodule
# ADD ./usdot-asn1c /asn1_codec/asn1c
# RUN cd asn1c && test -f configure || autoreconf -iv && ./configure && make && make install

# Make generated files available to the build & compile example
RUN export LD_LIBRARY_PATH=/usr/local/lib
Expand Down Expand Up @@ -59,7 +62,7 @@ RUN echo "export CC=gcc" >> ~/.bashrc
RUN mkdir -p /build && cd /build && cmake /asn1_codec && make

# === RUNTIME IMAGE ===
FROM alpine:3.12
FROM alpine:3.18
USER root
WORKDIR /asn1_codec
VOLUME ["/asn1_codec_share"]
Expand Down
89 changes: 89 additions & 0 deletions Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# === BUILDER IMAGE ===
FROM alpine:3.18 as builder
USER root
WORKDIR /asn1_codec
VOLUME ["/asn1_codec_share"]

# add build dependencies
RUN apk add --upgrade --no-cache --virtual .build-deps \
cmake \
g++ \
make \
bash \
librdkafka \
librdkafka-dev

# Dependencies that are not needed if asn1c is not installed in the build container:
# libtool
# automake
# autoconf
# bison
# flex

# Install pugixml
ADD ./pugixml /asn1_codec/pugixml
RUN cd /asn1_codec/pugixml && mkdir -p build && cd build && cmake .. && make && make install

# The codec C files are pre-generated manually so it isn't necessary to build asn1c in the container
# # Build and install asn1c submodule
# ADD ./usdot-asn1c /asn1_codec/asn1c
# RUN cd asn1c && test -f configure || autoreconf -iv && ./configure && make && make install

# Make generated files available to the build & compile example
RUN export LD_LIBRARY_PATH=/usr/local/lib
ADD ./asn1c_combined /asn1_codec/asn1c_combined
RUN cd /asn1_codec/asn1c_combined && bash doIt.sh



# Remove any lingering .asn files
RUN rm -rf /asn1c_codec/asn1c_combined/j2735-asn-files
RUN rm -rf /asn1c_codec/asn1c_combined/semi-asn-files
RUN rm -rf /asn1c_codec/asn1c_combined/scms-asn-files

# Remove duplicate files
RUN rm -rf /asn1c_codec/asn1c_combined/generated-files

# add the source and build files
ADD CMakeLists.txt /asn1_codec
ADD ./config /asn1_codec/config
ADD ./include /asn1_codec/include
ADD ./src /asn1_codec/src
ADD ./kafka-test /asn1_codec/kafka-test
ADD ./unit-test-data /asn1_codec/unit-test-data
ADD ./data /asn1_codec/data
ADD ./run_acm.sh /asn1_codec
ADD ./data /asn1_codec/data

RUN echo "export LD_LIBRARY_PATH=/usr/local/lib" >> ~/.profile
RUN echo "export LD_LIBRARY_PATH=/usr/local/lib" >> ~/.bashrc
RUN echo "export CC=gcc" >> ~/.profile
RUN echo "export CC=gcc" >> ~/.bashrc

# Build acm.
RUN mkdir -p /build && cd /build && cmake /asn1_codec && make




# === RUNTIME IMAGE ===
FROM alpine:3.18
USER root
WORKDIR /asn1_codec
VOLUME ["/asn1_codec_share"]

# add runtime dependencies
RUN apk add --upgrade --no-cache \
bash \
librdkafka \
librdkafka-dev

# copy the built files from the builder
COPY --from=builder /asn1_codec /asn1_codec
COPY --from=builder /build /build

# Add test data. This changes frequently so keep it low in the file.
ADD ./docker-test /asn1_codec/docker-test

# Keep the container running but don't start up the app
CMD ["tail", "-f", "/dev/null"]
25 changes: 14 additions & 11 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# === BUILDER IMAGE ===
FROM alpine:3.12 as builder
FROM alpine:3.18 as builder
USER root
WORKDIR /asn1_codec
VOLUME ["/asn1_codec_share"]
Expand All @@ -10,21 +10,24 @@ RUN apk add --upgrade --no-cache --virtual .build-deps \
g++ \
make \
bash \
automake \
libtool \
autoconf \
librdkafka \
librdkafka-dev \
flex \
bison
librdkafka-dev

# Dependencies that are not needed if asn1c is not installed in the build container:
# libtool
# automake
# autoconf
# bison
# flex

# Install pugixml
ADD ./pugixml /asn1_codec/pugixml
RUN cd /asn1_codec/pugixml && mkdir -p build && cd build && cmake .. && make && make install

# Build and install asn1c submodule
ADD ./usdot-asn1c /asn1_codec/asn1c
RUN cd asn1c && test -f configure || autoreconf -iv && ./configure && make && make install
# The codec C files are pre-generated manually so it isn't necessary to build asn1c in the container
# # Build and install asn1c submodule
# ADD ./usdot-asn1c /asn1_codec/asn1c
# RUN cd asn1c && test -f configure || autoreconf -iv && ./configure && make && make install

# Make generated files available to the build & compile example
RUN export LD_LIBRARY_PATH=/usr/local/lib
Expand Down Expand Up @@ -58,7 +61,7 @@ RUN echo "export CC=gcc" >> ~/.bashrc
RUN mkdir -p /build && cd /build && cmake /asn1_codec && make

# === RUNTIME IMAGE ===
FROM alpine:3.12
FROM alpine:3.18
USER root
WORKDIR /asn1_codec
VOLUME ["/asn1_codec_share"]
Expand Down
25 changes: 14 additions & 11 deletions Dockerfile.standalone
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# === BUILDER IMAGE ===
FROM alpine:3.12 as builder
FROM alpine:3.18 as builder
USER root
WORKDIR /asn1_codec

Expand All @@ -9,21 +9,24 @@ RUN apk add --upgrade --no-cache --virtual .build-deps \
g++ \
make \
bash \
automake \
libtool \
autoconf \
librdkafka \
librdkafka-dev \
flex \
bison
librdkafka-dev

# Dependencies that are not needed if asn1c is not installed in the build container:
# libtool
# automake
# autoconf
# bison
# flex

# Install pugixml
ADD ./pugixml /asn1_codec/pugixml
RUN cd /asn1_codec/pugixml && mkdir -p build && cd build && cmake .. && make && make install

# Build and install asn1c submodule
ADD ./usdot-asn1c /asn1_codec/asn1c
RUN cd asn1c && test -f configure || autoreconf -iv && ./configure && make && make install
# The codec C files are pre-generated manually so it isn't necessary to build asn1c in the container
# # Build and install asn1c submodule
# ADD ./usdot-asn1c /asn1_codec/asn1c
# RUN cd asn1c && test -f configure || autoreconf -iv && ./configure && make && make install

# Make generated files available to the build & compile example
RUN export LD_LIBRARY_PATH=/usr/local/lib
Expand Down Expand Up @@ -52,7 +55,7 @@ ADD ./data /asn1_codec/data
RUN mkdir -p /build && cd /build && cmake /asn1_codec && make

# === RUNTIME IMAGE ===
FROM alpine:3.12
FROM alpine:3.18
USER root
WORKDIR /asn1_codec

Expand Down
25 changes: 14 additions & 11 deletions Dockerfile.testing
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# === BUILDER IMAGE ===
FROM alpine:3.12 as builder
FROM alpine:3.18 as builder
USER root
WORKDIR /asn1_codec
VOLUME ["/asn1_codec_share"]
Expand All @@ -10,21 +10,24 @@ RUN apk add --upgrade --no-cache --virtual .build-deps \
g++ \
make \
bash \
automake \
libtool \
autoconf \
librdkafka \
librdkafka-dev \
flex \
bison
librdkafka-dev

# Dependencies that are not needed if asn1c is not installed in the build container:
# libtool
# automake
# autoconf
# bison
# flex

# Install pugixml
ADD ./pugixml /asn1_codec/pugixml
RUN cd /asn1_codec/pugixml && mkdir -p build && cd build && cmake .. && make && make install

# Build and install asn1c submodule
ADD ./usdot-asn1c /asn1_codec/asn1c
RUN cd asn1c && test -f configure || autoreconf -iv && ./configure && make && make install
# The codec C files are pre-generated manually so it isn't necessary to build asn1c in the container
# # Build and install asn1c submodule
# ADD ./usdot-asn1c /asn1_codec/asn1c
# RUN cd asn1c && test -f configure || autoreconf -iv && ./configure && make && make install

# Make generated files available to the build & compile example
RUN export LD_LIBRARY_PATH=/usr/local/lib
Expand Down Expand Up @@ -60,7 +63,7 @@ RUN echo "export CC=gcc" >> ~/.bashrc
RUN mkdir -p /build && cd /build && cmake /asn1_codec && make

# === RUNTIME IMAGE ===
FROM alpine:3.12
FROM alpine:3.18
USER root
WORKDIR /asn1_codec
VOLUME ["/asn1_codec_share"]
Expand Down
18 changes: 17 additions & 1 deletion asn1c_combined/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ This script expects the necessary files to have already been generated by the `g
The necessary files can be generated using the `generate-files.sh` script. This script will reference the necessary ASN.1 files from the `j2735-asn-files` directory from the specified year and generate the C code in the `generated-files` directory.

### Installing asn1c

#### Prerequisites
For a WSL Ubuntu environment, install the `asn1c` prerequisites as follows:

```bash
sudo apt install build-essential automake autoconf libtool-bin bison flex
```

#### Install
The `generate-files.sh` script requires the `asn1c` compiler to be installed. The `asn1c` compiler can be installed in WSL using the following commands:

```bash
Expand All @@ -21,7 +30,9 @@ sudo make install
### J2735 ASN Files
The 'j2735-asn-files' subdirectory should contain the ASN.1 files for the J2735 standard. These are organized by year.

The `generate-files.sh` script will reference the necessary files from the `j2735-asn-files` directory when generating the C code.
Place the ASN files in the appropriate subdirectory for the year. For example, for 2024, place the ASN files in the `j2735-asn-files/2024` subdirectory.

The `generate-files.sh` script will reference the necessary files from the `j2735-asn-files/$year` directory when generating the C code.

#### Obtaining the J2735 ASN Files
Redistribution of the ASN files is not permitted, so they are not included in this repository. You must obtain them from SAE and place them in the `j2735-asn-files` directory under the appropriate year subdirectory.
Expand All @@ -32,6 +43,11 @@ A table of the ASN files for each year is provided below.
| ---- | ----------- |
| 2016 | https://www.sae.org/standards/content/j2735set_201603/ |
| 2020 | https://www.sae.org/standards/content/j2735set_202007/ |
| 2024 | https://www.sae.org/standards/content/j2735set_202409/ |

#### Patches to the J2735 ASN files

In the 2024 set of ASN files there are a couple changes that need to be made for them to compile with the current version of asn1c. These changes are shown in the form of `.patch` files in the `j2735-asn-files/2024/asn-edits` directory. The `.patch` files contain only the spcific lines in the specific files that need to be changed, due to the aforementioned prohibition on redistributing the ASN files. The patches were created with the `diff` command line utility, and are applied automatically by the `generate-files.sh` script before it runs asn1c to compile the ASN files. The `patch` command line in that script includes the `--forward` option, which prevents the patch from being reversed if the script is run more than once.

## Environment Variables
The `doIt.sh` and `generate-files.sh` scripts uses the following environment variables:
Expand Down
4 changes: 2 additions & 2 deletions asn1c_combined/doIt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
export LD_LIBRARY_PATH=/usr/local/lib
export CC=gcc

# if J2735_YEAR is not set, default to 2020
# if J2735_YEAR is not set, default to 2024
if [ -z "$J2735_YEAR" ]; then
year="2020"
year="2024"
else
year=$J2735_YEAR
fi
Expand Down
Loading

0 comments on commit 73ca21f

Please sign in to comment.