Reorganized source files

This commit is contained in:
Ben Merritt 2017-02-18 17:46:11 +00:00
parent 8b94ed59e6
commit 93434e7d39
10 changed files with 28 additions and 20 deletions

View File

@ -1,38 +1,43 @@
#The build configuration # The build configuration (debug or release)
CONFIG := release CONFIG := release
# Extension packaging options
EXTENSION := pg_libphonenumber EXTENSION := pg_libphonenumber
version := 1.0 version := 0.1.0
extension_script := $(EXTENSION)--$(version).sql extension_script := $(EXTENSION)--$(version).sql
DATA_built := $(extension_script) DATA_built := $(extension_script)
REGRESS := regression REGRESS := regression
#Build options # Build options
cpp_files := $(wildcard *.cpp) cpp_files := $(wildcard src/*.cpp)
# The native module to build
MODULE_big := pg_libphonenumber MODULE_big := pg_libphonenumber
# The object files that go into the module
OBJS := $(patsubst %.cpp,%.o,$(cpp_files)) OBJS := $(patsubst %.cpp,%.o,$(cpp_files))
PG_CPPFLAGS := -fPIC -std=c++11
# C flags
PG_CPPFLAGS := -fPIC -std=c++11 -Isrc/
ifeq ($(CONFIG),debug) ifeq ($(CONFIG),debug)
PG_CPPFLAGS += -g -Og PG_CPPFLAGS += -g -Og
else else
PG_CPPFLAGS += -O3 PG_CPPFLAGS += -O3
endif endif
# Extra libraries to link
SHLIB_LINK := -lphonenumber -lstdc++ SHLIB_LINK := -lphonenumber -lstdc++
#Clean options # Clean options
EXTRA_CLEAN := $(extension_script) tools/get_sizeof_phone_number EXTRA_CLEAN := $(extension_script) tools/get_sizeof_phone_number
#Load PGXS. # Load PGXS.
PG_CONFIG := pg_config PG_CONFIG := pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs) PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS) include $(PGXS)
#How to build the extension script: # Build the extension script:
$(extension_script): $(EXTENSION).sql.template tools/get_sizeof_phone_number $(extension_script): $(EXTENSION).sql.template tools/get_sizeof_phone_number
sed "s/SIZEOF_PHONE_NUMBER/$(shell tools/get_sizeof_phone_number)/" $< > $@ sed "s/SIZEOF_PHONE_NUMBER/$(shell tools/get_sizeof_phone_number)/" $< > $@
tools/get_sizeof_phone_number: tools/get_sizeof_phone_number.cpp short_phone_number.h # Gets the size of a ShortPhoneNumber (which corresponds to the phone_number type in SQL)
$(CXX) -std=c++11 $< -o $@ tools/get_sizeof_phone_number: tools/get_sizeof_phone_number.cpp src/short_phone_number.h
$(CXX) $(PG_CPPFLAGS) $< -o $@

View File

@ -1,22 +1,25 @@
# pg-libphonenumber # pg-libphonenumber
A (partially implemented!) PostgreSQL extension that provides access to [Google's libphonenumber](https://github.com/googlei18n/libphonenumber)
A (partially implemented!) PostgreSQL extension that provides access to
[Google's `libphonenumber`](https://github.com/googlei18n/libphonenumber)
## Project status ## Project status
This extension is in an <strong>ALPHA</strong> state. Do not use it in production environments. This extension is in an <strong>alpha</strong> state. It's not complete or
tested enough for critical production deployments, but with a little help, we
should be able to get it there.
## Synopsis ## Synopsis
CREATE EXTENSION pg_libphonenumber; CREATE EXTENSION pg_libphonenumber;
SELECT parse_phone_number('03 7010 1234', 'AU'); SELECT parse_phone_number('03 7010 1234', 'AU');
SELECT parse_phone_number('2819010011', 'US'); SELECT parse_phone_number('2819010011', 'US');
CREATE TABLE foo ( ph phone_number ); CREATE TABLE foo ( ph phone_number );
-- DO NOT RELY ON THIS -- DO NOT RELY ON THIS
-- may not always this work way with implicit cast. -- may not always this work way with implicit cast.
SELECT '2819010011'::phone_number; -- assumes US SELECT '2819010011'::phone_number; -- assumes US
## Installation ## Installation

View File

@ -1,3 +1,3 @@
encoding = 'utf-8' encoding = 'utf-8'
relocatable = true relocatable = true
default_version = '1.0' default_version = '0.1.0'

View File

View File

@ -1,6 +1,6 @@
#include <iostream> #include <iostream>
#include "../short_phone_number.h" #include "short_phone_number.h"
int main(int argc, const char** argv) { int main(int argc, const char** argv) {
std::cout << sizeof(ShortPhoneNumber) << std::endl; std::cout << sizeof(ShortPhoneNumber) << std::endl;