Commit Graph

47 Commits

Author SHA1 Message Date
juj
a0af5d7f95 Fix windows emsdk returncode (#1623)
When `emsdk install foo` would fail on Windows, the return code would
get ignored since there were later commands in the script file.

To fix that, capture the error code from the emsdk call, and output that
as the final return code.

Also a drive-by Python path fix, which seemed to be out of date in the
.ps1 file.
2025-10-25 00:22:31 +03:00
Sam Clegg
2b10b1bfc3 Use default python in PATH for circleci windows bot. NFC (#1609)
`C:\Python312\python.exe` is already in the path by default.

We no longer need to set this special path or environment variable. In
fact this code was doing nothing since it was adding the end of the PATH
so the system python was already coming first.
2025-10-03 15:34:43 -07:00
juj
2d480a1b7c Update Node.js to LTS 22.16.0. (#1563)
This matches the minimum OS requirements set of macOS 11.0 and Windows
10:

https://github.com/nodejs/node/blob/v22.x/BUILDING.md#platform-list
2025-05-29 15:00:30 -07:00
Conrad Burchert
ed2035a3cc Bazel: Migrate to bzlmod (#1530)
This migrates the bazel integration to the new Bazel dependency system
"bzlmod". bzlmod is becoming mandatory this year (see second sentence
here: https://bazel.build/external/migration).

This is a backwards incompatible migration, directly removing the old
WORKSPACE based approach. Users will have to change how they depend on
bzlmod, however I assume pretty much every user will be happy about it,
because they are forced to use bzlmod anyway or add extra flags to
continue to build with newer Bazel versions. Given that users normally
depend on specific git commits in the old system, they won't be hit with
this until they decide to upgrade emsdk.

The basic principle here is simple: I took everything that WORKSPACE did
and searched an alternative in bzlmod. Some interesting bits:

- We have less worries about multiple versions and people depending on
emscripten multiple times in different ways. This is resolved by the new
system: Bazel first iterates through the MODULE.bazel files recursively,
then finds the minimum version needed for each module and then executes
the module extensions that define repos exactly once at that version. So
no more ifs needed to detect multiple inclusions.
- A bunch of nodejs stuff moves to MODULE.bazel, because that is how the
nodejs module works now. As their module extension gets executed only
once you need to declare everything that you could need before that in
the MODULE.bazel file. A side effect of that is that we have to make a
fake repository when emscripten doesn't have an arm64 binary for linux,
because we can't actually figure that out in MODULE.bazel, so we have to
declare that it always exists and then create one in all cases.

There is a bunch of autoformatter changes in here as well, I could try
to revert them if you prefer.

Closes #1509
2025-04-09 14:38:12 -07:00
walkingeyerobot
ce1d281ce6 Fix bazel ci (#1504)
This is a temporary fix until I can do
https://bazel.build/external/migration
2024-12-14 02:39:55 +00:00
Christian Clauss
095c488961 Python lint: Use flake8 --extend-ignore instead of --ignore (#1498) 2024-12-06 15:20:31 -08:00
Christian Clauss
ac2adfeac4 Fix typos discovered by codespell (#1496)
# https://pypi.org/project/codespell
% `codespell`
```
./emsdk.py:1459: thier ==> their
./test/test.bat:1: equivilent ==> equivalent
./test/test.py:198: Specificlly ==> Specifically
./scripts/update_bazel_workspace.py:2: revisons ==> revisions
./scripts/update_node.py:11: direcotry ==> directory
./bazel/emscripten_toolchain/BUILD.bazel:57: implictly ==> implicitly
./docker/Dockerfile:87: terninal ==> terminal
```
2024-12-06 09:26:36 -08:00
Sam Clegg
d63e0d425a Don't install java when installing windows sdk (#1324)
We use the native version of closure compiler these days so we don't
need to install java on windows IIUC.

See https://github.com/emscripten-core/emscripten/pull/20919
2024-10-29 14:07:17 -07:00
juj
1e2f1a239e Update Node from 18.20.3 LTS to 20.18.0 in precompiled releases. (#1476)
Update Node from 18.20.3 LTS to 20.18.0 in precompiled releases. This
does have an effect of retroactively updating Node version also to old
releases, but this is expected to be fine.
2024-10-19 00:48:45 +03:00
juj
53249b91e7 Remove old unused node.js versions from manifest. (#1467) 2024-10-17 20:41:30 +03:00
Michael Allwright
82d41a76d3 [Bazel] Support generating a secondary cache (#1405)
This is a working solution for generating a separate Emscripten cache.
Note that this requires an additional entry in the workspace as follows:
```starlark
load("@emsdk//:emscripten_cache.bzl", emsdk_emscripten_cache = "emscripten_cache")
emsdk_emscripten_cache()
```
When used like this, the default Emscripten cache will be used. However,
if the entry is as follows:
```starlark
load("@emsdk//:emscripten_cache.bzl", emsdk_emscripten_cache = "emscripten_cache")
emsdk_emscripten_cache(flags = ["--lto"])
```
Then embuilder will be called to build all system libraries and ports
(i.e., the `ALL` option to embuilder) with the LTO option enabled. This
can take awhile, so I have also made possible to specify which libraries
you want to build explicitly:
```starlark
load("@emsdk//:emscripten_cache.bzl", emsdk_emscripten_cache = "emscripten_cache")
emsdk_emscripten_cache(
    flags = ["--lto"],
    libraries = [
        "crtbegin",
        "libprintf_long_double-debug",
        "libstubs-debug",
        "libnoexit",
        "libc-debug",
        "libdlmalloc",
        "libcompiler_rt",
        "libc++-noexcept",
        "libc++abi-debug-noexcept",
        "libsockets"
    ]
)
```

Resolves #807, resolves #971, resolves #1099, resolves #1362, resolves
#1401
2024-07-01 09:23:07 -07:00
Derek Schuff
4b9e83d629 Remove Intel mac CircleCI configuration (#1409)
Also switch bazel-mac to the arm64 config.
The CircleCI Intel mac config will be turned down soon.
2024-06-20 16:16:05 -07:00
Ezekiel Warren
ad59642673 fix(bazel): use param file for compile (#1373)
* fixes issues on windows when dealing with many dependencies causing a
  'command line too long' error
2024-04-22 14:19:11 -04:00
Sam Clegg
ccd111fb1f Prefer curl for downloading files over urllib (#1355)
This is especially important on macOS where `urllib` can fail to
verify certificates.

See https://stackoverflow.com/questions/40684543/how-to-make-python-use-ca-certificates-from-mac-os-truststore

Fixes: #1207, #85, #1356, #1357, #1358
2024-03-14 13:19:45 -07:00
Sam Clegg
cc1b3efbd3 Error on unknown arguments passed to --activate (#1313)
See #1312
2023-12-08 10:30:37 -08:00
Derek Schuff
3391e039d6 Replace update_bazel_workspace.sh with a python script (#1271)
This script is (IMO) more readable, but the real reason for this change is that
it raises an error message when the binary package fails to download. (The shell
script silently generated a bogus hash instead, because the shell's `set -e`
builtin does not affect commands executing inside a $() context.
It seemed just as easy to rewrite the script in Python as to fix that.

This change also updates some outdated filename references.
2023-08-24 10:10:29 -07:00
Sam Clegg
4f2db9682c Rename zipfile to archive or download as appropriate. NFC (#1257) 2023-07-10 14:04:24 -07:00
Sam Clegg
c88612d6d3 Fix activated_path_skip on repeated running of emsdk_env.sh (#1250)
The first time around `node` was being correctly added to the PATH, but
the second time around this code was observing the emsdk copy of node
in the PATH and assuming it could be skipped.

Fixes: #1240
2023-06-27 16:37:22 -07:00
Sam Clegg
88ee963cba Add some basic testing of arm64 linux (#1247) 2023-06-27 13:50:25 -07:00
Derek Schuff
d7327b4850 Update node, 15.14.0 -> 16.20.0 (#1232)
This allows us to use the native ARM64 version on MacOS.
Also update the test scripts to work on ARM64 mac, and skip tests that aren't relevant.
2023-06-20 18:57:05 +00:00
Sam Clegg
dd8bbe5e82 Update node version 14.15.5 -> 15.14.0 (#829) 2023-04-11 18:17:46 +00:00
Sam Clegg
22ede2db8e Add activated_path_skip to node v14.18.2 packages (#1209)
This should have been part of #1189.  See #1183.
2023-04-10 13:54:35 -07:00
Sam Clegg
1eaaa4c5b4 Remove -upstream component of SDK names (#1166)
This name existed to distinguish the SDK from fastcomp, but as of #1165,
we no longer support fastcomp.
2023-01-13 20:11:55 -08:00
Sam Clegg
f3bb209b86 Remove fastcomp SDK and fastcomp build rules. NFC (#1165)
Folks that want to work with fastcomp will now need to use an older
checkout of emsdk.
2023-01-09 04:53:13 -08:00
Sam Clegg
3d87d5ea81 Avoid exporting EM_CONFIG for modern SDK versions (#1110)
Newer versions of emscipten, starting all the way back in 1.39.13, can
automatically locate the `.emscripten` config file that emsdk creates so
there is no need for the explicit EM_CONFIG environment variable.  Its
redundant and adds unnessary noisce/complexity.

Really, adding emcc to the PATH is all the is needed these days.

One nice thing about this change is that it allows folks to run
whichever emcc they want to and have it just work, even if they have
configured emsdk.   Without this change, if I activate emsdk and I run
`some/other/emcc` then emsdk's `EM_CONFIG` will still be present and
override the configuration embedded in `some/other/emcc`.

e.g. in the same shell, with emsdk activated, I can run both these
commands and have them both just work as expected.

```
$ emcc --version
$ /path/to/my/emcc --version
```
2022-10-06 14:13:13 -07:00
Sam Clegg
fd08e9ad24 Error (don't just warn) on unknown architecture (#935)
Also, add tests for unknown architecture and wrong bitness and
add a mechanism (`EMSDK_ARCH`) to override the architecture assumed
by emsdk.
2022-02-25 00:44:14 -05:00
Kevin Lubick
600dc4d912 Add closure example for wasm_cc_binary (#941)
* Stub out addition of closure_externs_file option in wasm_cc_binary

* WIP

* args are passed, externs cannot be found

* try location

* update tests
2022-02-17 13:16:18 -05:00
Sam Clegg
24e78812e0 Minor node version update v14.15.5 -> v14.18.2 (#953)
The newer versions of eslint require 14.17.0 or above.  This
updates our node version to the latest in the 14.XX series.

I don't expect any user-visible changes.
2022-01-09 07:43:39 -08:00
Sam Clegg
4764bfa848 Add test and remove unused args (#951)
Followup to #930: Add a tests, and remove newly-unused arguments
to unzip and untargz.
2021-12-22 16:21:07 -08:00
Ezekiel Warren
774b871eca Bazel Windows Support (#929) 2021-12-20 14:24:56 -05:00
Sam Clegg
044d620ff2 2.0.33 (#922)
I add to temporarily disable the test_binaryen_from_source test
under macOS to work around:
https://github.com/WebAssembly/binaryen/issues/4299
2021-11-01 15:30:30 -07:00
Sam Clegg
1c420fd6e5 2.0.32 (#915) 2021-10-19 17:55:27 -07:00
Kevin Lubick
40882443a1 Update build_bazel_rules_nodejs to fix closure compiles (#912)
* Update build_bazel_rules_nodejs to fix closure compiles

* Fix spacing in update_bazel_workspace.sh script

* space
2021-10-19 14:44:48 -07:00
Kevin Lubick
773e4f955d Add embind example to Bazel docs (#910)
* Add embind example to Bazel docs

* address feedback
2021-10-14 13:49:36 -04:00
Sam Clegg
6a932246db Use .json extension for emscripten-releases-tags.json. NFC (#870) 2021-08-25 17:21:40 -07:00
Sam Clegg
bb3189b941 Consistent error messages (#840) 2021-06-16 09:10:12 -07:00
Sam Clegg
c341e544a7 Error out on attempt to activate a missing tools (#838)
Previously if a tool (any part of an SDK) was not installed
we would issue a warning and continue to active without returning
non-zero.

This meant doing `emsdk install 2.0.0 && emsdk activate latest`
would appear to be work aside from the warning messages about
latest not being installed.

This is especially annoying since we dropped support for side
by side SDK installations.  The following sequence is no longer
valid and we want to make that clear by erroring out:

```
$ emsdk install 2.0.1
$ emsdk install 2.0.2
$ emsdk activate 2.0.1
```

Since 2.0.2 replaces 2.0.1 on the filesystem the active here
could fail hard rather than just warning.
2021-06-15 22:19:47 -07:00
Yulong Wang
9fca4702ac bugfix: allow to install SDK binaries alone (#834) 2021-06-08 10:57:29 -07:00
Sam Clegg
57b8067188 Improve emscripten-releases-tags.txt to support mutliple aliases (#837)
Also, improve reporting of version resolution. e.g.:

```
$ ./emsdk  install sdk-latest
Resolving SDK alias 'latest' to '2.0.23'
Resolving SDK version '2.0.23' to 'sdk-releases-upstream-77b065ace39e6ab21446e13f92897f956c80476a-64bit'
Installing SDK 'sdk-releases-upstream-77b065ace39e6ab21446e13f92897f956c80476a-64bit'..
...
```
2021-06-08 10:08:01 -07:00
Sam Clegg
33ce2bdf2c 2.0.19 (#811) 2021-05-04 15:25:01 -07:00
Sam Clegg
b4c9194d81 Unset emsdk-related environment variable from inactive tools (#801)
When we deactivate a tool we also want to remove its environment
variables.   One driver for this is that modern sdks don't set
`EM_CACHE` whereas old ones did and we want to make sure that
`EM_CACHE` gets unset when folks upgrade (and then re-set if
they downgrade).  See #797.
2021-04-29 08:43:20 -07:00
Sam Clegg
4282d5d44b Avoid setting EM_CACHE unless we really need to (#797)
This avoid polluting the global environment which makes
side-by-side installational of different emscripten version
harder.

See https://github.com/emscripten-core/emscripten/pull/13954
2021-04-26 06:29:01 -07:00
Tim Talashok
c1589b5564 Use emsdk as external bazel dependency (#766)
* Makes provided bazel rules look up @emsdk workspace instead of local workspace
* Uses system-specific emscripten binaries instead of defaulting to linux
* Provides macros for loading emsdk dependencies (nodejs and emscripten binaries)
* Unhardcodes paths in bazel rules and .sh wrappers
* `update_bazel_workspace.sh` now updates `revisions.bzl`
* `emscripten_deps()` can be fed with specific emscripten version
* Adds external usage test

Addresses #650 and #696
2021-03-24 16:50:44 -07:00
Alon Zakai
fdda8524ce Simplify the notation for installing by hash to just emsdk install HASH (#767)
Previously this had to be

emsdk install sdk-releases-upstream-HASH

The only thing preventing using just the hash was that there was no
default for the backend, so defaulting to upstream fixes this. And then
we can do

emsdk install HASH
2021-03-22 14:07:34 -07:00
Sam Clegg
d342821195 Skip npm step if node_modules already exists (#640)
See https://github.com/WebAssembly/waterfall/pull/670
2021-03-09 16:56:27 -08:00
Sam Clegg
226b548c31 Rename binaryen-master to binaryen-main (#746)
This matches the branch name that was already updated/renamed.
2021-03-08 08:33:25 -08:00
Sam Clegg
7d155f8424 Move tests to "test" directory. NFC. (#745) 2021-03-08 08:03:07 -08:00