Skip to content

Commit

Permalink
Some cleanup in the SConscript files
Browse files Browse the repository at this point in the history
  • Loading branch information
kb173 committed Feb 6, 2021
1 parent feb3625 commit 538e2b3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 36 deletions.
22 changes: 10 additions & 12 deletions SConstruct
Expand Up @@ -28,7 +28,7 @@ vector_library = "libVectorExtractor"

demo_path = "demo/addons/geodot/"

lib_file_ending = ""
lib_file_ending = ".a"

# Try to detect the host platform automatically.
# This is used if no `platform` argument is passed
Expand Down Expand Up @@ -78,54 +78,52 @@ subprocess.call(
"cd " + vector_cpp_path + " && scons platform=" + env['platform'] + " osgeo_path=" + env['osgeo_path'],
shell=True)

# For the reference:
# For reference:
# - CCFLAGS are compilation flags shared between C and C++
# - CFLAGS are for C-specific compilation flags
# - CXXFLAGS are for C++-specific compilation flags
# - CPPFLAGS are for pre-processor flags
# - CPPDEFINES are for pre-processor defines
# - LINKFLAGS are for linking flags

env.Append(CXXFLAGS=['-std=c++17'])

# Check our platform specifics
if env['platform'] == "osx":
lib_file_ending = ".dylib"
env['target_path'] += 'osx/'
cpp_library += '.osx'

env.Append(CXXFLAGS=['-std=c++17'])
env.Append(LINKFLAGS=['-arch', 'x86_64'])

if env['target'] in ('debug', 'd'):
env.Append(CCFLAGS=['-g', '-O2', '-arch', 'x86_64'])
env.Append(LINKFLAGS=['-arch', 'x86_64'])
else:
env.Append(CCFLAGS=['-g', '-O3', '-arch', 'x86_64'])
env.Append(LINKFLAGS=['-arch', 'x86_64'])

env.Append(LIBS=['libgdal.dylib'])
env.Append(LIBPATH=[os.path.join(env['osgeo_path'], "lib")])

elif env['platform'] in ('x11', 'linux'):
lib_file_ending = ".a"
env['target_path'] += 'x11/'
cpp_library += '.linux'

env.Append(LINKFLAGS=[
'-Wl,-rpath,\'$$ORIGIN\''
])

env.Append(CXXFLAGS=['-std=c++17'])

if env['target'] in ('debug', 'd'):
env.Append(CCFLAGS=['-fPIC', '-g3', '-Og'])
else:
env.Append(CCFLAGS=['-fPIC', '-g', '-O3'])

elif env['platform'] == "windows":
lib_file_ending = ".a"
env['target_path'] += 'win64/'
env['target_name'] += ".dll"
env.Append(LINKFLAGS=['-static-libgcc', '-static-libstdc++', '-static'])
cpp_library += '.windows'

env.Append(CXXFLAGS=['-std=c++17'])
env.Replace(CXX=['/usr/bin/x86_64-w64-mingw32-g++'])
# Set the compiler to MinGW (is this command valid on native Windows too?)
env.Replace(CXX=['x86_64-w64-mingw32-g++'])

gdal_include_path = os.path.join(env['osgeo_path'], "include")
env.Append(CPPPATH=[gdal_include_path])
Expand Down
14 changes: 2 additions & 12 deletions src/raster-tile-extractor/SConstruct
Expand Up @@ -10,7 +10,6 @@ env = DefaultEnvironment()
# Define our options
opts.Add(EnumVariable('target', "Compilation target", 'debug', ['d', 'debug', 'r', 'release']))
opts.Add(EnumVariable('platform', "Compilation platform", '', ['', 'windows', 'x11', 'linux', 'osx']))
opts.Add(EnumVariable('p', "Compilation target, alias for 'platform'", '', ['', 'windows', 'x11', 'linux', 'osx']))
opts.Add(BoolVariable('use_llvm', "Use the LLVM / Clang compiler", 'no'))
opts.Add(PathVariable('osgeo_path', "(Windows and Mac) path to OSGeo installation", "", PathVariable.PathAccept))

