Skip to content

Commit 889c151

Browse files
authored
Enable "emsdk [install|activate] latest-upstream" (#195)
This makes it possible to tell the emsdk to get "latest-upstream", which fetches the latest lkgr from there. This will probably be a common use pattern, I expect we may want to recommend users start trying out the wasm backend that way soon. This will also let us simplify this code: https://github.com/kripken/emscripten/blob/incoming/.circleci/config.yml#L334 Aside from adding the "latest-upstream" alias, this PR has * A few minor cleanups in the emsdk code. ( Minor restructuring of how we define the upstream stuff in the manifest: It seemed odd to have 3 things (clang, emscripten, binaryen) that are all coming from a single archive from the waterfall. Simpler to have just one - the archive is one big lump, there's no way to download just part of it. * Also add node 8.9.1 as a dependency of the upstream sdk, which makes things usable out of the box (node.js is the one thing not provided by the waterfall archive).
1 parent 7a0e274 commit 889c151

File tree

3 files changed

+29
-28
lines changed

3 files changed

+29
-28
lines changed

Dockerfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@ RUN mkdir -p /root/emsdk/
66
COPY . /root/emsdk/
77

88
RUN cd /root/ \
9+
&& echo "int main() {}" > hello_world.cpp \
910
&& apt-get update \
1011
&& apt-get install -y python cmake build-essential openjdk-9-jre-headless \
1112
&& /root/emsdk/emsdk install latest \
1213
&& /root/emsdk/emsdk activate latest \
1314
&& source /root/emsdk/emsdk_env.sh --build=Release \
14-
&& echo "int main() {}" > hello_world.cpp \
15-
&& emcc hello_world.cpp
15+
&& emcc hello_world.cpp \
16+
&& /root/emsdk/emsdk update-tags \
17+
&& /root/emsdk/emsdk install latest-upstream \
18+
&& /root/emsdk/emsdk activate latest-upstream \
19+
&& source /root/emsdk/emsdk_env.sh --build=Release \
20+
&& emcc hello_world.cpp -s WASM_OBJECT_FILES=1
1621

emsdk

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,9 @@ class Tool:
11421142
def __str__(self):
11431143
return self.name
11441144

1145+
def __repr__(self):
1146+
return self.name
1147+
11451148
def expand_vars(self, str):
11461149
if WINDOWS and '%MSBuildPlatformsDir%' in str:
11471150
str = str.replace('%MSBuildPlatformsDir%', find_msbuild_dir())
@@ -1524,6 +1527,13 @@ def find_latest_nightly_sdk():
15241527
else:
15251528
return find_latest_nightly_32bit_sdk()
15261529

1530+
def find_latest_upstream_sdk():
1531+
waterfall_lkgr = load_waterfall_lkgr()
1532+
if not waterfall_lkgr:
1533+
print('Failed to find an upstream lkgr')
1534+
sys.exit(1)
1535+
return 'sdk-upstream-%s-64bit' % waterfall_lkgr[0]
1536+
15271537
# Finds the best-matching python tool for use.
15281538
def find_used_python():
15291539
for t in reversed(tools): # Find newest tool first - those are always at the end of the list.
@@ -1697,10 +1707,13 @@ def download_waterfall_lkgr():
16971707

16981708
def load_waterfall_lkgr():
16991709
try:
1700-
data = json.loads(open(os.path.join('upstream', 'lkgr.json'), 'r').read())
1710+
text = open(sdk_path(os.path.join('upstream', 'lkgr.json')), 'r').read()
1711+
data = json.loads(text)
17011712
lkgr = data['build']
17021713
return [lkgr]
1703-
except:
1714+
except Exception as e:
1715+
print('Error parsing lkgr.json!')
1716+
print(str(e))
17041717
return []
17051718

17061719
def is_string(s):
@@ -1992,7 +2005,7 @@ def construct_env(tools_to_activate, permanent):
19922005
# A core variable EMSDK points to the root of Emscripten SDK directory.
19932006
env_vars_to_add += [('EMSDK', to_unix_path(emsdk_path()))]
19942007

1995-
em_config_path = os.path.normpath(os.path.join(emscripten_config_directory, '.emscripten'))
2008+
em_config_path = os.path.normpath(dot_emscripten_path())
19962009
if not 'EM_CONFIG' in os.environ or to_unix_path(os.environ['EM_CONFIG']) != to_unix_path(em_config_path):
19972010
env_vars_to_add += [('EM_CONFIG', em_config_path)]
19982011
if emscripten_config_directory == emsdk_path():
@@ -2210,6 +2223,8 @@ def main():
22102223
sys.argv[i] = str(find_latest_nightly_32bit_sdk())
22112224
elif sys.argv[i] == 'sdk-nightly-latest-64bit':
22122225
sys.argv[i] = str(find_latest_nightly_64bit_sdk())
2226+
elif sys.argv[i] == 'latest-upstream' or sys.argv[i] == 'latest-clang-upstream':
2227+
sys.argv[i] = str(find_latest_upstream_sdk())
22132228

22142229
if cmd == 'list':
22152230
print('')

emsdk_manifest.json

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -191,32 +191,13 @@
191191
"cmake_build_type": "Release"
192192
},
193193
{
194-
"id": "clang",
195-
"version": "upstream-%waterfall-lkgr%",
196-
"bitness": 64,
197-
"linux_url": "https://storage.googleapis.com/wasm-llvm/builds/linux/%waterfall-lkgr%/wasm-binaries.tbz2",
198-
"install_path": "upstream/%waterfall-lkgr%",
199-
"activated_path": "%installation_dir%",
200-
"activated_cfg": "LLVM_ROOT='%installation_dir%/bin'"
201-
},
202-
{
203-
"id": "emscripten",
194+
"id": "waterfall",
204195
"version": "upstream-%waterfall-lkgr%",
205196
"bitness": 64,
206197
"linux_url": "https://storage.googleapis.com/wasm-llvm/builds/linux/%waterfall-lkgr%/wasm-binaries.tbz2",
207198
"install_path": "upstream/%waterfall-lkgr%",
208-
"activated_path": "%installation_dir%",
209-
"activated_cfg": "EMSCRIPTEN_ROOT='%installation_dir%/emscripten'"
210-
},
211-
{
212-
"id": "binaryen",
213-
"version": "upstream-%waterfall-lkgr%",
214-
"bitness": 64,
215-
"linux_url": "https://storage.googleapis.com/wasm-llvm/builds/linux/%waterfall-lkgr%/wasm-binaries.tbz2",
216-
"install_path": "upstream/%waterfall-lkgr%",
217-
"activated_path": "%installation_dir%",
218-
"activated_cfg": "BINARYEN_ROOT='%installation_dir%'",
219-
"activated_env": "BINARYEN_ROOT=%installation_dir%"
199+
"activated_path": "%installation_dir%/emscripten",
200+
"activated_cfg": "LLVM_ROOT='%installation_dir%/bin';BINARYEN_ROOT='%installation_dir%'"
220201
},
221202
{
222203
"id": "clang",
@@ -1565,7 +1546,7 @@
15651546
{
15661547
"version": "upstream-%waterfall-lkgr%",
15671548
"bitness": 64,
1568-
"uses": ["clang-upstream-%waterfall-lkgr%-64bit", "emscripten-upstream-%waterfall-lkgr%-64bit", "binaryen-upstream-%waterfall-lkgr%-64bit"],
1549+
"uses": ["waterfall-upstream-%waterfall-lkgr%-64bit", "node-8.9.1-64bit"],
15691550
"os": "linux"
15701551
},
15711552
{

0 commit comments

Comments
 (0)