Просмотр исходного кода

Linux template, packaging dependencies, tgz on Linux

Ivan Safrin 14 лет назад
Родитель
Сommit
77d5890643

+ 21 - 0
Assets/Templates/C++/Linux/HelloPolycodeApp.cpp

@@ -0,0 +1,21 @@
+#include "HelloPolycodeApp.h"
+
+HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) : EventHandler() {
+
+#ifdef __APPLE__
+	core = new CocoaCore(view, 640,480,false,0,90);	  
+#else
+	core = new SDLCore(view, 640,480,false,0,90);	  
+#endif
+
+	CoreServices::getInstance()->getResourceManager()->addArchive("default.pak");
+	CoreServices::getInstance()->getResourceManager()->addDirResource("default", false);
+
+	Screen *screen = new Screen();
+	ScreenLabel *label = new ScreenLabel("Hello, Polycode!", 32);
+	screen->addChild(label);
+}
+
+bool HelloPolycodeApp::Update() {
+    return core->Update();
+}

+ 14 - 0
Assets/Templates/C++/Linux/HelloPolycodeApp.h

@@ -0,0 +1,14 @@
+#include <Polycode.h>
+#include "PolycodeView.h"
+
+using namespace Polycode;
+
+class HelloPolycodeApp : public EventHandler {
+public:
+    HelloPolycodeApp(PolycodeView *view);
+    ~HelloPolycodeApp();
+    bool Update();
+    
+private:
+	Core *core;
+};

+ 11 - 0
Assets/Templates/C++/Linux/Makefile

@@ -0,0 +1,11 @@
+CC=g++
+CFLAGS=-I../../Core/Dependencies/include -I../../Core/Dependencies/include/AL -I../../Core/include -I../../Modules/include -I../../Modules/Dependencies/include -I../../Modules/Dependencies/include/bullet
+LDFLAGS=../../Core/lib/libPolycore.a ../../Core/Dependencies/lib/libfreetype.a ../../Core/Dependencies/lib/liblibvorbisfile.a ../../Core/Dependencies/lib/liblibvorbis.a ../../Core/Dependencies/lib/liblibogg.a ../../Core/Dependencies/lib/libopenal.a ../../Core/Dependencies/lib/libphysfs.a ../../Core/Dependencies/lib/libpng15.a ../../Core/Dependencies/lib/libz.a -lGL -lGLU -lSDL ../../Modules/lib/libPolycode2DPhysics.a ../../Modules/Dependencies/lib/libBox2D.a ../../Modules/lib/libPolycode3DPhysics.a ../../Modules/Dependencies/lib/libBulletDynamics.a ../../Modules/Dependencies/lib/libBulletCollision.a ../../Modules/Dependencies/lib/libLinearMath.a ../../Modules/lib/libPolycodeNetworking.a
+
+default:
+	$(CC) $(CFLAGS) main.cpp HelloPolycodeApp.cpp -o PolycodeTemplate $(LDFLAGS)
+	cp ../../Core/Assets/default.pak .
+clean:
+	rm PolycodeTemplate
+	rm default.pak
+	

+ 10 - 0
Assets/Templates/C++/Linux/main.cpp

@@ -0,0 +1,10 @@
+#include "Polycode.h"
+#include "PolycodeView.h"
+#include "HelloPolycodeApp.h"
+
+int main(int argc, char *argv[]) {
+	PolycodeView *view = new PolycodeView("Hello Polycode!");
+	HelloPolycodeApp *app = new HelloPolycodeApp(view);
+	while(app->Update()) {}
+	return 0;
+}

+ 5 - 0
Assets/Templates/CMakeLists.txt

@@ -4,5 +4,10 @@ IF(APPLE)
     INSTALL(DIRECTORY "C++/Xcode"
 	DESTINATION "Template/")
 ENDIF(APPLE)
+
+IF(UNIX)
+    INSTALL(DIRECTORY "C++/Linux"
+	DESTINATION "Template/")
+ENDIF(UNIX)
     
 ENDIF(POLYCODE_INSTALL_TEMPLATE)

+ 9 - 1
CMakeLists.txt

@@ -78,10 +78,18 @@ INSTALL(DIRECTORY ${Polycode_SOURCE_DIR}/Examples/C++/Build/${CMAKE_SYSTEM_NAME}
 INSTALL(DIRECTORY ${Polycode_SOURCE_DIR}/Examples/C++/Contents DESTINATION Examples/${CMAKE_SYSTEM_NAME})
 INSTALL(DIRECTORY ${Polycode_SOURCE_DIR}/Examples/C++/Resources DESTINATION Examples/${CMAKE_SYSTEM_NAME})
 
+INSTALL(DIRECTORY ${POLYCODE_RELEASE_DIR}/Framework/Core/Dependencies DESTINATION Core)
+INSTALL(DIRECTORY ${POLYCODE_RELEASE_DIR}/Framework/Modules/Dependencies DESTINATION Modules)
+
 SET(CPACK_PACKAGE_VERSION_MAJOR "0")
 SET(CPACK_PACKAGE_VERSION_MINOR "8")
 SET(CPACK_PACKAGE_VERSION_PATCH "2")
-SET(CPACK_GENERATOR "ZIP")
+
+IF(UNIX)
+	SET(CPACK_GENERATOR "TGZ")
+ELSE()
+	SET(CPACK_GENERATOR "ZIP")
+ENDIF(UNIX)
 
 INCLUDE(CPack)