Skip to content
Merged
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
5 changes: 0 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ jobs:
uses: microsoft/setup-msbuild@v1.3.1
if: runner.os == 'Windows'

- name: generate fake src/version.h so we can try to build
shell: bash
run: yarn update_version


- name: build libsession-util-nodejs
shell: bash
run: yarn install --frozen-lockfile
23 changes: 22 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,28 @@ set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)

set(VERBOSE ON)

# Get current commit hash as GIT_COMMIT
find_package(Git)
set(GIT_COMMIT "unknown") # Default value for when Git is not found
if (EXISTS "${CMAKE_SOURCE_DIR}/.git/index" AND GIT_FOUND)
execute_process(COMMAND "${GIT_EXECUTABLE}" rev-parse HEAD RESULT_VARIABLE GIT_GET_HASH_RESULT OUTPUT_VARIABLE GIT_COMMIT OUTPUT_STRIP_TRAILING_WHITESPACE)
if(GIT_GET_HASH_RESULT)
message(STATUS "You are currently on commit ${GIT_COMMIT}")
else()
message(WARNING "Cannot determine current commit. Make sure that you are building either from a Git working tree or from a source archive.")
endif()
endif()

# Read the package.json file and extract the top-level .version as LIBSESSION_NODEJS_VERSION
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/package.json" PACKAGE_JSON)
string(JSON LIBSESSION_NODEJS_VERSION GET "${PACKAGE_JSON}" version)

# Generate src/version.h
file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/src/version.h"
"const char* LIBSESSION_NODEJS_VERSION = \"${LIBSESSION_NODEJS_VERSION}\";
const char* LIBSESSION_NODEJS_COMMIT = \"${GIT_COMMIT}\";\n"
)

# Detect the number of processors
include(ProcessorCount)
ProcessorCount(N)
Expand All @@ -18,7 +40,6 @@ else()
endif()
message(STATUS "Number of processors detected: ${N}")


add_definitions(-DNAPI_VERSION=8)
set(CMAKE_CONFIGURATION_TYPES Release)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ git clone --recursive git@github.com:session-foundation/libsession-util-nodejs.g
```

Always do your changes in `[FOLDER_NOT_IN_SESSION_DESKTOP]/libsession-util-nodejs`, never in the one under session-desktop's `node_modules` as you might override your local changes.
Then, you can quickly compile a non-electron build by first running `yarn naughty-patch && yarn update_version` and then `yarn install` from that folder. You should only have to run `yarn naughty-patch && yarn update_version` manually once when you first setup the project. This is a quick incremental build which can check for C++ compilation errors.
Then, you can quickly compile a non-electron build by first running `yarn naughty-patch` and then `yarn install` from that folder. You should only have to run `yarn naughty-patch` manually once when you first setup the project. This is a quick incremental build which can check for C++ compilation errors.
Once your changes are ready to be tested in the `session-desktop` you can compile an electron build using this command:

```
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"email": "team@oxen.io"
},
"scripts": {
"update_version": "sh update_version.sh",
"clean": "rimraf .cache build",
"lint:cpp": "cppcheck --std=c++20 -j8 --quiet src libsession-util/src",
"install": "cmake-js build --runtime=electron --runtime-version=34.2.0 --CDSUBMODULE_CHECK=OFF --CDLOCAL_MIRROR=https://oxen.rocks/deps --CDENABLE_ONIONREQ=OFF --CDWITH_TESTS=OFF",
Expand Down
19 changes: 17 additions & 2 deletions prepare_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,24 @@ rm -f ./libsession_util_nodejs*.tar.gz
python -m venv .venv
. .venv/bin/activate
pip install git-archive-all

PACKAGE_VERSION=$(node -p "require('./package.json').version")
yarn update_version
echo "PACKAGE_VERSION: $PACKAGE_VERSION"
GIT_COMMIT=$(git rev-parse HEAD)

HEADER_PACKAGE_VERSION=$(grep 'LIBSESSION_NODEJS_VERSION' src/version.h | sed -E 's/.*"([0-9.]+)".*/\1/')
HEADER_GIT_COMMIT=$(grep 'LIBSESSION_NODEJS_COMMIT' src/version.h | sed -E 's/.*"([A-Za-z0-9.]+)".*/\1/')

echo "Package: $PACKAGE_VERSION; Commit: $GIT_COMMIT"
if [ "$PACKAGE_VERSION" != "$HEADER_PACKAGE_VERSION" ]; then
echo "Error: Version mismatch! package.json version is $PACKAGE_VERSION, but src/version.h has $HEADER_PACKAGE_VERSION. Build the project first before packaging 'yarn install'"
exit 1
fi

if [ "$GIT_COMMIT" != "$HEADER_GIT_COMMIT" ]; then
echo "Error: Version mismatch! Git commit is $GIT_COMMIT, but src/version.h has $HEADER_GIT_COMMIT. Build the project first before packaging 'yarn install'"
exit 1
fi

echo "Is '$PACKAGE_VERSION' the correct version? If yes, press 'y' to create the release. Press anything else to exit."
read_char char_read
case "$char_read" in
Expand Down
21 changes: 0 additions & 21 deletions update_version.sh

This file was deleted.