-
-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support compiling to javascript and webassembly using Emscripten.
- Loading branch information
Showing
90 changed files
with
2,479 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
bitlib | ||
------ | ||
|
||
by Reuben Thomas <[email protected]> | ||
http://luaforge.net/projects/bitlib | ||
|
||
|
||
bitlib is a C library for Lua 5.1 that provides bitwise operations. It | ||
is copyright Reuben Thomas 2000-2009, and is released under the MIT | ||
license, like Lua (see http://www.lua.org/copyright.html; it's | ||
basically the same as the BSD license). There is no warranty. | ||
|
||
Please report bugs and make suggestions to the email address above, or | ||
use the LuaForge trackers. | ||
|
||
Thanks to John Passaniti for his bitwise operations library, some of | ||
whose ideas I used, to Shmuel Zeigerman for the test suite, to | ||
Thatcher Ulrich for portability fixes, and to Enrico Tassi, John | ||
Stiles and Eduardo Ochs for bug reports. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#define BITLIB_FLOAT_BITS 53 | ||
#define BITLIB_FLOAT_MAX 0xfffffffffffffL | ||
#define BITLIB_FLOAT_MIN (-0x10000000000000L) | ||
#define BITLIB_FLOAT_UMAX 0x1fffffffffffffUL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/* Bitwise operations library */ | ||
/* (c) Reuben Thomas 2000-2008 */ | ||
/* See README for license */ | ||
|
||
#include "bit_limits.h" | ||
|
||
|
||
/* FIXME: Assumes lua_Integer is ptrdiff_t */ | ||
#define LUA_INTEGER_MAX PTRDIFF_MAX | ||
#define LUA_INTEGER_MIN PTRDIFF_MIN | ||
|
||
/* FIXME: Assumes size_t is an unsigned lua_Integer */ | ||
typedef size_t lua_UInteger; | ||
#define LUA_UINTEGER_MAX SIZE_MAX | ||
|
||
|
||
/* Bit type size and limits */ | ||
|
||
#define BIT_BITS \ | ||
(CHAR_BIT * sizeof(lua_Integer) > BITLIB_FLOAT_BITS ? \ | ||
BITLIB_FLOAT_BITS : (CHAR_BIT * sizeof(lua_Integer))) | ||
|
||
/* This code may give warnings if BITLIB_FLOAT_* are too big to fit in | ||
long, but that doesn't matter since in that case they won't be | ||
used. */ | ||
#define BIT_MAX \ | ||
(CHAR_BIT * sizeof(lua_Integer) > BITLIB_FLOAT_BITS ? BITLIB_FLOAT_MAX : LUA_INTEGER_MAX) | ||
|
||
#define BIT_MIN \ | ||
(CHAR_BIT * sizeof(lua_Integer) > BITLIB_FLOAT_BITS ? BITLIB_FLOAT_MIN : LUA_INTEGER_MIN) | ||
|
||
#define BIT_UMAX \ | ||
(CHAR_BIT * sizeof(lua_Integer) > BITLIB_FLOAT_BITS ? BITLIB_FLOAT_UMAX : LUA_UINTEGER_MAX) | ||
|
||
|
||
/* Define TOBIT to get a bit value */ | ||
#ifdef BUILTIN_CAST | ||
#define | ||
#define TOBIT(L, n, res) \ | ||
((void)(res), luaL_checkinteger((L), (n))) | ||
#else | ||
#include <stdint.h> | ||
#include <math.h> | ||
|
||
/* FIXME: Assumes lua_Number fits in a double (use of fmod). */ | ||
#define TOBIT(L, n, res) \ | ||
((lua_Integer)(((res) = fmod(luaL_checknumber(L, (n)), (double)BIT_UMAX + 1.0)), \ | ||
(res) > BIT_MAX ? ((res) -= (double)BIT_UMAX, (res) -= 1) : \ | ||
((res) < BIT_MIN ? ((res) += (double)BIT_UMAX, (res) += 1) : (res)))) | ||
#endif | ||
|
||
|
||
#define BIT_TRUNCATE(i) \ | ||
((i) & BIT_UMAX) | ||
|
||
|
||
/* Operations | ||
The macros MONADIC and VARIADIC only deal with bitwise operations. | ||
LOGICAL_SHIFT truncates its left-hand operand before shifting so | ||
that any extra bits at the most-significant end are not shifted | ||
into the result. | ||
ARITHMETIC_SHIFT does not truncate its left-hand operand, so that | ||
the sign bits are not removed and right shift work properly. | ||
*/ | ||
|
||
#define MONADIC(name, op) \ | ||
static int bit_ ## name(lua_State *L) { \ | ||
lua_Number f; \ | ||
lua_pushinteger(L, BIT_TRUNCATE(op TOBIT(L, 1, f))); \ | ||
return 1; \ | ||
} | ||
|
||
#define VARIADIC(name, op) \ | ||
static int bit_ ## name(lua_State *L) { \ | ||
lua_Number f; \ | ||
int n = lua_gettop(L), i; \ | ||
lua_Integer w = TOBIT(L, 1, f); \ | ||
for (i = 2; i <= n; i++) \ | ||
w op TOBIT(L, i, f); \ | ||
lua_pushinteger(L, BIT_TRUNCATE(w)); \ | ||
return 1; \ | ||
} | ||
|
||
#define LOGICAL_SHIFT(name, op) \ | ||
static int bit_ ## name(lua_State *L) { \ | ||
lua_Number f; \ | ||
lua_pushinteger(L, BIT_TRUNCATE(BIT_TRUNCATE((lua_UInteger)TOBIT(L, 1, f)) op \ | ||
(unsigned)luaL_checknumber(L, 2))); \ | ||
return 1; \ | ||
} | ||
|
||
#define ARITHMETIC_SHIFT(name, op) \ | ||
static int bit_ ## name(lua_State *L) { \ | ||
lua_Number f; \ | ||
lua_pushinteger(L, BIT_TRUNCATE((lua_Integer)TOBIT(L, 1, f) op \ | ||
(unsigned)luaL_checknumber(L, 2))); \ | ||
return 1; \ | ||
} | ||
|
||
MONADIC(cast, +) | ||
MONADIC(bnot, ~) | ||
VARIADIC(band, &=) | ||
VARIADIC(bor, |=) | ||
VARIADIC(bxor, ^=) | ||
ARITHMETIC_SHIFT(lshift, <<) | ||
LOGICAL_SHIFT(rshift, >>) | ||
ARITHMETIC_SHIFT(arshift, >>) | ||
|
||
static const struct luaL_reg bitlib[] = { | ||
{"cast", bit_cast}, | ||
{"bnot", bit_bnot}, | ||
{"band", bit_band}, | ||
{"bor", bit_bor}, | ||
{"bxor", bit_bxor}, | ||
{"lshift", bit_lshift}, | ||
{"rshift", bit_rshift}, | ||
{"arshift", bit_arshift}, | ||
{NULL, NULL} | ||
}; | ||
|
||
LUALIB_API int luaopen_bit (lua_State *L) { | ||
luaL_register(L, "bit", bitlib); | ||
lua_pushnumber(L, BIT_BITS); | ||
lua_setfield(L, -2, "bits"); | ||
return 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
if(NOT VCPKG_TARGET_IS_WINDOWS) | ||
vcpkg_check_linkage(ONLY_STATIC_LIBRARY) | ||
endif() | ||
|
||
vcpkg_from_github( | ||
OUT_SOURCE_PATH SOURCE_PATH | ||
REPO abseil/abseil-cpp | ||
REF "${VERSION}" | ||
SHA512 bd2cca8f007f2eee66f51c95a979371622b850ceb2ce3608d00ba826f7c494a1da0fba3c1427728f2c173fe50d59b701da35c2c9fdad2752a5a49746b1c8ef31 | ||
HEAD_REF master | ||
PATCHES | ||
use_pthread.patch | ||
) | ||
|
||
# With ABSL_PROPAGATE_CXX_STD=ON abseil automatically detect if it is being | ||
# compiled with C++14 or C++17, and modifies the installed `absl/base/options.h` | ||
# header accordingly. This works even if CMAKE_CXX_STANDARD is not set. Abseil | ||
# uses the compiler default behavior to update `absl/base/options.h` as needed. | ||
set(ABSL_USE_CXX17_OPTION "") | ||
if("cxx17" IN_LIST FEATURES) | ||
set(ABSL_USE_CXX17_OPTION "-DCMAKE_CXX_STANDARD=17") | ||
endif() | ||
|
||
set(ABSL_STATIC_RUNTIME_OPTION "") | ||
if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_CRT_LINKAGE STREQUAL "static") | ||
set(ABSL_STATIC_RUNTIME_OPTION "-DABSL_MSVC_STATIC_RUNTIME=ON") | ||
endif() | ||
|
||
vcpkg_cmake_configure( | ||
SOURCE_PATH "${SOURCE_PATH}" | ||
DISABLE_PARALLEL_CONFIGURE | ||
OPTIONS | ||
-DABSL_PROPAGATE_CXX_STD=ON | ||
${ABSL_USE_CXX17_OPTION} | ||
${ABSL_STATIC_RUNTIME_OPTION} | ||
) | ||
|
||
vcpkg_cmake_install() | ||
vcpkg_cmake_config_fixup(PACKAGE_NAME absl CONFIG_PATH lib/cmake/absl) | ||
vcpkg_fixup_pkgconfig() | ||
|
||
vcpkg_copy_pdbs() | ||
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share" | ||
"${CURRENT_PACKAGES_DIR}/debug/include" | ||
"${CURRENT_PACKAGES_DIR}/include/absl/copts" | ||
"${CURRENT_PACKAGES_DIR}/include/absl/strings/testdata" | ||
"${CURRENT_PACKAGES_DIR}/include/absl/time/internal/cctz/testdata" | ||
) | ||
|
||
if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") | ||
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/absl/base/config.h" "defined(ABSL_CONSUME_DLL)" "1") | ||
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/absl/base/internal/thread_identity.h" "defined(ABSL_CONSUME_DLL)" "1") | ||
endif() | ||
|
||
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 7c82b3a..48474ec 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -27,6 +27,8 @@ project(absl LANGUAGES CXX VERSION 20240722) | ||
set(ABSL_SOVERSION "2407.0.0") | ||
include(CTest) | ||
|
||
+add_compile_options(-pthread) | ||
+ | ||
# Output directory is correct by default for most build setups. However, when | ||
# building Abseil as a DLL, it is important to have the DLL in the same | ||
# directory as the executable using it. Thus, we put all executables in a single |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "abseil", | ||
"version": "20240722.0", | ||
"description": [ | ||
"Abseil is an open-source collection of C++ library code designed to augment the C++ standard library. The Abseil library code is collected from Google's own C++ code base, has been extensively tested and used in production, and is the same code we depend on in our daily coding lives.", | ||
"In some cases, Abseil provides pieces missing from the C++ standard; in others, Abseil provides alternatives to the standard for special needs we've found through usage in the Google code base. We denote those cases clearly within the library code we provide you.", | ||
"Abseil is not meant to be a competitor to the standard library; we've just found that many of these utilities serve a purpose within our code base, and we now want to provide those resources to the C++ community as a whole." | ||
], | ||
"homepage": "https://github.com/abseil/abseil-cpp", | ||
"license": "Apache-2.0", | ||
"dependencies": [ | ||
{ | ||
"name": "vcpkg-cmake", | ||
"host": true | ||
}, | ||
{ | ||
"name": "vcpkg-cmake-config", | ||
"host": true | ||
} | ||
], | ||
"features": { | ||
"cxx17": { | ||
"description": "Enable compiler C++17." | ||
} | ||
}, | ||
"builtin-baseline":"c82f74667287d3dc386bce81e44964370c91a289" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
vcpkg_minimum_required(VERSION 2022-10-12) # for ${VERSION} | ||
vcpkg_from_github( | ||
OUT_SOURCE_PATH SOURCE_PATH | ||
REPO icculus/physfs | ||
REF "release-${VERSION}" | ||
SHA512 e0d84d6ac6bd8f0973149a5add54ed5ed890b5fabb4592ba61b59a3b3e01c05e05f1754f18d7a1c8d72e68777a23cda0c50dc0512cf57a8310a950bf908f54b1 | ||
PATCHES | ||
use_pthread.patch | ||
) | ||
|
||
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" PHYSFS_STATIC) | ||
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" PHYSFS_SHARED) | ||
|
||
set(generator_param "") | ||
if(VCPKG_TARGET_IS_UWP) | ||
set(generator_param WINDOWS_USE_MSBUILD) | ||
endif() | ||
|
||
vcpkg_cmake_configure( | ||
SOURCE_PATH "${SOURCE_PATH}" | ||
${generator_param} | ||
OPTIONS | ||
-DPHYSFS_BUILD_STATIC=${PHYSFS_STATIC} | ||
-DPHYSFS_BUILD_SHARED=${PHYSFS_SHARED} | ||
-DPHYSFS_BUILD_TEST=OFF | ||
-DPHYSFS_BUILD_DOCS=OFF | ||
) | ||
|
||
vcpkg_cmake_install() | ||
vcpkg_copy_pdbs() | ||
|
||
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/PhysFS) | ||
vcpkg_fixup_pkgconfig() | ||
|
||
if(PHYSFS_STATIC) | ||
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/physfs.h" "defined(PHYSFS_STATIC)" "1") | ||
else() | ||
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/physfs.h" "dllexport" "dllimport") | ||
endif() | ||
|
||
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") | ||
|
||
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") | ||
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") | ||
file(INSTALL "${SOURCE_PATH}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
physfs provides CMake targets: | ||
|
||
find_package(PhysFS CONFIG REQUIRED) | ||
target_link_libraries(main PRIVATE $<IF:$<TARGET_EXISTS:PhysFS::PhysFS>,PhysFS::PhysFS,PhysFS::PhysFS-static>) | ||
|
||
physfs is compatible with built-in CMake targets: | ||
|
||
find_package(PhysFS REQUIRED) | ||
target_include_directories(main PRIVATE ${PHYSFS_INCLUDE_DIR}) | ||
target_link_libraries(main PRIVATE ${PHYSFS_LIBRARY}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index b3291cc..a5d8225 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -25,6 +25,8 @@ set(PHYSFS_CPP_SRCS) | ||
|
||
# I hate that they define "WIN32" ... we're about to move to Win64...I hope! | ||
|
||
+add_compile_options(-pthread) | ||
+ | ||
if(APPLE) | ||
set(OTHER_LDFLAGS ${OTHER_LDFLAGS} "-framework IOKit -framework Foundation") | ||
list(APPEND PHYSFS_M_SRCS src/physfs_platform_apple.m) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
find_library(PHYSFS_LIBRARY_RELEASE NAMES physfs physfs-static NAMES_PER_DIR PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib" NO_DEFAULT_PATH) | ||
find_library(PHYSFS_LIBRARY_DEBUG NAMES physfs physfs-static NAMES_PER_DIR PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib" NO_DEFAULT_PATH) | ||
include(SelectLibraryConfigurations) | ||
select_library_configurations(PHYSFS) | ||
unset(PHYSFS_FOUND) | ||
_find_package(${ARGS}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "physfs", | ||
"version-semver": "3.2.0", | ||
"port-version": 1, | ||
"description": "a library to provide abstract access to various archives", | ||
"homepage": "https://icculus.org/physfs/", | ||
"license": "Zlib", | ||
"dependencies": [ | ||
{ | ||
"name": "vcpkg-cmake", | ||
"host": true | ||
}, | ||
{ | ||
"name": "vcpkg-cmake-config", | ||
"host": true | ||
} | ||
], | ||
"builtin-baseline":"c82f74667287d3dc386bce81e44964370c91a289" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
diff --git a/src/google/protobuf/parse_context.h b/src/google/protobuf/parse_context.h | ||
index df12ee1ab..3eb2e56c7 100644 | ||
--- a/src/google/protobuf/parse_context.h | ||
+++ b/src/google/protobuf/parse_context.h | ||
@@ -653,7 +653,7 @@ inline const char* VarintParseSlow(const char* p, uint32_t res, uint64_t* out) { | ||
return tmp.first; | ||
} | ||
|
||
-#ifdef __aarch64__ | ||
+#if defined(__aarch64__) && !defined(_MSC_VER) | ||
// Generally, speaking, the ARM-optimized Varint decode algorithm is to extract | ||
// and concatenate all potentially valid data bits, compute the actual length | ||
// of the Varint, and mask off the data bits which are not actually part of the | ||
@@ -883,7 +883,7 @@ static const char* VarintParseSlowArm(const char* p, uint64_t* out, | ||
|
||
template <typename T> | ||
PROTOBUF_NODISCARD const char* VarintParse(const char* p, T* out) { | ||
-#if defined(__aarch64__) && defined(PROTOBUF_LITTLE_ENDIAN) | ||
+#if defined(__aarch64__) && defined(PROTOBUF_LITTLE_ENDIAN) && !defined(_MSC_VER) | ||
// This optimization is not supported in big endian mode | ||
uint64_t first8; | ||
std::memcpy(&first8, p, sizeof(first8)); |
Oops, something went wrong.