Skip to content

Commit

Permalink
Merge pull request #7 from steinwurf/use-new-waf
Browse files Browse the repository at this point in the history
Use new waf
  • Loading branch information
petya2164 committed Apr 7, 2017
2 parents 7374736 + ef804b0 commit d2bd24a
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 174 deletions.
35 changes: 19 additions & 16 deletions .gitignore
Expand Up @@ -24,29 +24,33 @@ app/src/main/assets/ssl/certs/ca-certificates.crt
# Proguard folder generated by Eclipse
proguard/

# Intellij project files
*.iml
*.ipr
*.iws
.idea/

# For projects that use Waf for building: http://code.google.com/p/waf/
# Waf files
waf-*
waf3-*
.waf-*
.waf3-*
.lock-*
build
bundle_dependencies
resolve_symlinks
resolved_dependencies

# Gnu Global tag files
GPATH
GRTAGS
GSYMS
GTAGS

# Emacs temp / auto save
\#*#
*.#*
*~

#Eclipse ignore
.cproject
.project
*.project
.metadata
local.properties
#.classpath
.classpath
.settings/

# Visual Studio ignore
Expand All @@ -58,13 +62,12 @@ local.properties
*.sdf
*.opensdf
*.log
*.vcxproj*
VSProjects

# Windows thumbnail db
Thumbs.db

# OSX files
.DS_Store

# Android Studio
*.iml
*.ipr
*.iws
.idea
.gradle
2 changes: 2 additions & 0 deletions NEWS.rst
Expand Up @@ -6,4 +6,6 @@ every change, see the Git log.

Latest
------
* Major: Upgrade to waf-tools 4
* Major: Upgrade to petro 7
* Major: Use petro version 6
8 changes: 4 additions & 4 deletions buildbot.py
Expand Up @@ -40,13 +40,13 @@ def configure(properties):
if properties.get('build_distclean'):
run_command(['./gradlew', 'clean'])

command += ['configure', '--git-protocol=git@']
command += ['configure', '--git_protocol=git@']

if 'waf_bundle_path' in properties:
command += ['--bundle-path=' + properties['waf_bundle_path']]
if 'waf_resolve_path' in properties:
command += ['--resolve_path=' + properties['waf_resolve_path']]

