mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-02 05:53:11 +00:00
makefile: add nimbus-build-system-nimble-dir target
Create a makefile target that runs a script which is a wrapper around nimbus-build-system create_nimble_link.sh script. Referenced issue: * https://github.com/waku-org/nwaku/issues/3232
This commit is contained in:
parent
bbf9905f46
commit
c43cee6593
10
Makefile
10
Makefile
@ -4,8 +4,8 @@
|
||||
# - MIT license
|
||||
# at your option. This file may not be copied, modified, or distributed except
|
||||
# according to those terms.
|
||||
BUILD_SYSTEM_DIR := vendor/nimbus-build-system
|
||||
EXCLUDED_NIM_PACKAGES := vendor/nim-dnsdisc/vendor
|
||||
export BUILD_SYSTEM_DIR := vendor/nimbus-build-system
|
||||
export EXCLUDED_NIM_PACKAGES := vendor/nim-dnsdisc/vendor
|
||||
LINK_PCRE := 0
|
||||
FORMAT_MSG := "\\x1B[95mFormatting:\\x1B[39m"
|
||||
# we don't want an error here, so we can handle things later, in the ".DEFAULT" target
|
||||
@ -152,6 +152,12 @@ endif
|
||||
|
||||
clean: | clean-libbacktrace
|
||||
|
||||
### Create nimble links (used when building with Nix)
|
||||
|
||||
nimbus-build-system-nimble-dir:
|
||||
NIMBLE_DIR="$(CURDIR)/$(NIMBLE_DIR)" \
|
||||
PWD_CMD="$(PWD)" \
|
||||
$(CURDIR)/scripts/generate_nimble_links.sh
|
||||
|
||||
##################
|
||||
## RLN ##
|
||||
|
||||
@ -1,82 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This script generates `.nimble-link` files and the folder structure typically created by `make update`
|
||||
# within this repository. It is an alternative to `vendor/nimbus-build-system/scripts/create_nimble_link.sh`,
|
||||
# designed for execution inside a Nix derivation, where Git commands are not available.
|
||||
|
||||
output_file="submodule_paths.txt"
|
||||
|
||||
# The EXCLUDED_NIM_PACKAGES variable (defined in the Makefile) contains a colon-separated list of
|
||||
# submodule paths that should be ignored. We split it into an array for easier matching.
|
||||
IFS=':' read -ra EXCLUDED_PATTERNS <<< "$EXCLUDED_NIM_PACKAGES"
|
||||
|
||||
# Function to check if a given submodule path should be excluded
|
||||
should_exclude() {
|
||||
local path="$1"
|
||||
for pattern in "${EXCLUDED_PATTERNS[@]}"; do
|
||||
if [[ "$path" == *"$pattern"* ]]; then
|
||||
return 0 # Match found, exclude this submodule
|
||||
fi
|
||||
done
|
||||
return 1 # No match, include this submodule
|
||||
}
|
||||
|
||||
# Locate all `.gitmodules` files and extract submodule paths
|
||||
find . -name .gitmodules | while read -r gitmodules_file; do
|
||||
module_dir=$(dirname "$(realpath "$gitmodules_file")")
|
||||
|
||||
while IFS= read -r line; do
|
||||
# Extract the submodule path from lines matching `path = /some/path`
|
||||
if [[ $line =~ path[[:space:]]*=[[:space:]]*(.*) ]]; then
|
||||
submodule_path="${BASH_REMATCH[1]}"
|
||||
abs_path="$module_dir/$submodule_path"
|
||||
|
||||
# Skip if the submodule is in the excluded list
|
||||
if should_exclude "$abs_path"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# If the submodule contains a `src/` folder, use it as the path
|
||||
if [[ -d "$abs_path/src" ]]; then
|
||||
abs_path="$abs_path/src"
|
||||
fi
|
||||
|
||||
echo "$abs_path" >> "$output_file"
|
||||
fi
|
||||
done < "$gitmodules_file"
|
||||
done
|
||||
|
||||
echo "Submodule paths collected in $output_file"
|
||||
|
||||
# Directory where Nimble packages will be linked
|
||||
nimble_pkgs_dir="./vendor/.nimble/pkgs"
|
||||
|
||||
mkdir -p "$nimble_pkgs_dir"
|
||||
|
||||
# Process each submodule path collected earlier
|
||||
while IFS= read -r submodule_path; do
|
||||
# Determine the submodule name from its path
|
||||
if [[ "$submodule_path" == */src ]]; then
|
||||
submodule_name=$(basename "$(dirname "$submodule_path")")
|
||||
else
|
||||
submodule_name=$(basename "$submodule_path")
|
||||
fi
|
||||
|
||||
# Check if the submodule contains at least one `.nimble` file
|
||||
base_dir="${submodule_path%/src}"
|
||||
nimble_files_count=$(find "$base_dir" -maxdepth 1 -type f -name "*.nimble" | wc -l)
|
||||
|
||||
if [ "$nimble_files_count" -gt 0 ]; then
|
||||
submodule_dir="$nimble_pkgs_dir/${submodule_name}-#head"
|
||||
mkdir -p "$submodule_dir"
|
||||
|
||||
nimble_link_file="$submodule_dir/${submodule_name}.nimble-link"
|
||||
# `.nimble-link` files require two identical lines for Nimble to recognize them properly
|
||||
echo "$submodule_path" > "$nimble_link_file"
|
||||
echo "$submodule_path" >> "$nimble_link_file"
|
||||
fi
|
||||
done < "$output_file"
|
||||
|
||||
echo "Nimble packages prepared in $nimble_pkgs_dir"
|
||||
|
||||
rm "$output_file"
|
||||
@ -62,7 +62,6 @@ in stdenv.mkDerivation rec {
|
||||
ANDROID_NDK_HOME="${pkgs.androidPkgs.ndk}";
|
||||
NIMFLAGS = "-d:disableMarchNative -d:git_revision_override=${revision}";
|
||||
XDG_CACHE_HOME = "/tmp";
|
||||
EXCLUDED_NIM_PACKAGES="vendor/nim-dnsdisc/vendor";
|
||||
|
||||
makeFlags = targets ++ [
|
||||
"V=${toString verbosity}"
|
||||
@ -74,7 +73,7 @@ in stdenv.mkDerivation rec {
|
||||
configurePhase = ''
|
||||
patchShebangs . vendor/nimbus-build-system > /dev/null
|
||||
make nimbus-build-system-paths
|
||||
./nix/create-nimble-link.sh
|
||||
make nimbus-build-system-nimble-dir
|
||||
'';
|
||||
|
||||
preBuild = ''
|
||||
|
||||
@ -26,4 +26,4 @@ mkdir -p "${NIMBLE_DIR}/pkgs"
|
||||
for gitmodules_file in $(find . -name '.gitmodules'); do
|
||||
echo "Processing .gitmodules file: $gitmodules_file"
|
||||
process_gitmodules "$gitmodules_file"
|
||||
done
|
||||
done
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user