-
Notifications
You must be signed in to change notification settings - Fork 12
valgrind example #514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
valgrind example #514
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -23,7 +23,7 @@ Please note that these examples, although similar, are distinct from the ones us | |||||
| <!-- vale HouseStyle.Spelling = NO --> | ||||||
| - [clojure](./clojure) | ||||||
| - [cobol](./cobol) | ||||||
| - [c](./c) | ||||||
| - [c](./c) - also demonstrates running `valgrind` inside earthbuild, useful on macOS / Windows where valgrind isn't available natively. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The project name is Earthly, not 'earthbuild'. Using the correct name ensures consistency with the rest of the documentation.
Suggested change
|
||||||
| - [cpp](./cpp) | ||||||
| - [dotnet](./dotnet) | ||||||
| - [elixir](./elixir) | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,18 @@ | ||
| VERSION 0.8 | ||
| FROM alpine:3.23.3 | ||
|
|
||
| # renovate: datasource=docker packageName=alpine | ||
| ARG --global alpine_version=3.23.3 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To avoid duplication and ensure consistency, consider defining |
||
| FROM alpine:$alpine_version | ||
| WORKDIR /c-example | ||
|
|
||
| deps: | ||
| RUN apk --update add build-base cmake | ||
| # renovate: datasource=repology depName=alpine_3_23/build-base versioning=loose | ||
| ARG build_base_version=0.5-r3 | ||
| # renovate: datasource=repology depName=alpine_3_23/cmake versioning=loose | ||
| ARG cmake_version=4.1.3-r0 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| RUN apk --update add \ | ||
| build-base=$build_base_version \ | ||
| cmake=$cmake_version | ||
|
|
||
| build: | ||
| FROM +deps | ||
|
|
@@ -19,14 +28,41 @@ docker: | |
|
|
||
| unit-test: | ||
| FROM +deps | ||
| RUN apk add cunit-dev | ||
| # renovate: datasource=repology depName=alpine_3_23/cunit-dev versioning=loose | ||
| ARG cunit_dev_version=2.1.3-r7 | ||
| RUN apk add cunit-dev=$cunit_dev_version | ||
|
Comment on lines
+31
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| COPY src src | ||
| COPY test test | ||
| RUN cmake test | ||
| RUN make | ||
| RUN ./unit-test | ||
|
|
||
| # memcheck runs the unit-test binary under valgrind's memcheck tool to detect | ||
| # leaks, invalid reads/writes, and uninitialised reads. Built with -g -O0 so | ||
| # stack traces resolve to source lines. | ||
| memcheck: | ||
| FROM +deps | ||
| # renovate: datasource=repology depName=alpine_3_23/cunit-dev versioning=loose | ||
| ARG cunit_dev_version=2.1.3-r7 | ||
|
Comment on lines
+45
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| # renovate: datasource=repology depName=alpine_3_23/valgrind versioning=loose | ||
| ARG valgrind_version=3.25.1-r2 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| RUN apk add \ | ||
| cunit-dev=$cunit_dev_version \ | ||
| valgrind=$valgrind_version | ||
| COPY src src | ||
| COPY test test | ||
| RUN cmake -DCMAKE_C_FLAGS="-g -O0" test | ||
| RUN make | ||
| RUN valgrind \ | ||
| --error-exitcode=1 \ | ||
| --leak-check=full \ | ||
| --show-leak-kinds=all \ | ||
| --errors-for-leak-kinds=definite \ | ||
| --track-origins=yes \ | ||
| ./unit-test | ||
|
|
||
| all: | ||
| BUILD +build | ||
| BUILD +unit-test | ||
| BUILD +memcheck | ||
| BUILD +docker | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The project name is Earthly, not 'earthbuild'. Using the correct name ensures consistency with the rest of the documentation.