add fast library

This commit is contained in:
speyrefitte
2014-06-27 18:01:00 +02:00
parent 1547eeda46
commit f0024db024
12 changed files with 83 additions and 291 deletions

View File

@@ -1,27 +0,0 @@
'''
@author: sylvain
'''
import os
import sipconfig
# The name of the SIP build file generated by SIP and used by the build
# system.
build_file = "rle.sbf"
# Get the SIP configuration information.
config = sipconfig.Configuration()
# Run SIP to generate the code.
os.system(" ".join([config.sip_bin, "-c", ".", "-b", build_file, "../src/rle.sip"]))
# Create the Makefile.
makefile = sipconfig.SIPModuleMakefile(config, build_file)
# Add the library we are wrapping. The name doesn't include any platform
# specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the
# ".dll" extension on Windows).
makefile.extra_libs = ["rle"]
# Generate the Makefile itself.
makefile.generate()

View File

@@ -1,11 +0,0 @@
%Module rle
namespace rle {
%TypeHeaderCode
#include <rle.h>
%End
int decode_uint8(char* output, int width, int height, char* input, int size);
int decode_uint16(char* output, int width, int height, char* input, int size);
int decode_uint24(char* output, int width, int height, char* input, int size);
};

51
lib/sconstruct Normal file
View File

@@ -0,0 +1,51 @@
import os
import sipconfig
script_dir = os.path.dirname(os.path.realpath(Dir("#/Sconstruct").abspath))
build_dir = os.path.join(script_dir, "build")
src_dir = os.path.join(script_dir, "src")
sip_dir = os.path.join(script_dir, "sip")
#generate install dir
install_dir = os.path.join(script_dir, "..", "rdpy", "fast")
def build_sip(target, source, env):
# Get the SIP configuration information.
config = sipconfig.Configuration()
# Run SIP to generate the code.
os.system(" ".join([config.sip_bin, "-c", "src", str(source[0])]))
# Create the Makefile.
#makefile = sipconfig.SIPModuleMakefile(config, str(target[0]))
# Add the library we are wrapping. The name doesn't include any platform
# specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the
# ".dll" extension on Windows).
#makefile.extra_libs = ["rle"]
#add build directory as extra lib
#makefile.extra_lib_dirs = [os.path.dirname(str(target[0]))]
# Generate the Makefile itself.
#makefile.generate()
#building library
env = Environment()
env.Append(BUILDERS = {'Sip' : Builder(action = build_sip)})
env.VariantDir('build', 'src', duplicate=0)
cppdefines = {}
targetName = os.path.join(build_dir, "libfastrdpy.so")
sources = [Glob(os.path.join(src_dir, '*.c'))]
env.Append(CPPDEFINES = cppdefines);
libSip = env.Sip([os.path.join(build_dir, "rle.sbf")], [os.path.join(sip_dir, "rle.sip")])
libC = env.SharedLibrary(target = targetName,
source = sources
)
env.Depends(libSip, libC)

9
lib/sip/rle.sip Normal file
View File

@@ -0,0 +1,9 @@
%Module(name=rle, language="C")
%UnitCode
#include <../src/rle.h>
%End
int rle_decode_uint8(void* output, int width, int height, char* input, int size);
int rle_decode_uint16(void* output, int width, int height, char* input, int size);
int rle_decode_uint24(void* output, int width, int height, char* input, int size);

View File

@@ -1,8 +1,6 @@
#include "rle_m.h"
namespace test {
int decode_uint8(char* output, int width, int height, char* input, int size)
int rle_decode_uint8(char* output, int width, int height, char* input, int size)
{
char* prevline;
char* line;
@@ -241,7 +239,7 @@ int decode_uint8(char* output, int width, int height, char* input, int size)
return 1;
}
int decode_uint16(char* output, int width, int height, char* input, int size)
int rle_decode_uint16(char* output, int width, int height, char* input, int size)
{
char* prevline;
char* line;
@@ -526,7 +524,7 @@ int decode_uint16(char* output, int width, int height, char* input, int size)
return 1;
}
int decode_uint24(char* output, int width, int height, char* input, int size)
int rle_decode_uint24(char* output, int width, int height, char* input, int size)
{
char* prevline;
char* line;
@@ -832,5 +830,3 @@ int decode_uint24(char* output, int width, int height, char* input, int size)
}
return 1;
}
}

View File

@@ -1,10 +1,9 @@
#ifndef _RLE_H_
#define _RLE_H_
namespace rle {
int decode_uint8(char* output, int width, int height, char* input, int size);
int decode_uint16(char* output, int width, int height, char* input, int size);
int decode_uint24(char* output, int width, int height, char* input, int size);
}
int rle_decode_uint8(char* output, int width, int height, char* input, int size);
int rle_decode_uint16(char* output, int width, int height, char* input, int size);
int rle_decode_uint24(char* output, int width, int height, char* input, int size);
#endif