forked from git/git
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add spatial-filter extension in contrib/filter-extensions
See Makefile for build instructions.
- Loading branch information
Showing
4 changed files
with
539 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Run this from the main git directory. That way we inherit useful variables. | ||
# | ||
# make FILTER_EXTENSIONS=contrib/filter-extensions/spatial/spatial.a \ | ||
# LDFLAGS=-lstdc++ \ | ||
# EXTENSION_LIBS=-lsqlite3 | ||
# | ||
|
||
ifneq ($(findstring s,$(MAKEFLAGS)),s) | ||
ifndef V | ||
QUIET_CC = @echo ' ' CC $@; | ||
QUIET_CXX = @echo ' ' CXX $@; | ||
QUIET_AR = @echo ' ' AR $@; | ||
endif | ||
endif | ||
|
||
FILTER_STATIC_LIB = spatial.a | ||
|
||
FILTER_CFLAGS = -std=c99 -I../../.. | ||
FILTER_CXXFLAGS = -std=c++11 | ||
|
||
all: $(FILTER_STATIC_LIB) | ||
ifeq ($(MAKELEVEL),0) | ||
$(error "Run via parent git make") | ||
endif | ||
@: | ||
|
||
$(FILTER_STATIC_LIB): spatial_filter.o adapter_functions.o | ||
$(QUIET_AR)$(AR) $(ARFLAGS) $@ $^ | ||
|
||
spatial_filter.o: spatial_filter.cpp | ||
$(QUIET_CXX)$(CXX) -c $(ALL_CFLAGS) $(FILTER_CFLAGS) $(ALL_CXXFLAGS) $(FILTER_CXXFLAGS) $< | ||
|
||
adapter_functions.o: adapter_functions.c | ||
$(QUIET_CC)$(CC) -c $(ALL_CFLAGS) $(FILTER_CFLAGS) $< | ||
|
||
clean: | ||
$(RM) *.a *.o | ||
|
||
.PHONY: all clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <git-compat-util.h> | ||
#include <hash.h> | ||
#include <object.h> | ||
#include <repository.h> | ||
#include <trace.h> | ||
|
||
#include "adapter_functions.h" | ||
|
||
// Allows access to C structs or functions that are defined | ||
// in C++ incompatible headers. | ||
|
||
void sf_trace_printf(const char* format, ...) { | ||
static struct trace_key key = TRACE_KEY_INIT(FILTER); | ||
struct strbuf buf = STRBUF_INIT; | ||
va_list args; | ||
va_start(args, format); | ||
strbuf_vaddf(&buf, format, args); | ||
va_end(args); | ||
trace_strbuf(&key, &buf); | ||
strbuf_release(&buf); | ||
} | ||
|
||
const struct object_id* sf_obj2oid(const struct object *obj) { | ||
return &obj->oid; | ||
} | ||
|
||
const unsigned char* sf_oid2hash(const struct object_id *oid) { | ||
return oid->hash; | ||
} | ||
|
||
unsigned sf_obj2type(const struct object *obj) { | ||
return obj->type; | ||
} | ||
|
||
const char* sf_repo2gitdir(const struct repository *repo) { | ||
return repo->gitdir; | ||
} | ||
|
||
int sf_repo2hashsz(const struct repository *repo) { | ||
return repo->hash_algo->rawsz; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef SPATIAL_FILTER_ADAPTER_FUNCTIONS_H | ||
#define SPATIAL_FILTER_ADAPTER_FUNCTIONS_H | ||
|
||
// C++ compatible header that allows access to C structs | ||
// or functions that are defined in C++ incompatible headers. | ||
|
||
// From trace.h | ||
uint64_t getnanotime(void); | ||
|
||
// Delegates to trace_strbuf from trace.h | ||
void sf_trace_printf(const char* format, ...); | ||
|
||
struct object; | ||
struct object_id; | ||
|
||
// Accessors for struct object from object.h | ||
const struct object_id* sf_obj2oid(const struct object *obj); | ||
unsigned sf_obj2type(const struct object *obj); | ||
|
||
// Accessors for struct object_id from hash.h | ||
const unsigned char* sf_oid2hash(const struct object_id *oid); | ||
|
||
struct repository; | ||
|
||
// Accessors for struct repository from repository.h | ||
const char* sf_repo2gitdir(const struct repository *repo); | ||
int sf_repo2hashsz(const struct repository *repo); | ||
|
||
#endif /* SPATIAL_FILTER_ADAPTER_FUNCTIONS_H */ |
Oops, something went wrong.