Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New version of the build system, fixed an error I was having. #20

Merged
merged 2 commits into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@

static int initialized = 0;

// The atexit handler used to close all connections to open data stores
static void cleanup() {
OGRCleanupAll();
}

// Initialize libraries, register the atexit handler and set up error reporting.
void simplet_init() {
if (initialized) return;
CPLSetConfigOption("OGR_ENABLE_PARTIAL_REPROJECTION", "ON");
#ifdef DEBUG
CPLSetConfigOption("CPL_DEBUG", "ON");
#else
CPLSetConfigOption("CPL_DEBUG", "OFF");
#endif
OGRRegisterAll();
GDALAllRegister();
atexit(cleanup);
initialized = 1;
};
4 changes: 2 additions & 2 deletions src/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void simplet_map_free(simplet_map_t *map) {
simplet_list_free(map->layers);
}

if (map->proj) OSRRelease(map->proj);
if (map->proj) OSRDestroySpatialReference(map->proj);

if (map->bgcolor) free(map->bgcolor);

Expand Down Expand Up @@ -248,7 +248,7 @@ const char *simplet_map_status_to_string(simplet_map_t *map) {

// Check if the map is valid for rendering
simplet_status_t simplet_map_is_valid(simplet_map_t *map) {
// Does it have a previously set error.
// Does it have a previously set error?
if (!(map->status == SIMPLET_OK)) return SIMPLET_ERR;

// Does it have a bounds?
Expand Down
1 change: 1 addition & 0 deletions src/query.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ simplet_status_t simplet_query_process(simplet_query_t *query,
if (!(olayer = OGR_DS_ExecuteSQL(source, query->ogrsql, NULL, NULL))) {
int err = CPLGetLastErrorNo();
if (!err) {
// FIXME: This should be a problem, but it is ignored right now.
thejefflarson marked this conversation as resolved.
Show resolved Hide resolved
return SIMPLET_OK;
} else {
return set_error(query, SIMPLET_OGR_ERR, CPLGetLastErrorMsg());
Expand Down
12 changes: 6 additions & 6 deletions src/raster_layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,12 @@ simplet_status_t simplet_raster_layer_process(simplet_raster_layer_t *layer,
memset(window, 0, kernel_size * kernel_size);
GDALRasterBandH b = GDALGetRasterBand(source, band);

CPLErr err = GDALRasterIO(b, GF_Read, (int)x_lookup[x] - kernel_size / 2,
(int)y_lookup[x] - kernel_size / 2,
kernel_size, kernel_size,
window,
kernel_size, kernel_size,
GDT_Byte, 0, 0);
GDALRasterIO(b, GF_Read, (int)x_lookup[x] - kernel_size / 2,
(int)y_lookup[x] - kernel_size / 2,
kernel_size, kernel_size,
window,
kernel_size, kernel_size,
GDT_Byte, 0, 0);

for (int kx = 0; kx < kernel_size; kx++) {
for (int ky = 0; ky < kernel_size; ky++) {
Expand Down
3 changes: 0 additions & 3 deletions src/vector_layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ simplet_status_t simplet_vector_layer_process(simplet_vector_layer_t *layer,
if (!(source = OGROpenShared(layer->source, 0, NULL)))
return set_error(layer, SIMPLET_OGR_ERR, "error opening layer source");

// Retain the datasource because we want to cache open connections to a
// data source like postgres.
if (OGR_DS_GetRefCount(source) == 1) OGR_DS_Reference(source);
if (!(iter = simplet_get_list_iter(layer->queries))) {
OGRReleaseDataSource(source);
return set_error(layer, SIMPLET_OOM, "out of memory getting list iterator");
Expand Down
20 changes: 10 additions & 10 deletions waf

Large diffs are not rendered by default.

78 changes: 40 additions & 38 deletions wscript
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,62 @@ import os


def options(opt):
opt.load('compiler_c')
opt.load("compiler_c")


def configure(conf):
conf.load('compiler_c')
conf.load("compiler_c")
conf.load("clang_compilation_database", tooldir="./tools/")
conf.check_cc(lib='m', uselib_store='M', use='M')
conf.check_cfg(package='pangocairo', args=['--cflags', '--libs'],
uselib_store='CAIRO')
conf.check_cfg(path='gdal-config', args=['--cflags'], package='',
uselib_store='GDAL')
conf.check_cfg(path='gdal-config', args=['--libs'], package='',
uselib_store='GDAL')

conf.env.append_unique('CFLAGS', ['-std=c99', '-Wall', '-Wextra'])
conf.define('_GNU_SOURCE', 1) # for asprintf

if 'DEBUG' in os.environ:
conf.env.append_unique('CFLAGS', ['-g', '-fsanitize=address',
'-fno-omit-frame-pointer'])
conf.env.append_unique('LINKFLAGS', ['-fsanitize=address'])
conf.define('DEBUG', 1)
conf.check_cc(lib="m", uselib_store="M", use="M")
conf.check_cfg(
package="pangocairo", args=["--cflags", "--libs"], uselib_store="CAIRO"
)
conf.check_cfg(
path="gdal-config", args=["--cflags"], package="", uselib_store="GDAL"
)
conf.check_cfg(path="gdal-config", args=["--libs"], package="", uselib_store="GDAL")

conf.env.append_unique("CFLAGS", ["-std=c99", "-Wall", "-Wextra"])
conf.define("_GNU_SOURCE", 1) # for asprintf

if "DEBUG" in os.environ:
conf.env.append_unique(
"CFLAGS", ["-g", "-fsanitize=address", "-fno-omit-frame-pointer"]
)
conf.env.append_unique("LINKFLAGS", ["-fsanitize=address"])
conf.define("DEBUG", 1)
else:
conf.env.append_unique('CFLAGS', ['-O3'])
conf.env.append_unique("CFLAGS", ["-O3"])


def build(bld):
sources = bld.path.ant_glob(['src/*.c'])
kwargs = {
'source': sources,
'uselib': 'CAIRO GDAL M',
'target': 'simple-tiles'
}
sources = bld.path.ant_glob(["src/*.c"])
kwargs = {"source": sources, "uselib": "CAIRO GDAL M", "target": "simple-tiles"}

bld.shlib(**dict(list(kwargs.items()) + [('features', 'c cshlib')]))
bld.stlib(**dict(list(kwargs.items()) + [('features', 'c cstlib')]))
bld.shlib(**dict(list(kwargs.items()) + [("features", "c cshlib")]))
bld.stlib(**dict(list(kwargs.items()) + [("features", "c cstlib")]))

libs = []
for k in ['LIB_GDAL', 'LIB_M']:
for k in ["LIB_GDAL", "LIB_M"]:
if bld.env[k] != []:
libs.append('-l' + ' -l'.join(bld.env[k]))
libs.append("-l" + " -l".join(bld.env[k]))

includes = ' '.join(['-I' + ' -I'.join(bld.env[k]) for k
in ['INCLUDES_CAIRO', 'INCLUDES_GDAL']])
includes = " ".join(
["-I" + " -I".join(bld.env[k]) for k in ["INCLUDES_CAIRO", "INCLUDES_GDAL"]]
)

bld(source='src/simple-tiles.pc.in', VERSION='0.6.0',
LIBS=' '.join(libs), INCLUDES=includes)
bld(
source="src/simple-tiles.pc.in",
VERSION="0.6.0",
LIBS=" ".join(libs),
INCLUDES=includes,
)

bld.install_files('${PREFIX}/include/simple-tiles',
bld.path.ant_glob(['src/*.h']))
bld.install_files("${PREFIX}/include/simple-tiles", bld.path.ant_glob(["src/*.h"]))

bld.recurse('test')
bld.recurse("test")


def test(ctx):
Options.commands = ['build'] + Options.commands
ctx.recurse('test', name='test')
Options.commands = ["build"] + Options.commands
ctx.recurse("test", name="test")