diff options
| author | Thomas Tanner <trtanner@btinternet.com> | 2015-10-13 15:24:41 +0100 |
|---|---|---|
| committer | Thomas Tanner <trtanner@btinternet.com> | 2015-10-13 15:24:41 +0100 |
| commit | ec07d3d4d9ec2245f0b23edf6746f4ae1e5dfce4 (patch) | |
| tree | 36398767aee155f703c255511bbe0e6b8c7919c4 /src/SConscript | |
| parent | 939993aefe4b0e2928835d2594713e96383c38ce (diff) | |
Updated scons build a bit to produce helpful-ish git tag for organizer.
Use r"..." strings in template file to make it easier to copy/paste paths from windows clipboard.
Changed organizer.pro to not produce strange messages if you opened it because it couldn't find a .hg directory
Diffstat (limited to 'src/SConscript')
| -rw-r--r-- | src/SConscript | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/src/SConscript b/src/SConscript index 2beec1ae..f09db093 100644 --- a/src/SConscript +++ b/src/SConscript @@ -1,6 +1,43 @@ +import ctypes
import os
import subprocess
+def resolve_name(source):
+ # Get the actual name of the file, after reparse points and symlinks are
+ # taken into account.
+ GENERIC_READ = 0x80000000
+ FILE_SHARE_READ = 0x1
+ OPEN_EXISTING = 0x3
+ FILE_FLAG_BACKUP_SEMANTICS = 0x02000000
+ handle = ctypes.windll.kernel32.CreateFileA(source,
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ None,
+ OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS,
+ None)
+ # get the target
+ FILE_NAME_NORMALIZED = 0x0
+ FILE_NAME_OPENED = 0x8
+ buff = ctypes.create_string_buffer(1024)
+ res = ctypes.windll.kernel32.GetFinalPathNameByHandleA(handle,
+ buff,
+ ctypes.sizeof(buff),
+ FILE_NAME_NORMALIZED)
+ target = buff.value
+ ctypes.windll.kernel32.CloseHandle(handle)
+ return target
+
+def search_up(path, target):
+ while True:
+ if os.path.exists(os.path.join(path, target)):
+ return True
+ npath = os.path.dirname(path)
+ if npath == path:
+ break
+ path = npath
+ return False
+
Import('qt_env')
env = qt_env.Clone()
@@ -53,7 +90,6 @@ for file in env.Glob('*.rc'): # Doing appendunique seems to throw the moc code into a tizzy
env['CPPPATH'] += [
'../archive',
-# '../boss_modified/boss-api',
'../plugins/gamefeatures',
'.', # Why is this necessary?
'${LOOTPATH}',
@@ -83,10 +119,19 @@ cpp_files = [ ]
about_env = env.Clone()
+# This is somewhat of a hack until I can work out a way of setting up a build
+# with all the repos without using millions of junction points
try:
- hgid = subprocess.check_output(['hg', 'id', '-i']).rstrip()
+ target = resolve_name(Dir('.').srcnode().abspath)
+ if search_up(target, '.hg'):
+ hgid = subprocess.check_output([env['MERCURIAL'], 'id', '-i']).rstrip()
+ elif search_up(target, '.git'):
+ hgid = subprocess.check_output([env['GIT'], '-C', target, 'describe',
+ '--tag']).rstrip()
+ else:
+ hgid = "Unknown"
except:
- hgid = 'Unknown version'
+ hgid = "Problem determining version"
# FIXME: It'd be much easier to stringify this in the source code
about_env.AppendUnique(CPPDEFINES = [ 'HGID=\\"%s\\"' % hgid ])
|
