Skip to content

Commit

Permalink
Adjust header files to compile with submodules.
Browse files Browse the repository at this point in the history
  • Loading branch information
brianwalenz committed Feb 25, 2020
1 parent 1705a99 commit 47b5074
Show file tree
Hide file tree
Showing 146 changed files with 407 additions and 201 deletions.
218 changes: 218 additions & 0 deletions scripts/version_update.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
#!/usr/bin/env perl

###############################################################################
#
# This file is part of canu, a software program that assembles whole-genome
# sequencing reads into contigs.
#
# This software is based on:
# 'Canu' v2.0 (https://github.com/marbl/canu)
# which is based on:
# 'Celera Assembler' r4587 (http://wgs-assembler.sourceforge.net)
# the 'kmer package' r1994 (http://kmer.sourceforge.net)
#
# Except as indicated otherwise, this is a 'United States Government Work',
# and is released in the public domain.
#
# File 'README.licenses' in the root directory of this distribution
# contains full conditions and disclaimers.
##

use strict;
use File::Compare;
use Cwd qw(getcwd);

my $cwd = getcwd();

# This script expects a module name on the command line, e.g.,
# 'version-update.pl canu'. This name is used is the non-git based version
# string.
#
# On release change $label to 'release', update $major and $minor. Make the
# release, then change label back to 'snapshot'. This will result in the
# released code having a version string of "$modName 1.9".

my $modName = shift @ARGV;
my $MODNAME = $modName; $MODNAME =~ tr/a-z-/A-Z_/;

my $verFile = shift @ARGV;

my $label = "snapshot"; # If not 'release' print this in the version output.
my $major = "2"; # Bump before release.
my $minor = "0"; # Bump before release.

my $branch = "master";
my $version = "v$major.$minor";

my @submodules;

my $commits = undef;
my $hash1 = undef; # This from 'git describe'
my $hash2 = undef; # This from 'git rev-list'
my $revCount = 0;
my $dirty = undef;
my $dirtya = undef;
my $dirtyc = undef;

# Required module name on the command line.

if (($modName eq "") || ($modName eq undef) || ($verFile eq undef)) {
die "usage: $0 module-name version-file.H\n";
}

# If in a git repo, we can get the actual values.

if (-d "../.git") {
$label = "snapshot";

# Count the number of changes since the last release.
open(F, "git rev-list HEAD |") or die "Failed to run 'git rev-list'.\n";
while (<F>) {
chomp;

$hash2 = $_ if (!defined($hash2));
$revCount++;
}
close(F);

# Find the commit and version we're at.
open(F, "git describe --tags --long --always --abbrev=40 |") or die "Failed to run 'git describe'.\n";
while (<F>) {
chomp;
if (m/^v(\d+)\.(.+)-(\d+)-g(.{40})$/) {
$major = $1;
$minor = $2;
$commits = $3;
$hash1 = $4;

$version = "v$major.$minor";
} else {
die "Failed to parse describe string '$_'.\n";
}
}
close(F);

# Decide if we've got locally committed changes.
open(F, "git status |");
while (<F>) {
if (m/is\s+ahead\s/) {
$dirtya = "ahead of github";
}
if (m/not\s+staged\s+for\s+commit/) {
$dirtyc = "uncommitted changes";
}
}
close(F);

if (defined($dirtya) && defined($dirtyc)) {
$dirty = "ahead of github w/changes";
}
elsif (defined($dirtya)) {
$dirty = "ahead of github";
}
elsif (defined($dirtyc)) {
$dirty = "w/changes";
}
else {
$dirty = "sync'd with github";
}


# But if we're on a branch, replace the version with the name of the branch.
open(F, "git rev-parse --abbrev-ref HEAD |");
while (<F>) {
chomp;
$branch = $_;
}

if ($branch ne "master") {
if ($branch =~ m/v(\d+)\.(\d+)/) {
$major = $1;
$minor = $2;
}

$label = "branch";
$version = $branch;
}


# Get information on any submodules here.
open(F, "git submodule status |");
while (<F>) {
if (m/^(.*)\s+(.*)\s+\((.*)\)$/) {
push @submodules, "$2 $3 $1";
}
}
close(F);
}


# If not in a git repo, we might be able to figure things out based on the directory name.

elsif ($cwd =~ m/$modName-(.{40})\/src/) {
$label = "snapshot";
$hash1 = $1;
$hash2 = $1;
}

elsif ($cwd =~ m/$modName-master\/src/) {
$label = "master-snapshot";
}


# Report what we found. This is really for the gmake output.

