Exemplo n.º 1
0
def exportPhase2(cgOptions, phase1src):
    
    genfiles = phase1src

    # add makefile
    genfiles['Makefile'] = mkMakefile( cgOptions )
    genfiles['workspace.c'] ='''\
#include "acado_common.h"
ACADOworkspace acadoWorkspace;
ACADOvariables acadoVariables;
'''

    # write things in user specified directory if 'export_without_build_path' is not None
    # then return without building
    if cgOptions['export_without_build_path'] is not None:
        codegen.writeDifferentFiles(cgOptions['export_without_build_path'], genfiles)
        return

    # write things in user specified directory if 'force_export_path' is not None
    # then compile as normal
    if cgOptions['force_export_path'] is not None:
        codegen.writeDifferentFiles(cgOptions['force_export_path'], genfiles)
        exportpath = cgOptions['force_export_path']
    # otherwise write things in memoized directory, then compile as normal
    else:
        exportpath = codegen.memoizeFiles(genfiles,prefix=cgOptions['hashPrefix']+'__')

    # compile!
    (ret, msgs) = subprocess_tee.call(['make',codegen.makeJobs()], cwd=exportpath)
    if ret != 0:
        raise Exception("ocp compilation failed:\n\n"+msgs)

    # return shared object
    return exportpath
Exemplo n.º 2
0
def exportPhase2(cgOptions, phase1src):
    # call pkg-config to get qpoases source and includes
    qpoStuff = {}
    for name in ["qpOASESsrc", "qpOASESinc"]:
        qpoStuff[name] = pkgconfig.call(["--variable", name, "acado"])
    qpoStuff["qpOASESsrc"] = qpoStuff["qpOASESsrc"].split(" ")

    # get qpoases source as file dictionary
    qpoSrcPath = os.path.join(qpoStuff["qpOASESsrc"][0].split("qpoases")[0], "qpoases")
    phase2src = codegen.directoryToDict(qpoSrcPath)

    # merge qpoases source with phase 1 output
    def mergeAll(srcdict, destdict):
        for name, src in srcdict.items():
            if isinstance(src, dict):
                if name not in destdict:
                    destdict[name] = {}
                assert isinstance(
                    destdict[name], dict
                ), "dictionary merge failed, source was directory but destination was a file"
                destdict[name] = mergeAll(src, destdict[name])
            else:
                destdict[name] = src
        return destdict

    genfiles = mergeAll(phase1src, {"qpoases": phase2src})

    # add makefile
    genfiles["Makefile"] = mkMakefile(cgOptions, qpoStuff["qpOASESsrc"])
    genfiles[
        "workspace.c"
    ] = """\
#include "acado_common.h"
ACADOworkspace acadoWorkspace;
ACADOvariables acadoVariables;
"""

    # write things in user specified directory if 'export_without_build_path' is not None
    # then return without building
    if cgOptions["export_without_build_path"] is not None:
        codegen.writeDifferentFiles(cgOptions["export_without_build_path"], genfiles)
        return

    # write things in user specified directory if 'force_export_path' is not None
    # then compile as normal
    if cgOptions["force_export_path"] is not None:
        codegen.writeDifferentFiles(cgOptions["force_export_path"], genfiles)
        exportpath = cgOptions["force_export_path"]
    # otherwise write things in memoized directory, then compile as normal
    else:
        exportpath = codegen.memoizeFiles(genfiles, prefix=cgOptions["hashPrefix"] + "__")

    # compile!
    (ret, msgs) = subprocess_tee.call(["make", codegen.makeJobs()], cwd=exportpath)
    if ret != 0:
        raise Exception("ocp compilation failed:\n\n" + msgs)

    # return shared object
    return exportpath
