-
-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Maintenance: build improvements (#213)
Automatically generating Xcode JSONs
- Loading branch information
Showing
3 changed files
with
93 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env python | ||
import json | ||
import sys | ||
import os | ||
import subprocess | ||
|
||
output_dir = sys.argv[1] | ||
files = sys.argv[2:] | ||
files = [f for f in files if f.endswith('.json') and os.path.basename(f).count('_') == 1] | ||
files.sort(key=os.path.basename) | ||
|
||
out = {} | ||
def processFile(f): | ||
with open(f) as fp: | ||
obj = json.load(fp) | ||
out_file = os.path.basename(f).split('_')[1] # type: str | ||
out[out_file] = out.get(out_file, {}) | ||
for platform, entries in obj.items(): | ||
out[out_file][platform] = out[out_file].get(platform, []) | ||
out[out_file][platform].extend(entries) | ||
|
||
map(processFile, files) | ||
|
||
subprocess.check_call(['/bin/mkdir', '-p', output_dir]) | ||
for out_file, content in out.items(): | ||
with open(os.path.join(output_dir, out_file), 'w') as fp: | ||
json.dump(content, fp, indent=4, sort_keys=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env python | ||
import json | ||
import os | ||
import subprocess | ||
|
||
platform = os.environ['TEMPLATE_PLATFORM'] | ||
SDKs = {"tvos":"appletvos", "iphone":"iphoneos"} | ||
xcodeVersion = subprocess.check_output(['/usr/bin/xcrun', '--sdk', SDKs[platform],'--show-sdk-version']).strip() | ||
coronaVersion = int(float(xcodeVersion)*10000) | ||
xcode = subprocess.check_output(['/usr/bin/xcodebuild', '-version']).split('\n')[0].strip() | ||
|
||
def getCustomTemplateName(): | ||
target = os.environ['TEMPLATE_TARGET'] | ||
target = target[len('template'):] | ||
if target: | ||
return target | ||
customTemplate = getCustomTemplateName() | ||
|
||
def isBeta(): | ||
return False | ||
|
||
def getLabel(): | ||
if coronaVersion < 140000: | ||
return xcodeVersion + " (Legacy)" | ||
if customTemplate == '-angle': | ||
return xcodeVersion + " Metal" | ||
return xcodeVersion | ||
|
||
|
||
entry = { | ||
"label": getLabel(), | ||
"xcodeVersion": xcodeVersion, | ||
"failMessage": "install or xcode-select " + xcode + " to enable", | ||
"coronaVersion": coronaVersion, | ||
"beta": isBeta(), | ||
} | ||
if customTemplate: | ||
entry["customTemplate"] = customTemplate | ||
|
||
platforms = {"tvos":"tvos", "iphone":"ios"} | ||
output = { | ||
platforms[platform] : [ | ||
entry | ||
] | ||
} | ||
|
||
subprocess.check_call(['/bin/mkdir', '-p', 'output']) | ||
fileName = {"tvos":"tvOS-SDKs.json", "iphone":"iOS-SDKs.json"} | ||
ordNum = 1000000 - coronaVersion + (5 if isBeta() else 0) + (1 if customTemplate else 0) | ||
fileName = str(ordNum).zfill(7) + '_' + fileName[platform] | ||
with open(os.path.join('output', fileName), 'w') as f: | ||
json.dump(output, f, indent=4) |