Skip to content

Commit

Permalink
version number should be stored in a text file
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Pacheco committed Jul 16, 2015
1 parent 8d6fb9b commit 06a14c7
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 12 deletions.
9 changes: 9 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ MDBV8_VERS_TAG = "dev"
# the "src/" directory prefix.)
#
MDBV8_SOURCES = mdb_v8.c mdb_v8_cfg.c
MDBV8_GENSOURCES = mdb_v8_version.c

# List of source files to run through cstyle. This includes header files.
MDBV8_CSTYLE_SOURCES = $(wildcard src/*.c src/*.h)
Expand Down Expand Up @@ -112,3 +113,11 @@ MDBV8_ARCH=ia32
include Makefile.arch.targ
MDBV8_ARCH=amd64
include Makefile.arch.targ

#
# mdb_v8_version.c is generated based on the "version" file. The version number
# is baked into the binary itself (so the dmod can report its version) and also
# used in the publish target.
#
$(MDBV8_BUILD)/mdb_v8_version.c: version
tools/mkversion < $^ > $@
3 changes: 2 additions & 1 deletion Makefile.arch.defs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ MDBV8_BUILD_$(MDBV8_ARCH) := $(MDBV8_BUILD)/$(MDBV8_ARCH)
MDBV8_DYLIB_$(MDBV8_ARCH) := $(MDBV8_BUILD_$(MDBV8_ARCH))/$(MDBV8_SONAME)
# List of full paths to architecture-specific object files
MDBV8_OBJECTS_$(MDBV8_ARCH) := \
$(MDBV8_SOURCES:%.c=$(MDBV8_BUILD_$(MDBV8_ARCH))/%.o)
$(MDBV8_SOURCES:%.c=$(MDBV8_BUILD_$(MDBV8_ARCH))/%.o) \
$(MDBV8_GENSOURCES:%.c=$(MDBV8_BUILD_$(MDBV8_ARCH))/%.o)

# List of architecture-specific targets (for defining target-specific variables)
MDBV8_TARGETS_$(MDBV8_ARCH) := \
Expand Down
6 changes: 4 additions & 2 deletions Makefile.arch.targ
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
# architectures.
#

$(MDBV8_OBJECTS_$(MDBV8_ARCH)): \
$(MDBV8_BUILD_$(MDBV8_ARCH))/%.o: src/%.c | $(MDBV8_BUILD_$(MDBV8_ARCH))
$(MDBV8_BUILD_$(MDBV8_ARCH))/%.o: src/%.c | $(MDBV8_BUILD_$(MDBV8_ARCH))
$(COMPILE.c)

$(MDBV8_BUILD_$(MDBV8_ARCH))/%.o: $(MDBV8_BUILD)/%.c | $(MDBV8_BUILD_$(MDBV8_ARCH))
$(COMPILE.c)

$(MDBV8_DYLIB_$(MDBV8_ARCH)): $(MDBV8_OBJECTS_$(MDBV8_ARCH))
Expand Down
10 changes: 1 addition & 9 deletions src/mdb_v8.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,10 @@

#include "v8dbg.h"
#include "v8cfg.h"
#include "mdb_v8_version.h"

#define offsetof(s, m) ((size_t)(&(((s *)0)->m)))

/*
* Version information for this build of mdb_v8. If this needs to be more
* sophisticated, we could put this in a separate C file, even generated by the
* build from a text file. For now, this is sufficient.
*/
int mdbv8_vers_major = 0;
int mdbv8_vers_minor = 9;
int mdbv8_vers_micro = 0;

#ifndef MDBV8_VERS_TAG
#error build must define MDBV8_VERS_TAG
#endif
Expand Down
40 changes: 40 additions & 0 deletions src/mdb_v8_version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2015, Joyent, Inc. All rights reserved.
*/

/*
* mdb_v8_version.h: declares version number values
*/

#ifndef _MDBV8_VERSION_H
#define _MDBV8_VERSION_H

/*
* These constants are defined in mdb_v8_version.c, which is generated as part
* of the build.
*/
extern int mdbv8_vers_major;
extern int mdbv8_vers_minor;
extern int mdbv8_vers_micro;

#endif /* _MDBV8_VERSION_H */
19 changes: 19 additions & 0 deletions tools/mkversion
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

#
# tools/mkversion: given the contents of the "version" file on stdin, emit a C
# file on stdout that defines appropriate values for the version major, minor,
# and micro numbers. Lines beginning with '#' are ignored in the input. Only
# the first non-ignored line will be used.
#

awk -F. '!/^#/{ print $1, $2, $3 }' | head -1 | while read major minor micro; do
cat <<-EOF
/*
* This file was generated by $0 at $(date).
*/
int mdbv8_vers_major = $major;
int mdbv8_vers_minor = $minor;
int mdbv8_vers_micro = $micro;
EOF
done
11 changes: 11 additions & 0 deletions version
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# This file is processed by tools/mkversion. The value here denotes the current
# version of the debugger module. Normal (non-release) builds will be tagged
# with this version, plus a "dev" tag that indicates the version is not final.
# For a release build, a "release" tag will be applied. While there may be many
# "dev" builds with the same version, there should be only one canonical
# "release" build with a given version number.
#
# This value is also used by the "publish" target in the build process.
#
0.9.0

0 comments on commit 06a14c7

Please sign in to comment.