Exemplo n.º 3
0
def exportPhase2(cgOptions, phase1src):
    # call pkg-config to get qpoases source and includes
    qpoStuff = {}
    for name in ['qpOASESsrc', 'qpOASESinc']:
        qpoStuff[name] = pkgconfig.call(['--variable', name, 'acado'])
    qpoStuff['qpOASESsrc'] = qpoStuff['qpOASESsrc'].split(' ')

    # get qpoases source as file dictionary
    qpoSrcPath = os.path.join(qpoStuff['qpOASESsrc'][0].split('qpoases')[0],
                              'qpoases')
    phase2src = codegen.directoryToDict(qpoSrcPath)

    # merge qpoases source with phase 1 output
    def mergeAll(srcdict, destdict):
        for name, src in srcdict.items():
            if isinstance(src, dict):
                if name not in destdict:
                    destdict[name] = {}
                assert isinstance(
                    destdict[name], dict
                ), "dictionary merge failed, source was directory but destination was a file"
                destdict[name] = mergeAll(src, destdict[name])
            else:
                destdict[name] = src
        return destdict

    genfiles = mergeAll(phase1src, {'qpoases': phase2src})

    # add makefile
    genfiles['Makefile'] = mkMakefile(cgOptions, qpoStuff['qpOASESsrc'])
    genfiles['workspace.c'] = '''\
#include "acado_common.h"
ACADOworkspace acadoWorkspace;
ACADOvariables acadoVariables;
'''

    # write things in user specified directory if 'export_without_build_path' is not None
    if cgOptions['export_without_build_path'] is not None:
        codegen.writeDifferentFiles(cgOptions['export_without_build_path'],
                                    genfiles)
        return

    # otherwise write things in memoized directory, then compile
    exportpath = codegen.memoizeFiles(genfiles,
                                      prefix=cgOptions['hashPrefix'] + '__')

    # compile!
    (ret, msgs) = subprocess_tee.call(['make', codegen.makeJobs()],
                                      cwd=exportpath)
    if ret != 0:
        raise Exception("ocp compilation failed:\n\n" + msgs)

    # return shared object
    return exportpath
Exemplo n.º 4
0
def exportPhase2(cgOptions, phase1src):
    # call pkg-config to get qpoases source and includes
    qpoStuff = {}
    for name in ['qpOASESsrc', 'qpOASESinc']:
        qpoStuff[name] = pkgconfig.call(['--variable',name,'acado'])
    qpoStuff['qpOASESsrc'] = qpoStuff['qpOASESsrc'].split(' ')

    # get qpoases source as file dictionary
    qpoSrcPath = os.path.join(qpoStuff['qpOASESsrc'][0].split('qpoases')[0], 'qpoases')
    phase2src = codegen.directoryToDict(qpoSrcPath)

    # merge qpoases source with phase 1 output
    def mergeAll(srcdict,destdict):
        for name,src in srcdict.items():
            if isinstance(src,dict):
                if name not in destdict:
                    destdict[name] = {}
                assert isinstance(destdict[name], dict), "dictionary merge failed, source was directory but destination was a file"
                destdict[name] = mergeAll(src,destdict[name])
            else:
                destdict[name] = src
        return destdict
    genfiles = mergeAll(phase1src, {'qpoases':phase2src})

    # add makefile
    genfiles['Makefile'] = mkMakefile(cgOptions, qpoStuff['qpOASESsrc'])
    genfiles['workspace.c'] ='''\
#include "acado_common.h"
ACADOworkspace acadoWorkspace;
ACADOvariables acadoVariables;
'''

    # write things in user specified directory if 'export_without_build_path' is not None
    if cgOptions['export_without_build_path'] is not None:
        codegen.writeDifferentFiles(cgOptions['export_without_build_path'], genfiles)
        return

    # otherwise write things in memoized directory, then compile
    exportpath = codegen.memoizeFiles(genfiles,prefix=cgOptions['hashPrefix']+'__')

    # compile!
    (ret, msgs) = subprocess_tee.call(['make',codegen.makeJobs()], cwd=exportpath)
    if ret != 0:
        raise Exception("ocp compilation failed:\n\n"+msgs)

    # return shared object
    return exportpath