Skip to content
This repository has been archived by the owner on Oct 31, 2021. It is now read-only.

Commit

Permalink
Fixed build issues with GNUC under Linux.
Browse files Browse the repository at this point in the history
Added (and fixed) makefile support for Shiny lib, Shiny Lua lib and examples.
  • Loading branch information
dermaxi committed Mar 23, 2013
1 parent 37c43ef commit 3a8723b
Show file tree
Hide file tree
Showing 23 changed files with 342 additions and 84 deletions.
2 changes: 2 additions & 0 deletions Samples/Advanced/Advanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ THE SOFTWARE.

#include "Shared.h"

#include <stdlib.h>


/*---------------------------------------------------------------------------*/

Expand Down
23 changes: 23 additions & 0 deletions Samples/Advanced/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Shiny Profiler
# Advanced sample GNU Makefile
#
# You have to build libShiny.a first in 'Shiny' directory.

TARGET = Advanced

CXXFLAGS = -g -Wall
INCLUDES = -I../../Shiny/include
LFLAGS = -L../../Shiny/lib/
LIBS = -lShiny

SRCS = $(wildcard *.cpp)


all: $(TARGET)

$(TARGET): $(SRCS)
$(CXX) $(CXXFLAGS) $(INCLUDES) -o $@ $^ $(LFLAGS) $(LIBS)

clean:
$(RM) $(TARGET) $(OBJS)

20 changes: 20 additions & 0 deletions Samples/MainLoop/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Shiny Profiler
# MainLoop sample GNU Makefile
#
# You have to build libShiny.a first in 'Shiny' directory.

TARGET = MainLoop
CXXFLAGS = -g -Wall
INCLUDES = -I../../Shiny/include
LFLAGS = -L../../Shiny/lib/
LIBS = -lShiny
SRCS = MainLoop.cpp

all: $(TARGET)

$(TARGET): $(SRCS)
$(CXX) $(CXXFLAGS) $(INCLUDES) -o $@ $^ $(LFLAGS) $(LIBS)

clean:
$(RM) $(TARGET)

20 changes: 20 additions & 0 deletions Samples/Simple/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Shiny Profiler
# Simple sample GNU Makefile
#
# You have to build libShiny.a first in 'Shiny' directory.

TARGET = Simple
CXXFLAGS = -g -Wall
INCLUDES = -I../../Shiny/include
LFLAGS = -L../../Shiny/lib/
LIBS = -lShiny
SRCS = Simple.cpp

all: $(TARGET)

$(TARGET): $(SRCS)
$(CXX) $(CXXFLAGS) $(INCLUDES) -o $@ $^ $(LFLAGS) $(LIBS)

clean:
$(RM) $(TARGET)

89 changes: 89 additions & 0 deletions Shiny/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Shiny Profiler
# GNU Makefile for Linux
#
# By default libShiny.a will be compiled with g++ C++ compiler. If you prefer
# or need a plain C version use the 'cclib' target. The C compiled lib should
# be compatible to C AND C++ code according to ISO C99 and ISO C++98 (or
# later).
#
# To build Shiny as a static C++ lib use:
#
# make
#
# To build it as a static C lib (ISO C99) use:
#
# make cclib
#
# For building libs including more debug support use:
#
# make cxxdebug
# or
# make ccdebug
#
# If you experience incompatibilities please feel free to tailor this makefile
# to your needs and report problems here:
# - sourceforge: http:https://sourceforge.net/projects/shinyprofiler/
# - Google Code: http:https://code.google.com/p/shinyprofiler/


