updated cjson

This commit is contained in:
Eric 2023-07-12 13:21:37 -07:00
parent 4ff968a80b
commit ed6e73b796
No known key found for this signature in database
GPG Key ID: 89C93F0F8D6D5A98
19 changed files with 2929 additions and 1362 deletions

56
.efrocachemap generated
View File

@ -4068,26 +4068,26 @@
"build/assets/windows/Win32/ucrtbased.dll": "https://files.ballistica.net/cache/ba1/2d/ef/5335207d41b21b9823f6805997f1",
"build/assets/windows/Win32/vc_redist.x86.exe": "https://files.ballistica.net/cache/ba1/b0/8a/55e2e77623fe657bea24f223a3ae",
"build/assets/windows/Win32/vcruntime140d.dll": "https://files.ballistica.net/cache/ba1/86/5b/2af4d1e26a1a8073c89acb06e599",
"build/prefab/full/linux_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/b9/b3/2fa4ee60a830770b0fdfd27d0662",
"build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/58/5d/aafcd4e057f4048e0ab4b097b614",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/49/96/45734d046f665c33cf041c5e0751",
"build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/49/e3/e76596a602fec3be164171b678f8",
"build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/24/6c/b0e065c2d5ee684ef782e940c815",
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/af/ef/f3c900b2b76b3483ba67feab931f",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/65/9b/b420fd2a80e6293340e93bace338",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/a5/47/434af2120591774986a41e84bc1d",
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/08/48/6c1af81372a988542ff82704eb95",
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/7a/d1/cf9ef6bdf9d7c0fd99deedb54170",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/a6/30/1279e53155667db8b5c9a2bbf7d0",
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/4c/a5/6a2334a97a6c48dc04403e29274e",
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/9f/60/6159ef28401646f9e654c29e0673",
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/09/cb/4eeb647b2bb083ab7056a1231bd7",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/08/dd/37874122d5d465c62deac533b648",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/6e/fd/00e796c943776ae69971931d249b",
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/9a/e4/2fea9c0d36d3b7238eda94783b6f",
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/fc/31/d7c0f7629642530d41c4d209ecef",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/98/41/f5401e303ed81ad91d7f4022e572",
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/4f/3e/a371bc2c1946057f5053342643e0",
"build/prefab/full/linux_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/07/f3/286b2cf0e1b50530b18965cb8b80",
"build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/76/ca/9a12f8c55e4b80e3b7125864c5e8",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/55/5d/9677204cb8a81f44cdf36cbe16ed",
"build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/ed/d9/5d087b681d88ce9fbf847e2e18ac",
"build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/9f/2f/efef4e5a2e1a6faf675eba4d371a",
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/0c/8b/e07ebcb43cab26c8b7c086d364ee",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/98/a7/b52e3fc93f750bc906e13b0f73f4",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/95/f2/31a57f21956ca9db25b291d9e73f",
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/98/30/6664dbd278148938969de4340336",
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/b1/c4/acfecf05f122c2748e976d03d2a1",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/fe/19/1e894d75b761b3e5b1e352e69bb4",
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/3b/ba/086f1125c06960c1c7e5a713e1a4",
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/70/77/a779069bfaf1b77f57606e84e8c2",
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/b1/cf/fdf91926b6c70fe52f06224cae39",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/52/99/7a6bcb5ab85bf4a1d075d1c751fb",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/ec/d7/aff376d79fd0a3778b4e3cdbad0f",
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/7b/36/09f5279721eb692d7132b9217abe",
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/48/23/d3ecc696eb84836db814a0f03746",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/f7/a1/beffa3b641e5f0212eeaadbf94c0",
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/4b/ec/3fe45fb55be8d95a853536387269",
"build/prefab/lib/linux_arm64_gui/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/84/aa/534f35b6499762739646ea173382",
"build/prefab/lib/linux_arm64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/25/2f/3bd787d6debb2c4073fd6c2e8098",
"build/prefab/lib/linux_arm64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/84/aa/534f35b6499762739646ea173382",
@ -4104,14 +4104,14 @@
"build/prefab/lib/mac_x86_64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/47/61/eca0961c54b2eae2cf65fac7848d",
"build/prefab/lib/mac_x86_64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/06/5c/90c3a49e16a004e2db71909af919",
"build/prefab/lib/mac_x86_64_server/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/47/61/eca0961c54b2eae2cf65fac7848d",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/72/70/aab14b866e1c3562421a757abfeb",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/0a/df/c8bb059be642ad2a905ef2da6679",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/1d/47/3441b90233f32aca5657acc410f7",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/3d/54/f255fe1f8eced421101a4ae392bf",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/34/5d/f1544e97b2677c9ef3aef62e569e",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/9b/f7/e821d0e43e2f7a34980b6556e69d",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/07/af/60dfd76561968bee5a00d2530ba4",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/65/e9/338ef36cbefafd0f718bb42417d1",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/de/a9/add7fc92d73241fb32df336c4012",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/b5/88/dc175d964962a3fec5b604d6a5cc",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/a2/20/867922da68023be227e26d04d96c",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/ce/9d/6df11d4bb08bfbb239fcf9b1bc10",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/a0/42/96482e90951d3c141820cb413fc6",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/56/cc/980a9c4a5b0d11d5a84ab895b354",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/7a/3d/7a4a4f0bb522c2ab7912dcd3d1cc",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/47/f0/aebfc9f112aaf48b69e2dbb3b823",
"src/assets/ba_data/python/babase/_mgen/__init__.py": "https://files.ballistica.net/cache/ba1/f8/85/fed7f2ed98ff2ba271f9dbe3391c",
"src/assets/ba_data/python/babase/_mgen/enums.py": "https://files.ballistica.net/cache/ba1/f8/cd/3af311ac63147882590123b78318",
"src/ballistica/base/mgen/pyembed/binding_base.inc": "https://files.ballistica.net/cache/ba1/3e/7a/203e2a5d2b5bb42cfe3fd2fe16c2",

View File

@ -82,6 +82,7 @@
<w>aname</w>
<w>anamorphosis</w>
<w>andr</w>
<w>andrarch</w>
<w>androidaddr</w>
<w>androideabi</w>
<w>androidstudiocode</w>
@ -658,6 +659,7 @@
<w>cyaml</w>
<w>cycledelay</w>
<w>cygwinccompiler</w>
<w>dandroid</w>
<w>darwiin</w>
<w>darwiinremote</w>
<w>datab</w>
@ -743,6 +745,7 @@
<w>distro</w>
<w>distroot</w>
<w>distros</w>
<w>dlibtype</w>
<w>dline</w>
<w>dliwk</w>
<w>dlldir</w>
@ -1555,6 +1558,7 @@
<w>libegl</w>
<w>libext</w>
<w>libffi</w>
<w>libfile</w>
<w>libgen</w>
<w>libinst</w>
<w>liblzma</w>
@ -1634,6 +1638,7 @@
<w>locs</w>
<w>logcallobj</w>
<w>logcat</w>
<w>loggingpath</w>
<w>logincode</w>
<w>loginid</w>
<w>logintoken</w>
@ -1989,6 +1994,8 @@
<w>onslaughtplug</w>
<w>opcode</w>
<w>opdir</w>
<w>opealsoft</w>
<w>openalsoft</w>
<w>opendiff</w>
<w>openssh</w>
<w>operasinger</w>

View File

@ -1,5 +1,13 @@
### 1.7.22 (build 21167, api 8, 2023-07-12)
### 1.7.23 (build 21165, api 8, 2023-07-11)
- Network security improvements.
- Network security improvements. (Thanks Dliwk!)
- You can now double click a chat message to copy it (Thanks Vishal332008!)
- Android's audio library has been updated to the latest version (and is now
much easier for me to keep up to date). Please holler if you run into anything
wonky related to audio.
- Updated our C json handling code to the latest version of cJSON. Should fix
some potential vulnerabilities.
### 1.7.22 (build 21165, api 8, 2023-07-11)

View File

@ -58,6 +58,7 @@
<w>alsa</w>
<w>alsoft</w>
<w>anchorx</w>
<w>andrarch</w>
<w>androideabi</w>
<w>animcurve</w>
<w>aniso</w>
@ -396,6 +397,7 @@
<w>curv</w>
<w>cutef</w>
<w>cvar</w>
<w>dandroid</w>
<w>data</w>
<w>databytes</w>
<w>datac</w>
@ -457,6 +459,7 @@
<w>displaytime</w>
<w>displaytimer</w>
<w>dlfcn</w>
<w>dlibtype</w>
<w>dlife</w>
<w>dliwk</w>
<w>dllpath</w>
@ -913,6 +916,7 @@
<w>libballistica</w>
<w>libbz</w>
<w>libbzip</w>
<w>libfile</w>
<w>libutf</w>
<w>libuuid</w>
<w>lifecyclelog</w>
@ -934,6 +938,7 @@
<w>lockstr</w>
<w>locktype</w>
<w>logcallobj</w>
<w>loggingpath</w>
<w>logincode</w>
<w>loginid</w>
<w>logmsg</w>
@ -1177,7 +1182,9 @@
<w>ooooooooooooooooooooooooooooooooooo</w>
<w>ooooooooooooooooooooooooooooooooooooo</w>
<w>opcode</w>
<w>opealsoft</w>
<w>openal</w>
<w>openalsoft</w>
<w>opengl</w>
<w>opensl</w>
<w>oper</w>

View File

@ -28,7 +28,7 @@ if TYPE_CHECKING:
# Build number and version of the ballistica binary we expect to be
# using.
TARGET_BALLISTICA_BUILD = 21165
TARGET_BALLISTICA_BUILD = 21167
TARGET_BALLISTICA_VERSION = '1.7.22'
_g_env_config: EnvConfig | None = None

View File

@ -17,6 +17,10 @@
#include <AL/alc.h>
#endif
#if BA_OSTYPE_ANDROID
#include <AL/alext.h>
#endif
#define CHECK_AL_ERROR _check_al_error(__FILE__, __LINE__)
#if BA_DEBUG_BUILD
#define DEBUG_CHECK_AL_ERROR CHECK_AL_ERROR

View File

@ -25,9 +25,10 @@ namespace ballistica::base {
extern std::string g_rift_audio_device_name;
#endif
// FIXME: move these to platform.
extern "C" void opensl_pause_playback();
extern "C" void opensl_resume_playback();
#if BA_OSTYPE_ANDROID
LPALCDEVICEPAUSESOFT alcDevicePauseSOFT;
LPALCDEVICERESUMESOFT alcDeviceResumeSOFT;
#endif
const int kAudioProcessIntervalNormal{500};
const int kAudioProcessIntervalFade{50};
@ -41,7 +42,7 @@ struct AudioServer::Impl {
~Impl() = default;
#if BA_ENABLE_AUDIO
ALCcontext* alc_context_{};
ALCcontext* alc_context{};
#endif
};
@ -203,10 +204,21 @@ void AudioServer::OnAppStartInThread() {
"No audio devices found. Do you have speakers/headphones/etc. "
"connected?");
}
impl_->alc_context_ = alcCreateContext(device, nullptr);
BA_PRECONDITION(impl_->alc_context_);
BA_PRECONDITION(alcMakeContextCurrent(impl_->alc_context_));
impl_->alc_context = alcCreateContext(device, nullptr);
BA_PRECONDITION(impl_->alc_context);
BA_PRECONDITION(alcMakeContextCurrent(impl_->alc_context));
CHECK_AL_ERROR;
#if BA_OSTYPE_ANDROID
if (alcIsExtensionPresent(device, "ALC_SOFT_pause_device")) {
alcDevicePauseSOFT = reinterpret_cast<LPALCDEVICEPAUSESOFT>(
alcGetProcAddress(device, "alcDevicePauseSOFT"));
alcDeviceResumeSOFT = reinterpret_cast<LPALCDEVICERESUMESOFT>(
alcGetProcAddress(device, "alcDeviceResumeSOFT"));
} else {
FatalError("ALC_SOFT pause/resume functionality not found.");
}
#endif
}
ALfloat listener_pos[] = {0.0f, 0.0f, 0.0f};
@ -250,8 +262,8 @@ AudioServer::~AudioServer() {
{
ALCdevice* device;
BA_PRECONDITION_LOG(alcMakeContextCurrent(nullptr));
device = alcGetContextsDevice(impl_->alc_context_);
alcDestroyContext(impl_->alc_context_);
device = alcGetContextsDevice(impl_->alc_context);
alcDestroyContext(impl_->alc_context);
assert(alcGetError(device) == ALC_NO_ERROR);
alcCloseDevice(device);
}
@ -288,7 +300,7 @@ void AudioServer::SetPaused(bool pause) {
// On android lets tell open-sl to stop its processing.
#if BA_OSTYPE_ANDROID
opensl_pause_playback();
alcDevicePauseSOFT(alcGetContextsDevice(impl_->alc_context));
#endif // BA_OSTYPE_ANDROID
paused_ = true;
@ -304,12 +316,12 @@ void AudioServer::SetPaused(bool pause) {
// Conceptual/AudioSessionProgrammingGuide/Cookbook/
// Cookbook.html#//apple_ref/doc/uid/TP40007875-CH6-SW38
#if BA_ENABLE_AUDIO
alcMakeContextCurrent(impl_->alc_context_); // hmm is this necessary?..
alcMakeContextCurrent(impl_->alc_context); // hmm is this necessary?..
#endif
#endif
// On android lets tell openal-soft to stop processing.
#if BA_OSTYPE_ANDROID
opensl_resume_playback();
alcDeviceResumeSOFT(alcGetContextsDevice(impl_->alc_context));
#endif // BA_OSTYPE_ANDROID
paused_ = false;

View File

@ -178,7 +178,6 @@ void CoreFeatureSet::LifecycleLog(const char* msg, double offset_seconds) {
return;
}
char buffer[128];
// It's not safe to use Log until
snprintf(buffer, sizeof(buffer), "LIFE: %s @ %.3fs.", msg,
g_core->GetAppTimeSeconds() + offset_seconds);
Log(LogLevel::kInfo, buffer);

View File

@ -22,6 +22,13 @@ void CorePython::ApplyBaEnvConfig() {
g_core->platform->SetBaEnvVals(envcfg);
}
static void CheckPyInitStatus(const char* where, const PyStatus& status) {
if (PyStatus_Exception(status)) {
FatalError(std::string("Error in ") + where + ": "
+ (status.err_msg ? status.err_msg : "(nullptr err_msg)") + ".");
}
}
void CorePython::InitPython() {
assert(g_core->InMainThread());
assert(g_buildconfig.monolithic_build());
@ -49,8 +56,7 @@ void CorePython::InitPython() {
// windows-specific file encodings, etc.)
preconfig.utf8_mode = 1;
PyStatus status = Py_PreInitialize(&preconfig);
BA_PRECONDITION(!PyStatus_Exception(status));
CheckPyInitStatus("Py_PreInitialize", Py_PreInitialize(&preconfig));
// Configure as isolated if we include our own Python and as standard
// otherwise.
@ -71,12 +77,22 @@ void CorePython::InitPython() {
// In cases where we bundle Python, set up all paths explicitly.
// https://docs.python.org/3/c-api/init_config.html#path-configuration
if (g_buildconfig.contains_python_dist()) {
PyConfig_SetBytesString(&config, &config.base_exec_prefix, "");
PyConfig_SetBytesString(&config, &config.base_executable, "");
PyConfig_SetBytesString(&config, &config.base_prefix, "");
PyConfig_SetBytesString(&config, &config.exec_prefix, "");
PyConfig_SetBytesString(&config, &config.executable, "");
PyConfig_SetBytesString(&config, &config.prefix, "");
CheckPyInitStatus(
"pyconfig base_exec_prefix set",
PyConfig_SetBytesString(&config, &config.base_exec_prefix, ""));
CheckPyInitStatus(
"pyconfig base_executable set",
PyConfig_SetBytesString(&config, &config.base_executable, ""));
CheckPyInitStatus(
"pyconfig base_prefix set",
PyConfig_SetBytesString(&config, &config.base_prefix, ""));
CheckPyInitStatus(
"pyconfig exec_prefix set",
PyConfig_SetBytesString(&config, &config.exec_prefix, ""));
CheckPyInitStatus("pyconfig executable set",
PyConfig_SetBytesString(&config, &config.executable, ""));
CheckPyInitStatus("pyconfig prefix set",
PyConfig_SetBytesString(&config, &config.prefix, ""));
// Note: we're using utf-8 mode above so Py_DecodeLocale will convert
// from utf-8.
@ -121,8 +137,8 @@ void CorePython::InitPython() {
}
// Init Python.
status = Py_InitializeFromConfig(&config);
BA_PRECONDITION_FATAL(!PyStatus_Exception(status));
CheckPyInitStatus("Py_InitializeFromConfig",
Py_InitializeFromConfig(&config));
PyConfig_Clear(&config);
}

View File

@ -39,7 +39,7 @@ auto main(int argc, char** argv) -> int {
namespace ballistica {
// These are set automatically via script; don't modify them here.
const int kEngineBuildNumber = 21165;
const int kEngineBuildNumber = 21167;
const char* kEngineVersion = "1.7.22";
auto MonolithicMain(const core::CoreConfig& core_config) -> int {

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
#define BALLISTICA_SHARED_GENERIC_JSON_H_
/*
Copyright (c) 2009 Dave Gamble
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -27,152 +27,282 @@
#include "ballistica/shared/ballistica.h"
// ericf note: Changes here from vanilla cJSON:
// - Placed under ballistica namespace.
// - Removed extern "C" braces.
// - Removed CJSON_CDECL, CJSON_PUBLIC, and other visibility controls.
// - In general, just treating this like our other internal C++ source.
// - Also added a few simple C++ wrappers (see bottom of this file)
namespace ballistica {
#pragma clang diagnostic push
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
// #ifdef __cplusplus
// extern "C" {
// #endif
/* project version */
#define CJSON_VERSION_MAJOR 1
#define CJSON_VERSION_MINOR 7
#define CJSON_VERSION_PATCH 16
/* cJSON Types: */
#define cJSON_False 0u
#define cJSON_True 1u
#define cJSON_NULL 2u
#define cJSON_Number 3u
#define cJSON_String 4u
#define cJSON_Array 5u
#define cJSON_Object 6u
#define cJSON_Invalid (0)
#define cJSON_False (1 << 0)
#define cJSON_True (1 << 1)
#define cJSON_NULL (1 << 2)
#define cJSON_Number (1 << 3)
#define cJSON_String (1 << 4)
#define cJSON_Array (1 << 5)
#define cJSON_Object (1 << 6)
#define cJSON_Raw (1 << 7) /* raw json */
#define cJSON_IsReference 256u
#define cJSON_IsReference 256
#define cJSON_StringIsConst 512
/* The cJSON structure: */
typedef struct cJSON {
struct cJSON *next,
*prev; /* next/prev allow you to walk array/object chains. Alternatively,
use GetArraySize/GetArrayItem/GetObjectItem */
struct cJSON*
child; /* An array or object item will have a child pointer pointing to a
chain of the items in the array/object. */
/* next/prev allow you to walk array/object chains. Alternatively, use
* GetArraySize/GetArrayItem/GetObjectItem */
struct cJSON* next;
struct cJSON* prev;
/* An array or object item will have a child pointer pointing to a chain of
* the items in the array/object. */
struct cJSON* child;
uint32_t type; /* The type of the item, as above. */
/* The type of the item, as above. */
int type;
char* valuestring; /* The item's string, if type==cJSON_String */
int valueint; /* The item's number, if type==cJSON_Number */
double valuedouble; /* The item's number, if type==cJSON_Number */
/* The item's string, if type==cJSON_String and type == cJSON_Raw */
char* valuestring;
/* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */
int valueint;
/* The item's number, if type==cJSON_Number */
double valuedouble;
char* string; /* The item's name string, if this item is the child of, or is
in the list of subitems of an object. */
/* The item's name string, if this item is the child of, or is in the list of
* subitems of an object. */
char* string;
} cJSON;
typedef struct cJSON_Hooks {
/* malloc/free are CDECL on Windows regardless of the default calling
* convention of the compiler, so ensure the hooks allow passing those
* functions directly. */
void* (*malloc_fn)(size_t sz);
void (*free_fn)(void* ptr);
} cJSON_Hooks;
/* Supply malloc, realloc and free functions to cJSON */
extern void cJSON_InitHooks(cJSON_Hooks* hooks);
typedef int cJSON_bool;
/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse
* them. This is to prevent stack overflows. */
#ifndef CJSON_NESTING_LIMIT
#define CJSON_NESTING_LIMIT 1000
#endif
/* returns the version of cJSON as a string */
const char* cJSON_Version(void);
/* Supply malloc, realloc and free functions to cJSON */
void cJSON_InitHooks(cJSON_Hooks* hooks);
/* Memory Management: the caller is always responsible to free the results from
* all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib
* free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is
* cJSON_PrintPreallocated, where the caller has full responsibility of the
* buffer. */
/* Supply a block of JSON, and this returns a cJSON object you can interrogate.
* Call cJSON_Delete when finished. */
extern auto cJSON_Parse(const char* value) -> cJSON*;
/* Render a cJSON entity to text for transfer/storage. Free the char* when
* finished. */
extern auto cJSON_Print(cJSON* item) -> char*;
/* Render a cJSON entity to text for transfer/storage without any formatting.
* Free the char* when finished. */
extern auto cJSON_PrintUnformatted(cJSON* item) -> char*;
*/
cJSON* cJSON_Parse(const char* value);
cJSON* cJSON_ParseWithLength(const char* value, size_t buffer_length);
/* ParseWithOpts allows you to require (and check) that the JSON is null
* terminated, and to retrieve the pointer to the final byte parsed. */
/* If you supply a ptr in return_parse_end and parsing fails, then
* return_parse_end will contain a pointer to the error so will match
* cJSON_GetErrorPtr(). */
cJSON* cJSON_ParseWithOpts(const char* value, const char** return_parse_end,
cJSON_bool require_null_terminated);
cJSON* cJSON_ParseWithLengthOpts(const char* value, size_t buffer_length,
const char** return_parse_end,
cJSON_bool require_null_terminated);
/* Render a cJSON entity to text for transfer/storage. */
char* cJSON_Print(const cJSON* item);
/* Render a cJSON entity to text for transfer/storage without any formatting. */
char* cJSON_PrintUnformatted(const cJSON* item);
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess
* at the final size. guessing well reduces reallocation. fmt=0 gives
* unformatted, =1 gives formatted */
char* cJSON_PrintBuffered(const cJSON* item, int prebuffer, cJSON_bool fmt);
/* Render a cJSON entity to text using a buffer already allocated in memory with
* given length. Returns 1 on success and 0 on failure. */
/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will
* use, so to be safe allocate 5 bytes more than you actually need */
cJSON_bool cJSON_PrintPreallocated(cJSON* item, char* buffer, const int length,
const cJSON_bool format);
/* Delete a cJSON entity and all subentities. */
extern void cJSON_Delete(cJSON* c);
void cJSON_Delete(cJSON* item);
/* Returns the number of items in an array (or object). */
extern auto cJSON_GetArraySize(cJSON* array) -> int;
/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful.
*/
extern auto cJSON_GetArrayItem(cJSON* array, int item) -> cJSON*;
int cJSON_GetArraySize(const cJSON* array);
/* Retrieve item number "index" from array "array". Returns NULL if
* unsuccessful. */
cJSON* cJSON_GetArrayItem(const cJSON* array, int index);
/* Get item "string" from object. Case insensitive. */
extern auto cJSON_GetObjectItem(cJSON* object, const char* string) -> cJSON*;
cJSON* cJSON_GetObjectItem(const cJSON* const object, const char* const string);
cJSON* cJSON_GetObjectItemCaseSensitive(const cJSON* const object,
const char* const string);
cJSON_bool cJSON_HasObjectItem(const cJSON* object, const char* string);
/* For analysing failed parses. This returns a pointer to the parse error.
* You'll probably need to look a few chars back to make sense of it. Defined
* when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
extern auto cJSON_GetErrorPtr() -> const char*;
const char* cJSON_GetErrorPtr(void);
/* Check item type and return its value */
char* cJSON_GetStringValue(const cJSON* const item);
double cJSON_GetNumberValue(const cJSON* const item);
/* These functions check the type of an item */
cJSON_bool cJSON_IsInvalid(const cJSON* const item);
cJSON_bool cJSON_IsFalse(const cJSON* const item);
cJSON_bool cJSON_IsTrue(const cJSON* const item);
cJSON_bool cJSON_IsBool(const cJSON* const item);
cJSON_bool cJSON_IsNull(const cJSON* const item);
cJSON_bool cJSON_IsNumber(const cJSON* const item);
cJSON_bool cJSON_IsString(const cJSON* const item);
cJSON_bool cJSON_IsArray(const cJSON* const item);
cJSON_bool cJSON_IsObject(const cJSON* const item);
cJSON_bool cJSON_IsRaw(const cJSON* const item);
/* These calls create a cJSON item of the appropriate type. */
extern auto cJSON_CreateNull() -> cJSON*;
extern auto cJSON_CreateTrue() -> cJSON*;
extern auto cJSON_CreateFalse() -> cJSON*;
extern auto cJSON_CreateBool(int b) -> cJSON*;
extern auto cJSON_CreateNumber(double num) -> cJSON*;
extern auto cJSON_CreateString(const char* string) -> cJSON*;
extern auto cJSON_CreateArray() -> cJSON*;
extern auto cJSON_CreateObject() -> cJSON*;
cJSON* cJSON_CreateNull(void);
cJSON* cJSON_CreateTrue(void);
cJSON* cJSON_CreateFalse(void);
cJSON* cJSON_CreateBool(cJSON_bool boolean);
cJSON* cJSON_CreateNumber(double num);
cJSON* cJSON_CreateString(const char* string);
/* raw json */
cJSON* cJSON_CreateRaw(const char* raw);
cJSON* cJSON_CreateArray(void);
cJSON* cJSON_CreateObject(void);
/* These utilities create an Array of count items. */
extern auto cJSON_CreateIntArray(const int* numbers, int count) -> cJSON*;
extern auto cJSON_CreateFloatArray(const float* numbers, int count) -> cJSON*;
extern auto cJSON_CreateDoubleArray(const double* numbers, int count) -> cJSON*;
extern auto cJSON_CreateStringArray(const char** strings, int count) -> cJSON*;
/* Create a string where valuestring references a string so
* it will not be freed by cJSON_Delete */
cJSON* cJSON_CreateStringReference(const char* string);
/* Create an object/array that only references it's elements so
* they will not be freed by cJSON_Delete */
cJSON* cJSON_CreateObjectReference(const cJSON* child);
cJSON* cJSON_CreateArrayReference(const cJSON* child);
/* These utilities create an Array of count items.
* The parameter count cannot be greater than the number of elements in the
* number array, otherwise array access will be out of bounds.*/
cJSON* cJSON_CreateIntArray(const int* numbers, int count);
cJSON* cJSON_CreateFloatArray(const float* numbers, int count);
cJSON* cJSON_CreateDoubleArray(const double* numbers, int count);
cJSON* cJSON_CreateStringArray(const char* const* strings, int count);
/* Append item to the specified array/object. */
extern void cJSON_AddItemToArray(cJSON* array, cJSON* item);
extern void cJSON_AddItemToObject(cJSON* object, const char* string,
cJSON* item);
cJSON_bool cJSON_AddItemToArray(cJSON* array, cJSON* item);
cJSON_bool cJSON_AddItemToObject(cJSON* object, const char* string,
cJSON* item);
/* Use this when string is definitely const (i.e. a literal, or as good as), and
* will definitely survive the cJSON object. WARNING: When this function was
* used, make sure to always check that (item->type & cJSON_StringIsConst) is
* zero before writing to `item->string` */
cJSON_bool cJSON_AddItemToObjectCS(cJSON* object, const char* string,
cJSON* item);
/* Append reference to item to the specified array/object. Use this when you
* want to add an existing cJSON to a new cJSON, but don't want to corrupt your
* existing cJSON. */
extern void cJSON_AddItemReferenceToArray(cJSON* array, cJSON* item);
extern void cJSON_AddItemReferenceToObject(cJSON* object, const char* string,
cJSON* item);
cJSON_bool cJSON_AddItemReferenceToArray(cJSON* array, cJSON* item);
cJSON_bool cJSON_AddItemReferenceToObject(cJSON* object, const char* string,
cJSON* item);
/* Remove/Detach items from Arrays/Objects. */
extern auto cJSON_DetachItemFromArray(cJSON* array, int which) -> cJSON*;
extern void cJSON_DeleteItemFromArray(cJSON* array, int which);
extern auto cJSON_DetachItemFromObject(cJSON* object, const char* string)
-> cJSON*;
extern void cJSON_DeleteItemFromObject(cJSON* object, const char* string);
cJSON* cJSON_DetachItemViaPointer(cJSON* parent, cJSON* const item);
cJSON* cJSON_DetachItemFromArray(cJSON* array, int which);
void cJSON_DeleteItemFromArray(cJSON* array, int which);
cJSON* cJSON_DetachItemFromObject(cJSON* object, const char* string);
cJSON* cJSON_DetachItemFromObjectCaseSensitive(cJSON* object,
const char* string);
void cJSON_DeleteItemFromObject(cJSON* object, const char* string);
void cJSON_DeleteItemFromObjectCaseSensitive(cJSON* object, const char* string);
/* Update array items. */
extern void cJSON_ReplaceItemInArray(cJSON* array, int which, cJSON* newitem);
extern void cJSON_ReplaceItemInObject(cJSON* object, const char* string,
cJSON* newitem);
cJSON_bool cJSON_InsertItemInArray(
cJSON* array, int which,
cJSON* newitem); /* Shifts pre-existing items to the right. */
cJSON_bool cJSON_ReplaceItemViaPointer(cJSON* const parent, cJSON* const item,
cJSON* replacement);
cJSON_bool cJSON_ReplaceItemInArray(cJSON* array, int which, cJSON* newitem);
cJSON_bool cJSON_ReplaceItemInObject(cJSON* object, const char* string,
cJSON* newitem);
cJSON_bool cJSON_ReplaceItemInObjectCaseSensitive(cJSON* object,
const char* string,
cJSON* newitem);
/* Duplicate a cJSON item */
extern auto cJSON_Duplicate(cJSON* item, int recurse) -> cJSON*;
cJSON* cJSON_Duplicate(const cJSON* item, cJSON_bool recurse);
/* Duplicate will create a new, identical cJSON item to the one you pass, in new
memory that will need to be released. With recurse!=0, it will duplicate any
children connected to the item. The item->next and ->prev pointers are always
zero on return from Duplicate. */
* memory that will need to be released. With recurse!=0, it will duplicate any
* children connected to the item. The item->next and ->prev pointers are always
* zero on return from Duplicate. */
/* Recursively compare two cJSON items for equality. If either a or b is NULL or
* invalid, they will be considered unequal. case_sensitive determines if object
* keys are treated case sensitive (1) or case insensitive (0) */
cJSON_bool cJSON_Compare(const cJSON* const a, const cJSON* const b,
const cJSON_bool case_sensitive);
/* ParseWithOpts allows you to require (and check) that the JSON is null
* terminated, and to retrieve the pointer to the final byte parsed. */
extern auto cJSON_ParseWithOpts(const char* value,
const char** return_parse_end,
int require_null_terminated) -> cJSON*;
/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from
* strings. The input pointer json cannot point to a read-only address area,
* such as a string constant, but should point to a readable and writable
* address area. */
void cJSON_Minify(char* json);
extern void cJSON_Minify(char* json);
/* Macros for creating things quickly. */
#define cJSON_AddNullToObject(object, name) \
cJSON_AddItemToObject(object, name, cJSON_CreateNull())
#define cJSON_AddTrueToObject(object, name) \
cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
#define cJSON_AddFalseToObject(object, name) \
cJSON_AddItemToObject(object, name, cJSON_CreateFalse())
#define cJSON_AddBoolToObject(object, name, b) \
cJSON_AddItemToObject(object, name, cJSON_CreateBool(b))
#define cJSON_AddNumberToObject(object, name, n) \
cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
#define cJSON_AddStringToObject(object, name, s) \
cJSON_AddItemToObject(object, name, cJSON_CreateString(s))
/* Helper functions for creating and adding items to an object at the same time.
* They return the added item or NULL on failure. */
cJSON* cJSON_AddNullToObject(cJSON* const object, const char* const name);
cJSON* cJSON_AddTrueToObject(cJSON* const object, const char* const name);
cJSON* cJSON_AddFalseToObject(cJSON* const object, const char* const name);
cJSON* cJSON_AddBoolToObject(cJSON* const object, const char* const name,
const cJSON_bool boolean);
cJSON* cJSON_AddNumberToObject(cJSON* const object, const char* const name,
const double number);
cJSON* cJSON_AddStringToObject(cJSON* const object, const char* const name,
const char* const string);
cJSON* cJSON_AddRawToObject(cJSON* const object, const char* const name,
const char* const raw);
cJSON* cJSON_AddObjectToObject(cJSON* const object, const char* const name);
cJSON* cJSON_AddArrayToObject(cJSON* const object, const char* const name);
/* When assigning an integer value, it needs to be propagated to valuedouble
* too. */
#define cJSON_SetIntValue(object, val) \
((object) ? (object)->valueint = (object)->valuedouble = (val) : (val))
#define cJSON_SetIntValue(object, number) \
((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
/* helper for the cJSON_SetNumberValue macro */
double cJSON_SetNumberHelper(cJSON* object, double number);
#define cJSON_SetNumberValue(object, number) \
((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
/* Change the valuestring of a cJSON_String object, only takes effect when type
* of object is cJSON_String */
char* cJSON_SetValuestring(cJSON* object, const char* valuestring);
// ericf addition: c++ wrapper for this stuff.
/* If the object is not a boolean type this does nothing and returns
* cJSON_Invalid else it returns the new type*/
#define cJSON_SetBoolValue(object, boolValue) \
((object != NULL && ((object)->type & (cJSON_False | cJSON_True))) \
? (object)->type = ((object)->type & (~(cJSON_False | cJSON_True))) \
| ((boolValue) ? cJSON_True : cJSON_False) \
: cJSON_Invalid)
/* Macro for iterating over an array or object */
#define cJSON_ArrayForEach(element, array) \
for (element = (array != NULL) ? (array)->child : NULL; element != NULL; \
element = element->next)
/* malloc/free objects using the malloc/free functions that have been set with
* cJSON_InitHooks */
void* cJSON_malloc(size_t size);
void cJSON_free(void* object);
// ericf addition: simple c++ wrappers for a few things here.
// NOTE: once added to a dict/list/etc, the underlying cJSON's
// lifecycle is dependent on its parent, not this object.
@ -221,19 +351,6 @@ class JsonDict : public JsonObject {
}
};
// class JsonNumber : public JsonObject {
// public:
// JsonNumber(double val) { set_obj(cJSON_CreateNumber(val)); }
// };
// class JsonString : public JsonObject {
// public:
// JsonString(const std::string& s) { set_obj(cJSON_CreateString(s.c_str()));
// } JsonString(const char* s) { set_obj(cJSON_CreateString(s)); }
// };
#pragma clang diagnostic pop
} // namespace ballistica
#endif // BALLISTICA_SHARED_GENERIC_JSON_H_

View File

@ -14,7 +14,7 @@
with these routines reserved for higher performance on data known to be
valid.
*/
#include "utf8.h"
#include "ballistica/shared/generic/utf8.h"
#if _WIN32 || _WIN64
#include <malloc.h>

View File

@ -2,13 +2,10 @@
#
"""General functionality related to running builds."""
# pylint: disable=too-many-lines
from __future__ import annotations
import os
import sys
import datetime
import subprocess
from enum import Enum
from dataclasses import dataclass
@ -63,29 +60,6 @@ PY_REQUIREMENTS = [
PyRequirement(pipname='filelock', minversion=[3, 12, 0]),
]
# Parts of full-tests suite we only run on particular days. This runs in
# listed order so should be randomized by hand to avoid clustering
# similar tests too much.
SPARSE_TEST_BUILDS: list[list[str]] = [
['ios.pylibs.debug', 'android.pylibs.arm'],
['linux.package', 'android.pylibs.arm64'],
['windows.package', 'mac.pylibs'],
['tvos.pylibs', 'android.pylibs.x86'],
['android.pylibs.arm.debug'],
['windows.package.server'],
['ios.pylibs', 'android.pylibs.arm64.debug'],
['linux.package.server'],
['android.pylibs.x86.debug', 'mac.package'],
['mac.package.server.arm64', 'android.pylibs.x86_64'],
['windows.package.oculus'],
['mac.package.server.x86_64', 'android.pylibs.x86_64.debug'],
['mac.pylibs.debug', 'android.package'],
]
# Currently only doing sparse-tests in core; not spinoffs (whole word
# will get subbed out in spinoffs so this will evaluate to False).
DO_SPARSE_TEST_BUILDS = 'ballistica' + 'kit' == 'ballisticakit'
class PrefabTarget(Enum):
"""Types of prefab builds able to be run."""
@ -309,314 +283,6 @@ def archive_old_builds(
)
def gen_fulltest_buildfile_android() -> None:
"""Generate fulltest command list for jenkins.
(so we see nice pretty split-up build trees)
"""
# pylint: disable=too-many-branches
# Its a pretty big time-suck building all architectures for all of
# our subplatforms, so lets usually just build a single one. We'll
# rotate it though and occasionally do all 4 at once just to be
# safe.
dayoffset = datetime.datetime.now().timetuple().tm_yday
# Let's only do a full 'prod' once every two times through the loop.
# (it really should never catch anything that individual platforms
# don't)
modes = ['arm', 'arm64', 'x86', 'x86_64']
modes += modes
modes.append('prod')
# By default we cycle through build architectures for each flavor.
# However, for minor flavor with low risk of platform-dependent
# breakage we stick to a single one to keep disk space costs lower.
# (build files amount to several gigs per mode per flavor)
#
# UPDATE: Now that we have CPU time to spare, we simply always do
# 'arm64' or 'prod' depending on build type; this results in 1 or 4
# architectures worth of build files per flavor instead of 8 (prod +
# 4 singles) and keeps our daily runs identical.
lightweight_flavors = {'template', 'arcade', 'demo', 'iircade'}
lines = []
for _i, flavor in enumerate(
sorted(os.listdir('ballisticakit-android/BallisticaKit/src'))
):
if flavor == 'main' or flavor.startswith('.'):
continue
if flavor in lightweight_flavors:
mode = 'arm64'
else:
# mode = modes[(dayoffset + i) % len(modes)]
mode = 'prod'
lines.append(
'ANDROID_PLATFORM='
+ flavor
+ ' ANDROID_MODE='
+ mode
+ ' make android-cloud-build'
)
# Now add sparse tests that land on today.
if DO_SPARSE_TEST_BUILDS:
extras = SPARSE_TEST_BUILDS[dayoffset % len(SPARSE_TEST_BUILDS)]
extras = [e for e in extras if e.startswith('android.')]
cspre = 'tools/cloudshell linbeast --env ba-android-alldeps --'
# This is currently broken; turning off.
# Update: should be working again; hooray!
do_py_android = True
for extra in extras:
if extra == 'android.pylibs.arm':
if do_py_android:
lines.append(
f'{cspre} tools/pcommand' f' python_build_android arm'
)
elif extra == 'android.pylibs.arm.debug':
if do_py_android:
lines.append(
f'{cspre} tools/pcommand'
f' python_build_android_debug arm'
)
elif extra == 'android.pylibs.arm64':
if do_py_android:
lines.append(
f'{cspre} tools/pcommand python_build_android arm64'
)
elif extra == 'android.pylibs.arm64.debug':
if do_py_android:
lines.append(
f'{cspre} tools/pcommand'
f' python_build_android_debug arm64'
)
elif extra == 'android.pylibs.x86':
if do_py_android:
lines.append(
f'{cspre} tools/pcommand' f' python_build_android x86'
)
elif extra == 'android.pylibs.x86.debug':
if do_py_android:
lines.append(
f'{cspre} tools/pcommand'
f' python_build_android_debug x86'
)
elif extra == 'android.pylibs.x86_64':
if do_py_android:
lines.append(
f'{cspre} tools/pcommand'
f' python_build_android x86_64'
)
elif extra == 'android.pylibs.x86_64.debug':
if do_py_android:
lines.append(
f'{cspre} tools/pcommand'
f' python_build_android_debug x86_64'
)
elif extra == 'android.package':
lines.append('make android-package-cloud')
else:
raise RuntimeError(f'Unknown extra: {extra}')
os.makedirs('build', exist_ok=True)
with open(
'build/fulltest_buildfile_android', 'w', encoding='utf-8'
) as outfile:
outfile.write('\n'.join(lines))
def gen_fulltest_buildfile_windows() -> None:
"""Generate fulltest command list for jenkins.
(so we see nice pretty split-up build trees)
"""
dayoffset = datetime.datetime.now().timetuple().tm_yday
lines: list[str] = []
# We want to do one regular, one headless, and one oculus build, but
# let's switch up 32 or 64 bit based on the day. Also occasionally
# throw a release build in but stick to mostly debug builds to keep
# build times speedier.
pval1 = 'Win32' if dayoffset % 2 == 0 else 'x64'
pval2 = 'Win32' if (dayoffset + 1) % 2 == 0 else 'x64'
pval3 = 'Win32' if (dayoffset + 2) % 2 == 0 else 'x64'
cfg1 = 'Release' if dayoffset % 7 == 0 else 'Debug'
cfg2 = 'Release' if (dayoffset + 1) % 7 == 0 else 'Debug'
cfg3 = 'Release' if (dayoffset + 2) % 7 == 0 else 'Debug'
lines.append(
f'WINDOWS_PROJECT=Generic WINDOWS_PLATFORM={pval1} '
f'WINDOWS_CONFIGURATION={cfg1} make windows-cloud-build'
)
lines.append(
f'WINDOWS_PROJECT=Headless WINDOWS_PLATFORM={pval2} '
f'WINDOWS_CONFIGURATION={cfg2} make windows-cloud-build'
)
lines.append(
f'WINDOWS_PROJECT=Oculus WINDOWS_PLATFORM={pval3} '
f'WINDOWS_CONFIGURATION={cfg3} make windows-cloud-build'
)
# Now add sparse tests that land on today.
if DO_SPARSE_TEST_BUILDS:
extras = SPARSE_TEST_BUILDS[dayoffset % len(SPARSE_TEST_BUILDS)]
extras = [e for e in extras if e.startswith('windows.')]
for extra in extras:
if extra == 'windows.package':
lines.append('make windows-package')
elif extra == 'windows.package.server':
lines.append('make windows-server-package')
elif extra == 'windows.package.oculus':
lines.append('make windows-oculus-package')
else:
raise RuntimeError(f'Unknown extra: {extra}')
os.makedirs('build', exist_ok=True)
with open(
'build/fulltest_buildfile_windows', 'w', encoding='utf-8'
) as outfile:
outfile.write('\n'.join(lines))
def gen_fulltest_buildfile_apple() -> None:
"""Generate fulltest command list for jenkins.
(so we see nice pretty split-up build trees)
"""
# pylint: disable=too-many-branches
dayoffset = datetime.datetime.now().timetuple().tm_yday
# noinspection PyListCreation
lines = []
# pybuildapple = 'tools/pcommand python_build_apple'
pybuildapple = (
'tools/cloudshell --env tools fromini -- '
'tools/pcommand python_build_apple'
)
# iOS stuff
lines.append('make ios-cloud-build')
lines.append('make ios-new-cloud-build')
if DO_SPARSE_TEST_BUILDS:
extras = SPARSE_TEST_BUILDS[dayoffset % len(SPARSE_TEST_BUILDS)]
extras = [e for e in extras if e.startswith('ios.')]
for extra in extras:
if extra == 'ios.pylibs':
lines.append(f'{pybuildapple} ios')
elif extra == 'ios.pylibs.debug':
lines.append(f'{pybuildapple}_debug ios')
else:
raise RuntimeError(f'Unknown extra: {extra}')
# tvOS stuff
lines.append('make tvos-cloud-build')
if DO_SPARSE_TEST_BUILDS:
extras = SPARSE_TEST_BUILDS[dayoffset % len(SPARSE_TEST_BUILDS)]
extras = [e for e in extras if e.startswith('tvos.')]
for extra in extras:
if extra == 'tvos.pylibs':
lines.append(f'{pybuildapple} tvos')
elif extra == 'tvos.pylibs.debug':
lines.append(f'{pybuildapple}_debug tvos')
else:
raise RuntimeError(f'Unknown extra: {extra}')
# macOS stuff
lines.append('make mac-cloud-build')
# (throw release build in the mix to hopefully catch opt-mode-only errors).
lines.append('MAC_CONFIGURATION=Release make mac-appstore-cloud-build')
lines.append('make mac-new-cloud-build')
lines.append('CMAKE_CLOUDSHELL_HOST=fromini make cmake-cloud-server-build')
lines.append('CMAKE_CLOUDSHELL_HOST=fromini make cmake-cloud-build')
if DO_SPARSE_TEST_BUILDS:
extras = SPARSE_TEST_BUILDS[dayoffset % len(SPARSE_TEST_BUILDS)]
extras = [e for e in extras if e.startswith('mac.')]
for extra in extras:
if extra == 'mac.package':
lines.append(
'BA_MAC_DISK_IMAGE_SKIP_NOTARIZATION=1'
' make mac-package-cloud'
# 'make mac-package-cloud'
)
elif extra == 'mac.package.server.x86_64':
lines.append('make mac-server-package-x86-64')
elif extra == 'mac.package.server.arm64':
lines.append('make mac-server-package-arm64')
elif extra == 'mac.pylibs':
lines.append(f'{pybuildapple} mac')
elif extra == 'mac.pylibs.debug':
lines.append(f'{pybuildapple}_debug mac')
else:
raise RuntimeError(f'Unknown extra: {extra}')
os.makedirs('build', exist_ok=True)
with open(
'build/fulltest_buildfile_apple', 'w', encoding='utf-8'
) as outfile:
outfile.write('\n'.join(lines))
def gen_fulltest_buildfile_linux() -> None:
"""Generate fulltest command list for jenkins.
(so we see nice pretty split-up build trees)
"""
dayoffset = datetime.datetime.now().timetuple().tm_yday
targets = ['build', 'server-build']
lines = []
for target in targets:
lines.append(f'make cmake-cloud-{target}')
if DO_SPARSE_TEST_BUILDS:
extras = SPARSE_TEST_BUILDS[dayoffset % len(SPARSE_TEST_BUILDS)]
extras = [e for e in extras if e.startswith('linux.')]
for extra in extras:
if extra == 'linux.package':
lines.append('make linux-package')
elif extra == 'linux.package.server':
lines.append('make linux-server-package')
else:
raise RuntimeError(f'Unknown extra: {extra}')
os.makedirs('build', exist_ok=True)
with open(
'build/fulltest_buildfile_linux', 'w', encoding='utf-8'
) as outfile:
outfile.write('\n'.join(lines))
def gen_fulltest_buildfile_spinoff() -> None:
"""Generate fulltest command list for jenkins.
(so we see nice pretty split-up build trees)
"""
from batools.featureset import FeatureSet
# Run a spinoff test with each of our feature-sets individually.
# Note that there will likely be redundant tests with the same final
# resolved sets of feature sets. We can filter those out later if it
# seems worthwhile.
targets = sorted(f.name for f in FeatureSet.get_all_for_project('.'))
lines = []
for target in targets:
lines.append(f'SPINOFF_TEST_TARGET={target} make spinoff-test-cloud')
os.makedirs('build', exist_ok=True)
with open(
'build/fulltest_buildfile_spinoff', 'w', encoding='utf-8'
) as outfile:
outfile.write('\n'.join(lines))
def get_current_prefab_platform(wsl_gives_windows: bool = True) -> str:
"""Get an identifier for the platform running this build.

View File

@ -240,56 +240,6 @@ def printcolors() -> None:
)
def gen_fulltest_buildfile_android() -> None:
"""Generate fulltest command list for jenkins.
(so we see nice pretty split-up build trees)
"""
import batools.build
batools.build.gen_fulltest_buildfile_android()
def gen_fulltest_buildfile_windows() -> None:
"""Generate fulltest command list for jenkins.
(so we see nice pretty split-up build trees)
"""
import batools.build
batools.build.gen_fulltest_buildfile_windows()
def gen_fulltest_buildfile_apple() -> None:
"""Generate fulltest command list for jenkins.
(so we see nice pretty split-up build trees)
"""
import batools.build
batools.build.gen_fulltest_buildfile_apple()
def gen_fulltest_buildfile_linux() -> None:
"""Generate fulltest command list for jenkins.
(so we see nice pretty split-up build trees)
"""
import batools.build
batools.build.gen_fulltest_buildfile_linux()
def gen_fulltest_buildfile_spinoff() -> None:
"""Generate fulltest command list for jenkins.
(so we see nice pretty split-up build trees)
"""
import batools.build
batools.build.gen_fulltest_buildfile_spinoff()
def python_version_android_base() -> None:
"""Print built Python base version."""
from efrotools.pybuild import PY_VER_ANDROID

View File

@ -109,7 +109,7 @@ def _main() -> None:
if '--soft' in sys.argv:
return
raise CleanError(
'This only works on dst projects;'
'Spinoff only works from dst projects;'
' you appear to be in a src project.'
" To silently no-op in this case, pass '--soft'."
)

View File

@ -0,0 +1,137 @@
# Released under the MIT License. See LICENSE for details.
#
"""Functionality to build the openal library."""
from __future__ import annotations
import os
import subprocess
from typing import TYPE_CHECKING
from efro.error import CleanError
if TYPE_CHECKING:
pass
# Arch names we take and their official android versions.
ARCHS = {
'arm': 'armeabi-v7a',
'arm64': 'arm64-v8a',
'x86': 'x86',
'x86_64': 'x86_64',
}
MODES = {'debug', 'release'}
def _build_dir(arch: str, mode: str) -> str:
"""Build dir given an arch and mode."""
return f'build/openal_build_android_{arch}_{mode}'
def build(arch: str, mode: str) -> None:
"""Do the thing."""
from efrotools import replace_exact
if arch not in ARCHS:
raise CleanError(f"Invalid arch '{arch}'.")
if mode not in MODES:
raise CleanError(f"Invalid mode '{mode}'.")
# Get ndk path.
ndk_path = (
subprocess.run(
['tools/pcommand', 'android_sdk_utils', 'get-ndk-path'],
check=True,
capture_output=True,
)
.stdout.decode()
.strip()
)
# Grab from git and build.
builddir = _build_dir(arch, mode)
subprocess.run(['rm', '-rf', builddir], check=True)
subprocess.run(['mkdir', '-p', os.path.dirname(builddir)], check=True)
subprocess.run(
['git', 'clone', 'https://github.com/kcat/openal-soft.git', builddir],
check=True,
)
commit = 'd3875f3' # Version 1.23.1
subprocess.run(['git', 'checkout', commit], check=True, cwd=builddir)
# One bit of filtering: by default, openalsoft sends all sorts of
# log messages to the android log. This is reasonable since its
# possible to filter by tag/level. However I'd prefer it to send
# only the ones that it would send to stderr so I don't always have
# to worry about filtering.
loggingpath = f'{builddir}/core/logging.cpp'
with open(loggingpath, encoding='utf-8') as infile:
txt = infile.read()
txt = replace_exact(
txt,
' __android_log_print(android_severity(level),'
' "openal", "%s", str);',
' // ericf tweak; only send logs to'
' android that we\'d send to stderr.\n'
' if (gLogLevel >= level) {\n'
' __android_log_print(android_severity(level),'
' "openal", "%s", str);\n'
' }',
)
with open(loggingpath, 'w', encoding='utf-8') as outfile:
outfile.write(txt)
subprocess.run(
[
'cmake',
'.',
f'-DANDROID_ABI={ARCHS[arch]}',
'-DANDROID_NATIVE_API_LEVEL=21',
f'-DCMAKE_BUILD_TYPE={mode}',
'-DLIBTYPE=STATIC',
'-DCMAKE_TOOLCHAIN_FILE='
f'{ndk_path}/build/cmake/android.toolchain.cmake',
],
cwd=builddir,
check=True,
)
subprocess.run(['make'], cwd=builddir, check=True)
print('SUCCESS!')
def gather() -> None:
"""Gather the things. Assumes all have been built."""
# Sanity-check; make sure everything appears to be built.
for arch in ARCHS:
for mode in MODES:
builddir = _build_dir(arch, mode)
libfile = os.path.join(builddir, 'libopenal.a')
if not os.path.exists(libfile):
raise CleanError(f"Built lib not found: '{libfile}'.")
outdir = 'src/external/openal-android'
subprocess.run(['rm', '-rf', outdir], check=True)
subprocess.run(['mkdir', '-p', f'{outdir}/include'], check=True)
builddir = _build_dir('arm', 'debug') # Doesn't matter here.
subprocess.run(
['cp', '-r', f'{builddir}/include/AL', f'{outdir}/include'],
check=True,
)
for arch, andrarch in ARCHS.items():
for mode in MODES:
builddir = _build_dir(arch, mode)
installdir = f'{outdir}/lib/{andrarch}_{mode}'
subprocess.run(['mkdir', '-p', installdir], check=True)
subprocess.run(
['cp', f'{builddir}/libopenal.a', installdir], check=True
)
print('OpenAL gather successful!')

View File

@ -40,3 +40,30 @@ def sortlines() -> None:
val = sys.argv[2]
lines = val.splitlines()
print('\n'.join(sorted(lines, key=lambda l: l.lower())))
def openal_build_android() -> None:
"""Build openalsoft for android."""
from efro.error import CleanError
from efrotools.openalbuild import build
args = sys.argv[2:]
if len(args) != 2:
raise CleanError(
'Expected one <ARCH> arg: arm, arm64, x86, x86_64'
' and one <MODE> arg: debug, release'
)
build(args[0], args[1])
def openal_gather() -> None:
"""Gather built opealsoft libs into src."""
from efro.error import CleanError
from efrotools.openalbuild import gather
args = sys.argv[2:]
if args:
raise CleanError('No args expected.')
gather()

View File

@ -54,6 +54,8 @@ from efrotools.pcommand import (
from efrotools.pcommand2 import (
with_build_lock,
sortlines,
openal_build_android,
openal_gather,
)
from batools.pcommand import (
resize_image,
@ -64,11 +66,6 @@ from batools.pcommand import (
androidaddr,
push_ipa,
printcolors,
gen_fulltest_buildfile_android,
gen_fulltest_buildfile_windows,
gen_fulltest_buildfile_apple,
gen_fulltest_buildfile_linux,
gen_fulltest_buildfile_spinoff,
prune_includes,
python_version_android,
python_version_apple,