Skip to content

Commit

Permalink
Fixed generation of version number for scons compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
dov committed Jul 27, 2023
1 parent ed314d2 commit a582fce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
15 changes: 2 additions & 13 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ env['SBOX'] = False
env['COMMITIDSHORT'] = commit_id[0:6]
commit_id = os.popen('git rev-parse HEAD').read().replace('\n','')
commit_time = os.popen('git log --pretty=\'%ci\' -n1').read().replace('\n','')
env['GIT_COMMIT_ID'] = commit_id
env['GIT_COMMIT_TIME'] = commit_time

# Get version from configure.in
inp = open("configure.ac")
Expand All @@ -32,14 +34,6 @@ for line in inp.readlines():
break

# All purpose template filling routine
def create_version(env, target, source):
out = open(str(target[0]), "wb")
out.write(("#define VERSION \"" + env['VER'] + "\"\n"
'#define GIT_COMMIT_ID \"' + commit_id + '"\n'
'#define GIT_COMMIT_TIME \"' + commit_time + '"\n'
'#define ARCH \"' + env['ARCH'] + '"\n').encode('utf8'))
out.close()

def create_dist(env, target, source):
# Skip if this is not a git repo
if os.path.exists(".git"):
Expand Down Expand Up @@ -124,11 +118,6 @@ else:

env['VARIANT'] = variant

# Since we don't run configure when doing scons
config_target = env.Command("config.h",
[],
create_version)
env.AlwaysBuild(config_target)
env.Append(CPPPATH=[],
# Needed for our internal PCRE
CPPDEFINES=['PCRE_STATIC'],
Expand Down
4 changes: 4 additions & 0 deletions src/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ libs = env['LIBS']
cpppath = ["gtkimageviewer"] + env['CPPPATH'] + ["glib-jsonrpc/","agg"]
cppdefines = ['-DPACKAGE_DOC_DIR=\'"${PACKAGE_DOC_DIR}"\'',
'-DPACKAGE_PLUGIN_DIR=\'"${PACKAGE_PLUGIN_DIR}"\'',
'-DVERSION=\'"${VERSION}\"\'',
'-DARCH=\'"${ARCH}\"\'',
'-DGIT_COMMIT_ID=\'"${GIT_COMMIT_ID}\"\'',
'-DGIT_COMMIT_TIME=\'"${GIT_COMMIT_TIME}\"\'',
]
env.Append(CPPFLAGS=cppdefines)

Expand Down

0 comments on commit a582fce

Please sign in to comment.