Expand All @@ -19,28 +18,22 @@ bits = 64

# Updates the environment with the option variables.
opts.Update(env)

# Process some arguments
if env['p'] != '':
env['platform'] = env['p']

if env['platform'] == '':
print("No valid target platform selected.")
quit()

env['target_path'] = 'build/'
env['target_name'] = 'libRasterTileExtractor'

env.Append(CXXFLAGS=['-std=c++17', '-fPIC'])

# Check our platform specifics
if env['platform'] in ('x11', 'linux'):
env.Append(CXXFLAGS=['-std=c++17', '-fPIC'])

gdal_include_path = ""
gdal_lib_path = ""
gdal_lib_name = "libgdal"

elif env['platform'] == "windows":
env.Append(CXXFLAGS=['-std=c++17'])
env.Replace(CXX=['/usr/bin/x86_64-w64-mingw32-g++'])
env.Append(LINKFLAGS=['-static-libgcc', '-static-libstdc++'])

Expand All @@ -54,9 +47,6 @@ elif env['platform'] == "windows":
quit()

elif env['platform'] == 'osx':
# env.Append(LINKFLAGS=['/WHOLEARCHIVE'])
env.Append(CXXFLAGS=['-std=c++17'])

# Include GDAL
gdal_include_path = os.path.join(env['osgeo_path'], "include")
gdal_lib_path = os.path.join(env['osgeo_path'], "lib")
Expand Down
14 changes: 2 additions & 12 deletions src/vector-extractor/SConstruct
Expand Up @@ -10,7 +10,6 @@ env = DefaultEnvironment()
# Define our options
opts.Add(EnumVariable('target', "Compilation target", 'debug', ['d', 'debug', 'r', 'release']))
opts.Add(EnumVariable('platform', "Compilation platform", '', ['', 'windows', 'x11', 'linux', 'osx']))
opts.Add(EnumVariable('p', "Compilation target, alias for 'platform'", '', ['', 'windows', 'x11', 'linux', 'osx']))
opts.Add(BoolVariable('use_llvm', "Use the LLVM / Clang compiler", 'no'))
opts.Add(PathVariable('osgeo_path', "(Windows and Mac) path to OSGeo installation", "", PathVariable.PathAccept))

Expand All @@ -19,28 +18,22 @@ bits = 64

# Updates the environment with the option variables.
opts.Update(env)

# Process some arguments
if env['p'] != '':
env['platform'] = env['p']

if env['platform'] == '':
print("No valid target platform selected.")
quit()

env['target_path'] = 'build/'
env['target_name'] = 'libVectorExtractor'

env.Append(CXXFLAGS=['-std=c++17', '-fPIC'])

# Check our platform specifics
if env['platform'] in ('x11', 'linux'):
env.Append(CXXFLAGS=['-std=c++17', '-fPIC'])

gdal_include_path = ""
gdal_lib_path = ""
gdal_lib_name = "libgdal"

elif env['platform'] == "windows":
env.Append(CXXFLAGS=['-std=c++17'])
env.Replace(CXX=['/usr/bin/x86_64-w64-mingw32-g++'])
env.Append(LINKFLAGS=['-static-libgcc', '-static-libstdc++'])

Expand All @@ -54,9 +47,6 @@ elif env['platform'] == "windows":
quit()

elif env['platform'] == 'osx':
# env.Append(LINKFLAGS=['/WHOLEARCHIVE'])
env.Append(CXXFLAGS=['-std=c++17'])

# Include GDAL
gdal_include_path = os.path.join(env['osgeo_path'], "include")
gdal_lib_path = os.path.join(env['osgeo_path'], "lib")
Expand Down

0 comments on commit 538e2b3

Please sign in to comment.