Skip to content

Instantly share code, notes, and snippets.

@tim-janik
Created September 11, 2016 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tim-janik/0957f2f7e3f640a4d997e770ce737a41 to your computer and use it in GitHub Desktop.
Save tim-janik/0957f2f7e3f640a4d997e770ce737a41 to your computer and use it in GitHub Desktop.
build_always
# -*- Mode: python; python-indent-offset: 2 -*-
project ('test always_build', 'c')
buildid_h = custom_target ('buildid.h',
output : 'buildid.h',
command : ['../mkbuildid.sh', '+"%M"'],
build_always : true)
executable ('tester', 'tester.c', buildid_h)
#!/bin/sh
set -e
BUILDID="$(date '+"%M"')"
test ! -e buildid.h ||
test "$(echo $BUILDID)" != "$(cat buildid.h)" ||
exit 0
echo $BUILDID > buildid.h
#include <stdio.h>
#include <stdint.h>
static const char *buildid =
#include "buildid.h"
;
int
main (int argc, char *argv[])
{
printf ("buildid: %s\n", buildid);
return 0;
}
// g++ -Wall -O2 -std=gnu++11 -fdiagnostics-color x.cc && ./a.out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment