Made build system automatically find sizeof(PhoneNumber)
This commit is contained in:
parent
aa6946caa4
commit
0c6eab434f
|
@ -1,3 +1,5 @@
|
||||||
*.swp
|
*.swp
|
||||||
*.o
|
*.o
|
||||||
*.so
|
*.so
|
||||||
|
/get_sizeof_phone_number
|
||||||
|
/pg_libphonenumber--*.sql
|
||||||
|
|
12
Makefile
12
Makefile
|
@ -1,11 +1,21 @@
|
||||||
EXTENSION := pg_libphonenumber
|
EXTENSION := pg_libphonenumber
|
||||||
DATA := pg_libphonenumber--1.0.sql
|
version := 1.0
|
||||||
|
extension_script := $(EXTENSION)--$(version).sql
|
||||||
|
DATA_built := $(extension_script)
|
||||||
|
|
||||||
MODULE_big := pg_libphonenumber
|
MODULE_big := pg_libphonenumber
|
||||||
OBJS := pg_libphonenumber.o
|
OBJS := pg_libphonenumber.o
|
||||||
PG_CPPFLAGS := -fPIC -std=c++11 -g
|
PG_CPPFLAGS := -fPIC -std=c++11 -g
|
||||||
SHLIB_LINK := -lphonenumber -lstdc++
|
SHLIB_LINK := -lphonenumber -lstdc++
|
||||||
|
|
||||||
|
EXTRA_CLEAN := $(extension_script) get_sizeof_phone_number
|
||||||
|
|
||||||
PG_CONFIG := pg_config
|
PG_CONFIG := pg_config
|
||||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||||
include $(PGXS)
|
include $(PGXS)
|
||||||
|
|
||||||
|
$(extension_script): $(EXTENSION).sql.template get_sizeof_phone_number
|
||||||
|
sed "s/SIZEOF_PHONE_NUMBER/$(shell ./get_sizeof_phone_number)/" $< > $@
|
||||||
|
|
||||||
|
get_sizeof_phone_number: get_sizeof_phone_number.cpp
|
||||||
|
g++ $< -o $@
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "phonenumbers/phonenumber.pb.h"
|
||||||
|
|
||||||
|
using namespace i18n::phonenumbers;
|
||||||
|
|
||||||
|
int main(int argc, const char** argv) {
|
||||||
|
std::cout << sizeof(PhoneNumber) << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#define I18N_PHONENUMBERS_USE_BOOST
|
|
||||||
#include "phonenumbers/phonenumberutil.h"
|
#include "phonenumbers/phonenumberutil.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -19,8 +19,9 @@ CREATE FUNCTION phone_number_send(phone_number) RETURNS bytea
|
||||||
LANGUAGE c IMMUTABLE STRICT
|
LANGUAGE c IMMUTABLE STRICT
|
||||||
AS 'pg_libphonenumber', 'phone_number_send';
|
AS 'pg_libphonenumber', 'phone_number_send';
|
||||||
|
|
||||||
|
--SIZEOF_PHONE_NUMBER is replaced when generating the "real" script.
|
||||||
CREATE TYPE phone_number (
|
CREATE TYPE phone_number (
|
||||||
INTERNALLENGTH = 64,
|
INTERNALLENGTH = SIZEOF_PHONE_NUMBER,
|
||||||
INPUT = phone_number_in,
|
INPUT = phone_number_in,
|
||||||
OUTPUT = phone_number_out,
|
OUTPUT = phone_number_out,
|
||||||
RECEIVE = phone_number_recv,
|
RECEIVE = phone_number_recv,
|
Loading…
Reference in New Issue