Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Halley is divided in a several sub-projects:
## Platforms
The following platforms are supported:
* **Windows**: Tested on Windows 10 Professional 64-bit (Might work on as low as XP 32-bit, but XP is no longer a tested target)
* **Mac OS X**: Tested on Mac OS X 10.9.6
* **macOS**: Tested on Mac OS X 10.9.6 (Intel); also builds and runs natively on Apple Silicon (arm64) — see [macOS (Apple Silicon)](#macos-apple-silicon--arm64) below
* **Linux**: Tested on Ubuntu 16.04

## Installation
Expand Down Expand Up @@ -94,5 +94,28 @@ The following platforms are supported:
* Run `halley-editor tests/entity` (or whichever other project you want to test)
* Launch that project

### macOS (Apple Silicon / arm64)
The bundled `deps/osx` libraries are x86_64-only, so a native arm64 build pulls current dependencies from [Homebrew](https://brew.sh) instead:
```
brew install freetype sdl2 googletest openssl
```
(`yaml-cpp` is vendored under `src/contrib`, so its Homebrew package is optional.)

[ShaderConductor](https://github.com/microsoft/ShaderConductor) (required for the tools/editor) has no arm64 prebuilt, so build it from source. Its pinned DXC/LLVM fork needs a couple of flags to compile under recent Apple Clang — configure it with `-DCMAKE_CXX_FLAGS=-Wno-invalid-specialization -DSPIRV_WERROR=OFF`, and drop the `-march=core2 -msse2` / `-Werror` lines that `Source/CMakeLists.txt` forces for non-arm hosts. This yields an arm64 `libShaderConductor.dylib`.

Configure Halley with Ninja, pointing CMake at the Homebrew prefix and your ShaderConductor build. The explicit `SDL2_*` paths matter, otherwise CMake picks up the Windows-configured SDL2 headers under `deps/include`:
```
cmake -G Ninja \
-DBUILD_HALLEY_TOOLS=1 -DBUILD_HALLEY_TESTS=1 \
-DCMAKE_PREFIX_PATH=/opt/homebrew \
-DSDL2_INCLUDE_DIR=/opt/homebrew/include/SDL2 \
-DSDL2_LIBRARIES=/opt/homebrew/lib/libSDL2.dylib \
-DShaderConductor_INCLUDE_DIR="<ShaderConductor>/Include;<ShaderConductor>/Include/ShaderConductor" \
-DShaderConductor_LIBRARY=<ShaderConductor>/Build/.../Lib/libShaderConductor.dylib \
..
cmake --build . --config RelWithDebInfo
```
Then launch the editor with `./bin/halley-editor --dont-load-dll`.

## Documentation
The full documentation is available on the [Wiki](https://github.com/amzeratul/halley/wiki).
6 changes: 4 additions & 2 deletions cmake/HalleyProject.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,12 @@ if (APPLE)
find_library(IOKIT_LIBRARY IOKit)
find_library(COREVIDEO_LIBRARY CoreVideo)
find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox)
find_library(SECURITY_LIBRARY Security)
find_library(COREFOUNDATION_LIBRARY CoreFoundation)

mark_as_advanced(CARBON_LIBRARY COCOA_LIBRARY COREAUDIO_LIBRARY AUDIOTOOLBOX_LIBRARY AUDIOUNIT_LIBRARY FORCEFEEDBACK_LIBRARY IOKIT_LIBRARY COREVIDEO_LIBRARY)
mark_as_advanced(CARBON_LIBRARY COCOA_LIBRARY COREAUDIO_LIBRARY AUDIOTOOLBOX_LIBRARY AUDIOUNIT_LIBRARY FORCEFEEDBACK_LIBRARY IOKIT_LIBRARY COREVIDEO_LIBRARY SECURITY_LIBRARY COREFOUNDATION_LIBRARY)

set(EXTRA_LIBS ${EXTRA_LIBS} ${CARBON_LIBRARY} ${COCOA_LIBRARY} ${COREAUDIO_LIBRARY} ${AUDIOTOOLBOX_LIBRARY} ${AUDIOUNIT_LIBRARY} ${FORCEFEEDBACK_LIBRARY} ${IOKIT_LIBRARY} ${COREVIDEO_LIBRARY} iconv)
set(EXTRA_LIBS ${EXTRA_LIBS} ${CARBON_LIBRARY} ${COCOA_LIBRARY} ${COREAUDIO_LIBRARY} ${AUDIOTOOLBOX_LIBRARY} ${AUDIOUNIT_LIBRARY} ${FORCEFEEDBACK_LIBRARY} ${IOKIT_LIBRARY} ${COREVIDEO_LIBRARY} ${SECURITY_LIBRARY} ${COREFOUNDATION_LIBRARY} iconv)

if (BUILD_MACOSX_BUNDLE)
add_definitions(-DHALLEY_MACOSX_BUNDLE)
Expand Down
2 changes: 1 addition & 1 deletion src/contrib/zlib/zutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# endif
#endif

#if defined(MACOS) || defined(TARGET_OS_MAC)
#if defined(MACOS) /* classic Mac OS only; modern macOS always defines TARGET_OS_MAC=1, which must not trigger the fdopen stub below */
# define OS_CODE 7
# ifndef Z_SOLO
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
Expand Down
10 changes: 10 additions & 0 deletions src/engine/core/include/halley/bytes/byte_serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ namespace Halley {
Serializer& operator<<(uint32_t val) { return serializeInteger(val); }
Serializer& operator<<(int64_t val) { return serializeInteger(val); }
Serializer& operator<<(uint64_t val) { return serializeInteger(val); }
#if defined(__APPLE__)
// On Apple LP64, int64_t/uint64_t are long long, leaving long/unsigned long (e.g. size_t) unmatched
Serializer& operator<<(long val) { return serializeInteger(static_cast<int64_t>(val)); }
Serializer& operator<<(unsigned long val) { return serializeInteger(static_cast<uint64_t>(val)); }
#endif
Serializer& operator<<(float val) { return serializePod(val); }
Serializer& operator<<(double val) { return serializePod(val); }

Expand Down Expand Up @@ -478,6 +483,11 @@ namespace Halley {
Deserializer& operator>>(uint32_t& val) { return deserializeInteger(val); }
Deserializer& operator>>(int64_t& val) { return deserializeInteger(val); }
Deserializer& operator>>(uint64_t& val) { return deserializeInteger(val); }
#if defined(__APPLE__)
// On Apple LP64, int64_t/uint64_t are long long, leaving long/unsigned long (e.g. size_t) unmatched
Deserializer& operator>>(long& val) { int64_t v; deserializeInteger(v); val = static_cast<long>(v); return *this; }
Deserializer& operator>>(unsigned long& val) { uint64_t v; deserializeInteger(v); val = static_cast<unsigned long>(v); return *this; }
#endif
Deserializer& operator>>(float& val) { return deserializePod(val); }
Deserializer& operator>>(double& val) { return deserializePod(val); }

Expand Down
11 changes: 7 additions & 4 deletions src/engine/core/src/os/os_mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ Path OSMac::parseProgramPath(const String&)
char buffer[2048];
uint32_t bufSize = 2048;
_NSGetExecutablePath(buffer, &bufSize);
Path programPath = Path(String(buffer)).parentPath() / ".";
// Return the full executable path; Environment::parseProgramPath derives the
// program directory from this via parentPath(), matching other platforms.
const Path executablePath = Path(String(buffer));
const Path programDir = executablePath.parentPath() / ".";

std::cout << "Setting CWD to " << programPath << std::endl;
chdir(programPath.string().c_str());
std::cout << "Setting CWD to " << programDir << std::endl;
chdir(programDir.string().c_str());

return programPath;
return executablePath;
}

void OSMac::openURL(const String& url)
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/avf/src/avf_movie_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Halley {
void deInit() override;

bool canPlayVideo() const override { return true; }
std::shared_ptr<MoviePlayer> makePlayer(VideoAPI& video, AudioAPI& audio, std::shared_ptr<ResourceDataStream> data) override;
std::shared_ptr<MoviePlayer> makePlayer(const HalleyAPI& halleyAPI, std::shared_ptr<ResourceDataStream> data) override;

private:
SystemAPI& system;
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/avf/src/avf_movie_api.mm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{
}

std::shared_ptr<MoviePlayer> AVFMovieAPI::makePlayer(VideoAPI& video, AudioAPI& audio, std::shared_ptr<ResourceDataStream> data)
std::shared_ptr<MoviePlayer> AVFMovieAPI::makePlayer(const HalleyAPI& halleyAPI, std::shared_ptr<ResourceDataStream> data)
{
return std::make_shared<AVFMoviePlayer>(video, audio, data);
return std::make_shared<AVFMoviePlayer>(halleyAPI, data);
}
3 changes: 2 additions & 1 deletion src/plugins/avf/src/avf_movie_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
namespace Halley
{
class VideoAPI;
class HalleyAPI;

class AVFMoviePlayer : public MoviePlayer
{
public:
AVFMoviePlayer(VideoAPI& video, AudioAPI& audio, std::shared_ptr<ResourceDataStream> data);
AVFMoviePlayer(const HalleyAPI& halleyAPI, std::shared_ptr<ResourceDataStream> data);
~AVFMoviePlayer() noexcept;

protected:
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/avf/src/avf_movie_player.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

using namespace Halley;

AVFMoviePlayer::AVFMoviePlayer(VideoAPI& video, AudioAPI& audio, std::shared_ptr<ResourceDataStream> data)
: MoviePlayer(video, audio)
AVFMoviePlayer::AVFMoviePlayer(const HalleyAPI& halleyAPI, std::shared_ptr<ResourceDataStream> data)
: MoviePlayer(halleyAPI)
, data(std::move(data))
{
init();
Expand Down
8 changes: 6 additions & 2 deletions src/plugins/opengl/src/shader_opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ ShaderOpenGL::ShaderOpenGL(const ShaderDefinition& definition)
id = glCreateProgram();
glCheckError();
#ifdef WITH_OPENGL
glObjectLabel(GL_PROGRAM, id, -1, definition.name.c_str());
if (glObjectLabel) { // null unless KHR_debug is available (e.g. not on macOS OpenGL 4.1)
glObjectLabel(GL_PROGRAM, id, -1, definition.name.c_str());
}
#endif

name = definition.name;
Expand Down Expand Up @@ -86,7 +88,9 @@ static GLuint loadShader(const Bytes& src, GLenum type, String name)
GLuint shader = glCreateShader(type);
glCheckError();
#ifdef WITH_OPENGL
glObjectLabel(GL_SHADER, shader, -1, name.c_str());
if (glObjectLabel) { // null unless KHR_debug is available (e.g. not on macOS OpenGL 4.1)
glObjectLabel(GL_SHADER, shader, -1, name.c_str());
}
#endif

// Load source
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/opengl/src/texture_opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ void TextureOpenGL::create(Vector2i size, TextureFormat format, bool useMipMap,
glCheckError();

#ifdef WITH_OPENGL
glObjectLabel(GL_TEXTURE, textureId, -1, getAssetId().c_str());
if (glObjectLabel) { // null unless KHR_debug is available (e.g. not on macOS OpenGL 4.1)
glObjectLabel(GL_TEXTURE, textureId, -1, getAssetId().c_str());
}
#endif

texSize = size;
Expand Down
8 changes: 4 additions & 4 deletions src/tests/src/vector_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace {
a.push_back(std::move(a.back()));
}

EXPECT_EQ(a.front(), T::value_type());
EXPECT_EQ(a.front(), typename T::value_type());
EXPECT_EQ(a.back(), v);
}

Expand All @@ -74,8 +74,8 @@ namespace {
a.push_back(std::move(a.back()));
}

EXPECT_EQ(a.front(), T::value_type());
EXPECT_NE(a.back(), T::value_type());
EXPECT_EQ(a.front(), typename T::value_type());
EXPECT_NE(a.back(), typename T::value_type());
}

template <typename T>
Expand Down Expand Up @@ -132,7 +132,7 @@ namespace {
if constexpr (std::is_same_v<typename T::value_type, Halley::String>) {
a.push_back(toString(val));
} else {
a.push_back(T::value_type(val));
a.push_back(typename T::value_type(val));
}
EXPECT_TRUE(a.sbo_active());
}
Expand Down
5 changes: 4 additions & 1 deletion src/tools/tools/src/assets/importers/shader_importer_dxc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
#include <dxcapi.h>
#include <wrl.h>
using namespace Microsoft::WRL;
#endif

// Uses D3D12 types; only valid on Windows
#include "shader_importer_dxc.inl"
#endif

using namespace Halley;

#ifdef _MSC_VER
static DxcCreateInstanceProc getDxcCreateInstanceFunction(const char* dllName)
{
// NOTE: This leaks the DLL module, FreeLibrary() is never called.
Expand All @@ -34,6 +36,7 @@ static DxcCreateInstanceProc getDxcCreateInstanceFunction(const char* dllName)

return fn;
}
#endif

Bytes ShaderImporterDXC::compileDXIL(const String& name, ShaderType type, const Bytes& bytes, const String& language, const MaterialDefinition& material) {
#ifdef _MSC_VER
Expand Down