Skip to content

Commit

Permalink
Maintenance: build improvements (#213)
Browse files Browse the repository at this point in the history
Automatically generating Xcode JSONs
  • Loading branch information
Shchvova authored Dec 19, 2020
1 parent 4eb601c commit d460035
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 37 deletions.
51 changes: 14 additions & 37 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,39 +40,6 @@ jobs:
name: SourceCode
path: ./output

Xcode-template-matrix-old:
strategy:
matrix:
xcode:
- Xcode_11.3.1
target:
- template
platform:
- iphone
needs: source-code
runs-on: macos-10.15
env:
DEVELOPER_DIR: /Applications/${{ matrix.xcode }}.app/Contents/Developer
TEMPLATE_TARGET: ${{ matrix.target }}
steps:
- name: Get processed code
uses: actions/download-artifact@v1
with:
name: SourceCode
- name: Unpack source code
run: tar -xzf SourceCode/corona.tgz
- run: ./tools/GHAction/daily_env.sh
- name: Build templates
working-directory: ./platform/${{ matrix.platform }}
run: ./gh_build_templates.sh
env:
CERT_PASSWORD: ${{ secrets.CertPassword }}
- name: Upload templates
uses: actions/upload-artifact@v1
with:
name: Templates-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.target }}
path: ./output

Xcode-template-matrix:
strategy:
matrix:
Expand All @@ -85,11 +52,16 @@ jobs:
platform:
- iphone
- tvos
include:
- xcode: Xcode_11.3.1
target: template
platform: iphone
needs: source-code
runs-on: macos-10.15
env:
DEVELOPER_DIR: /Applications/${{ matrix.xcode }}.app/Contents/Developer
TEMPLATE_TARGET: ${{ matrix.target }}
TEMPLATE_PLATFORM: ${{ matrix.platform }}
steps:
- name: Get processed code
uses: actions/download-artifact@v1
Expand All @@ -103,6 +75,8 @@ jobs:
run: ./gh_build_templates.sh
env:
CERT_PASSWORD: ${{ secrets.CertPassword }}
- name: Build templates JSON spec
run: ./tools/GHAction/generate_xcode_json.py
- name: Upload templates
uses: actions/upload-artifact@v1
with:
Expand All @@ -112,17 +86,18 @@ jobs:
collect-ios-templates:
needs:
- Xcode-template-matrix
- Xcode-template-matrix-old
runs-on: ubuntu-20.04
steps:
- uses: actions/download-artifact@v2
- name: Collect templates together
run: |
mkdir -p output
mkdir -p output/iostemplate
for D in Templates-*
do
mv -v "$D/"* output/
mv -v "$D/"*.tar.bz output/iostemplate
done
- name: Generate template JSON
run: find Templates-* -name '*_*-SDKs.json' -exec ./tools/GHAction/aggregate_xcode_jsons.py output {} \+
- name: Upload templates
uses: actions/upload-artifact@v1
with:
Expand Down Expand Up @@ -281,12 +256,14 @@ jobs:
- name: Unpack source code
run: tar -xzf SourceCode/corona.tgz
- run: ./tools/GHAction/daily_env.sh
- name: Check for macOS min supported version
run: exit $( echo $(cat platform/mac/AppDelegate.mm | perl -ne 'print for /kosVersionCurrent = @"([0-9.]+)"/') ' < ' $(/usr/bin/xcrun --sdk macosx --show-sdk-version) | bc )
- name: Get collected templates
uses: actions/download-artifact@v1
with:
name: Collected-ios-templates
- name: Put collected iOS templates in place
run: cp -v Collected-ios-templates/* platform/resources/iostemplate/
run: cp -v Collected-ios-templates/* platform/resources/
- name: Get Webtemplate
uses: actions/download-artifact@v1
with:
Expand Down
27 changes: 27 additions & 0 deletions tools/GHAction/aggregate_xcode_jsons.py
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)
52 changes: 52 additions & 0 deletions tools/GHAction/generate_xcode_json.py
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)

0 comments on commit d460035

Please sign in to comment.