Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/clang_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ jobs:
restore-keys: ${{ runner.os }}-cache-clang-${{ matrix.id }}-

- name: Run
run: docker run -e CI -e TRAVIS_BUILD_DIR="$PWD" -e PROJ_CMAKE_BUILD_OPTIONS="$PROJ_CMAKE_BUILD_OPTIONS" -e WORK_DIR="$PWD" -e TRAVIS_OS_NAME=linux -e BUILD_NAME=linux_clang -v $PWD:$PWD ubuntu:20.04 $PWD/.github/workflows/clang_linux/start.sh
run: docker run -e PROJ_GITHUB_SHA=${{ github.sha }} -e CI -e TRAVIS_BUILD_DIR="$PWD" -e PROJ_CMAKE_BUILD_OPTIONS="$PROJ_CMAKE_BUILD_OPTIONS" -e WORK_DIR="$PWD" -e TRAVIS_OS_NAME=linux -e BUILD_NAME=linux_clang -v $PWD:$PWD ubuntu:20.04 $PWD/.github/workflows/clang_linux/start.sh
2 changes: 2 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ jobs:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ${{ matrix.dockerfile }}
build-args: |
PROJ_GITHUB_SHA=${{ github.sha }}
platforms: linux/${{ steps.prep.outputs.ARCH }}
tags: ${{ steps.prep_tags.outputs.tags }}
labels: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Run docker build
run: |
docker run --user $(id -u):$(id -g) --rm \
-e GITHUB_SHA=${{ github.sha }} \
-e PROJ_GITHUB_SHA=${{ github.sha }} \
-v "$PWD":/build/proj_src \
-v "$PWD"/wasm_out:/build/install \
proj-emscripten-builder
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fedora_rawhide.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
restore-keys: ${{ runner.os }}-cache-fedora_rawhide-

- name: Run
run: docker run -e CI -e WORK_DIR="$PWD" -v $PWD:$PWD fedora:rawhide $PWD/.github/workflows/fedora_rawhide/start.sh
run: docker run -e PROJ_GITHUB_SHA=${{ github.sha }} -e CI -e WORK_DIR="$PWD" -v $PWD:$PWD fedora:rawhide $PWD/.github/workflows/fedora_rawhide/start.sh
2 changes: 1 addition & 1 deletion .github/workflows/linux_gcc_32bit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
restore-keys: ${{ runner.os }}-cache-gcc32bit-

- name: Run
run: docker run -e CI -e WORK_DIR="$PWD" -v $PWD:$PWD ubuntu:20.04 $PWD/.github/workflows/linux_gcc_32bit/start.sh
run: docker run -e PROJ_GITHUB_SHA=${{ github.sha }} -e CI -e WORK_DIR="$PWD" -v $PWD:$PWD ubuntu:20.04 $PWD/.github/workflows/linux_gcc_32bit/start.sh
2 changes: 1 addition & 1 deletion .github/workflows/mingw_w64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
restore-keys: ${{ runner.os }}-cache-mingw_w64-

- name: Build
run: docker run -e CI -e TRAVIS_OS_NAME=linux -e BUILD_NAME=mingw_w64 -e WORK_DIR="$PWD" -v $PWD:$PWD ubuntu:22.04 $PWD/.github/workflows/mingw_w64/start.sh
run: docker run -e PROJ_GITHUB_SHA=${{ github.sha }} -e CI -e TRAVIS_OS_NAME=linux -e BUILD_NAME=mingw_w64 -e WORK_DIR="$PWD" -v $PWD:$PWD ubuntu:22.04 $PWD/.github/workflows/mingw_w64/start.sh
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ LABEL maintainer="Howard Butler <howard@hobu.co>"

ARG DESTDIR="/build"

ARG PROJ_GITHUB_SHA

# Setup build env
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --fix-missing --no-install-recommends \
Expand Down
50 changes: 50 additions & 0 deletions cmake/ProjConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,54 @@ if(EXISTS ${AUTOCONF_PROJ_CONFIG_H})
"before CMake's build.")
endif()

# Get the git hash to write it in the release message.
set(PROJ_GIT_HASH "")
if(DEFINED ENV{PROJ_GITHUB_SHA})
string(SUBSTRING "$ENV{PROJ_GITHUB_SHA}" 0 7 PROJ_GIT_HASH)
else()
find_package(Git QUIET)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be put above the if block, since GIT_FOUND is a variable used on L97.

Furthermore, looking at CMake docs for FindGit, I see that GIT_FOUND is deprecated since version 4.2, so these instances should be set to Git_FOUND (which is valid since older versions).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mwtoews . It is now Git_FOUND.

About the location of the find_package, in case PROJ_GITHUB_SHA is defined, the second part later in the file is not needed. It can be used to disable the automatic check of the status of the repo.
Do you think it is enough that way? Would you prefer something else?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the automatic check of the status of the repo (L98-L101) could instead be moved up to this block (L60-L86) instead. (The original point I was making is that the same condition appears twice, except the second check at L97 may not always have Git_FOUND defined, which is actually fine with CMake, since undefined vars evaluate false).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth it? I separated in two because it is doing two different things (but based on the same if statement, I know).

