mirror of
https://github.com/elliotnunn/BuildCubeE.git
synced 2024-06-06 06:29:26 +00:00
bug fixery
This commit is contained in:
parent
0a6338069e
commit
8829962159
133
Build
133
Build
|
@ -9,7 +9,7 @@ import time
|
||||||
import shutil
|
import shutil
|
||||||
import re
|
import re
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from subprocess import run, PIPE
|
from subprocess import run, PIPE, DEVNULL
|
||||||
from machfs import Volume
|
from machfs import Volume
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
|
@ -39,7 +39,7 @@ def extract_makefile_defines(makefile, seed={}):
|
||||||
REB = re.compile(rb'Build-date: (\d\d\d\d-\d\d-\d\d)')
|
REB = re.compile(rb'Build-date: (\d\d\d\d-\d\d-\d\d)')
|
||||||
def get_build_date(from_dir):
|
def get_build_date(from_dir):
|
||||||
try:
|
try:
|
||||||
msg = run(['git', 'rev-list', '--format=%B', '--max-count=1', 'HEAD'], cwd=from_dir, stdout=PIPE, check=True)
|
msg = run(['git', 'rev-list', '--format=%B', '--max-count=1', 'HEAD'], cwd=from_dir, stdout=PIPE, stderr=DEVNULL, check=True)
|
||||||
msg = msg.stdout
|
msg = msg.stdout
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
|
@ -129,79 +129,80 @@ try:
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
overs = []
|
overs = []
|
||||||
|
|
||||||
remaining = list(overs)
|
if overs:
|
||||||
|
remaining = list(overs)
|
||||||
|
|
||||||
overs_re = '|'.join(re.escape(x) for x in overs)
|
overs_re = '|'.join(re.escape(x) for x in overs)
|
||||||
overs_re = r'^[^#\s]*\b(Thing.lib)"?\s*ƒ\s*'.replace('Thing.lib', overs_re)
|
overs_re = r'^[^#\s]*\b(Thing.lib)"?\s*ƒ\s*'.replace('Thing.lib', overs_re)
|
||||||
overs_re = re.compile(overs_re, re.IGNORECASE)
|
|
||||||
|
|
||||||
for f in all_makefiles:
|
|
||||||
mfile = open(f).read().split('\n')
|
|
||||||
|
|
||||||
havechanged = False
|
|
||||||
newmfile = []
|
|
||||||
|
|
||||||
idx = -1
|
|
||||||
while idx + 1 < len(mfile):
|
|
||||||
idx += 1
|
|
||||||
m = overs_re.match(mfile[idx])
|
|
||||||
if m:
|
|
||||||
thefile = m.group(1)
|
|
||||||
havechanged = True
|
|
||||||
newmfile.append('# Rule replaced at build time by ' + path.basename(__file__))
|
|
||||||
remaining = [x for x in remaining if x.upper() != thefile.upper()]
|
|
||||||
|
|
||||||
srcfile = '{Sources}%s:%s' % (OVERDIR, thefile)
|
|
||||||
newmfile.append(m.group(0) + srcfile)
|
|
||||||
newmfile.append('\tDuplicate -y {Deps} {Targ}')
|
|
||||||
|
|
||||||
lastidx = idx # how many "old" lines should be commented out?
|
|
||||||
if mfile[idx].endswith('∂'):
|
|
||||||
while lastidx + 1 < len(mfile) and mfile[lastidx + 1].endswith('∂'):
|
|
||||||
lastidx += 1 # capture continuations of first line
|
|
||||||
while lastidx + 1 < len(mfile) and mfile[lastidx + 1].startswith('\t'):
|
|
||||||
lastidx += 1 # capture build lines starting with tab
|
|
||||||
|
|
||||||
while idx <= lastidx:
|
|
||||||
newmfile.append('#\t' + mfile[idx])
|
|
||||||
idx += 1
|
|
||||||
else:
|
|
||||||
newmfile.append(mfile[idx])
|
|
||||||
|
|
||||||
if havechanged:
|
|
||||||
open(f, 'w').write('\n'.join(newmfile))
|
|
||||||
|
|
||||||
if remaining: # try to find where these override files with *no build rule* should go
|
|
||||||
found_locations = {k: [] for k in remaining}
|
|
||||||
|
|
||||||
overs_re = '|'.join(re.escape(x) for x in remaining)
|
|
||||||
overs_re = r'^[^#]*"({\w+}(?:\w+:)*)(Thing.lib)"'.replace('Thing.lib', overs_re)
|
|
||||||
overs_re = re.compile(overs_re, re.IGNORECASE)
|
overs_re = re.compile(overs_re, re.IGNORECASE)
|
||||||
|
|
||||||
for f in all_makefiles:
|
for f in all_makefiles:
|
||||||
mfile = open(f).read().split('\n')
|
mfile = open(f).read().split('\n')
|
||||||
|
|
||||||
for line in mfile:
|
havechanged = False
|
||||||
m = overs_re.match(line)
|
newmfile = []
|
||||||
|
|
||||||
|
idx = -1
|
||||||
|
while idx + 1 < len(mfile):
|
||||||
|
idx += 1
|
||||||
|
m = overs_re.match(mfile[idx])
|
||||||
if m:
|
if m:
|
||||||
orig_name = next(x for x in remaining if x.upper() == m.group(2).upper())
|
thefile = m.group(1)
|
||||||
found_loc = m.group(1)+m.group(2)
|
havechanged = True
|
||||||
if found_loc.upper() not in (x.upper() for x in found_locations[orig_name]):
|
newmfile.append('# Rule replaced at build time by ' + path.basename(__file__))
|
||||||
found_locations[orig_name].append(found_loc)
|
remaining = [x for x in remaining if x.upper() != thefile.upper()]
|
||||||
|
|
||||||
for f in main_makefiles:
|
srcfile = '{Sources}%s:%s' % (OVERDIR, thefile)
|
||||||
with open(f, 'a') as fd:
|
newmfile.append(m.group(0) + srcfile)
|
||||||
fd.write('\n# Rules created at build time by %s\n' % path.basename(__file__))
|
newmfile.append('\tDuplicate -y {Deps} {Targ}')
|
||||||
for orig_name, found_locs in found_locations.items():
|
|
||||||
if len(found_locs) == 1:
|
|
||||||
remaining = [x for x in remaining if x != orig_name]
|
|
||||||
fd.write(found_locs[0])
|
|
||||||
fd.write(' ƒ {Sources}%s:%s\n' % (OVERDIR, orig_name))
|
|
||||||
fd.write('\tDuplicate -y {Deps} {Targ}\n')
|
|
||||||
|
|
||||||
diag = 'Successfully spliced: %d/%d' % (len(overs)-len(remaining), len(overs))
|
lastidx = idx # how many "old" lines should be commented out?
|
||||||
if remaining: diag += '; Failed: ' + ' '.join(remaining)
|
if mfile[idx].endswith('∂'):
|
||||||
log(diag)
|
while lastidx + 1 < len(mfile) and mfile[lastidx + 1].endswith('∂'):
|
||||||
|
lastidx += 1 # capture continuations of first line
|
||||||
|
while lastidx + 1 < len(mfile) and mfile[lastidx + 1].startswith('\t'):
|
||||||
|
lastidx += 1 # capture build lines starting with tab
|
||||||
|
|
||||||
|
while idx <= lastidx:
|
||||||
|
newmfile.append('#\t' + mfile[idx])
|
||||||
|
idx += 1
|
||||||
|
else:
|
||||||
|
newmfile.append(mfile[idx])
|
||||||
|
|
||||||
|
if havechanged:
|
||||||
|
open(f, 'w').write('\n'.join(newmfile))
|
||||||
|
|
||||||
|
if remaining: # try to find where these override files with *no build rule* should go
|
||||||
|
found_locations = {k: [] for k in remaining}
|
||||||
|
|
||||||
|
overs_re = '|'.join(re.escape(x) for x in remaining)
|
||||||
|
overs_re = r'^[^#]*"({\w+}(?:\w+:)*)(Thing.lib)"'.replace('Thing.lib', overs_re)
|
||||||
|
overs_re = re.compile(overs_re, re.IGNORECASE)
|
||||||
|
|
||||||
|
for f in all_makefiles:
|
||||||
|
mfile = open(f).read().split('\n')
|
||||||
|
|
||||||
|
for line in mfile:
|
||||||
|
m = overs_re.match(line)
|
||||||
|
if m:
|
||||||
|
orig_name = next(x for x in remaining if x.upper() == m.group(2).upper())
|
||||||
|
found_loc = m.group(1)+m.group(2)
|
||||||
|
if found_loc.upper() not in (x.upper() for x in found_locations[orig_name]):
|
||||||
|
found_locations[orig_name].append(found_loc)
|
||||||
|
|
||||||
|
for f in main_makefiles:
|
||||||
|
with open(f, 'a') as fd:
|
||||||
|
fd.write('\n# Rules created at build time by %s\n' % path.basename(__file__))
|
||||||
|
for orig_name, found_locs in found_locations.items():
|
||||||
|
if len(found_locs) == 1:
|
||||||
|
remaining = [x for x in remaining if x != orig_name]
|
||||||
|
fd.write(found_locs[0])
|
||||||
|
fd.write(' ƒ {Sources}%s:%s\n' % (OVERDIR, orig_name))
|
||||||
|
fd.write('\tDuplicate -y {Deps} {Targ}\n')
|
||||||
|
|
||||||
|
diag = 'Successfully spliced: %d/%d' % (len(overs)-len(remaining), len(overs))
|
||||||
|
if remaining: diag += '; Failed: ' + ' '.join(remaining)
|
||||||
|
log(diag)
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user