Skip to content

Commit

Permalink
meson make: use VERSION file
Browse files Browse the repository at this point in the history
To create a distribution package with meson you run
  `meson dist -C <your_build_dir>`
This will collect all git tracked files and pack them into an archive.
There is no way to collect version information for that.

So now the base version stands in the VERSION file. To relase a flashrom
version you change that file and tag the changing commit.

When building from git the git version is embedded in the flashrom
binary. E.g.:
flashrom 1.4.0-devel (git:v1.2-1172-g7f186838) on Linux 6.1.3 (x86_64)

Change-Id: Idc17eadb397b3c579bddfbf9ae6bf1b171f5dfb7
Signed-off-by: Thomas Heijligen <[email protected]>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/72657
Reviewed-by: Anastasia Klimchuk <[email protected]>
Tested-by: build bot (Jenkins) <[email protected]>
  • Loading branch information
heijligen authored and Anastasia Klimchuk committed May 7, 2023
1 parent 3d5c9a5 commit c4d89ea
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 334 deletions.
16 changes: 7 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,11 @@ LIB_OBJS = libflashrom.o layout.o erasure_layout.o flashrom.o udelay.o parallel.

CLI_OBJS = cli_classic.o cli_output.o cli_common.o print.o

# versioninfo.inc stores metadata required to build a packaged flashrom. It is generated by the export rule and
# imported below. If versioninfo.inc is not found and the variables are not defined by the user, the info will
# be obtained using util/getrevision.sh, which is the common case during development.
-include versioninfo.inc
VERSION ?= $(shell ./util/getrevision.sh --revision)

SCMDEF := -D'FLASHROM_VERSION="$(VERSION)"'
VERSION ?= $(shell cat ./VERSION)
VERSION_GIT ?= $(shell git describe 2>/dev/null)
ifdef VERSION_GIT
VERSION := "$(VERSION) (git:$(VERSION_GIT))"
endif

# No spaces in release names unless set explicitly
RELEASENAME ?= $(shell echo "$(VERSION)" | sed -e 's/ /_/')
Expand Down Expand Up @@ -1021,7 +1019,7 @@ config:
fi

%.o: %.c | config
$(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_FLAGS) $(SCMDEF) -o $@ -c $<
$(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_FLAGS) -D'FLASHROM_VERSION=$(VERSION)' -o $@ -c $<

$(PROGRAM)$(EXEC_SUFFIX): $(CLI_OBJS) libflashrom.a
$(CC) -o $@ $^ $(LDFLAGS)
Expand Down Expand Up @@ -1101,7 +1099,7 @@ libpayload: clean
make CC="CC=i386-elf-gcc lpgcc" AR=i386-elf-ar RANLIB=i386-elf-ranlib

gitconfig:
./util/getrevision.sh -c 2>/dev/null && ./util/git-hooks/install.sh
git rev-parse 2>/dev/null && ./util/git-hooks/install.sh

.PHONY: all install clean distclean config _export export tarball libpayload

Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.4.0-devel
4 changes: 2 additions & 2 deletions doc/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if sphinx.found()

custom_target(
'man-pages',
command : [sphinx, '-b', 'man', '-q', '-d', '@PRIVATE_DIR@', '-Drelease=' + meson.project_version(),'@CURRENT_SOURCE_DIR@', '@OUTDIR@'],
command : [sphinx, '-b', 'man', '-q', '-d', '@PRIVATE_DIR@', '-Drelease=' + flashrom_version,'@CURRENT_SOURCE_DIR@', '@OUTDIR@'],
build_always_stale : true, # sphinx handles rebuilds
output : man_outputs,
install : true,
Expand All @@ -25,7 +25,7 @@ if sphinx.found()
if get_option('documentation').auto() or get_option('documentation').enabled()
custom_target(
'documentation',
command : [sphinx, '-b', 'html', '-q', '-d', '@PRIVATE_DIR@', '-Drelease=' + meson.project_version(),'@CURRENT_SOURCE_DIR@', '@OUTDIR@/html'],
command : [sphinx, '-b', 'html', '-q', '-d', '@PRIVATE_DIR@', '-Drelease=' + flashrom_version,'@CURRENT_SOURCE_DIR@', '@OUTDIR@/html'],
build_always_stale : true, # sphinx handles rebuilds
output : 'html',
install : true,
Expand Down
28 changes: 14 additions & 14 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project('flashromutils', 'c',
version : run_command('util/getversion.sh', '--version', check : true).stdout().strip(),
version : run_command('cat', 'VERSION', check: true).stdout().strip(),
license : 'GPL-2.0',
meson_version : '>=0.53.0',
default_options : [
Expand All @@ -19,14 +19,23 @@ if get_option('classic_cli').enabled() and get_option('default_library') == 'sha
''')
endif

subdir('doc')

# libtool versioning
lt_current = '1'
lt_revision = '0'
lt_age = '0'
lt_version = '@0@.@1@.@2@'.format(lt_current, lt_age, lt_revision)

flashrom_version = meson.project_version()
git = find_program('git', native : true, required : false)
if git.found()
version_git = run_command('git', 'describe', check : false)
if version_git.returncode() == 0
flashrom_version += ' (git:@0@)'.format(version_git.stdout().strip())
endif
endif

subdir('doc')

# hide/enable some warnings
warning_flags = [
'-Wshadow',
Expand All @@ -47,7 +56,7 @@ add_project_arguments('-D__BSD_VISIBLE', language : 'c') # required for u_char,
add_project_arguments('-D__XSI_VISIBLE', language : 'c') # required for gettimeofday() on FreeBSD
add_project_arguments('-D_NETBSD_SOURCE', language : 'c') # required for indirect include of strings.h on NetBSD
add_project_arguments('-D_DARWIN_C_SOURCE', language : 'c') # required for indirect include of strings.h on MacOS
add_project_arguments('-DFLASHROM_VERSION="' + meson.project_version() + '"', language : 'c')
add_project_arguments('-DFLASHROM_VERSION="' + flashrom_version + '"', language : 'c')

# get defaults from configure
config_print_wiki= get_option('classic_cli_print_wiki')
Expand Down Expand Up @@ -614,19 +623,10 @@ libflashrom = library(
link_depends : mapfile,
)

version = meson.project_version()
#strip leading characters
if version.startswith('v')
version = version.split('v')[1]
endif
if version.startswith('p')
version = version.split('p')[1]
endif

pkgg = import('pkgconfig')
pkgg.generate(
libraries : libflashrom,
version : version,
version : flashrom_version.split()[0], # cut off the git version
name : 'flashrom',
filebase : 'flashrom',
description : 'library to interact with flashrom',
Expand Down
238 changes: 0 additions & 238 deletions util/getrevision.sh

This file was deleted.

Loading

0 comments on commit c4d89ea

Please sign in to comment.