if(Git_FOUND AND EXISTS "${PROJ_SOURCE_DIR}/.git")
# Get the short hash
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY "${PROJ_SOURCE_DIR}"
RESULT_VARIABLE GIT_REV_RESULT
OUTPUT_VARIABLE PROJ_GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)

if(GIT_REV_RESULT EQUAL 0)
# Check if the working directory is dirty
execute_process(
COMMAND ${GIT_EXECUTABLE} status --porcelain --untracked-files=no
WORKING_DIRECTORY "${PROJ_SOURCE_DIR}"
RESULT_VARIABLE GIT_STATUS_RESULT
OUTPUT_VARIABLE GIT_STATUS_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)

# If the command succeeds and outputs anything, the tree is dirty
if(GIT_STATUS_RESULT EQUAL 0 AND NOT GIT_STATUS_OUTPUT STREQUAL "")
string(APPEND PROJ_GIT_HASH "*")
endif()
Comment on lines +71 to +85
Copy link
Copy Markdown
Contributor Author

@jjimenezshaw jjimenezshaw May 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This piece of code is to detect a dirty tree (modified files). This is more helpful in the developer's environment, where things can be modified. It makes clear that the code used was not exactly what is in the git hash.

I think it is not that helpful in the CI environment, where source code should not be modified.

else()
set(PROJ_GIT_HASH "")
endif()
endif()
endif()
if(PROJ_GIT_HASH)
add_compile_definitions(PROJ_GIT_HASH=\"${PROJ_GIT_HASH}\")
endif()
message(PROJ_GIT_HASH=\"${PROJ_GIT_HASH}\")

# Tell CMake to re-configure if the Git HEAD or index changes
if(Git_FOUND AND EXISTS "${PROJ_SOURCE_DIR}/.git")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
"${PROJ_SOURCE_DIR}/.git/HEAD" # for the hash
"${PROJ_SOURCE_DIR}/.git/index" # for the *
)
endif()
Comment on lines +96 to +102
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case something is modified in git, proj is reconfigured. This is helpful in the developer's environment. I don't know if it is too much overhead.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that should be fine


configure_file(cmake/proj_config.cmake.in src/proj_config.h)
17 changes: 1 addition & 16 deletions scripts/ci/emscripten/build_wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -250,17 +250,6 @@ fi
# Helper functions to extract some info from PROJ in C and C++
log_step "6.5 Creating C Wrapper Functions"

# --- Determine Git Revision ---
GIT_REV=""
if [ -n "${GITHUB_SHA}" ]; then
GIT_REV="${GITHUB_SHA}"
else
if git rev-parse HEAD >/dev/null 2>&1; then
GIT_REV=$(git rev-parse HEAD)
fi
fi
echo "GIT_REV=${GIT_REV}"

WRAPPER_FILE="${TEMP_BUILD_DIR}/proj_wrappers.cpp"
WRAPPER_OBJ_FILE="${TEMP_BUILD_DIR}/proj_wrappers.o"

Expand Down Expand Up @@ -319,10 +308,6 @@ const char* get_compilation_date() {
return "$DDD" ;
}

const char* get_build_git_revision() {
return "${GIT_REV}";
}

int get_ptr_size() {
return sizeof(void*);
}
Expand All @@ -349,7 +334,7 @@ FINAL_LIBS="${INSTALL_DIR}/lib/libproj.a \
${WRAPPER_OBJ_FILE}"

# include all exported symbols
echo -e "_malloc\n_free\n_get_compilation_date\n_get_build_git_revision\n_get_ptr_size" > ${INSTALL_DIR}/exported_symbols.txt
echo -e "_malloc\n_free\n_get_compilation_date\n_get_ptr_size" > ${INSTALL_DIR}/exported_symbols.txt
grep "^proj_\|^geod_" ${PROJ_SRC_DIR}/scripts/reference_exported_symbols.txt | grep -v "(" | sed 's/^/_/' >> ${INSTALL_DIR}/exported_symbols.txt
head ${INSTALL_DIR}/exported_symbols.txt

Expand Down
13 changes: 10 additions & 3 deletions src/release.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@
#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)

char const pj_release[] = "Rel. " STR(PROJ_VERSION_MAJOR) "." STR(
PROJ_VERSION_MINOR) "." STR(PROJ_VERSION_PATCH) ", "
"September 15th, 2026";
#ifdef PROJ_GIT_HASH
#define PROJ_GIT_REV_STR " (" PROJ_GIT_HASH ")"
#else
#define PROJ_GIT_REV_STR ""
#endif

char const pj_release[] =
"Rel. " STR(PROJ_VERSION_MAJOR) "." STR(PROJ_VERSION_MINOR) "." STR(
PROJ_VERSION_PATCH) PROJ_GIT_REV_STR ", "
"September 15th, 2026";
Comment on lines +16 to +18
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This string is the simplest modification to the previous one: it just adds the hash in parenthesis . I am open to other options.


const char *pj_get_release() { return pj_release; }
Loading