Index: build/runte4core.lua =================================================================== --- build/runte4core.lua (revision 0) +++ build/runte4core.lua (revision 0) @@ -0,0 +1,266 @@ +-- T-Engine4 +-- Copyright (C) 2009, 2010 Nicolas Casalini +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- Nicolas Casalini "DarkGod" +-- darkgod@te4.org + +project "TEngine" + kind "WindowedApp" + language "C" + targetname "t-engine" + files { "../src/*.c", } + links { "physfs", "lua".._OPTIONS.lua, "fov", "luasocket", "luaprofiler", "lualanes", "lpeg", "tcodimport", "lxp", "expatstatic", "luamd5", "luazlib", "luabitop" } + defines { "_DEFAULT_VIDEOMODE_FLAGS_='SDL_HWSURFACE|SDL_DOUBLEBUF'" } + defines { [[TENGINE_HOME_PATH='".t-engine"']], "TE4CORE_VERSION="..TE4CORE_VERSION } + + configuration "linux" + files { "../src/getself.c" } + links { "dl", "SDL", "SDL_ttf", "SDL_image", "SDL_mixer", "GL", "GLU", "m", "pthread" } + defines { [[TENGINE_HOME_PATH='".t-engine"']], 'SELFEXE_LINUX' } + + configuration "windows" + files { "../src/getself.c" } + links { "mingw32", "SDLmain", "SDL", "SDL_ttf", "SDL_image", "SDL_mixer", "OPENGL32", "GLU32", "wsock32" } + defines { [[TENGINE_HOME_PATH='"T-Engine"']], 'SELFEXE_WINDOWS' } + prebuildcommands { "windres ../src/windows/icon.rc -O coff -o ../src/windows/icon.res" } + linkoptions { "../src/windows/icon.res" } + + configuration "macosx" + files { "../src/mac/SDL*", "../src/mac/getself.m" } + defines { [[TENGINE_HOME_PATH='".t-engine"']], "USE_TENGINE_MAIN", 'SELFEXE_MACOSX' } + linkoptions { "-framework SDL", "-framework SDL_image", "-framework SDL_ttf", "-framework SDL_mixer", "-framework Cocoa", "-framework OpenGL" } + links { "IOKit" } + configuration "Debug" + postbuildcommands { + "mkdir -p ../bin/Debug/t-engine.app/Contents/Resources/", + "cp -r ../bootstrap ../bin/Debug/t-engine.app/Contents/Resources/", + "cp -r ../game ../bin/Debug/t-engine.app/Contents/Resources/", + "cp ../mac/te4.icns ../bin/Debug/t-engine.app/Contents/Resources/", + "mkdir -p ../bin/Debug/t-engine.app/Contents/Frameworks/", + "cp -r /Library/Frameworks/SDL.framework ../bin/Debug/t-engine.app/Contents/Frameworks/", + "cp -r /Library/Frameworks/SDL_image.framework ../bin/Debug/t-engine.app/Contents/Frameworks/", + "cp -r /Library/Frameworks/SDL_ttf.framework ../bin/Debug/t-engine.app/Contents/Frameworks/", + "cp -r /Library/Frameworks/SDL_mixer.framework ../bin/Debug/t-engine.app/Contents/Frameworks/", + } + configuration "Release" + postbuildcommands { + "cp -r ../bootstrap ../bin/Release/t-engine.app/Contents/Resources/", + "cp -r ../game ../bin/Release/t-engine.app/Contents/Resources/", + "cp ../mac/te4.icns ../bin/Release/t-engine.app/Contents/Resources/", + } + + +configuration "macosx" + excludes {"../src/getself.c"} + files { "../src/mac/getself.m" } + includedirs { + "/System/Library/Frameworks/OpenGL.framework/Headers", + "/Library/Frameworks/SDL.framework/Headers", + "/Library/Frameworks/SDL_net.framework/Headers", + "/Library/Frameworks/SDL_image.framework/Headers", + "/Library/Frameworks/SDL_ttf.framework/Headers", + "/Library/Frameworks/SDL_mixer.framework/Headers" + } + libdirs{ + "/usr/X11R6/lib" + } + defines { "USE_TENGINE_MAIN", 'SELFEXE_MACOSX' } + linkoptions { "-framework SDL", "-framework SDL_image", "-framework SDL_ttf", "-framework SDL_mixer", "-framework Cocoa", "-framework OpenGL" } + links { "IOKit" } + +configuration "windows" + linkoptions { "-mwindows" } + links { "mingw32", "SDLmain", "SDL", "SDL_ttf", "SDL_image", "SDL_mixer", "OPENGL32", "GLU32", "wsock32" } + defines { [[TENGINE_HOME_PATH='"T-Engine"']], 'SELFEXE_WINDOWS' } + + +configuration "linux" + buildoptions { "-fPIC" } + defines { [[TENGINE_HOME_PATH='".t-engine"']], 'SELFEXE_LINUX' } + + +---------------------------------------------------------------- +---------------------------------------------------------------- +-- Libraries used by T-Engine +---------------------------------------------------------------- +---------------------------------------------------------------- +project "physfs" + kind "StaticLib" + language "C" + targetname "physfs" + buildoptions { "-fPIC" } + + defines {"PHYSFS_SUPPORTS_ZIP"} + + files { "../src/physfs/*.c", "../src/physfs/zlib123/*.c", "../src/physfs/archivers/*.c", } + + configuration "linux" + files { "../src/physfs/platform/unix.c", "../src/physfs/platform/posix.c", } + configuration "windows" + files { "../src/physfs/platform/windows.c", } + configuration "macosx" + files { "../src/physfs/platform/macosx.c", "../src/physfs/platform/posix.c", } + includedirs { "/Library/Frameworks/SDL.framework/Headers" } + +if _OPTIONS.lua == "default" then + project "luadefault" + kind "StaticLib" + language "C" + targetname "lua" + buildoptions { "-fPIC" } + + files { "../src/lua/*.c", } +elseif _OPTIONS.lua == "jitx86" then + project "luajitx86" + kind "StaticLib" + language "C" + targetname "lua" + buildoptions { "-fPIC" } + + files { "../src/luajit/*.c", } + configuration "linux" + defines { "LUA_USE_POSIX" } +elseif _OPTIONS.lua == "jit2" then + project "luajit2" + kind "StaticLib" + language "C" + targetname "lua" + buildoptions { "-fPIC" } + + files { "../src/luajit2/src/*.c", "../src/luajit2/src/*.s", } +-- configuration "linux" +-- defines { "LUA_USE_POSIX" } +end + +project "luasocket" + kind "StaticLib" + language "C" + targetname "luasocket" + buildoptions { "-fPIC" } + + configuration "not windows" + files { + "../src/luasocket/auxiliar.c", + "../src/luasocket/buffer.c", + "../src/luasocket/except.c", + "../src/luasocket/inet.c", + "../src/luasocket/io.c", + "../src/luasocket/luasocket.c", + "../src/luasocket/options.c", + "../src/luasocket/select.c", + "../src/luasocket/tcp.c", + "../src/luasocket/timeout.c", + "../src/luasocket/udp.c", + "../src/luasocket/usocket.c", + "../src/luasocket/mime.c", + } + configuration "windows" + files { + "../src/luasocket/auxiliar.c", + "../src/luasocket/buffer.c", + "../src/luasocket/except.c", + "../src/luasocket/inet.c", + "../src/luasocket/io.c", + "../src/luasocket/luasocket.c", + "../src/luasocket/options.c", + "../src/luasocket/select.c", + "../src/luasocket/tcp.c", + "../src/luasocket/timeout.c", + "../src/luasocket/udp.c", + "../src/luasocket/wsocket.c", + "../src/luasocket/mime.c", + } + +project "fov" + kind "StaticLib" + language "C" + targetname "fov" + buildoptions { "-fPIC" } + + files { "../src/fov/*.c", } + +project "lpeg" + kind "StaticLib" + language "C" + targetname "lpeg" + buildoptions { "-fPIC" } + + files { "../src/lpeg/*.c", } + +project "luaprofiler" + kind "StaticLib" + language "C" + targetname "luaprofiler" + buildoptions { "-fPIC" } + + files { "../src/luaprofiler/*.c", } + +project "lualanes" + kind "StaticLib" + language "C" + targetname "lualanes" + buildoptions { "-fPIC" } + + files { "../src/lualanes/*.c", } + +project "tcodimport" + kind "StaticLib" + language "C" + targetname "tcodimport" + buildoptions { "-fPIC" } + + files { "../src/libtcod_import/*.c", } + +project "expatstatic" + kind "StaticLib" + language "C" + targetname "expatstatic" + defines{ "HAVE_MEMMOVE" } + buildoptions { "-fPIC" } + + files { "../src/expat/*.c", } + +project "lxp" + kind "StaticLib" + language "C" + targetname "lxp" + buildoptions { "-fPIC" } + + files { "../src/lxp/*.c", } + +project "luamd5" + kind "StaticLib" + language "C" + targetname "luamd5" + buildoptions { "-fPIC" } + + files { "../src/luamd5/*.c", } + +project "luazlib" + kind "StaticLib" + language "C" + targetname "luazlib" + buildoptions { "-fPIC" } + + files { "../src/lzlib/*.c", } + +project "luabitop" + kind "StaticLib" + language "C" + targetname "luabitop" + buildoptions { "-fPIC" } + + files { "../src/luabitop/*.c", } Index: src/main.c =================================================================== --- src/main.c (revision 3105) +++ src/main.c (working copy) @@ -1,4 +1,4 @@ -/* + /* TE4 - T-Engine 4 Copyright (C) 2009, 2010, 2011 Nicolas Casalini @@ -794,6 +794,7 @@ } } + /** * Core entry point. */ @@ -978,3 +979,43 @@ fclose(stdout); #endif } + +// Let some platforms use a different entry point +#ifdef USE_TENGINE_MAIN +#ifdef main +#undef main +#endif +#define main tengine_main +#endif + +void define_core(core_boot_type *core_def, const char *coretype, int id, const char *reboot_engine, const char *reboot_engine_version, const char *reboot_module, const char *reboot_name, int reboot_new, const char *reboot_einfo) +{ + if (core_def->coretype) free(core_def->coretype); + if (core_def->reboot_engine) free(core_def->reboot_engine); + if (core_def->reboot_engine_version) free(core_def->reboot_engine_version); + if (core_def->reboot_module) free(core_def->reboot_module); + if (core_def->reboot_name) free(core_def->reboot_name); + if (core_def->reboot_einfo) free(core_def->reboot_einfo); + + core_def->corenum = id; + core_def->coretype = coretype ? strdup(coretype) : NULL; + core_def->reboot_engine = reboot_engine ? strdup(reboot_engine) : NULL; + core_def->reboot_engine_version = reboot_engine_version ? strdup(reboot_engine_version) : NULL; + core_def->reboot_module = reboot_module ? strdup(reboot_module) : NULL; + core_def->reboot_name = reboot_name ? strdup(reboot_name) : NULL; + core_def->reboot_einfo = reboot_einfo ? strdup(reboot_einfo) : NULL; + core_def->reboot_new = reboot_new; +} + + +int tengine_main(int argc, char **argv) +{ + core_boot_type *core_def = calloc(1, sizeof(core_boot_type)); + + core_def->define = &define_core; + core_def->define(core_def, "te4core", -1, NULL, NULL, NULL, NULL, 0, NULL); + + te4main(argc, argv, core_def); + + exit(EXIT_SUCCESS); +} \ No newline at end of file Index: src/getself.c =================================================================== --- src/getself.c (revision 3105) +++ src/getself.c (working copy) @@ -58,45 +58,5 @@ } #elif defined(SELFEXE_MACOSX) -#include -#include -#include - -const char *get_self_executable(int argc, char **argv) -{ - size_t sz = 0; - char *buf; - char *sl; - - _NSGetExecutablePath(NULL, &sz); - buf = (char*) malloc(++sz); - _NSGetExecutablePath(buf, &sz); - - sl = strrchr(buf, '/'); - *(sl + 1) = '\0'; - return buf; -} - -#import - -int get_number_cpus() -{ - int count ; - size_t size=sizeof(count) ; - - if (sysctlbyname("hw.ncpu",&count,&size,NULL,0)) return 1; - return count; -} - -#else -const char *get_self_executable(int argc, char **argv) -{ - return NULL; -} - -int get_number_cpus() -{ - return 1; -} - +// Found in mac/getself.m for Objective-C compiling #endif Index: premake4.lua =================================================================== --- premake4.lua (revision 3105) +++ premake4.lua (working copy) @@ -55,5 +55,6 @@ targetdir "bin/Release" -dofile("build/runner.lua") -dofile("build/te4core.lua") +--dofile("build/runner.lua") +--dofile("build/te4core.lua") +dofile("build/runte4core.lua") \ No newline at end of file Index: bootstrap/boot.lua =================================================================== --- bootstrap/boot.lua (revision 3105) +++ bootstrap/boot.lua (working copy) @@ -9,8 +9,10 @@ local dir = __SELFEXE -- Remove bin/Debug from the path, to make dev easier - dir = dir:gsub("bin"..fs.getPathSeparator().."Debug"..fs.getPathSeparator(), "") +-- yufra: this was crashing my mac build since the wrong directory was being mounted (things get put in t-engine.app folder hierarchy, not just bin/Debug +-- dir = dir:gsub("bin"..fs.getPathSeparator().."Debug"..fs.getPathSeparator(), "") + if not __APPLE__ then -- Now remove executable name dir = dir:gsub("(.*"..fs.getPathSeparator()..").+", "%1") @@ -53,6 +55,9 @@ table.sort(usable, function(a, b) return b.id < a.id end) for i, file in ipairs(usable) do print("Selected cores:", file.id, file.file) end + -- Check we found something + assert(#usable > 0, "Couldn't find any T-Engine cores.") + -- Check for sanity and tell the runner to use it local core = "/engines/cores/"..usable[1].file if fs.exists(core) then