Commit 4146952e authored by Laszlo Papp's avatar Laszlo Papp
Browse files

Initial commit

parents
*~
*.swp
*.so
*.o
*.a
build
release-build
Doxyfile
*.patch
# CMake
CMakeCache.txt
CMakeFiles
cmake_install.cmake
CMakeLists.txt.user
CMakeLists.txt.user.*
#QtCreator
qtcreator-build
#############################################################################
# This file is part of the libqgit2 library
# Copyright (C) 2011 Laszlo Papp
#
# 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 2 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, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# CMake build script for the libgit2 project
#
# Building (out of source build):
# > mkdir build && cd build
# > cmake .. [-DSETTINGS=VALUE]
# > cmake --build .
#
# Testing:
# > ctest -V
#
# Install:
# > cmake --build . --target install
cmake_minimum_required(VERSION 2.6)
project(libqgit2)
FILE(STRINGS "qgit2.h" QGIT2_HEADER REGEX "^#define LIBQGIT2_VERSION \"[^\"]*\"$")
STRING(REGEX REPLACE "^.*LIBQGIT2_VERSION \"([0-9]+).*$" "\\1" LIBQGIT2_VERSION_MAJOR "${QGIT2_HEADER}")
STRING(REGEX REPLACE "^.*LIBQGIT2_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" LIBQGIT2_VERSION_MINOR "${QGIT2_HEADER}")
STRING(REGEX REPLACE "^.*LIBQGIT2_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" LIBQGIT2_VERSION_REV "${QGIT2_HEADER}")
SET(LIBQGIT2_VERSION_STRING "${LIBQGIT2_VERSION_MAJOR}.${LIBQGIT2_VERSION_MINOR}.${LIBQGIT2_VERSION_REV}")
# Installation paths
SET(INSTALL_BIN bin CACHE PATH "Where to install binaries to.")
SET(INSTALL_LIB lib CACHE PATH "Where to install libraries to.")
SET(INSTALL_INC include CACHE PATH "Where to install headers to.")
# Build options
OPTION (BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON)
OPTION (BUILD_TESTS "Build Tests" ON)
#Project options, to provide a selective build process
#Note that some of these are mutually exclusive or just
#do not make a whole lot of sense combined.
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
if(CMAKE_INSTALL_PREFIX STREQUAL "/usr")
option(INSTALL_CMAKE_FILES "Install the *.cmake files into the CMake root" ON)
else()
option(INSTALL_CMAKE_FILES "Install the *.cmake files into the CMake root" OFF)
endif()
set(LIBQGIT2_BUILD_ALL TRUE
CACHE INTERNAL "Build all of LIBQGIT2"
)
SET(CMAKE_CXX_FLAGS "-Wall")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Wall -O2 -g")
SET(CMAKE_CXX_FLAGS_RELEASE "-Wall -O2")
SET(CMAKE_CXX_FLAGS_DEBUG "-Wall -g3 -ggdb -O0" CACHE STRING "Debug options." FORCE)
# Build Release by default
IF (NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
ENDIF ()
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
# Collect sourcefiles
FILE(GLOB SRC src/*.cpp)
message(STATUS)
message(STATUS "========== LIBQGIT2 Build Information ==========")
message(STATUS "Build Version: ${LIBQGIT2_VERSION_STRING} (${LIBQGIT2_VERSION_NAME})")
message(STATUS "Install Prefix: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "Install the *.cmake files into CMake root (INSTALL_CMAKE_FILES): ${INSTALL_CMAKE_FILES}")
message(STATUS)
message(STATUS "To change any of these options, override them using -D{OPTION_NAME} on the commandline.")
message(STATUS "To build and install LIBQGIT2, run \"make\" and \"make install\"")
message(STATUS)
# Compile and link libqgit2
ADD_LIBRARY(qgit2 ${SRC})
TARGET_LINK_LIBRARIES(qgit2)
SET_TARGET_PROPERTIES(qgit2 PROPERTIES VERSION ${LIBQGIT2_VERSION_STRING})
SET_TARGET_PROPERTIES(qgit2 PROPERTIES SOVERSION ${LIBQGIT2_VERSION_MAJOR})
# Install
INSTALL(TARGETS qgit2
RUNTIME DESTINATION ${INSTALL_BIN}
LIBRARY DESTINATION ${INSTALL_LIB}
ARCHIVE DESTINATION ${INSTALL_LIB}
)
# INSTALL(DIRECTORY src/git2 DESTINATION ${INSTALL_INC} )
INSTALL(FILES qgit2.h DESTINATION ${INSTALL_INC} )
if(INSTALL_CMAKE_FILES)
install(
FILES
DESTINATION
${CMAKE_ROOT}/Modules
OPTIONAL
)
else()
install(
FILES
DESTINATION
${SHARE_INSTALL_DIR}/mula/cmake
OPTIONAL
)
endif()
#Packaging options
set(CPACK_SET_DESTDIR ON)
set(CPACK_GENERATOR "DEB;TGZ")
set(CPACK_PACKAGE_NAME "LIBQGIT2")
set(CPACK_PACKAGE_FILE_NAME "LIBQGIT2-${LIBQGIT2_VERSION_STRING}")
set(CPACK_PACKAGE_VERSION "${LIBQGIT2_VERSION_MAJOR}.${LIBQGIT2_VERSION_MINOR}.${LIBQGIT2_VERSION_PATCH}")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libgit2")
set(CPACK_PACKAGE_CONTACT "Laszlo Papp <djszapi@archlinux.us>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "libgit2 bindings for Qt")
set(CPACK_DEBIAN_PACKAGE_SECTION "Utils")
include(InstallRequiredSystemLibraries)
include(CPack)
This diff is collapsed.
/******************************************************************************
* This file is part of the Gluon Development Platform
* Copyright (C) 2011 Laszlo Papp <djszapi@archlinux.us>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef LIBQGIT2_EXPORT_H
#define LIBQGIT2_EXPORT_H
#include <QtCore/qglobal.h>
#include <QtCore/QObject>
#ifndef LIBQGIT2_EXPORT
#if defined(MAKE_LIBQGIT2_LIB)
#define LIBQGIT2_EXPORT Q_DECL_EXPORT
#else
#define LIBQGIT2_EXPORT Q_DECL_IMPORT
#endif
#endif
#ifndef LIBQGIT2_EXPORT_DEPRECATED
#define LIBQGIT2_EXPORT_DEPRECATED Q_DECL_DEPRECATED LIBQGIT2_EXPORT
#endif
#ifndef LIBQGIT2_BLOB_EXPORT
#if defined(MAKE_LIBQGIT2_COMPONENT_BLOB)
# define LIBQGIT2_BLOB_EXPORT Q_DECL_EXPORT
#else
# define LIBQGIT2_BLOB_EXPORT Q_DECL_IMPORT
#endif
#endif
# ifndef LIBQGIT2_BLOB_EXPORT_DEPRECATED
# define LIBQGIT2_BLOB_EXPORT_DEPRECATED Q_DECL_DEPRECATED LIBQGIT2_EXPORT
# endif
#ifndef LIBQGIT2_REPOSITORY_EXPORT
#if defined(MAKE_LIBQGIT2_COMPONENT_REPOSITORY)
# define LIBQGIT2_REPOSITORY_EXPORT Q_DECL_EXPORT
#else
# define LIBQGIT2_REPOSITORY_EXPORT Q_DECL_IMPORT
#endif
#endif
# ifndef LIBQGIT2_REPOSITORY_EXPORT_DEPRECATED
# define LIBQGIT2_REPOSITORY_EXPORT_DEPRECATED Q_DECL_DEPRECATED LIBQGIT2_EXPORT
# endif
#ifndef LIBQGIT2_DATABASE_EXPORT
#if defined(MAKE_LIBQGIT2_COMPONENT_DATABASE)
# define LIBQGIT2_DATABASE_EXPORT Q_DECL_EXPORT
#else
# define LIBQGIT2_DATABASE_EXPORT Q_DECL_IMPORT
#endif
#endif
# ifndef LIBQGIT2_DATABASE_EXPORT_DEPRECATED
# define LIBQGIT2_DATABASE_EXPORT_DEPRECATED Q_DECL_DEPRECATED LIBQGIT2_EXPORT
# endif
#ifndef LIBQGIT2_DATABASEBACKEND_EXPORT
#if defined(MAKE_LIBQGIT2_COMPONENT_DATABASEBACKEND)
# define LIBQGIT2_DATABASEBACKEND_EXPORT Q_DECL_EXPORT
#else
# define LIBQGIT2_DATABASEBACKEND_EXPORT Q_DECL_IMPORT
#endif
#endif
# ifndef LIBQGIT2_DATABASEBACKEND_EXPORT_DEPRECATED
# define LIBQGIT2_DATABASEBACKEND_EXPORT_DEPRECATED Q_DECL_DEPRECATED LIBQGIT2_EXPORT
# endif
#ifndef LIBQGIT2_OID_EXPORT
#if defined(MAKE_LIBQGIT2_COMPONENT_OID)
# define LIBQGIT2_OID_EXPORT Q_DECL_EXPORT
#else
# define LIBQGIT2_OID_EXPORT Q_DECL_IMPORT
#endif
#endif
# ifndef LIBQGIT2_OID_EXPORT_DEPRECATED
# define LIBQGIT2_OID_EXPORT_DEPRECATED Q_DECL_DEPRECATED LIBQGIT2_EXPORT
# endif
#ifndef LIBQGIT2_OBJECT_EXPORT
#if defined(MAKE_LIBQGIT2_OBJECT)
# define LIBQGIT2_OBJECT_EXPORT Q_DECL_EXPORT
#else
# define LIBQGIT2_OBJECT_EXPORT Q_DECL_IMPORT
#endif
#endif
# ifndef LIBQGIT2_OBJECT_EXPORT_DEPRECATED
# define LIBQGIT2_OBJECT_EXPORT_DEPRECATED Q_DECL_DEPRECATED LIBQGIT2_EXPORT
# endif
#ifndef LIBQGIT2_INDEX_EXPORT
#if defined(MAKE_LIBQGIT2_INDEX_OBJECT)
# define LIBQGIT2_INDEX_EXPORT Q_DECL_EXPORT
#else
# define LIBQGIT2_INDEX_EXPORT Q_DECL_IMPORT
#endif
#endif
# ifndef LIBQGIT2_INDEX_EXPORT_DEPRECATED
# define LIBQGIT2_INDEX_EXPORT_DEPRECATED Q_DECL_DEPRECATED LIBQGIT2_EXPORT
# endif
#ifndef LIBQGIT2_REFS_EXPORT
#if defined(MAKE_LIBQGIT2_REFS_OBJECT)
# define LIBQGIT2_REFS_EXPORT Q_DECL_EXPORT
#else
# define LIBQGIT2_REFS_EXPORT Q_DECL_IMPORT
#endif
#endif
# ifndef LIBQGIT2_REFS_EXPORT_DEPRECATED
# define LIBQGIT2_REFS_EXPORT_DEPRECATED Q_DECL_DEPRECATED LIBQGIT2_EXPORT
# endif
#ifndef LIBQGIT2_TAG_EXPORT
#if defined(MAKE_LIBQGIT2_TAG)
# define LIBQGIT2_TAG_EXPORT Q_DECL_EXPORT
#else
# define LIBQGIT2_TAG_EXPORT Q_DECL_IMPORT
#endif
#endif
# ifndef LIBQGIT2_TAG_EXPORT_DEPRECATED
# define LIBQGIT2_TAG_EXPORT_DEPRECATED Q_DECL_DEPRECATED LIBQGIT2_EXPORT
# endif
#ifndef LIBQGIT2_SIGNATURE_EXPORT
#if defined(MAKE_LIBQGIT2_SIGNATURE)
# define LIBQGIT2_SIGNATURE_EXPORT Q_DECL_EXPORT
#else
# define LIBQGIT2_SIGNATURE_EXPORT Q_DECL_IMPORT
#endif
#endif
# ifndef LIBQGIT2_SIGNATURE_EXPORT_DEPRECATED
# define LIBQGIT2_SIGNATURE_EXPORT_DEPRECATED Q_DECL_DEPRECATED LIBQGIT2_EXPORT
# endif
#ifndef LIBQGIT2_REVWALK_EXPORT
#if defined(MAKE_LIBQGIT2_REVWALK)
# define LIBQGIT2_REVWALK_EXPORT Q_DECL_EXPORT
#else
# define LIBQGIT2_REVWALK_EXPORT Q_DECL_IMPORT
#endif
#endif
# ifndef LIBQGIT2_REVWALK_EXPORT_DEPRECATED
# define LIBQGIT2_REVWALK_EXPORT_DEPRECATED Q_DECL_DEPRECATED LIBQGIT2_EXPORT
# endif
#ifndef LIBQGIT2_COMMIT_EXPORT
#if defined(MAKE_LIBQGIT2_COMMIT)
# define LIBQGIT2_COMMIT_EXPORT Q_DECL_EXPORT
#else
# define LIBQGIT2_COMMIT_EXPORT Q_DECL_IMPORT
#endif
#endif
# ifndef LIBQGIT2_COMMIT_EXPORT_DEPRECATED
# define LIBQGIT2_COMMIT_EXPORT_DEPRECATED Q_DECL_DEPRECATED LIBQGIT2_EXPORT
# endif
#ifndef LIBQGIT2_TREE_EXPORT
#if defined(MAKE_LIBQGIT2_TREE)
# define LIBQGIT2_TREE_EXPORT Q_DECL_EXPORT
#else
# define LIBQGIT2_TREE_EXPORT Q_DECL_IMPORT
#endif
#endif
# ifndef LIBQGIT2_TREE_EXPORT_DEPRECATED
# define LIBQGIT2_TREE_EXPORT_DEPRECATED Q_DECL_DEPRECATED LIBQGIT2_EXPORT
# endif
#ifndef LIBQGIT2_TREEENTRY_EXPORT
#if defined(MAKE_LIBQGIT2_TREEENTRY)
# define LIBQGIT2_TREEENTRY_EXPORT Q_DECL_EXPORT
#else
# define LIBQGIT2_TREEENTRY_EXPORT Q_DECL_IMPORT
#endif
#endif
# ifndef LIBQGIT2_TREEENTRY_EXPORT_DEPRECATED
# define LIBQGIT2_TREEENTRY_EXPORT_DEPRECATED Q_DECL_DEPRECATED LIBQGIT2_EXPORT
# endif
#ifndef LIBQGIT2_RAWOBJECT_EXPORT
#if defined(MAKE_LIBQGIT2_RAWOBJECT)
# define LIBQGIT2_RAWOBJECT_EXPORT Q_DECL_EXPORT
#else
# define LIBQGIT2_RAWOBJECT_EXPORT Q_DECL_IMPORT
#endif
#endif
# ifndef LIBQGIT2_RAWOBJECT_EXPORT_DEPRECATED
# define LIBQGIT2_RAWOBJECT_EXPORT_DEPRECATED Q_DECL_DEPRECATED LIBQGIT2_EXPORT
# endif
#endif // LIBQGIT2_EXPORT_H
/******************************************************************************
* This file is part of the Gluon Development Platform
* Copyright (c) 2011 Laszlo Papp <djszapi@archlinux.us>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef INCLUDE_QGIT2_H
#define INCLUDE_QGIT2_H
#define LIBQGIT2_VERSION "0.1.0"
#define LIBQGIT2_VER_MAJOR 0
#define LIBQGIT2_VER_MINOR 1
#define LIBQGIT2_VER_REVISION 0
#include "src/oid.h"
#include "src/signature.h"
#include "src/database.h"
#include "src/repository.h"
#include "src/revwalk.h"
#include "src/refs.h"
#include "src/object.h"
#include "src/blob.h"
#include "src/commit.h"
#include "src/tag.h"
#include "src/tree.h"
#include "src/index.h"
#endif
cmake_minimum_required(VERSION 2.6)
if(NOT GLUON_BUILD_ALL)
find_package(GluonGraphics REQUIRED)
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${GLUON_GRAPHICS_INCLUDES})
set(particlecollidercomponent_SRCS
particlecollidercomponent.cpp
)
qt4_automoc(${particlecollidercomponent_SRCS})
add_library(gluon_component_particlecollider SHARED ${particlecollidercomponent_SRCS})
if(GLUON_BUILD_ALL)
add_dependencies(gluon_component_particlecollider GluonEngine GluonGraphics)
endif()
set_target_properties(gluon_component_particlecollider PROPERTIES VERSION ${GLUON_VERSION_STRING} SOVERSION ${GLUON_VERSION_STRING} DEFINE_SYMBOL MAKE_GLUON_COMPONENT_PARTICLECOLLIDER_LIB)
target_link_libraries(gluon_component_particlecollider GluonEngine ${GLUON_GRAPHICS_LIBS})
install(
TARGETS
gluon_component_particlecollider
DESTINATION
${LIB_INSTALL_DIR}/gluon
)
/******************************************************************************
* This file is part of the Gluon Development Platform
* Copyright (c) 2011 Laszlo Papp <djszapi@archlinux.us>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "blob.h"
using namespace LibQGit2;
Blob::Blob(Repository* repository, QObject* parent )
{
git_blob_new(&m_blob, repository->data());
}
Blob::Blob( const Blob& other )
{
m_blob = other.m_blob;
}
Blob::~Blob()
{
}
int Blob::lookup(Repository* repository, const OId& oid)
{
return git_blob_lookup(&m_blob, repository->data(), oid.constData());
}
const char* Blob::rawContent()
{
return git_blob_rawcontent(m_blob);
}
int Blob::rawSize()
{
return git_blob_rawsize(m_blob);
}
int Blob::setRawContentFromFile(const QString& fileName)
{
return git_blob_set_rawcontent_fromfile(m_blob, fileName.toAscii().constData());
}
int Blob::setRawContent(const void* buffer, size_t len)
{
return git_blob_set_rawcontent(m_blob, buffer, len);
}
int Blob::writeFile(OId *writtenId, Repository *repository, const QString& path)
{
return git_blob_writefile(writtenId->data(), repository->data(), path.toAscii().constData());
}
git_blob* Blob::data() const
{
return m_blob;
}
const git_blob* Blob::constData() const
{
return const_cast<const git_blob *>(m_blob);
}
/******************************************************************************
* This file is part of the Gluon Development Platform
* Copyright (c) 2011 Laszlo Papp <djszapi@archlinux.us>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef LIBQGIT2_BLOB_H
#define LIBQGIT2_BLOB_H
#include "libqgit2_export.h"
#include "repository.h"
#include <QtCore/QObject>
#include <git2/blob.h>
namespace LibQGit2
{
class LIBQGIT2_BLOB_EXPORT Blob
{
public:
/**
* Construct a new in-memory Blob.
*
* The blob object must be manually filled using
* the 'set_rawcontent' methods before it can
* be written back to disk.
*
* @param repository The repository where the object will reside
* @return 0 on success; error code otherwise
*/
Blob(Repository* repository, QObject* parent = 0 );
Blob( const Blob& other );
/**
* Delete a Blob previously allocated.
*/
~Blob();
public:
/**
* Lookup a blob object from a repository.
* The generated blob object is owned by the revision
* repo and shall not be freed by the user.
*
* @param repository the repository to use when locating the blob.
* @param id identity of the blob to locate.
* @return 0 on success; error code otherwise
*/
int lookup(Repository* repository, const OId& oid);
/**
* Get a read-only buffer with the raw content of a blob.
*
* A pointer to the raw content of a blob is returned;
* this pointer is owned internally by the object and shall
* not be free'd. The pointer may be invalidated at a later
* time (e.g. when changing the contents of the blob).
*
* @return the pointer; NULL if the blob has no contents
*/
const char* rawContent();
/**
* Get the size in bytes of the contents of a blob
*
* @return size on bytes
*/
int rawSize();
/**
* Fill a blob with the contents inside
* the pointed file.
*
* @param filename name of the file to read
* @return 0 on success; error code otherwise
*/
int setRawContentFromFile(const QString& fileName);
/**
* Fill a blob with the contents inside
* the pointed buffer
*
* @param buffer buffer with the contents for the blob
* @param len size of the buffer
* @return 0 on success; error code otherwise
*/
int setRawContent(const void* buffer, size_t len);
/**
* Read a file from the working folder of a repository
* and write it to the Object Database as a loose blob,
* if such doesn't exist yet.
*
* @param writtenId return the id of the written blob
* @param repository repository where the blob will be written
* @param path file from which the blob will be created
*/
int writeFile(OId *writtenId, Repository *repository, const QString& path);
git_blob* data() const;
const git_blob* constData() const;