if (defined($commits)) {
print STDERR "Building $label $version +$commits changes (r$revCount $hash1) ($dirty)\n";
foreach my $s (@submodules) {
print STDERR " $s\n";
}
print STDERR "\n";
} else {
print STDERR "Building $label $version\n";
print STDERR "\n";
}

# Dump a new file, but don't overwrite the original.

open(F, "> ${verFile}.new") or die "Failed to open '${verFile}.new' for writing: $!\n";
print F "// Automagically generated by version_update.pl! Do not commit!\n";
print F "#define ${MODNAME}_VERSION_LABEL \"$label\"\n";
print F "#define ${MODNAME}_VERSION_MAJOR \"$major\"\n";
print F "#define ${MODNAME}_VERSION_MINOR \"$minor\"\n";
print F "#define ${MODNAME}_VERSION_COMMITS \"$commits\"\n";
print F "#define ${MODNAME}_VERSION_REVISION \"$revCount\"\n";
print F "#define ${MODNAME}_VERSION_HASH \"$hash1\"\n";
print F "\n";

if (defined($commits)) {
print F "#define ${MODNAME}_VERSION \"$modName $label $version +$commits changes (r$revCount $hash1)\\n\"\n";
} elsif (defined($hash1)) {
print F "#define ${MODNAME}_VERSION \"$modName snapshot ($hash1)\\n\"\n";
} elsif ($label =~ m/release/) {
print F "#define ${MODNAME}_VERSION \"$modName $major.$minor\\n\"\n";
} else {
print F "#define ${MODNAME}_VERSION \"$modName $label ($version)\\n\"\n";
}

if ($MODNAME ne "MERYL_UTILITY") {
print F "\n";
print F "#undef MERYL_UTILITY_VERSION\n";
print F "#define MERYL_UTILITY_VERSION ${MODNAME}_VERSION\n";
}

close(F);

# If they're the same, don't replace the original.

if (compare("${verFile}", "${verFile}.new") == 0) {
unlink "${verFile}.new";
} else {
unlink "${verFile}";
rename "${verFile}.new", "${verFile}";
}

# That's all, folks!

exit(0);

