Commit 0611f06d authored by Greg Williams's avatar Greg Williams
Browse files

Cleaned up example integration into build

parent 8447962d
Loading
Loading
Loading
Loading
+46 −14
Original line number Diff line number Diff line
@@ -78,16 +78,24 @@ LIB_OBJS = \
	$(OUT_DIR)/kinetic_client.o
KINETIC_LIB_OTHER_DEPS = Makefile Rakefile $(VERSION_FILE)

default: $(KINETIC_LIB)
default: makedirs $(KINETIC_LIB)

all: clean test default run
makedirs:
	@echo; mkdir -p ./bin/examples &> /dev/null; mkdir -p ./out &> /dev/null

clean:
all: clean test default run examples

clean: makedirs
	bundle exec rake clobber
	rm -rf $(BIN_DIR)/* $(OUT_DIR)/*.o *.core *.log
	find ./bin/**/* -type f | xargs rm $1
	rm -rf ./bin/**/*.dSYM
	rm -rf ./bin/**/*.a
	rm -f $(OUT_DIR)/*.o *.core *.log
	git submodule update --init

.PHONY: clean
.PHONY: clean makedirs

.POSIX:

# $(OUT_DIR)/%.o: %.c $(DEPS)
# 	$(CC) -c -o $@ $< $(CFLAGS)
@@ -229,12 +237,12 @@ start_simulator:

erase_simulator: start_simulator
	./vendor/kinetic-simulator/eraseSimulator.sh
	sleep 1
	sleep 2

stop_simulator:
	./vendor/kinetic-simulator/stopSimulator.sh

.PHONY: start_simulator erase_simulator stop_simulator
.PHONY: erase_simulator


#===============================================================================
@@ -290,17 +298,41 @@ run: $(UTIL_EXEC) start_simulator
#===============================================================================

EXAMPLE_SRC = ./src/examples
EXAMPLE_BIN = $(BIN_DIR)/
EXAMPLE_LDFLAGS += -lm -l ssl $(KINETIC_LIB) -l crypto -l pthread
EXAMPLES = write_file_blocking

# $(OUT_DIR)/%.o: $(EXAMPLE_SRC)/%.c $(KINETIC_LIB)
# 	$(CC) -c -o $@ $< $(CFLAGS)
example_sources = $(wildcard $(EXAMPLE_SRC)/*.c)
example_executables = $(patsubst $(EXAMPLE_SRC)/%.c,$(BIN_DIR)/examples/%,$(example_sources))

$(EXAMPLE_BIN)/write_file_blocking: $(EXAMPLE_SRC)/write_file_blocking.c $(KINETIC_LIB)
list_examples:
	echo $(example_executables)

$(BIN_DIR)/examples/%: $(EXAMPLE_SRC)/%.c $(KINETIC_LIB)
	@echo
	@echo --------------------------------------------------------------------------------
	@echo Building example: $@
	@echo ================================================================================
	@echo Building example: $<
	@echo --------------------------------------------------------------------------------
	$(CC) -o $@ $< $(CFLAGS) -I$(PUB_INC) $(UTIL_LDFLAGS) $(KINETIC_LIB)
	@echo ================================================================================
	@echo

build_examples: $(example_executables)

run_example_%: $(BIN_DIR)/examples/%
	@echo
	@echo ================================================================================
	@echo Executing example: '$<'
	@echo --------------------------------------------------------------------------------;
	$<
	@echo ================================================================================
	@echo

setup_examples: $(example_executables) \
	build_examples start_simulator erase_simulator

examples: $(KINETIC_LIB) $(EXAMPLE_BIN)/write_file_blocking
examples: setup_examples \
	run_example_write_file_blocking \
	run_example_write_file_blocking_threads \
	run_example_write_file_nonblocking \
	run_example_write_file_nonblocking_threads \
	stop_simulator
+7 −0
Original line number Diff line number Diff line
@@ -80,6 +80,9 @@ void store_data(write_args* args)

int main(int argc, char** argv)
{
    (void)argc;
    (void)argv;

    // Read in file contents to store
    const char* dataFile = "test/support/data/test.data";
    struct stat st;
@@ -105,6 +108,7 @@ int main(int argc, char** argv)
        .hmacKey = ByteArray_CreateWithCString(HmacKeyString),
    };
    write_args* writeArgs = calloc(1, sizeof(write_args));
    KineticClient_Init("stdout", 2);
    status = KineticClient_Connect(&sessionConfig, &writeArgs->sessionHandle);
    if (status != KINETIC_STATUS_SUCCESS) {
        fprintf(stderr, "Connection to host '%s' failed w/ status: %s",
@@ -138,6 +142,9 @@ int main(int argc, char** argv)

    // Shutdown client connection and cleanup
    KineticClient_Disconnect(&writeArgs->sessionHandle);
    KineticClient_Shutdown();
    free(writeArgs);
    free(buf);

    return 0;
}
+37 −0
Original line number Diff line number Diff line
/*
* kinetic-c
* Copyright (C) 2014 Seagate Technology.
*
* 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.
*
*/

#include "kinetic_client.h"
#include "kinetic_types.h"
#include "byte_array.h"
#include <stdlib.h>
#include <getopt.h>
#include <stdio.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/file.h>

int main(int argc, char** argv)
{
    (void)argc;
    (void)argv;
    fprintf(stderr, "\nEXAMPLE NOT YET IMPLEMENTED!\n");
    return 0;
}
+37 −0
Original line number Diff line number Diff line
/*
* kinetic-c
* Copyright (C) 2014 Seagate Technology.
*
* 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.
*
*/

#include "kinetic_client.h"
#include "kinetic_types.h"
#include "byte_array.h"
#include <stdlib.h>
#include <getopt.h>
#include <stdio.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/file.h>

int main(int argc, char** argv)
{
    (void)argc;
    (void)argv;
    fprintf(stderr, "\nEXAMPLE NOT YET IMPLEMENTED!\n");
    return 0;
}
+37 −0
Original line number Diff line number Diff line
/*
* kinetic-c
* Copyright (C) 2014 Seagate Technology.
*
* 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.
*
*/

#include "kinetic_client.h"
#include "kinetic_types.h"
#include "byte_array.h"
#include <stdlib.h>
#include <getopt.h>
#include <stdio.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/file.h>

int main(int argc, char** argv)
{
    (void)argc;
    (void)argv;
    fprintf(stderr, "\nEXAMPLE NOT YET IMPLEMENTED!\n");
    return 0;
}