Reorganized source files
This commit is contained in:
parent
8b94ed59e6
commit
93434e7d39
29
Makefile
29
Makefile
|
@ -1,38 +1,43 @@
|
|||
#The build configuration
|
||||
# The build configuration (debug or release)
|
||||
CONFIG := release
|
||||
|
||||
# Extension packaging options
|
||||
EXTENSION := pg_libphonenumber
|
||||
version := 1.0
|
||||
version := 0.1.0
|
||||
extension_script := $(EXTENSION)--$(version).sql
|
||||
DATA_built := $(extension_script)
|
||||
REGRESS := regression
|
||||
|
||||
#Build options
|
||||
cpp_files := $(wildcard *.cpp)
|
||||
# Build options
|
||||
cpp_files := $(wildcard src/*.cpp)
|
||||
|
||||
# The native module to build
|
||||
MODULE_big := pg_libphonenumber
|
||||
|
||||
# The object files that go into the module
|
||||
OBJS := $(patsubst %.cpp,%.o,$(cpp_files))
|
||||
PG_CPPFLAGS := -fPIC -std=c++11
|
||||
|
||||
# C flags
|
||||
PG_CPPFLAGS := -fPIC -std=c++11 -Isrc/
|
||||
ifeq ($(CONFIG),debug)
|
||||
PG_CPPFLAGS += -g -Og
|
||||
else
|
||||
PG_CPPFLAGS += -O3
|
||||
endif
|
||||
# Extra libraries to link
|
||||
SHLIB_LINK := -lphonenumber -lstdc++
|
||||
|
||||
#Clean options
|
||||
# Clean options
|
||||
EXTRA_CLEAN := $(extension_script) tools/get_sizeof_phone_number
|
||||
|
||||
#Load PGXS.
|
||||
# Load PGXS.
|
||||
PG_CONFIG := pg_config
|
||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||
include $(PGXS)
|
||||
|
||||
#How to build the extension script:
|
||||
# Build the extension script:
|
||||
$(extension_script): $(EXTENSION).sql.template 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
|
||||
$(CXX) -std=c++11 $< -o $@
|
||||
|
||||
# Gets the size of a ShortPhoneNumber (which corresponds to the phone_number type in SQL)
|
||||
tools/get_sizeof_phone_number: tools/get_sizeof_phone_number.cpp src/short_phone_number.h
|
||||
$(CXX) $(PG_CPPFLAGS) $< -o $@
|
||||
|
|
15
README.md
15
README.md
|
@ -1,22 +1,25 @@
|
|||
# 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
|
||||
|
||||
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
|
||||
|
||||
|
||||
CREATE EXTENSION pg_libphonenumber;
|
||||
SELECT parse_phone_number('03 7010 1234', 'AU');
|
||||
SELECT parse_phone_number('2819010011', 'US');
|
||||
|
||||
|
||||
CREATE TABLE foo ( ph phone_number );
|
||||
|
||||
|
||||
-- DO NOT RELY ON THIS
|
||||
-- may not always this work way with implicit cast.
|
||||
SELECT '2819010011'::phone_number; -- assumes US
|
||||
SELECT '2819010011'::phone_number; -- assumes US
|
||||
|
||||
## Installation
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
encoding = 'utf-8'
|
||||
relocatable = true
|
||||
default_version = '1.0'
|
||||
default_version = '0.1.0'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <iostream>
|
||||
|
||||
#include "../short_phone_number.h"
|
||||
#include "short_phone_number.h"
|
||||
|
||||
int main(int argc, const char** argv) {
|
||||
std::cout << sizeof(ShortPhoneNumber) << std::endl;
|
||||
|
|
Loading…
Reference in New Issue