| 
 | 1 | +#!/usr/bin/env -S cmake -P  | 
 | 2 | +#  | 
 | 3 | +# Command-line script to regenerate the ext/standard/credits_*.h headers from  | 
 | 4 | +# CREDITS files.  | 
 | 5 | +#  | 
 | 6 | +# Run with: `cmake -P cmake/scripts/GenerateCredits.cmake`  | 
 | 7 | + | 
 | 8 | +if(NOT CMAKE_SCRIPT_MODE_FILE)  | 
 | 9 | +  message(FATAL_ERROR "This is a command-line script.")  | 
 | 10 | +endif()  | 
 | 11 | + | 
 | 12 | +set(PHP_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../)  | 
 | 13 | + | 
 | 14 | +if(NOT EXISTS ${PHP_SOURCE_DIR}/ext/standard/credits.h)  | 
 | 15 | +  message(FATAL_ERROR "This script should be run inside the php-src repository")  | 
 | 16 | +endif()  | 
 | 17 | + | 
 | 18 | +set(template [[  | 
 | 19 | +/*  | 
 | 20 | +                      DO NOT EDIT THIS FILE!  | 
 | 21 | + | 
 | 22 | + it has been automatically created by scripts/dev/credits from  | 
 | 23 | + the information found in the various ext/.../CREDITS and  | 
 | 24 | + sapi/.../CREDITS files  | 
 | 25 | + | 
 | 26 | + if you want to change an entry you have to edit the appropriate  | 
 | 27 | + CREDITS file instead  | 
 | 28 | + | 
 | 29 | +*/  | 
 | 30 | + | 
 | 31 | +]])  | 
 | 32 | + | 
 | 33 | +file(GLOB credits ${PHP_SOURCE_DIR}/*/*/CREDITS)  | 
 | 34 | + | 
 | 35 | +foreach(credit ${credits})  | 
 | 36 | +  cmake_path(GET credit PARENT_PATH parent)  | 
 | 37 | +  cmake_path(GET parent PARENT_PATH parent)  | 
 | 38 | +  cmake_path(GET parent FILENAME dir)  | 
 | 39 | + | 
 | 40 | +  list(APPEND dirs ${dir})  | 
 | 41 | +  file(STRINGS ${credit} lines ENCODING UTF-8)  | 
 | 42 | +  list(GET lines 0 title)  | 
 | 43 | +  list(GET lines 1 authors)  | 
 | 44 | +  list(APPEND ${dir}_credits "CREDIT_LINE(\"${title}\", \"${authors}\")")  | 
 | 45 | +endforeach()  | 
 | 46 | + | 
 | 47 | +list(REMOVE_DUPLICATES dirs)  | 
 | 48 | + | 
 | 49 | +foreach(dir ${dirs})  | 
 | 50 | +  list(SORT ${dir}_credits CASE INSENSITIVE)  | 
 | 51 | +  list(JOIN ${dir}_credits ";\n" credits)  | 
 | 52 | +  set(content "${template}${credits};\n")  | 
 | 53 | + | 
 | 54 | +  if(EXISTS ${PHP_SOURCE_DIR}/ext/standard/credits_${dir}.h)  | 
 | 55 | +    file(READ ${PHP_SOURCE_DIR}/ext/standard/credits_${dir}.h current)  | 
 | 56 | +    if(content STREQUAL "${current}")  | 
 | 57 | +      continue()  | 
 | 58 | +    endif()  | 
 | 59 | +  endif()  | 
 | 60 | + | 
 | 61 | +  file(WRITE ${PHP_SOURCE_DIR}/ext/standard/credits_${dir}.h "${content}")  | 
 | 62 | +  message("Updated ext/standard/credits_${dir}.h")  | 
 | 63 | +endforeach()  | 
0 commit comments