@@ -69,9 +69,10 @@ def _impl(ctx):
69
69
abi_libc_version = "default"
70
70
71
71
cc_target_os = "emscripten"
72
- emscripten_version = ctx .attr .emscripten_version
73
72
74
- builtin_sysroot = "external/emscripten/emscripten/cache/sysroot"
73
+ emscripten_dir = ctx .attr .emscripten_binaries .label .workspace_root
74
+
75
+ builtin_sysroot = emscripten_dir + "/emscripten/cache/sysroot"
75
76
76
77
################################################################
77
78
# Tools
@@ -909,7 +910,7 @@ def _impl(ctx):
909
910
"-iwithsysroot" + "/include/c++/v1" ,
910
911
"-iwithsysroot" + "/include/compat" ,
911
912
"-iwithsysroot" + "/include" ,
912
- "-isystem" , "external/emscripten /lib/clang/13.0.0/include" ,
913
+ "-isystem" , emscripten_dir + " /lib/clang/13.0.0/include" ,
913
914
],
914
915
),
915
916
# Inputs and outputs
@@ -1016,6 +1017,22 @@ def _impl(ctx):
1016
1017
]
1017
1018
1018
1019
crosstool_default_env_sets = [
1020
+ # Globals
1021
+ env_set (
1022
+ actions = all_compile_actions +
1023
+ all_link_actions +
1024
+ [ACTION_NAMES .cpp_link_static_library ],
1025
+ env_entries = [
1026
+ env_entry (
1027
+ key = "EM_BIN_PATH" ,
1028
+ value = emscripten_dir ,
1029
+ ),
1030
+ env_entry (
1031
+ key = "EM_CONFIG_PATH" ,
1032
+ value = ctx .file .em_config .path ,
1033
+ ),
1034
+ ],
1035
+ ),
1019
1036
# Use llvm backend. Off by default, enabled via --features=llvm_backend
1020
1037
env_set (
1021
1038
actions = all_compile_actions +
@@ -1052,49 +1069,42 @@ def _impl(ctx):
1052
1069
features .append (crosstool_default_flags_feature )
1053
1070
1054
1071
cxx_builtin_include_directories = [
1055
- "external/emscripten /emscripten/cache/sysroot/include/c++/v1" ,
1056
- "external/emscripten /emscripten/cache/sysroot/include/compat" ,
1057
- "external/emscripten /emscripten/cache/sysroot/include" ,
1058
- "external/emscripten /lib/clang/13.0.0/include" ,
1072
+ emscripten_dir + " /emscripten/cache/sysroot/include/c++/v1" ,
1073
+ emscripten_dir + " /emscripten/cache/sysroot/include/compat" ,
1074
+ emscripten_dir + " /emscripten/cache/sysroot/include" ,
1075
+ emscripten_dir + " /lib/clang/13.0.0/include" ,
1059
1076
]
1060
1077
1061
1078
artifact_name_patterns = []
1062
1079
1063
1080
make_variables = []
1064
1081
1065
- out = ctx .actions .declare_file (ctx .label .name )
1066
- ctx .actions .write (out , "Fake executable" )
1067
- return [
1068
- cc_common .create_cc_toolchain_config_info (
1069
- ctx = ctx ,
1070
- features = features ,
1071
- action_configs = action_configs ,
1072
- artifact_name_patterns = artifact_name_patterns ,
1073
- cxx_builtin_include_directories = cxx_builtin_include_directories ,
1074
- toolchain_identifier = toolchain_identifier ,
1075
- host_system_name = host_system_name ,
1076
- target_system_name = target_system_name ,
1077
- target_cpu = target_cpu ,
1078
- target_libc = target_libc ,
1079
- compiler = compiler ,
1080
- abi_version = abi_version ,
1081
- abi_libc_version = abi_libc_version ,
1082
- tool_paths = tool_paths ,
1083
- make_variables = make_variables ,
1084
- builtin_sysroot = builtin_sysroot ,
1085
- cc_target_os = cc_target_os ,
1086
- ),
1087
- DefaultInfo (
1088
- executable = out ,
1089
- ),
1090
- ]
1082
+ return cc_common .create_cc_toolchain_config_info (
1083
+ ctx = ctx ,
1084
+ features = features ,
1085
+ action_configs = action_configs ,
1086
+ artifact_name_patterns = artifact_name_patterns ,
1087
+ cxx_builtin_include_directories = cxx_builtin_include_directories ,
1088
+ toolchain_identifier = toolchain_identifier ,
1089
+ host_system_name = host_system_name ,
1090
+ target_system_name = target_system_name ,
1091
+ target_cpu = target_cpu ,
1092
+ target_libc = target_libc ,
1093
+ compiler = compiler ,
1094
+ abi_version = abi_version ,
1095
+ abi_libc_version = abi_libc_version ,
1096
+ tool_paths = tool_paths ,
1097
+ make_variables = make_variables ,
1098
+ builtin_sysroot = builtin_sysroot ,
1099
+ cc_target_os = cc_target_os ,
1100
+ )
1091
1101
1092
1102
emscripten_cc_toolchain_config_rule = rule (
1093
1103
implementation = _impl ,
1094
1104
attrs = {
1095
1105
"cpu" : attr .string (mandatory = True , values = ["asmjs" , "wasm" ]),
1096
- "emscripten_version" : attr .string (mandatory = True ),
1106
+ "em_config" : attr .label (mandatory = True , allow_single_file = True ),
1107
+ "emscripten_binaries" : attr .label (mandatory = True ),
1097
1108
},
1098
1109
provides = [CcToolchainConfigInfo ],
1099
- executable = True ,
1100
1110
)
0 commit comments