4 changes: 1 addition & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -730,9 +730,7 @@ $(foreach TGT,${ALL_TGTS},\
# A fake target, to regenerate the canu_version.H file on every build.
.PHONY: UPDATE_VERSION
UPDATE_VERSION:
@./canu_version_update.pl
AS_global.C: UPDATE_VERSION
@../scripts/version_update.pl canu utility/src/utility/version.H
# A fake target, to make the directory for the canu perl modules.
.PHONY: MAKE_DIRS
Expand Down
2 changes: 1 addition & 1 deletion src/bogart/AS_BAT_AssemblyGraph.H
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#ifndef INCLUDE_AS_BAT_ASSEMBLYGRAPH
#define INCLUDE_AS_BAT_ASSEMBLYGRAPH

#include "AS_global.H"
#include "runtime.H"
#include "AS_BAT_OverlapCache.H"
#include "AS_BAT_BestOverlapGraph.H" // For ReadEnd
#include "AS_BAT_Unitig.H" // For SeqInterval
Expand Down
2 changes: 1 addition & 1 deletion src/bogart/AS_BAT_BestOverlapGraph.H
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#ifndef INCLUDE_AS_BAT_BESTOVERLAPGRAPH
#define INCLUDE_AS_BAT_BESTOVERLAPGRAPH

#include "AS_global.H"
#include "runtime.H"

#include "AS_BAT_ReadInfo.H"
#include "AS_BAT_OverlapCache.H"
Expand Down
2 changes: 1 addition & 1 deletion src/bogart/AS_BAT_ChunkGraph.H
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#ifndef INCLUDE_AS_BAT_CHUNKGRAPH
#define INCLUDE_AS_BAT_CHUNKGRAPH

#include "AS_global.H"
#include "runtime.H"

// Returns a list of read IDs sorted by the number of reads in a BOG path
// seeded by that read.
Expand Down
2 changes: 1 addition & 1 deletion src/bogart/AS_BAT_Logging.H
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#ifndef INCLUDE_AS_BAT_LOGGING
#define INCLUDE_AS_BAT_LOGGING

#include "AS_global.H"
#include "runtime.H"
#include "files.H"

void setLogFile(char const *prefix, char const *name);
Expand Down
2 changes: 1 addition & 1 deletion src/bogart/AS_BAT_MergeOrphans.H
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#ifndef INCLUDE_AS_BAT_MERGEORPHANS
#define INCLUDE_AS_BAT_MERGEORPHANS

#include "AS_global.H"
#include "runtime.H"
#include "AS_BAT_BestOverlapGraph.H"
#include "AS_BAT_Unitig.H"

Expand Down
2 changes: 1 addition & 1 deletion src/bogart/AS_BAT_OptimizePositions.C
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* full conditions and disclaimers for each license.
*/

#include "AS_global.H"
#include "runtime.H"
#include "AS_BAT_Unitig.H"
#include "AS_BAT_ReadInfo.H"
#include "AS_BAT_BestOverlapGraph.H"
Expand Down
2 changes: 1 addition & 1 deletion src/bogart/AS_BAT_OverlapCache.H
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#ifndef INCLUDE_AS_BAT_OVERLAPCACHE
#define INCLUDE_AS_BAT_OVERLAPCACHE

#include "AS_global.H"
#include "runtime.H"
#include "ovStore.H"
#include "sqStore.H"

Expand Down
2 changes: 1 addition & 1 deletion src/bogart/AS_BAT_ReadInfo.H
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#ifndef INCLUDE_AS_BAT_READ_INFO
#define INCLUDE_AS_BAT_READ_INFO

#include "AS_global.H"
#include "runtime.H"
#include "ovStore.H"
#include "sqStore.H"

Expand Down
2 changes: 1 addition & 1 deletion src/bogart/AS_BAT_TigGraph.H
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#ifndef INCLUDE_AS_BAT_TIGGRAPH
#define INCLUDE_AS_BAT_TIGGRAPH

#include "AS_global.H"
#include "runtime.H"

#include "AS_BAT_Unitig.H"
#include "AS_BAT_TigVector.H"
Expand Down
2 changes: 1 addition & 1 deletion src/bogart/AS_BAT_TigVector.H
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#ifndef INCLUDE_AS_BAT_TIGVECTOR
#define INCLUDE_AS_BAT_TIGVECTOR

#include "AS_global.H"
#include "runtime.H"

class Unitig;

Expand Down
2 changes: 1 addition & 1 deletion src/bogart/AS_BAT_Unitig.C
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* full conditions and disclaimers for each license.
*/

#include "AS_global.H"
#include "runtime.H"
#include "AS_BAT_Unitig.H"
#include "AS_BAT_ReadInfo.H"
#include "AS_BAT_BestOverlapGraph.H"
Expand Down
2 changes: 1 addition & 1 deletion src/bogart/AS_BAT_Unitig.H
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#ifndef INCLUDE_AS_BAT_UNITIG
#define INCLUDE_AS_BAT_UNITIG

#include "AS_global.H"
#include "runtime.H"
#include "AS_BAT_TigVector.H"
#include "AS_BAT_OverlapCache.H"

Expand Down
2 changes: 1 addition & 1 deletion src/bogart/analyzeBest.C
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* full conditions and disclaimers for each license.
*/

#include "AS_global.H"
#include "runtime.H"
#include "AS_PER_seqStore.H"
#include "strings.H"

Expand Down
2 changes: 1 addition & 1 deletion src/bogart/bogart.mk
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ SOURCES := bogart.C \
AS_BAT_Unitig_AddRead.C \
AS_BAT_Unitig_PlaceReadUsingEdges.C

SRC_INCDIRS := .. ../utility ../stores
SRC_INCDIRS := .. ../utility/src/utility ../stores

TGT_LDFLAGS := -L${TARGET_DIR}/lib
TGT_LDLIBS := -lcanu
Expand Down
2 changes: 1 addition & 1 deletion src/bogus/bogus.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ TARGET := bogus
SOURCES := bogus.C \
bogusUtil.C

SRC_INCDIRS := .. ../utility ../stores
SRC_INCDIRS := .. ../utility/src/utility ../stores

TGT_LDFLAGS := -L${TARGET_DIR}/lib
TGT_LDLIBS := -lcanu
Expand Down
2 changes: 1 addition & 1 deletion src/bogus/bogusUtil.H
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#ifndef INCLUDE_BOGUSUTIL
#define INCLUDE_BOGUSUTIL

#include "AS_global.H"
#include "runtime.H"

#include "files.H"

Expand Down
2 changes: 1 addition & 1 deletion src/bogus/bogusness.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ endif
TARGET := bogusness
SOURCES := bogusness.C

SRC_INCDIRS := .. ../utility ../stores
SRC_INCDIRS := .. ../utility/src/utility ../stores

TGT_LDFLAGS := -L${TARGET_DIR}/lib
TGT_LDLIBS := -lcanu
Expand Down
2 changes: 1 addition & 1 deletion src/correction/computeGlobalScore.H
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#ifndef COMPUTEGLOBALSCORES_H
#define COMPUTEGLOBALSCORES_H

#include "AS_global.H"
#include "runtime.H"
#include "ovStore.H"

class globalScoreStats {
Expand Down
Loading

0 comments on commit 47b5074

Please sign in to comment.