Commit 003b8772 authored by satmandu's avatar satmandu Committed by GitHub

Automatically generate constants list for crew const (#5796)

* Automatically generate constants list for crew const

* Document code
parent 6622da08
......@@ -402,45 +402,44 @@ def const(var)
value = eval(var)
puts "#{var}=#{value}"
else
vars = [
'ARCH',
'ARCH_LIB',
'CHROMEOS_RELEASE',
'CURL',
'CREW_BREW_DIR',
'CREW_BUILD',
'CREW_CMAKE_LIBSUFFIX_OPTIONS',
'CREW_CMAKE_OPTIONS',
'CREW_CONFIG_PATH',
'CREW_DEST_DIR',
'CREW_DEST_HOME',
'CREW_DEST_LIB_PREFIX',
'CREW_DEST_MAN_PREFIX',
'CREW_DEST_PREFIX',
'CREW_LIB_PATH',
'CREW_LIB_PREFIX',
'CREW_LIB_SUFFIX',
'CREW_MAN_PREFIX',
'CREW_COMMON_FLAGS',
'CREW_COMMON_FNO_LTO_FLAGS',
'CREW_ENV_OPTIONS',
'CREW_MESON_FNO_LTO_OPTIONS',
'CREW_MESON_OPTIONS',
'CREW_META_PATH',
'CREW_NOT_COMPRESS',
'CREW_NOT_STRIP',
'CREW_NPROC',
'CREW_OPTIONS',
'CREW_PACKAGES_PATH',
'CREW_PREFIX',
'CREW_TGT',
'CREW_VERSION',
'HOME',
'LIBC_VERSION',
'USER'
@ruby_default_constants = %w[
ARGF
ARGV
CROSS_COMPILING
DOC
ENV
GC
IO
JSON
OpenSSL
Q
R
RUBY_COPYRIGHT
RUBY_DESCRIPTION
RUBY_ENGINE
RUBY_ENGINE_VERSION
RUBYGEMS_ACTIVATION_MONITOR
RUBY_PATCHLEVEL
RUBY_PLATFORM
RUBY_RELEASE_DATE
RUBY_REVISION
RUBY_VERSION
RubyVM
S
STDERR
STDIN
STDOUT
StringIO
TOPLEVEL_BINDING
URI
]
vars.each { |var|
value = eval(var)
# Get all constants
@constants = Module.constants.select {|e| e =~ /[[:upper:]]$/}
# Reject all constants which match the default list
@constants = @constants.map(&:to_s).reject{ |e| @ruby_default_constants.find{ |f| /\A#{e}\z/ =~ f }}
# Print a sorted list of the remaining constants used by crew.
@constants.sort.each { |var|
value = eval(var.to_s)
puts "#{var}=#{value}"
}
end
......
# Defines common constants used in different parts of crew
CREW_VERSION = '1.10.3'
CREW_VERSION = '1.10.4'
ARCH_ACTUAL = `uname -m`.strip
# This helps with virtualized builds on aarch64 machines
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment