+
+
\ No newline at end of file
diff --git a/ballisticacore-cmake/.idea/modules.xml b/ballisticacore-cmake/.idea/modules.xml
new file mode 100644
index 00000000..5fb34ea8
--- /dev/null
+++ b/ballisticacore-cmake/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ballisticacore-cmake/.idea/vcs.xml b/ballisticacore-cmake/.idea/vcs.xml
new file mode 100644
index 00000000..6c0b8635
--- /dev/null
+++ b/ballisticacore-cmake/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ballisticacore-cmake/CMakeLists.txt b/ballisticacore-cmake/CMakeLists.txt
new file mode 100644
index 00000000..888fee8c
--- /dev/null
+++ b/ballisticacore-cmake/CMakeLists.txt
@@ -0,0 +1,199 @@
+cmake_minimum_required(VERSION 3.12)
+project(BallisticaCore)
+include(CheckIncludeFile)
+
+option(HEADLESS "build headless server" OFF)
+option(TEST_BUILD "include testing features" OFF)
+
+# Requiring minimum of C++17 currently.
+set(CMAKE_CXX_STANDARD 17)
+
+if (APPLE)
+ # Seems as of Mojave we need to explicitly pull in /usr/local stuff.
+ include_directories("/usr/local/include")
+ link_directories("/usr/local/lib")
+
+ # On Mac with homebrew it seems that Requesting 3.7 when we've got
+ # 3.8 installed will point us at the 3.8 framework but will attempt
+ # to load a 3.7 library from within it which doesn't exist. So we need
+ # to be a bit more explicit telling it where to look. This is no longer
+ # necessary since we're using 3.8 now but may be once 3.9 becomes available
+ # through homebrew.
+ execute_process(COMMAND "python3.8-config" "--prefix"
+ OUTPUT_VARIABLE Python_ROOT_DIR
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+endif ()
+find_package (Python 3.8 REQUIRED EXACT COMPONENTS Development)
+
+
+if (HEADLESS)
+ add_definitions(-DBA_HEADLESS_BUILD=1)
+ else ()
+ find_package(SDL2 QUIET)
+ if (SDL2_FOUND)
+ # Getting complaint about space at the end of this on ubuntu16.
+ string(STRIP ${SDL2_LIBRARIES} SDL2_LIBRARIES)
+ else ()
+ message(FATAL_ERROR "SDL2 not found")
+ endif ()
+ find_package(OpenGL REQUIRED)
+ find_package(OpenAL REQUIRED)
+ if (APPLE)
+ # On mac this sets an include path that we don't need since
+ # we're using the system framework... should clean this up.
+ set(OPENAL_INCLUDE_DIR "")
+ endif ()
+ find_library(OGG_LIBRARY ogg)
+ find_library(VORBISFILE_LIBRARY vorbisfile)
+ if (NOT OGG_LIBRARY)
+ message(FATAL_ERROR "ogg library not found")
+ endif ()
+ if (NOT VORBISFILE_LIBRARY)
+ message(FATAL_ERROR "vorbisfile library not found")
+ endif ()
+ set(EXTRA_INCLUDE_DIRS ${OPENGL_INCLUDE_DIRS}
+ ${OPENAL_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS})
+ set(EXTRA_LIBRARIES ogg vorbisfile ${OPENGL_LIBRARIES} ${OPENAL_LIBRARY})
+endif ()
+
+if (TEST_BUILD)
+ add_definitions(-DBA_TEST_BUILD=1)
+endif ()
+
+# Currently seeing warnings about parameter order changing in GCC 7.1
+# on Raspberry Pi builds. We never need to care about C++ abi compatibility
+# so just silencing them for now. Can maybe remove this later if they stop.
+if (CMAKE_COMPILER_IS_GNUCXX)
+ set(CMAKE_CXX_FLAGS
+ "${CMAKE_CXX_FLAGS} -Wno-psabi")
+endif()
+
+# message("GOT SDL INC ${SDL2_INCLUDE_DIRS}")
+# message(FATAL_ERROR "SO FAR SO GOOD")
+
+set(BA_SRC_ROOT src)
+include_directories(${BA_SRC_ROOT})
+add_compile_options(-include ballistica/config/config_cmake.h)
+
+if (CMAKE_BUILD_TYPE MATCHES Debug)
+ add_definitions(-DBA_DEBUG_BUILD=1)
+endif ()
+
+set(ODE_SRC_ROOT ${BA_SRC_ROOT}/external/open_dynamics_engine-ef)
+
+add_library(ode
+ ${ODE_SRC_ROOT}/ode/IceAABB.cpp
+ ${ODE_SRC_ROOT}/ode/IceContainer.cpp
+ ${ODE_SRC_ROOT}/ode/IceHPoint.cpp
+ ${ODE_SRC_ROOT}/ode/IceIndexedTriangle.cpp
+ ${ODE_SRC_ROOT}/ode/IceMatrix3x3.cpp
+ ${ODE_SRC_ROOT}/ode/IceMatrix4x4.cpp
+ ${ODE_SRC_ROOT}/ode/IceOBB.cpp
+ ${ODE_SRC_ROOT}/ode/IcePlane.cpp
+ ${ODE_SRC_ROOT}/ode/IcePoint.cpp
+ ${ODE_SRC_ROOT}/ode/IceRandom.cpp
+ ${ODE_SRC_ROOT}/ode/IceRay.cpp
+ ${ODE_SRC_ROOT}/ode/IceRevisitedRadix.cpp
+ ${ODE_SRC_ROOT}/ode/IceSegment.cpp
+ ${ODE_SRC_ROOT}/ode/IceTriangle.cpp
+ ${ODE_SRC_ROOT}/ode/IceUtils.cpp
+ ${ODE_SRC_ROOT}/ode/ode.cpp
+ ${ODE_SRC_ROOT}/ode/ode_array.cpp
+ ${ODE_SRC_ROOT}/ode/ode_collision_cylinder_box.cpp
+ ${ODE_SRC_ROOT}/ode/ode_collision_cylinder_plane.cpp
+ ${ODE_SRC_ROOT}/ode/ode_collision_cylinder_sphere.cpp
+ ${ODE_SRC_ROOT}/ode/ode_collision_cylinder_trimesh.cpp
+ ${ODE_SRC_ROOT}/ode/ode_collision_kernel.cpp
+ ${ODE_SRC_ROOT}/ode/ode_collision_quadtreespace.cpp
+ ${ODE_SRC_ROOT}/ode/ode_collision_sapspace.cpp
+ ${ODE_SRC_ROOT}/ode/ode_collision_space.cpp
+ ${ODE_SRC_ROOT}/ode/ode_collision_std.cpp
+ ${ODE_SRC_ROOT}/ode/ode_collision_transform.cpp
+ ${ODE_SRC_ROOT}/ode/ode_collision_trimesh.cpp
+ ${ODE_SRC_ROOT}/ode/ode_collision_trimesh_box.cpp
+ ${ODE_SRC_ROOT}/ode/ode_collision_trimesh_ccylinder.cpp
+ ${ODE_SRC_ROOT}/ode/ode_collision_trimesh_distance.cpp
+ ${ODE_SRC_ROOT}/ode/ode_collision_trimesh_plane.cpp
+ ${ODE_SRC_ROOT}/ode/ode_collision_trimesh_ray.cpp
+ ${ODE_SRC_ROOT}/ode/ode_collision_trimesh_sphere.cpp
+ ${ODE_SRC_ROOT}/ode/ode_collision_trimesh_trimesh.cpp
+ ${ODE_SRC_ROOT}/ode/ode_collision_util.cpp
+ ${ODE_SRC_ROOT}/ode/ode_error.cpp
+ ${ODE_SRC_ROOT}/ode/ode_export-diff.cpp
+ ${ODE_SRC_ROOT}/ode/ode_fastdot.cpp
+ ${ODE_SRC_ROOT}/ode/ode_fastldlt.cpp
+ ${ODE_SRC_ROOT}/ode/ode_fastlsolve.cpp
+ ${ODE_SRC_ROOT}/ode/ode_fastltsolve.cpp
+ ${ODE_SRC_ROOT}/ode/ode_joint.cpp
+ ${ODE_SRC_ROOT}/ode/ode_lcp.cpp
+ ${ODE_SRC_ROOT}/ode/ode_mass.cpp
+ ${ODE_SRC_ROOT}/ode/ode_mat.cpp
+ ${ODE_SRC_ROOT}/ode/ode_math.cpp
+ ${ODE_SRC_ROOT}/ode/ode_matrix.cpp
+ ${ODE_SRC_ROOT}/ode/ode_memory.cpp
+ ${ODE_SRC_ROOT}/ode/ode_misc.cpp
+ ${ODE_SRC_ROOT}/ode/ode_obstack.cpp
+ ${ODE_SRC_ROOT}/ode/ode_quickstep.cpp
+ ${ODE_SRC_ROOT}/ode/ode_rotation.cpp
+ ${ODE_SRC_ROOT}/ode/ode_step.cpp
+ ${ODE_SRC_ROOT}/ode/ode_stepfast.cpp
+ ${ODE_SRC_ROOT}/ode/ode_timer.cpp
+ ${ODE_SRC_ROOT}/ode/ode_util.cpp
+ ${ODE_SRC_ROOT}/ode/OPC_AABBCollider.cpp
+ ${ODE_SRC_ROOT}/ode/OPC_AABBTree.cpp
+ ${ODE_SRC_ROOT}/ode/OPC_BaseModel.cpp
+ ${ODE_SRC_ROOT}/ode/OPC_BoxPruning.cpp
+ ${ODE_SRC_ROOT}/ode/OPC_Collider.cpp
+ ${ODE_SRC_ROOT}/ode/OPC_HybridModel.cpp
+ ${ODE_SRC_ROOT}/ode/OPC_LSSCollider.cpp
+ ${ODE_SRC_ROOT}/ode/OPC_MeshInterface.cpp
+ ${ODE_SRC_ROOT}/ode/OPC_Model.cpp
+ ${ODE_SRC_ROOT}/ode/OPC_OBBCollider.cpp
+ ${ODE_SRC_ROOT}/ode/OPC_OptimizedTree.cpp
+ ${ODE_SRC_ROOT}/ode/OPC_PlanesCollider.cpp
+ ${ODE_SRC_ROOT}/ode/OPC_RayCollider.cpp
+ ${ODE_SRC_ROOT}/ode/OPC_SphereCollider.cpp
+ ${ODE_SRC_ROOT}/ode/OPC_SweepAndPrune.cpp
+ ${ODE_SRC_ROOT}/ode/OPC_TreeBuilders.cpp
+ ${ODE_SRC_ROOT}/ode/OPC_TreeCollider.cpp
+ ${ODE_SRC_ROOT}/ode/OPC_VolumeCollider.cpp
+ ${ODE_SRC_ROOT}/ode/Opcode.cpp
+ )
+target_include_directories(ode PRIVATE ${ODE_SRC_ROOT})
+
+# EWWW; GCC gives us bad mesh collisions with -O3 (and maybe -O2)
+# need to finally get to the bottom of this but limiting to -01 for now.
+# (-O2 might be safe??... or what about -Os? Should test again.)
+if (CMAKE_BUILD_TYPE MATCHES Release)
+ target_compile_options(ode PRIVATE -O1)
+endif ()
+
+# BallisticaCore binary.
+add_executable(ballisticacore
+ ${BA_SRC_ROOT}/external/qrencode-3.4.4/qrencode/bitstream.c
+ ${BA_SRC_ROOT}/external/qrencode-3.4.4/qrencode/mask.c
+ ${BA_SRC_ROOT}/external/qrencode-3.4.4/qrencode/mmask.c
+ ${BA_SRC_ROOT}/external/qrencode-3.4.4/qrencode/mqrspec.c
+ ${BA_SRC_ROOT}/external/qrencode-3.4.4/qrencode/qrencode.c
+ ${BA_SRC_ROOT}/external/qrencode-3.4.4/qrencode/qrinput.c
+ ${BA_SRC_ROOT}/external/qrencode-3.4.4/qrencode/qrspec.c
+ ${BA_SRC_ROOT}/external/qrencode-3.4.4/qrencode/rscode.c
+ ${BA_SRC_ROOT}/external/qrencode-3.4.4/qrencode/split.c
+ # AUTOGENERATED_PUBLIC_BEGIN (this section is managed by the "update_project" tool)
+ ${BA_SRC_ROOT}/ballistica/app/app.cc
+ # AUTOGENERATED_PUBLIC_END
+ )
+
+target_include_directories(ballisticacore PRIVATE
+ ${Python_INCLUDE_DIRS}
+ ${BA_SRC_ROOT}/external/open_dynamics_engine-ef
+ ${BA_SRC_ROOT}/external/qrencode-3.4.4
+ ${EXTRA_INCLUDE_DIRS}
+ )
+
+# NOTE: seems we need to add 'dl' here for raspberry pi with manually
+# built Python 3.8. Might be able to remove later.
+target_link_libraries(ballisticacore PRIVATE
+ ballisticacore_private ode pthread ${Python_LIBRARIES}
+ ${SDL2_LIBRARIES} ${EXTRA_LIBRARIES} dl)
diff --git a/ballisticacore-cmake/src b/ballisticacore-cmake/src
new file mode 120000
index 00000000..5cd551cf
--- /dev/null
+++ b/ballisticacore-cmake/src
@@ -0,0 +1 @@
+../src
\ No newline at end of file
diff --git a/tools/batools/updateproject.py b/tools/batools/updateproject.py
index eb4907ca..6ac8a2c1 100755
--- a/tools/batools/updateproject.py
+++ b/tools/batools/updateproject.py
@@ -145,6 +145,10 @@ class Updater:
sys.exit(255)
def _update_compile_commands_file(self) -> None:
+ # Only do this in private repo:
+ if self._public:
+ return
+
# Update our local compile-commands file based on any changes to
# our cmake stuff. Do this at end so cmake changes already happened.
if not self._check and os.path.exists('ballisticacore-cmake'):
@@ -543,28 +547,43 @@ class Updater:
if os.path.exists(fname):
self._update_visual_studio_project(fname, '..\\..\\src')
- def _update_cmake_file(self, fname: str) -> None:
+ def _is_public_source_file(self, filename: str) -> bool:
+ if filename == '/app/app.cc':
+ return True
+ return False
+ def _update_cmake_file(self, fname: str) -> None:
with open(fname) as infile:
lines = infile.read().splitlines()
- auto_start = lines.index(' #AUTOGENERATED_BEGIN (this section'
- ' is managed by the "update_project" tool)')
- auto_end = lines.index(' #AUTOGENERATED_END')
- our_lines = [
- ' ${BA_SRC_ROOT}/ballistica' + f
- for f in sorted(self._source_files + self._header_files)
- if not f.endswith('.mm') and not f.endswith('.m')
- ]
- filtered = lines[:auto_start + 1] + our_lines + lines[auto_end:]
- self._file_changes[fname] = '\n'.join(filtered) + '\n'
+
+ for section in ['PUBLIC', 'PRIVATE']:
+ # Public repo has no private section.
+ if self._public and section == 'PRIVATE':
+ continue
+
+ auto_start = lines.index(
+ f' # AUTOGENERATED_{section}_BEGIN (this section'
+ f' is managed by the "update_project" tool)')
+ auto_end = lines.index(f' # AUTOGENERATED_{section}_END')
+ our_lines = [
+ ' ${BA_SRC_ROOT}/ballistica' + f
+ for f in sorted(self._source_files + self._header_files)
+ if not f.endswith('.mm') and not f.endswith('.m')
+ and self._is_public_source_file(f) == (section == 'PUBLIC')
+ ]
+ lines = lines[:auto_start + 1] + our_lines + lines[auto_end:]
+
+ self._file_changes[fname] = '\n'.join(lines) + '\n'
def _update_cmake_files(self) -> None:
+ # Note: currently not updating cmake files at all in public builds;
+ # will need to get this working at some point...
fname = 'ballisticacore-cmake/CMakeLists.txt'
- if os.path.exists(fname):
+ if not self._public:
self._update_cmake_file(fname)
fname = ('ballisticacore-android/BallisticaCore'
'/src/main/cpp/CMakeLists.txt')
- if os.path.exists(fname):
+ if not self._public:
self._update_cmake_file(fname)
def _find_sources_and_headers(self, scan_dir: str) -> None:
diff --git a/tools/efrotools/efrocache.py b/tools/efrotools/efrocache.py
index 7b3a5296..01c4c404 100644
--- a/tools/efrotools/efrocache.py
+++ b/tools/efrotools/efrocache.py
@@ -25,8 +25,6 @@ if TYPE_CHECKING:
BASE_URL = 'https://files.ballistica.net/cache/ba1/'
TARGET_TAG = '#__EFROCACHE_TARGET__'
-STRIP_BEGIN_TAG = '#__EFROCACHE_STRIP_BEGIN__'
-STRIP_END_TAG = '#__EFROCACHE_STRIP_END__'
CACHE_DIR_NAME = '.efrocache'
CACHE_MAP_NAME = '.efrocachemap'
@@ -142,19 +140,6 @@ def filter_makefile(makefile_dir: str, contents: str) -> str:
lines = contents.splitlines()
pcommand = 'tools/pcommand'
- # Strip out parts they don't want.
- while STRIP_BEGIN_TAG in lines:
- index = lines.index(STRIP_BEGIN_TAG)
- endindex = index
- while lines[endindex] != STRIP_END_TAG:
- endindex += 1
-
- # If the line after us is blank, include it too to keep spacing clean.
- if not lines[endindex + 1].strip():
- endindex += 1
-
- del lines[index:endindex + 1]
-
# Replace cachable targets with cache lookups
while TARGET_TAG in lines:
index = lines.index(TARGET_TAG)