diff --git a/.bazelrc b/.bazelrc deleted file mode 100644 index e3263ef..0000000 --- a/.bazelrc +++ /dev/null @@ -1,14 +0,0 @@ -# https://github.com/bazelbuild/bazel/issues/9451 -# ideally we want this, but it doesn't work... -# build --cxxopt=-fno-canonical-system-headers -# as a work around we use `sed` to "fix" the *.d files. - -build --crosstool_top=//toolchain:emscripten - -# Use --cpu as a differentiator. -build --cpu=wasm32 - -# Use the default Bazel C++ toolchain to build the tools used during the -# build. - -build --host_crosstool_top=@bazel_tools//tools/cpp:toolchain diff --git a/BUILD b/BUILD index f5b8ec3..5b2730e 100644 --- a/BUILD +++ b/BUILD @@ -13,6 +13,7 @@ cc_library( "proxy_wasm_api.h", "proxy_wasm_externs.h", ], + copts = ["-std=c++17"], deps = [ ":common_lib", "@com_google_protobuf//:protobuf_lite", @@ -25,6 +26,7 @@ cc_library( "proxy_wasm_common.h", "proxy_wasm_enums.h", ], + copts = ["-std=c++17"], ) cc_library( @@ -39,6 +41,7 @@ cc_library( "proxy_wasm_externs.h", "proxy_wasm_intrinsics.h", ], + copts = ["-std=c++17"], visibility = ["//visibility:public"], ) @@ -62,7 +65,8 @@ proto_library( cc_library( name = "proxy_wasm_intrinsics_lite", hdrs = ["proxy_wasm_intrinsics_lite.h"], - copts = ["-DPROXY_WASM_PROTOBUF_LITE=1"], + copts = ["-std=c++17"], + defines = ["PROXY_WASM_PROTOBUF_LITE"], visibility = ["//visibility:public"], deps = [ ":proxy_wasm_intrinsics", @@ -75,7 +79,8 @@ cc_library( cc_library( name = "proxy_wasm_intrinsics_full", hdrs = ["proxy_wasm_intrinsics_full.h"], - copts = ["-DPROXY_WASM_PROTOBUF_FULL=1"], + copts = ["-std=c++17"], + defines = ["PROXY_WASM_PROTOBUF_FULL"], visibility = ["//visibility:public"], deps = [ ":proxy_wasm_intrinsics", diff --git a/WORKSPACE b/WORKSPACE index 3a04fb1..9818efa 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,9 +1,13 @@ workspace(name = "proxy_wasm_cpp_sdk") -load("@proxy_wasm_cpp_sdk//bazel/dep:deps.bzl", "wasm_dependencies") +load("@proxy_wasm_cpp_sdk//bazel:repositories.bzl", "proxy_wasm_cpp_host_repositories") -wasm_dependencies() +proxy_wasm_cpp_host_repositories() -load("@proxy_wasm_cpp_sdk//bazel/dep:deps_extra.bzl", "wasm_dependencies_extra") +load("@proxy_wasm_cpp_sdk//bazel:dependencies.bzl", "proxy_wasm_cpp_host_dependencies") -wasm_dependencies_extra() +proxy_wasm_cpp_host_dependencies() + +load("@proxy_wasm_cpp_sdk//bazel:dependencies_extra.bzl", "proxy_wasm_cpp_host_dependencies_extra") + +proxy_wasm_cpp_host_dependencies_extra() diff --git a/bazel/dep/BUILD b/bazel/BUILD similarity index 100% rename from bazel/dep/BUILD rename to bazel/BUILD diff --git a/bazel/defs.bzl b/bazel/defs.bzl new file mode 100644 index 0000000..2e20a86 --- /dev/null +++ b/bazel/defs.bzl @@ -0,0 +1,116 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("@emsdk//emscripten_toolchain:wasm_rules.bzl", "wasm_cc_binary") +load("@rules_cc//cc:defs.bzl", "cc_binary") + +def _optimized_wasm_cc_binary_transition_impl(settings, attr): + # TODO(PiotrSikora): Add -flto to copts/linkopts when fixed in emsdk. + # See: https://github.com/emscripten-core/emsdk/issues/971 + return { + "//command_line_option:copt": ["-O3"], + "//command_line_option:cxxopt": [], + "//command_line_option:linkopt": [], + "//command_line_option:collect_code_coverage": False, + } + +_optimized_wasm_cc_binary_transition = transition( + implementation = _optimized_wasm_cc_binary_transition_impl, + inputs = [], + outputs = [ + "//command_line_option:copt", + "//command_line_option:cxxopt", + "//command_line_option:linkopt", + "//command_line_option:collect_code_coverage", + ], +) + +def _optimized_wasm_cc_binary_impl(ctx): + input_binary = ctx.attr.wasm_cc_target[0][DefaultInfo].files_to_run.executable + input_runfiles = ctx.attr.wasm_cc_target[0][DefaultInfo].default_runfiles + copied_binary = ctx.actions.declare_file(ctx.attr.name) + + ctx.actions.run( + mnemonic = "CopyFile", + executable = "cp", + arguments = [input_binary.path, copied_binary.path], + inputs = [input_binary], + outputs = [copied_binary], + ) + + return DefaultInfo( + executable = copied_binary, + runfiles = input_runfiles, + ) + +_optimized_wasm_cc_binary = rule( + implementation = _optimized_wasm_cc_binary_impl, + attrs = { + "wasm_cc_target": attr.label( + doc = "The wasm_cc_binary to extract files from.", + cfg = _optimized_wasm_cc_binary_transition, + mandatory = True, + ), + "_allowlist_function_transition": attr.label( + default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + ), + }, + executable = True, +) + +def proxy_wasm_cc_binary( + name, + additional_linker_inputs = [], + linkopts = [], + tags = [], + deps = [], + protobuf = "", + **kwargs): + proxy_wasm_deps = ["@proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics"] + if protobuf == "lite": + proxy_wasm_deps.append("@proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics_lite") + if protobuf == "full": + proxy_wasm_deps.append("@proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics_full") + + cc_binary( + name = "proxy_wasm_" + name.rstrip(".wasm"), + additional_linker_inputs = additional_linker_inputs + [ + "@proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics_js", + ], + linkopts = linkopts + [ + "--no-entry", + "--js-library=$(location @proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics_js)", + "-sSTANDALONE_WASM", + "-sEXPORTED_FUNCTIONS=_malloc", + ], + tags = tags + [ + "manual", + ], + deps = deps + proxy_wasm_deps, + **kwargs + ) + + wasm_cc_binary( + name = "wasm_" + name, + cc_target = ":proxy_wasm_" + name.rstrip(".wasm"), + tags = tags + [ + "manual", + ], + ) + + _optimized_wasm_cc_binary( + name = name, + wasm_cc_target = ":wasm_" + name, + tags = tags, + ) diff --git a/bazel/dep/deps_extra.bzl b/bazel/dependencies.bzl similarity index 79% rename from bazel/dep/deps_extra.bzl rename to bazel/dependencies.bzl index 58bdac1..7c6b35d 100644 --- a/bazel/dep/deps_extra.bzl +++ b/bazel/dependencies.bzl @@ -13,7 +13,9 @@ # limitations under the License. load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") +load("@emsdk//:deps.bzl", emsdk_deps = "deps") -# Wasm deps that rely on a first stage of dependency loading in wasm_dependencies(). -def wasm_dependencies_extra(): +# Requires proxy_wasm_cpp_host_repositories() to be loaded first. +def proxy_wasm_cpp_host_dependencies(): protobuf_deps() + emsdk_deps() diff --git a/bazel/dependencies_extra.bzl b/bazel/dependencies_extra.bzl new file mode 100644 index 0000000..d06a884 --- /dev/null +++ b/bazel/dependencies_extra.bzl @@ -0,0 +1,19 @@ +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("@emsdk//:emscripten_deps.bzl", "emscripten_deps") + +# Requires proxy_wasm_cpp_host_dependencies() to be loaded first. +def proxy_wasm_cpp_host_dependencies_extra(): + emscripten_deps() diff --git a/bazel/dep/deps.bzl b/bazel/repositories.bzl similarity index 74% rename from bazel/dep/deps.bzl rename to bazel/repositories.bzl index 843012b..ac6205b 100644 --- a/bazel/dep/deps.bzl +++ b/bazel/repositories.bzl @@ -15,18 +15,14 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") -def wasm_dependencies(): +def proxy_wasm_cpp_host_repositories(): maybe( http_archive, - name = "emscripten_toolchain", - build_file = "@proxy_wasm_cpp_sdk//:emscripten-toolchain.BUILD", - patch_cmds = [ - "./emsdk install 3.1.7", - "./emsdk activate --embedded 3.1.7", - ], - strip_prefix = "emsdk-3.1.7", - url = "https://github.com/emscripten-core/emsdk/archive/3.1.7.tar.gz", - sha256 = "bcceced0b7cad2e08375adf74ef20fa431230abbae8766bdad268c43e34f8d03", + name = "emsdk", + sha256 = "1ca0ff918d476c55707bb99bc0452be28ac5fb8f22a9260a8aae8a38d1bc0e27", + # v3.1.7 with Bazel fixes + strip_prefix = "emsdk-0ea8f8a8707070e9a7c83fbb4a3065683bcf1799/bazel", + url = "https://github.com/emscripten-core/emsdk/archive/0ea8f8a8707070e9a7c83fbb4a3065683bcf1799.tar.gz", ) maybe( diff --git a/bazel/wasm/wasm.bzl b/bazel/wasm/wasm.bzl index 4e6870a..b8727d9 100644 --- a/bazel/wasm/wasm.bzl +++ b/bazel/wasm/wasm.bzl @@ -13,92 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@rules_cc//cc:defs.bzl", "cc_binary") - -def _wasm_cc_transition_impl(settings, attr): - return { - "//command_line_option:cpu": "wasm32", - "//command_line_option:crosstool_top": "@proxy_wasm_cpp_sdk//toolchain:emscripten", - - # Overriding copt/cxxopt/linkopt to prevent sanitizers/coverage options leak - # into Wasm build configuration - "//command_line_option:copt": [], - "//command_line_option:cxxopt": [], - "//command_line_option:linkopt": [], - "//command_line_option:collect_code_coverage": "false", - "//command_line_option:fission": "no", - } - -wasm_cc_transition = transition( - implementation = _wasm_cc_transition_impl, - inputs = [], - outputs = [ - "//command_line_option:cpu", - "//command_line_option:crosstool_top", - "//command_line_option:copt", - "//command_line_option:cxxopt", - "//command_line_option:fission", - "//command_line_option:linkopt", - "//command_line_option:collect_code_coverage", - ], -) - -def wasm_binary_impl(ctx): - out = ctx.actions.declare_file(ctx.label.name) - ctx.actions.run( - executable = "cp", - arguments = [ctx.files.binary[0].path, out.path], - outputs = [out], - inputs = ctx.files.binary, - ) - - return [DefaultInfo(files = depset([out]), runfiles = ctx.runfiles([out]))] - -def _wasm_attrs(transition): - return { - "binary": attr.label(mandatory = True, cfg = transition), - "_whitelist_function_transition": attr.label(default = "@bazel_tools//tools/whitelists/function_transition_whitelist"), - } - -# Wasm binary rule implementation. -# This copies the binary specified in binary attribute in Wasm configuration to -# target configuration, so a binary in non-Wasm configuration can depend on them. -wasm_cc_binary_rule = rule( - implementation = wasm_binary_impl, - attrs = _wasm_attrs(wasm_cc_transition), -) - def wasm_cc_binary(**kwargs): - fail("`wasm_cc_binary` is deprecated. Please use `proxy_wasm_cc_binary`.") - -def proxy_wasm_cc_binary(name, additional_linker_inputs = [], linkopts = [], tags = [], deps = [], **kwargs): - wasm_name = "_wasm_" + name - kwargs.setdefault("visibility", ["//visibility:public"]) - cc_binary( - name = wasm_name, - additional_linker_inputs = additional_linker_inputs + [ - "@proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics_js", - ], - linkopts = linkopts + [ - "--no-entry", - "--js-library=$(location @proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics_js)", - "-sSTANDALONE_WASM", - "-sEXPORTED_FUNCTIONS=_malloc", - ], - # Adding manual tag it won't be built in non-Wasm (e.g. x86_64 config) - # when an wildcard is specified, but it will be built in Wasm configuration - # when the wasm_binary below is built. - tags = tags + [ - "manual", - ], - deps = deps + [ - "@proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics", - ], - **kwargs - ) + fail("`wasm_cc_binary` is deprecated. Please use `proxy_wasm_cc_binary` from `@proxy_wasm_cpp_sdk//bazel:defs.bzl`.") - wasm_cc_binary_rule( - name = name, - binary = ":" + wasm_name, - tags = tags, - ) +def proxy_wasm_cc_binary(**kwargs): + fail("Please use `proxy_wasm_cc_binary` from `@proxy_wasm_cpp_sdk//bazel:defs.bzl`.") diff --git a/emscripten-toolchain.BUILD b/emscripten-toolchain.BUILD deleted file mode 100644 index 2aaa475..0000000 --- a/emscripten-toolchain.BUILD +++ /dev/null @@ -1,8 +0,0 @@ -licenses(["notice"]) # Apache 2 - -package(default_visibility = ["//visibility:public"]) - -filegroup( - name = "all", - srcs = glob(["**/*"]), -) diff --git a/example/BUILD b/example/BUILD index 705b1cf..ea2cc66 100644 --- a/example/BUILD +++ b/example/BUILD @@ -1,8 +1,23 @@ -load("//bazel/wasm:wasm.bzl", "proxy_wasm_cc_binary") +load("@proxy_wasm_cpp_sdk//bazel:defs.bzl", "proxy_wasm_cc_binary") licenses(["notice"]) # Apache 2 proxy_wasm_cc_binary( name = "http_wasm_example.wasm", srcs = ["http_wasm_example.cc"], + copts = ["-std=c++17"], +) + +proxy_wasm_cc_binary( + name = "http_wasm_example_with_protobuf_lite.wasm", + srcs = ["http_wasm_example.cc"], + copts = ["-std=c++17"], + protobuf = "lite", +) + +proxy_wasm_cc_binary( + name = "http_wasm_example_with_protobuf_full.wasm", + srcs = ["http_wasm_example.cc"], + copts = ["-std=c++17"], + protobuf = "full", ) diff --git a/example/http_wasm_example.cc b/example/http_wasm_example.cc index 23e6738..ca5998a 100644 --- a/example/http_wasm_example.cc +++ b/example/http_wasm_example.cc @@ -46,7 +46,17 @@ static RegisterContextFactory register_ExampleContext(CONTEXT_FACTORY(ExampleCon "my_root_id"); bool ExampleRootContext::onStart(size_t) { +#if defined(PROXY_WASM_PROTOBUF_FULL) + LOG_TRACE("onStart with protobuf (full)"); + google::protobuf::Value value; + value.set_string_value("unused"); +#elif defined(PROXY_WASM_PROTOBUF_LITE) + LOG_TRACE("onStart with protobuf (lite)"); + google::protobuf::Value value; + value.set_string_value("unused"); +#else LOG_TRACE("onStart"); +#endif return true; } diff --git a/toolchain/BUILD b/toolchain/BUILD deleted file mode 100644 index e5797d6..0000000 --- a/toolchain/BUILD +++ /dev/null @@ -1,46 +0,0 @@ -licenses(["notice"]) # Apache 2 - -package(default_visibility = ["//visibility:public"]) - -load(":cc_toolchain_config.bzl", "cc_toolchain_config") - -cc_toolchain_suite( - name = "emscripten", - toolchains = { - "wasm32": ":wasm_toolchain", - }, -) - -filegroup(name = "empty") - -filegroup( - name = "emscripten_cache_content", - srcs = glob(["tmp/emscripten_cache/**/*"]), -) - -filegroup( - name = "all", - srcs = [ - "common.sh", - "emar.sh", - "emcc.sh", - ":emscripten_cache_content", - "@emscripten_toolchain//:all", - ], -) - -cc_toolchain( - name = "wasm_toolchain", - all_files = ":all", - ar_files = ":all", - compiler_files = ":all", - dwp_files = ":empty", - linker_files = ":all", - objcopy_files = ":empty", - strip_files = ":empty", - supports_param_files = 0, - toolchain_config = ":wasm_toolchain_config", - toolchain_identifier = "wasm-toolchain", -) - -cc_toolchain_config(name = "wasm_toolchain_config") diff --git a/toolchain/cc_toolchain_config.bzl b/toolchain/cc_toolchain_config.bzl deleted file mode 100644 index f80f67a..0000000 --- a/toolchain/cc_toolchain_config.bzl +++ /dev/null @@ -1,174 +0,0 @@ -# Copyright 2019 Solo.io, Inc. -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load( - "@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", - "feature", - "flag_group", - "flag_set", - "tool_path", -) -load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") - -def _impl(ctx): - tool_paths = [ - tool_path( - name = "gcc", - path = "emcc.sh", - ), - tool_path( - name = "ld", - path = "emcc.sh", - ), - tool_path( - name = "ar", - path = "emar.sh", - ), - tool_path( - name = "cpp", - path = "/bin/false", - ), - tool_path( - name = "gcov", - path = "/bin/false", - ), - tool_path( - name = "nm", - path = "/bin/false", - ), - tool_path( - name = "objdump", - path = "/bin/false", - ), - tool_path( - name = "strip", - path = "/bin/false", - ), - ] - - toolchain_include_directories_feature = feature( - name = "toolchain_include_directories", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - ACTION_NAMES.assemble, - ACTION_NAMES.preprocess_assemble, - ACTION_NAMES.linkstamp_compile, - ACTION_NAMES.c_compile, - ACTION_NAMES.cpp_compile, - ACTION_NAMES.cpp_header_parsing, - ACTION_NAMES.cpp_module_compile, - ACTION_NAMES.cpp_module_codegen, - ACTION_NAMES.lto_backend, - ACTION_NAMES.clif_match, - ], - flag_groups = [ - flag_group( - flags = [ - "-isystem", - "external/emscripten_toolchain/upstream/emscripten/cache/sysroot/include/", - "-isystem", - "external/emscripten_toolchain/upstream/lib/clang/15.0.0/include/", - ], - ), - ], - ), - ], - ) - - cxx17_feature = feature( - name = "c++17", - enabled = True, - flag_sets = [ - flag_set( - actions = [ACTION_NAMES.cpp_compile], - flag_groups = [flag_group(flags = ["-std=c++17"])], - ), - ], - ) - - no_canonical_prefixes_feature = feature( - name = "no-canonical-prefixes", - enabled = True, - flag_sets = [ - flag_set( - actions = [ - ACTION_NAMES.c_compile, - ACTION_NAMES.cpp_compile, - ACTION_NAMES.cpp_link_executable, - ACTION_NAMES.cpp_link_dynamic_library, - ACTION_NAMES.cpp_link_nodeps_dynamic_library, - ], - flag_groups = [ - flag_group( - flags = [ - "-no-canonical-prefixes", - ], - ), - ], - ), - ], - ) - - opt_feature = feature( - name = "opt", - enabled = True, - flag_sets = [ - flag_set( - actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], - flag_groups = [ - flag_group( - flags = ["-O3", "-ffunction-sections", "-fdata-sections", "-flto"], - ), - ], - ), - flag_set( - actions = [ - ACTION_NAMES.cpp_link_dynamic_library, - ACTION_NAMES.cpp_link_nodeps_dynamic_library, - ACTION_NAMES.cpp_link_executable, - ], - flag_groups = [flag_group(flags = ["-O3", "-Wl,--gc-sections", "-flto"])], - ), - ], - ) - - return cc_common.create_cc_toolchain_config_info( - ctx = ctx, - toolchain_identifier = "wasm-toolchain", - host_system_name = "i686-unknown-linux-gnu", - target_system_name = "wasm32-unknown-emscripten", - target_cpu = "wasm", - target_libc = "unknown", - compiler = "emscripten", - abi_version = "unknown", - abi_libc_version = "unknown", - tool_paths = tool_paths, - # we don't need to use features, as emcc already adds the directories. - # we just need to include them here so that bazel doesn't complain on - # "this rule is missing dependency declarations for the following files included". - cxx_builtin_include_directories = [ - "external/emscripten_toolchain/upstream/emscripten/cache/sysroot/include/", - "external/emscripten_toolchain/upstream/lib/clang/15.0.0/include/", - ], - features = [cxx17_feature, no_canonical_prefixes_feature, opt_feature], - ) - -cc_toolchain_config = rule( - implementation = _impl, - attrs = {}, - provides = [CcToolchainConfigInfo], -) diff --git a/toolchain/common.sh b/toolchain/common.sh deleted file mode 100755 index 0ef8a0a..0000000 --- a/toolchain/common.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# Copyright 2019 Solo.io, Inc. -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# emsdk_env.sh\emcc doesn't like the bazel sandbox -# specifically, emsdk_env.sh seems to try to `cd` and `cd` back which doesn't work well -if [[ "$OSTYPE" == "linux-gnu" ]]; then -cd -P /proc/self/cwd -fi - -TOOLCHAIN_ROOT=${EXT_BUILD_ROOT:-$PWD} - -export NODE_JS='' -export EMSCRIPTEN_ROOT="${TOOLCHAIN_ROOT}/external/emscripten_toolchain" -export SPIDERMONKEY_ENGINE='' -export EM_EXCLUSIVE_CACHE_ACCESS=1 -export EMCC_SKIP_SANITY_CHECK=1 -export EMCC_WASM_BACKEND=1 - -#echo "$(pwd)/external/emscripten_toolchain/emsdk_env.sh" -#realpath "external/emscripten_toolchain/emsdk_env.sh" -pushd "${EMSCRIPTEN_ROOT}" -source "./emsdk_env.sh" -popd - - # the emscripten sdk does some path comparison, so make EM_CACHE an absolute path to make it work. -mkdir -p "${TOOLCHAIN_ROOT}/tmp/emscripten_cache" -export EM_CACHE="${TOOLCHAIN_ROOT}/tmp/emscripten_cache" -export TEMP_DIR="${TOOLCHAIN_ROOT}/tmp" diff --git a/toolchain/emar.sh b/toolchain/emar.sh deleted file mode 100755 index 44910cc..0000000 --- a/toolchain/emar.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# Copyright 2019 Solo.io, Inc. -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -euo pipefail - -. $(dirname $0)/common.sh - -emar "$@" diff --git a/toolchain/emcc.sh b/toolchain/emcc.sh deleted file mode 100755 index e927fa2..0000000 --- a/toolchain/emcc.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -# Copyright 2019 Solo.io, Inc. -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -euo pipefail - -. $(dirname $0)/common.sh - -emcc "$@" - -# clang doesn't support `-no-canonical-system-headers` so sed it -# find the .d file in the args and fix it: - -for arg in "$@" -do - if [ "${arg: -2}" == ".d" ]; then - echo Fixing $arg - sed -e 's%[^ ]*/tmp/emscripten_cache/sysroot/include/%external/emscripten_toolchain/upstream/emscripten/cache/sysroot/include/%' $arg > $arg.tmp - mv $arg.tmp $arg - sed -e 's%[^ ]*/external/emscripten_toolchain/upstream/lib/clang/%external/emscripten_toolchain/upstream/lib/clang/%' $arg > $arg.tmp - mv $arg.tmp $arg - # some zlib headers are treated as system headers - sed -e 's%[^ ]*/external/zlib/%external/zlib/%' $arg > $arg.tmp - mv $arg.tmp $arg - break - fi -done