Skip to content

Commit

Permalink
Merge pull request #36 from kainjow/macos-build
Browse files Browse the repository at this point in the history
macOS build fixes and issues
  • Loading branch information
serge-rgb committed Jan 23, 2017
2 parents c147b64 + d6d07b7 commit f685ab9
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 49 deletions.
40 changes: 0 additions & 40 deletions build_osx.sh

This file was deleted.

34 changes: 29 additions & 5 deletions src/platform_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,36 @@

#include <mach-o/dyld.h>
#include <errno.h>
#include <limits.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
#include "platform.h"
#include "memory.h"

#define MAX_PATH PATH_MAX

// IMPLEMENT ====
float
perf_count_to_sec(u64 counter)
{
IMPL_MISSING;
return 0.0;
// Input as nanoseconds
return (float)counter * 1e-9;
}
u64
perf_counter()
{
IMPL_MISSING;
return 0;
// clock_gettime() on macOS is only supported on macOS Sierra and later.
// For older macOS operating systems, mach_absolute_time() will be need to be used.
timespec tp;
int res = clock_gettime(CLOCK_REALTIME, &tp);

// TODO: Check errno and provide more informations
if ( res ) {
milton_log("Something went wrong with clock_gettime\n");
}

return tp.tv_nsec;
}

b32
Expand Down Expand Up @@ -128,6 +145,13 @@ WallTime
platform_get_walltime()
{
WallTime wt = {0};
IMPL_MISSING;
struct timeval tv;
gettimeofday(&tv, NULL);
struct tm *time;
time = localtime(&tv.tv_sec);
wt.h = time->tm_hour;
wt.m = time->tm_min;
wt.s = time->tm_sec;
wt.ms = tv.tv_usec / 1000;
return wt;
}
2 changes: 1 addition & 1 deletion third_party/SDL2-2.0.3/src/video/cocoa/SDL_cocoaopengl.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
Expand Down
46 changes: 43 additions & 3 deletions tundra.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Build {
Env = {
CPPPATH = { "third_party",
"third_party/imgui",
{"third_party/SDL2-2.0.3/include"; Config = "win*"},
{"third_party/SDL2-2.0.3/include"; Config = { "win*", "macos" }},
"src"
},
CXXOPTS = { }
Expand Down Expand Up @@ -89,8 +89,9 @@ Build {
"src/sdl_milton.cc",
"src/StrokeList.cc",
{"src/platform_windows.cc"; Config = { "win*" }},
{"src/platform_unix.cc"; Config = { "linux-*" }},
{"src/platform_unix.cc"; Config = { "linux-*", "macos" }},
{"src/platform_linux.cc"; Config = { "linux-*" }},
{"src/platform_mac.cc"; Config = { "macos" }},
"src/third_party_libs.cc",

{ ResourceFile { Input="Milton.rc" }; Config="win*" },
Expand All @@ -106,12 +107,23 @@ Build {
{ "ole32.lib"; Config = { "win*" } },
{ "oleAut32.lib"; Config = { "win*" } },
{ "third_party/bin/SDL2.lib"; Config = { "win*" } },

{ "SDL2"; Config = "macos" },
{ "GL"; Config = "linux-*-*"},
--, "Xi", "m", "c"
{ "m"; Config = "linux-*-*"},
{ "Xi"; Config = "linux-*-*"},
{ "stdc++"; Config = "linux-*-*"},
{ "c++"; Config = "macos"},
},
LibPaths = {
{ "third_party/build"; Config = "macos" },
},
Frameworks = {
"Carbon",
"Cocoa",
"ForceFeedback",
"IOKit",
"OpenGL",
},
Depends = { copyRC }
}
Expand Down Expand Up @@ -181,6 +193,34 @@ Build {
ReplaceEnv = {
OBJECTROOT = "build",
},
},
Config {
Name = "macos-clang",
DefaultOnHost = "macosx",
Tools = { "clang-osx" },
Env = {
CXXOPTS = {
"-std=c++11",
"-Wno-missing-braces",
"-Wno-unused-function",
"-Wno-unused-variable",
"-Wno-unused-result",
"-Wno-write-strings",
"-Wno-c++11-compat-deprecated-writable-strings",
"-Wno-null-dereference",
"-Wno-format",
"-fno-strict-aliasing",
"-fno-omit-frame-pointer",
"-Wno-extern-c-compat",
"-Werror",
"-O0",
"-g",
},
SHADERGEN_BIN = "./$(OBJECTROOT)$(SEP)$(BUILD_ID)$(SEP)shadergen",
},
ReplaceEnv = {
OBJECTROOT = "build",
},
}
},
}

0 comments on commit f685ab9

Please sign in to comment.