mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Added a script to build a single file distribution
This commit is contained in:
		
							
								
								
									
										44
									
								
								scripts/build-single-header.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								scripts/build-single-header.sh
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,44 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| TAG=$(git describe) | ||||
| RE_INCLUDE='^#include[[:space:]]*["<](.*)[">]' | ||||
| RE_EMPTY='^(#pragma[[:space:]]+once)?[[:space:]]*(//.*)?$' | ||||
|  | ||||
| declare -A INCLUDED | ||||
|  | ||||
| process() | ||||
| { | ||||
| 	local PARENT=$1 | ||||
| 	local FOLDER=$(dirname $1) | ||||
| 	local SHOW_COMMENT=$2 | ||||
| 	while IFS= read -r LINE; do | ||||
| 		if [[ $LINE =~ $RE_INCLUDE ]]; then | ||||
| 			local CHILD=${BASH_REMATCH[1]} | ||||
| 			pushd "$FOLDER" > /dev/null | ||||
| 			if [[ -e $CHILD ]]; then | ||||
| 				local CHILD_PATH=$(realpath $CHILD) | ||||
| 				if [[ ! ${INCLUDED[$CHILD_PATH]} ]]; then | ||||
| 					#echo "// $PARENT -> $CHILD" | ||||
| 					INCLUDED[$CHILD_PATH]=true | ||||
| 					process "$CHILD" false | ||||
| 				fi | ||||
| 			else | ||||
| 				if [[ ! ${INCLUDED[$CHILD]} ]]; then | ||||
| 					echo "$LINE" | ||||
| 					INCLUDED[$CHILD]=true | ||||
| 				fi | ||||
| 			fi | ||||
| 			popd > /dev/null | ||||
| 		elif [[ "${SHOW_COMMENT}" = "true" ]] ; then | ||||
| 			echo "$LINE" | ||||
| 		elif [[ ! $LINE =~ $RE_EMPTY ]]; then | ||||
| 			echo "$LINE" | ||||
| 		fi | ||||
| 	done < $PARENT | ||||
| } | ||||
|  | ||||
| cd $(dirname $0)/../ | ||||
| INCLUDED=() | ||||
| process include/ArduinoJson.h true > ../ArduinoJson-$TAG.h | ||||
| INCLUDED=() | ||||
| process include/ArduinoJson.hpp true > ../ArduinoJson-$TAG.hpp | ||||
		Reference in New Issue
	
	Block a user