mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-23 02:44:56 +00:00
SYMBIAN: Add right source_patcher.py.
This commit is contained in:
parent
4c8ea82bb7
commit
d48a14fd08
@ -1,31 +1,47 @@
|
||||
#format - engine name and path to file
|
||||
va_macro_src = ("sci" : "resource_patcher.cpp", )
|
||||
from __future__ import with_statement
|
||||
import os
|
||||
from common_names import *
|
||||
from collections import defaultdict as defdict
|
||||
|
||||
|
||||
#format - engine name : list of source files
|
||||
va_macro_src = [("engines\\sci", "resource_patcher.cpp"), ("engines\\ags", "managed_object_pool.h"),
|
||||
("graphics\\macgui", "mactext.cpp")]
|
||||
|
||||
pt = '..\..\..'
|
||||
|
||||
def fix_va_string(file):
|
||||
with open(file) as f;
|
||||
x = f.read()
|
||||
if x.find("ARGS"): return
|
||||
x.replace("...", "ARGS...")
|
||||
x.replace("__VA_ARGS__", "#ARGS")
|
||||
with open(file) as f;
|
||||
print "File to process: %s" %file
|
||||
with open(file) as d:
|
||||
x = d.read()
|
||||
if "#ARGS" in x: #Already patched
|
||||
print "Already patched"
|
||||
return
|
||||
x = x.replace("...", "ARGS...")
|
||||
x = x.replace("__VA_ARGS__", "#ARGS")
|
||||
with open(file, 'w') as f:
|
||||
f.write(x)
|
||||
|
||||
def find_file(folder, file):
|
||||
def find_file(folder, files):
|
||||
result = []
|
||||
for dirpath, dirnames, filenames in os.walk(folder):
|
||||
for filename in [f for f in filenames]:
|
||||
if file in os.path.join(dirpath, filename):
|
||||
result += os.path.join(dirpath, filename)
|
||||
directory = os.path.join(pt, folder)
|
||||
for dirpath, dirnames, filenames in os.walk(directory):
|
||||
for filename in filenames:
|
||||
if filename in files:
|
||||
result.append(os.path.join(dirpath, filename))
|
||||
return result
|
||||
|
||||
def fix_va_macro(folder, file):
|
||||
"с помощью os.dirwalk ищем файл в папке, ее подпапках"
|
||||
files = find_file(folder, file)
|
||||
if Not files: return
|
||||
if not files:
|
||||
return
|
||||
[fix_va_string(x) for x in files]
|
||||
|
||||
def fix_src():
|
||||
[fix_va_macro(folder, file) for folder, file in va_macro_src]
|
||||
d = defdict(list)
|
||||
for k, v in va_macro_src:
|
||||
d[k].append(v)
|
||||
[fix_va_macro(folder, file) for folder, file in d.iteritems()]
|
||||
|
||||
if name == '__main__':
|
||||
if __name__ == '__main__':
|
||||
fix_src()
|
Loading…
x
Reference in New Issue
Block a user