SRCS = $(wildcard src/*.c)
OBJS = $(SRCS:.c=.o)

LIB_NAME = libShiny.a
LIB_PATH = lib
LIB_PATH_DEBUG = lib/debug


##################
# Compiler options
FLAGS = -g -O3 -fPIC -Wall
INCLUDE = -Iinclude

# C options
cclib ccdebug: CCOMP = $(CC)
cclib: FLAGS += -std=c99

# C++ options
cxxlib cxxdebug: CCOMP = $(CXX)

# Debug options
ccdebug cxxdebug: FLAGS = -g -ggdb3 -O0 -Wall
ccdebug cxxdebug: LIB_PATH = $(LIB_PATH_DEBUG)


##################
# Target definitions

# All target builds static C++ lib
all: cxxlib

# Copy static lib into lib/ or lib/debug
cclib cxxlib ccdebug cxxdebug: $(LIB_NAME)
mkdir -p $(LIB_PATH)
mv $^ $(LIB_PATH)

# Build static lib in either C or C++
$(LIB_NAME): $(OBJS)
$(AR) rcs $@ $^

# Create object files from source code
.c.o:
$(CCOMP) $(FLAGS) $(INCLUDE) -c $< -o $@


# Remove temporary files and compilation results
clean:
$(RM) $(OBJS) $(LIB_PATH)/$(LIB_NAME) $(LIB_PATH_DEBUG)/$(LIB_NAME)


help:
@echo "Available targets for Shiny"
@echo " cxxlib: Build static library libShiny.a using C++ compiler"
@echo " cclib: Build static library libShiny.a using C compiler"
@echo ""
@echo " cxxdebug: Build static library libShiny.a with debug symbols using C++ compiler"
@echo " ccdebug: Build static library libShiny.a with debug symbols using C compiler"
@echo ""
@echo " clean: Clean up directories"

.PHONY: all cclib cxxlib ccdebug cxxdebug help clean
8 changes: 0 additions & 8 deletions Shiny/include/Shiny.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,7 @@ THE SOFTWARE.

/*---------------------------------------------------------------------------*/

#ifdef __cplusplus
extern "C" {
#endif

#include "ShinyMacros.h"
#include "ShinyManager.h"

#ifdef __cplusplus
}
#endif

#endif /* end of include guard */
11 changes: 11 additions & 0 deletions Shiny/include/ShinyData.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ THE SOFTWARE.
#include "ShinyPrereqs.h"


#ifdef __cplusplus
extern "C" {
#endif


/*---------------------------------------------------------------------------*/

typedef struct {
Expand All @@ -54,6 +59,7 @@ typedef struct {
ShinyTickData childTicks;
} ShinyData;


SHINY_INLINE shinytick_t ShinyData_totalTicksCur(const ShinyData *self) {
return self->selfTicks.cur + self->childTicks.cur;
}
Expand Down Expand Up @@ -92,4 +98,9 @@ SHINY_INLINE void ShinyData_clearCurrent(ShinyData *self) {
self->childTicks.cur = 0;
}


#ifdef __cplusplus
} /* end of extern "C" */
#endif

#endif /* end of include guard */
9 changes: 9 additions & 0 deletions Shiny/include/ShinyMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ THE SOFTWARE.

#include "ShinyManager.h"


#ifdef __cplusplus
extern "C" {
#endif

#if SHINY_IS_COMPILED == TRUE


Expand Down Expand Up @@ -287,6 +292,10 @@ SHINY_INLINE ShinyData GetEmptyData() {
#define PROFILE_SET_ENABLED(boolean)
#endif

#endif /* #if SHINY_IS_COMPILED == TRUE */

#ifdef __cplusplus
} /* end of extern "C" */
#endif

#endif /* end of include guard */
24 changes: 19 additions & 5 deletions Shiny/include/ShinyManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ THE SOFTWARE.

#include <stdio.h>


#if SHINY_IS_COMPILED == TRUE

#ifdef __cplusplus
extern "C" {
#endif


/*---------------------------------------------------------------------------*/

Expand Down Expand Up @@ -85,6 +90,7 @@ extern ShinyManager Shiny_instance;

/*---------------------------------------------------------------------------*/


SHINY_INLINE void _ShinyManager_appendTicksToCurNode(ShinyManager *self) {
shinytick_t curTick;
ShinyGetTicks(&curTick);
Expand Down Expand Up @@ -190,9 +196,11 @@ SHINY_API const char* ShinyManager_getOutputErrorString(ShinyManager *self);
SHINY_API int ShinyManager_output(ShinyManager *self, const char *a_filename);
SHINY_API void ShinyManager_outputToStream(ShinyManager *self, FILE *stream);

#if __cplusplus

#ifdef __cplusplus
} /* end of extern "C" */


SHINY_INLINE std::string ShinyManager_outputTreeToString(ShinyManager *self) {
const char* error = ShinyManager_getOutputErrorString(self);
if (error) return error;
Expand All @@ -207,9 +215,11 @@ SHINY_INLINE std::string ShinyManager_outputFlatToString(ShinyManager *self) {
return ShinyZonesToString(&self->rootZone, self->zoneCount);
}


extern "C" { /* end of c++ */
#endif


SHINY_INLINE int ShinyManager_isZoneSelfTimeBelow(ShinyManager *self, ShinyZone* a_zone, float a_percentage) {
return a_percentage * (float) self->rootZone.data.childTicks.cur
<= (float) a_zone->data.selfTicks.cur;
Expand All @@ -230,9 +240,11 @@ SHINY_INLINE void ShinyManager_enumerateZones(ShinyManager *self, void (*a_func)
ShinyZone_enumerateZones(&self->rootZone, a_func);
}

#if __cplusplus

#ifdef __cplusplus
} /* end of extern "C" */


template <class T> void ShinyManager_enumerateNodes(ShinyManager *self, T* a_this, void (T::*a_func)(const ShinyNode*)) {
ShinyNode_enumerateNodes(&self->rootNode, a_this, a_func);
}
Expand All @@ -241,15 +253,18 @@ template <class T> void ShinyManager_enumerateZones(ShinyManager *self, T* a_thi
ShinyZone_enumerateZones(&self->rootZone, a_this, a_func);
}


extern "C" { /* end of c++ */
#endif


/*---------------------------------------------------------------------------*/

#if __cplusplus

#ifdef __cplusplus
} /* end of extern "C" */


class ShinyEndNodeOnDestruction {
public:

Expand All @@ -258,9 +273,8 @@ class ShinyEndNodeOnDestruction {
}
};

extern "C" { /* end of c++ */
#endif

#endif /* end of c++ */

#endif /* if SHINY_IS_COMPILED == TRUE */

Expand Down
14 changes: 11 additions & 3 deletions Shiny/include/ShinyNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ THE SOFTWARE.
#include "ShinyData.h"
#include "ShinyTools.h"


#if SHINY_IS_COMPILED == TRUE

#ifdef __cplusplus
extern "C" {
#endif


/*---------------------------------------------------------------------------*/

Expand Down Expand Up @@ -61,6 +66,7 @@ extern ShinyNode _ShinyNode_dummy;

/*---------------------------------------------------------------------------*/


SHINY_INLINE void ShinyNode_addChild(ShinyNode* self, ShinyNode* a_child) {
if (self->childCount++) {
self->lastChild->nextSibling = a_child;
Expand Down Expand Up @@ -117,9 +123,11 @@ SHINY_API void ShinyNode_clear(ShinyNode* self);

SHINY_API void ShinyNode_enumerateNodes(const ShinyNode* a_node, void (*a_func)(const ShinyNode*));

#if __cplusplus

#ifdef __cplusplus
} /* end of extern "C" */


template <class T>
void ShinyNode_enumerateNodes(const ShinyNode* a_node, T* a_this, void (T::*a_func)(const ShinyNode*)) {
(a_this->*a_func)(a_node);
Expand All @@ -128,8 +136,8 @@ void ShinyNode_enumerateNodes(const ShinyNode* a_node, T* a_this, void (T::*a_fu
if (a_node->nextSibling) ShinyNode_enumerateNodes(a_node->nextSibling, a_this, a_func);
}

extern "C" { /* end of c++ */
#endif

#endif /* end of c++ */

#endif /* if SHINY_IS_COMPILED == TRUE */

Expand Down
Loading

0 comments on commit 3a8723b

Please sign in to comment.