if 'dependency_project' in properties:
command += ['--{0}-use-checkout={1}'.format(
command += ['--{0}_checkout={1}'.format(
properties['dependency_project'],
properties['dependency_checkout'])]

Expand Down
34 changes: 9 additions & 25 deletions config.py
Expand Up @@ -10,34 +10,18 @@
pass

project_name = 'petro-android'
project_dependencies = \
[
'waf-tools',
'boost',
'petro',
]

project_dependencies = [
'waf-tools',
'petro',
]

# Importing a dynamically generated module
# Python recipe from http://code.activestate.com/recipes/82234

def importCode(code, name, add_to_sys_modules=0):
"""
Import dynamically generated code as a module. code is the
object containing the code (a string, a file handle or an
actual compiled code object, same types as accepted by an
exec statement). The name is the name to give to the module,
and the final argument says wheter to add it to sys.modules
or not. If it is added, a subsequent import statement using
name will return this module. If it is not added to sys.modules
import will try to load it in the normal fashion.
import foo
is equivalent to
foofile = open("/path/to/foo.py")
foo = importCode(foofile,"foo",1)
Returns a newly generated module.
Import dynamically generated code as a module.
Python recipe from http://code.activestate.com/recipes/82234
"""
import imp

Expand Down Expand Up @@ -71,7 +55,7 @@ def importCode(code, name, add_to_sys_modules=0):
# Import the code string as a module
mod = importCode(code, "config_helper")
# Run the actual config tool from the dynamic module
mod.config_tool(project_dependencies)
mod.config_tool(project_dependencies, project_name)
except:
print("Unexpected error:")
print(traceback.format_exc())
Expand Down
3 changes: 2 additions & 1 deletion jni/wscript_build
@@ -1,10 +1,11 @@
#! /usr/bin/env python
# encoding: utf-8

bld(features='cxx cxxshlib',
bld(features='cxx cxxshlib copy_binary',
source=bld.path.ant_glob('*.cpp'),
target='petro_android',
export_includes=['jni'],
install_path=None,
copy_path='../app/src/main/jniLibs/armeabi',
lib=['android'],
use=['petro'])
16 changes: 16 additions & 0 deletions resolve.json
@@ -0,0 +1,16 @@
[
{
"name": "waf-tools",
"resolver": "git",
"method": "semver",
"major": 4,
"sources": ["github.com/steinwurf/waf-tools.git"]
},
{
"name": "petro",
"resolver": "git",
"method": "semver",
"major": 7,
"sources": ["github.com/steinwurf/petro.git"]
}
]
20 changes: 10 additions & 10 deletions waf

Large diffs are not rendered by default.

119 changes: 1 addition & 118 deletions wscript
Expand Up @@ -2,135 +2,18 @@
# encoding: utf-8

import os
import shutil


from waflib import Task, Errors, Logs
from waflib.TaskGen import feature, after_method

import waflib.extras.wurf_options

APPNAME = 'petro_android'
APPNAME = 'petro-android'
VERSION = '0.0.0'

# /------------------------------------------------------------
# /----------------- ANDROID SPECIFIC -------------------------
# /------------------------------------------------------------


@feature('cxx')
@after_method('apply_link')
def copy_lib_to_libs_folder(self):
"""
When building an Android application from the IDE native libraries placed
in the libs folder will be packaged in the apk. So we copy the shared libs
we build there.
"""
if not self.bld.is_mkspec_platform('android'):
return

for x in self.features:
if x == 'cxxshlib':
break
else:
return

input_libs = self.link_task.outputs
output_libs = []
for i in input_libs:
outlib = os.path.basename(i.abspath())

outlib = self.bld.root.make_node(
os.path.abspath(os.path.join(
self.bld.srcnode.abspath(),
'app',
'src',
'main',
'jniLibs',
'armeabi',
outlib)))

output_libs.append(outlib)

cpy_tsk = self.create_task('AndroidCopyFileTask')
cpy_tsk.set_inputs(input_libs)
cpy_tsk.set_outputs(output_libs)
cpy_tsk.chmod = self.link_task.chmod


class AndroidCopyFileTask(Task.Task):

"""Performs the copying of generated files to the Android project."""

color = 'PINK'

def run(self):

for src_node, tgt_node in zip(self.inputs, self.outputs):
src = src_node.abspath()
tgt = tgt_node.abspath()

# Following is for shared libs and stale inodes (-_-)
try:
os.remove(tgt)
except OSError:
pass

# Make sure the output directories are available
try:
os.makedirs(os.path.dirname(tgt))
except OSError:
pass

# Copy the file
try:
shutil.copy2(src, tgt)
os.chmod(tgt, self.chmod)
except IOError as e:
Logs.error("The copy file step failed: {0}".format(e))
try:
os.stat(src)
except (OSError, IOError):
Logs.error('File %r does not exist' % src)
raise Errors.WafError('Could not install the file %r' % tgt)

# ------------------------------------------------------------/
# ----------------- ANDROID SPECIFIC -------------------------/
# ------------------------------------------------------------/


def options(opt):

opt.load('wurf_common_tools')


def resolve(ctx):

import waflib.extras.wurf_dependency_resolve as resolve

ctx.load('wurf_common_tools')

ctx.add_dependency(resolve.ResolveVersion(
name='waf-tools',
git_repository='github.com/steinwurf/waf-tools.git',
major=3))

ctx.add_dependency(resolve.ResolveVersion(
name='petro',
git_repository='github.com/steinwurf/petro.git',
major=6))


def configure(conf):

conf.load("wurf_common_tools")
conf.check_cxx(lib='android')


def build(bld):

bld.load("wurf_common_tools")

bld.env.append_unique(
'DEFINES_STEINWURF_VERSION',
'STEINWURF_PETRO_ANDROID_VERSION="{}"'.format(VERSION))
Expand Down

0 comments on commit d2bd24a

Please sign in to comment.