Add minimal emscripten build support (#7954)

This commit is contained in:
Gyeongjae Choi 2022-05-30 15:11:40 +09:00 committed by GitHub
parent 7a039e03fe
commit cc6d57aa0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -43,8 +43,7 @@ def find_lib_path() -> List[str]:
# directory here # directory here
dll_path.append(os.path.join(curr_path, './windows/Release/')) dll_path.append(os.path.join(curr_path, './windows/Release/'))
dll_path = [os.path.join(p, 'xgboost.dll') for p in dll_path] dll_path = [os.path.join(p, 'xgboost.dll') for p in dll_path]
elif sys.platform.startswith('linux') or sys.platform.startswith( elif sys.platform.startswith(('linux', 'freebsd', 'emscripten')):
'freebsd'):
dll_path = [os.path.join(p, 'libxgboost.so') for p in dll_path] dll_path = [os.path.join(p, 'libxgboost.so') for p in dll_path]
elif sys.platform == 'darwin': elif sys.platform == 'darwin':
dll_path = [os.path.join(p, 'libxgboost.dylib') for p in dll_path] dll_path = [os.path.join(p, 'libxgboost.dylib') for p in dll_path]

View File

@ -180,13 +180,16 @@ template class HostDeviceVector<uint64_t>; // bst_row_t
template class HostDeviceVector<uint32_t>; // bst_feature_t template class HostDeviceVector<uint32_t>; // bst_feature_t
template class HostDeviceVector<RegTree::Segment>; template class HostDeviceVector<RegTree::Segment>;
#if defined(__APPLE__) #if defined(__APPLE__) || defined(__EMSCRIPTEN__)
/* /*
* On OSX: * On OSX:
* *
* typedef unsigned int uint32_t; * typedef unsigned int uint32_t;
* typedef unsigned long long uint64_t; * typedef unsigned long long uint64_t;
* typedef unsigned long __darwin_size_t; * typedef unsigned long __darwin_size_t;
*
* On Emscripten:
* typedef unsigned long size_t;
*/ */
template class HostDeviceVector<std::size_t>; template class HostDeviceVector<std::size_t>;
#endif // defined(__APPLE__) #endif // defined(__APPLE__)