mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 13:09:50 +00:00
Update to latest bitbake
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@309 311d38ba-8fff-0310-9ca6-ca027cbcb966
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
#
|
||||
# Copyright (C) 2006 Holger Hans Peter Freyther
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
# THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
from bb import data
|
||||
from bb.parse import ParseError
|
||||
|
||||
#
|
||||
# This is the Python Part of the Native Parser Implementation.
|
||||
# We will only parse .bbclass, .inc and .bb files but no
|
||||
# configuration files.
|
||||
# supports, init and handle are the public methods used by
|
||||
# parser module
|
||||
#
|
||||
# The rest of the methods are internal implementation details.
|
||||
|
||||
|
||||
|
||||
#
|
||||
# internal
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# public
|
||||
#
|
||||
def supports(fn, data):
|
||||
return fn[-3:] == ".bb" or fn[-8:] == ".bbclass" or fn[-4:] == ".inc"
|
||||
|
||||
def init(fn, data):
|
||||
print "Init"
|
||||
|
||||
def handle(fn, data, include):
|
||||
print ""
|
||||
print "fn: %s" % fn
|
||||
print "data: %s" % data
|
||||
print "include: %s" % include
|
||||
|
||||
pass
|
||||
|
||||
# Inform bitbake that we are a parser
|
||||
# We need to define all three
|
||||
from bb.parse import handlers
|
||||
handlers.append( {'supports' : supports, 'handle': handle, 'init' : init})
|
||||
del handlers
|
||||
@@ -0,0 +1,12 @@
|
||||
To ease portability (lemon, flex, etc) we keep the
|
||||
result of flex and lemon in the source code. We agree
|
||||
to not manually change the scanner and parser.
|
||||
|
||||
|
||||
|
||||
How we create the files:
|
||||
flex -t bitbakescanner.l > bitbakescanner.cc
|
||||
lemon bitbakeparser.y
|
||||
mv bitbakeparser.c bitbakeparser.cc
|
||||
|
||||
Now manually create two files
|
||||
@@ -0,0 +1,28 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
#
|
||||
# Copyright (C) 2006 Holger Hans Peter Freyther
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
# THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
__version__ = '0.1'
|
||||
__all__ = [ 'BBHandler' ]
|
||||
|
||||
import BBHandler
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,27 @@
|
||||
#define T_SYMBOL 1
|
||||
#define T_VARIABLE 2
|
||||
#define T_EXPORT 3
|
||||
#define T_OP_ASSIGN 4
|
||||
#define T_STRING 5
|
||||
#define T_OP_IMMEDIATE 6
|
||||
#define T_OP_COND 7
|
||||
#define T_OP_PREPEND 8
|
||||
#define T_OP_APPEND 9
|
||||
#define T_TSYMBOL 10
|
||||
#define T_BEFORE 11
|
||||
#define T_AFTER 12
|
||||
#define T_ADDTASK 13
|
||||
#define T_ADDHANDLER 14
|
||||
#define T_FSYMBOL 15
|
||||
#define T_EXPORT_FUNC 16
|
||||
#define T_ISYMBOL 17
|
||||
#define T_INHERIT 18
|
||||
#define T_INCLUDE 19
|
||||
#define T_REQUIRE 20
|
||||
#define T_PROC_BODY 21
|
||||
#define T_PROC_OPEN 22
|
||||
#define T_PROC_CLOSE 23
|
||||
#define T_PYTHON 24
|
||||
#define T_FAKEROOT 25
|
||||
#define T_DEF_BODY 26
|
||||
#define T_DEF_ARGS 27
|
||||
@@ -1,133 +0,0 @@
|
||||
"""
|
||||
|
||||
BitBake C Parser Python Code
|
||||
|
||||
Copyright (C) 2005 Holger Hans Peter Freyther
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
"""
|
||||
|
||||
__version__ = "0xdeadbeef"
|
||||
|
||||
class CParser:
|
||||
"""
|
||||
The C-based Parser for Bitbake
|
||||
"""
|
||||
def __init__(self, data, type):
|
||||
"""
|
||||
Constructor
|
||||
"""
|
||||
self._data = data
|
||||
|
||||
def _syntax_error(self, file, line):
|
||||
"""
|
||||
lemon/flex reports an syntax error to us and we will
|
||||
raise an exception
|
||||
"""
|
||||
pass
|
||||
|
||||
def _export(self, data):
|
||||
"""
|
||||
EXPORT VAR = "MOO"
|
||||
we will now export VAR
|
||||
"""
|
||||
pass
|
||||
|
||||
def _assign(self, key, value):
|
||||
"""
|
||||
VAR = "MOO"
|
||||
we will assign moo to VAR
|
||||
"""
|
||||
pass
|
||||
|
||||
def _assign(self, key, value):
|
||||
"""
|
||||
"""
|
||||
pass
|
||||
|
||||
def _append(self, key, value):
|
||||
"""
|
||||
VAR += "MOO"
|
||||
we will append " MOO" to var
|
||||
"""
|
||||
pass
|
||||
|
||||
def _prepend(self, key, value):
|
||||
"""
|
||||
VAR =+ "MOO"
|
||||
we will prepend "MOO " to var
|
||||
"""
|
||||
pass
|
||||
|
||||
def _immediate(self, key, value):
|
||||
"""
|
||||
VAR := "MOO ${CVSDATE}"
|
||||
we will assign immediately and expand vars
|
||||
"""
|
||||
pass
|
||||
|
||||
def _conditional(self, key, value):
|
||||
"""
|
||||
"""
|
||||
pass
|
||||
|
||||
def _add_task(self, task, before = None, after = None):
|
||||
"""
|
||||
"""
|
||||
pass
|
||||
|
||||
def _include(self, file):
|
||||
"""
|
||||
"""
|
||||
pass
|
||||
|
||||
def _inherit(self, file):
|
||||
"""
|
||||
"""
|
||||
pass
|
||||
|
||||
def _shell_procedure(self, name, body):
|
||||
"""
|
||||
"""
|
||||
pass
|
||||
|
||||
def _python_procedure(self, name, body):
|
||||
"""
|
||||
"""
|
||||
pass
|
||||
|
||||
def _fakeroot_procedure(self, name, body):
|
||||
"""
|
||||
"""
|
||||
pass
|
||||
|
||||
def _def_procedure(self, a, b, c):
|
||||
"""
|
||||
"""
|
||||
pass
|
||||
|
||||
def _export_func(self, name):
|
||||
"""
|
||||
"""
|
||||
pass
|
||||
|
||||
def _add_handler(self, handler):
|
||||
"""
|
||||
"""
|
||||
pass
|
||||
@@ -42,13 +42,14 @@
|
||||
|
||||
%include {
|
||||
#include "token.h"
|
||||
#include "lexer.h"
|
||||
#include "python_output.h"
|
||||
}
|
||||
|
||||
|
||||
%token_destructor { $$.release_this (); }
|
||||
|
||||
%syntax_error { printf ("%s:%d: syntax error\n",
|
||||
lex->filename (), lex->line ()); }
|
||||
%syntax_error { e_parse_error( lex ); }
|
||||
|
||||
program ::= statements.
|
||||
|
||||
@@ -56,79 +57,82 @@ statements ::= statements statement.
|
||||
statements ::= .
|
||||
|
||||
variable(r) ::= SYMBOL(s).
|
||||
{ r.assignString( s.string() );
|
||||
{ r.assignString( (char*)s.string() );
|
||||
s.assignString( 0 );
|
||||
s.release_this(); }
|
||||
variable(r) ::= VARIABLE(v).
|
||||
{
|
||||
r.assignString( v.string() );
|
||||
r.assignString( (char*)v.string() );
|
||||
v.assignString( 0 );
|
||||
v.release_this(); }
|
||||
|
||||
statement ::= EXPORT variable(s) OP_ASSIGN STRING(v).
|
||||
{ e_assign( s.string(), v.string() );
|
||||
e_export( s.string() );
|
||||
{ e_assign( lex, s.string(), v.string() );
|
||||
e_export( lex, s.string() );
|
||||
s.release_this(); v.release_this(); }
|
||||
statement ::= EXPORT variable(s) OP_IMMEDIATE STRING(v).
|
||||
{ e_immediate (s.string(), v.string() );
|
||||
e_export( s.string() );
|
||||
{ e_immediate ( lex, s.string(), v.string() );
|
||||
e_export( lex, s.string() );
|
||||
s.release_this(); v.release_this(); }
|
||||
statement ::= EXPORT variable(s) OP_COND STRING(v).
|
||||
{ e_cond( s.string(), v.string() );
|
||||
{ e_cond( lex, s.string(), v.string() );
|
||||
s.release_this(); v.release_this(); }
|
||||
|
||||
statement ::= variable(s) OP_ASSIGN STRING(v).
|
||||
{ e_assign( s.string(), v.string() );
|
||||
{ e_assign( lex, s.string(), v.string() );
|
||||
s.release_this(); v.release_this(); }
|
||||
statement ::= variable(s) OP_PREPEND STRING(v).
|
||||
{ e_prepend( s.string(), v.string() );
|
||||
{ e_prepend( lex, s.string(), v.string() );
|
||||
s.release_this(); v.release_this(); }
|
||||
statement ::= variable(s) OP_APPEND STRING(v).
|
||||
{ e_append( s.string() , v.string() );
|
||||
{ e_append( lex, s.string() , v.string() );
|
||||
s.release_this(); v.release_this(); }
|
||||
statement ::= variable(s) OP_IMMEDIATE STRING(v).
|
||||
{ e_immediate( s.string(), v.string() );
|
||||
{ e_immediate( lex, s.string(), v.string() );
|
||||
s.release_this(); v.release_this(); }
|
||||
statement ::= variable(s) OP_COND STRING(v).
|
||||
{ e_cond( s.string(), v.string() );
|
||||
{ e_cond( lex, s.string(), v.string() );
|
||||
s.release_this(); v.release_this(); }
|
||||
|
||||
task ::= TSYMBOL(t) BEFORE TSYMBOL(b) AFTER TSYMBOL(a).
|
||||
{ e_addtask( t.string(), b.string(), a.string() );
|
||||
{ e_addtask( lex, t.string(), b.string(), a.string() );
|
||||
t.release_this(); b.release_this(); a.release_this(); }
|
||||
task ::= TSYMBOL(t) AFTER TSYMBOL(a) BEFORE TSYMBOL(b).
|
||||
{ e_addtask( t.string(), b.string(), a.string());
|
||||
{ e_addtask( lex, t.string(), b.string(), a.string());
|
||||
t.release_this(); a.release_this(); b.release_this(); }
|
||||
task ::= TSYMBOL(t).
|
||||
{ e_addtask( t.string(), NULL, NULL);
|
||||
{ e_addtask( lex, t.string(), NULL, NULL);
|
||||
t.release_this();}
|
||||
task ::= TSYMBOL(t) BEFORE TSYMBOL(b).
|
||||
{ e_addtask( t.string(), b.string(), NULL);
|
||||
{ e_addtask( lex, t.string(), b.string(), NULL);
|
||||
t.release_this(); b.release_this(); }
|
||||
task ::= TSYMBOL(t) AFTER TSYMBOL(a).
|
||||
{ e_addtask( t.string(), NULL, a.string());
|
||||
{ e_addtask( lex, t.string(), NULL, a.string());
|
||||
t.release_this(); a.release_this(); }
|
||||
tasks ::= tasks task.
|
||||
tasks ::= task.
|
||||
statement ::= ADDTASK tasks.
|
||||
|
||||
statement ::= ADDHANDLER SYMBOL(s).
|
||||
{ e_addhandler( s.string()); s.release_this (); }
|
||||
{ e_addhandler( lex, s.string()); s.release_this (); }
|
||||
|
||||
func ::= FSYMBOL(f). { e_export_func(f.string()); f.release_this(); }
|
||||
func ::= FSYMBOL(f). { e_export_func( lex, f.string()); f.release_this(); }
|
||||
funcs ::= funcs func.
|
||||
funcs ::= func.
|
||||
statement ::= EXPORT_FUNC funcs.
|
||||
|
||||
inherit ::= ISYMBOL(i). { e_inherit(i.string() ); i.release_this (); }
|
||||
inherit ::= ISYMBOL(i). { e_inherit( lex, i.string() ); i.release_this (); }
|
||||
inherits ::= inherits inherit.
|
||||
inherits ::= inherit.
|
||||
statement ::= INHERIT inherits.
|
||||
|
||||
statement ::= INCLUDE ISYMBOL(i).
|
||||
{ e_include(i.string() ); i.release_this(); }
|
||||
{ e_include( lex, i.string() ); i.release_this(); }
|
||||
|
||||
proc_body(r) ::= proc_body(l) PROC_BODY(b).
|
||||
statement ::= REQUIRE ISYMBOL(i).
|
||||
{ e_require( lex, i.string() ); i.release_this(); }
|
||||
|
||||
proc_body(r) ::= proc_body(l) PROC_BODY(b).
|
||||
{ /* concatenate body lines */
|
||||
r.assignString( token_t::concatString(l.string(), b.string()) );
|
||||
l.release_this ();
|
||||
@@ -136,26 +140,26 @@ proc_body(r) ::= proc_body(l) PROC_BODY(b).
|
||||
}
|
||||
proc_body(b) ::= . { b.assignString(0); }
|
||||
statement ::= variable(p) PROC_OPEN proc_body(b) PROC_CLOSE.
|
||||
{ e_proc( p.string(), b.string() );
|
||||
{ e_proc( lex, p.string(), b.string() );
|
||||
p.release_this(); b.release_this(); }
|
||||
statement ::= PYTHON SYMBOL(p) PROC_OPEN proc_body(b) PROC_CLOSE.
|
||||
{ e_proc_python (p.string(), b.string() );
|
||||
{ e_proc_python ( lex, p.string(), b.string() );
|
||||
p.release_this(); b.release_this(); }
|
||||
statement ::= PYTHON PROC_OPEN proc_body(b) PROC_CLOSE.
|
||||
{ e_proc_python( NULL, b.string());
|
||||
{ e_proc_python( lex, NULL, b.string());
|
||||
b.release_this (); }
|
||||
|
||||
statement ::= FAKEROOT SYMBOL(p) PROC_OPEN proc_body(b) PROC_CLOSE.
|
||||
{ e_proc_fakeroot(p.string(), b.string() );
|
||||
{ e_proc_fakeroot( lex, p.string(), b.string() );
|
||||
p.release_this (); b.release_this (); }
|
||||
|
||||
def_body(r) ::= def_body(l) DEF_BODY(b).
|
||||
{ /* concatenate body lines */
|
||||
r.assignString( token_t::concatString(l.string(), b.string());
|
||||
r.assignString( token_t::concatString(l.string(), b.string()) );
|
||||
l.release_this (); b.release_this ();
|
||||
}
|
||||
def_body(b) ::= . { b.sz = 0; }
|
||||
def_body(b) ::= . { b.assignString( 0 ); }
|
||||
statement ::= SYMBOL(p) DEF_ARGS(a) def_body(b).
|
||||
{ e_def( p.string(), a.string(), b.string());
|
||||
{ e_def( lex, p.string(), a.string(), b.string());
|
||||
p.release_this(); a.release_this(); b.release_this(); }
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+11
-11
@@ -71,6 +71,7 @@
|
||||
|
||||
#include "token.h"
|
||||
#include "lexer.h"
|
||||
#include "bitbakeparser.h"
|
||||
#include <ctype.h>
|
||||
|
||||
extern void *bbparseAlloc(void *(*mallocProc)(size_t));
|
||||
@@ -124,6 +125,7 @@ K_AFTER "after"
|
||||
K_BEFORE "before"
|
||||
K_DEF "def"
|
||||
K_INCLUDE "include"
|
||||
K_REQUIRE "require"
|
||||
K_INHERIT "inherit"
|
||||
K_PYTHON "python"
|
||||
K_FAKEROOT "fakeroot"
|
||||
@@ -149,6 +151,7 @@ PROC \({C_SP}*\)
|
||||
%s S_FUNC
|
||||
%s S_INCLUDE
|
||||
%s S_INHERIT
|
||||
%s S_REQUIRE
|
||||
%s S_PROC
|
||||
%s S_RVALUE
|
||||
%s S_TASK
|
||||
@@ -186,6 +189,8 @@ PROC \({C_SP}*\)
|
||||
|
||||
{K_INCLUDE} { BEGIN S_INCLUDE;
|
||||
yyextra->accept (T_INCLUDE); }
|
||||
{K_REQUIRE} { BEGIN S_REQUIRE;
|
||||
yyextra->accept (T_REQUIRE); }
|
||||
{K_INHERIT} { BEGIN S_INHERIT;
|
||||
yyextra->accept (T_INHERIT); }
|
||||
{K_ADDTASK} { BEGIN S_TASK;
|
||||
@@ -224,7 +229,8 @@ PROC \({C_SP}*\)
|
||||
<S_INHERIT>{SYMBOL} { yyextra->accept (T_ISYMBOL, yytext); }
|
||||
<S_INCLUDE>{FILENAME} { BEGIN INITIAL;
|
||||
yyextra->accept (T_ISYMBOL, yytext); }
|
||||
|
||||
<S_REQUIRE>{FILENAME} { BEGIN INITIAL;
|
||||
yyextra->accept (T_ISYMBOL, yytext); }
|
||||
<S_TASK>\n { BEGIN INITIAL; }
|
||||
<S_FUNC>\n { BEGIN INITIAL; }
|
||||
<S_INHERIT>\n { BEGIN INITIAL; }
|
||||
@@ -253,12 +259,7 @@ int lex_t::line ()const
|
||||
return yyget_lineno (scanner);
|
||||
}
|
||||
|
||||
const char* lex_t::filename ()const
|
||||
{
|
||||
return m_fileName;
|
||||
}
|
||||
|
||||
void parse (MappedFile* mf)
|
||||
void parse (FILE* file, PyObject* data)
|
||||
{
|
||||
void* parser = bbparseAlloc (malloc);
|
||||
yyscan_t scanner;
|
||||
@@ -268,9 +269,8 @@ void parse (MappedFile* mf)
|
||||
|
||||
lex.parser = parser;
|
||||
lex.scanner = scanner;
|
||||
lex.mf = mf;
|
||||
lex.rgbInput = mf->m_rgb;
|
||||
lex.cbInput = mf->m_cb;
|
||||
lex.file = file;
|
||||
lex.data = data;
|
||||
lex.parse = bbparse;
|
||||
yyset_extra (&lex, scanner);
|
||||
|
||||
@@ -281,7 +281,7 @@ void parse (MappedFile* mf)
|
||||
bbparseTrace (NULL, NULL);
|
||||
|
||||
if (result != T_EOF)
|
||||
WARNING ("premature end of file\n");
|
||||
printf ("premature end of file\n");
|
||||
|
||||
yylex_destroy (scanner);
|
||||
bbparseFree (parser, free);
|
||||
@@ -24,17 +24,29 @@ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#ifndef LEXER_H
|
||||
#define LEXER_H
|
||||
|
||||
/*
|
||||
* The PyObject Token. Likely to be
|
||||
* a bb.data implementation
|
||||
*/
|
||||
struct PyObject;
|
||||
|
||||
|
||||
/**
|
||||
* This is used by the Parser and Scanner
|
||||
* of BitBake.
|
||||
* The implementation and creation is done
|
||||
* in the scanner.
|
||||
*/
|
||||
struct lex_t {
|
||||
void *parser;
|
||||
void *scanner;
|
||||
FILE *file;
|
||||
PyObject *data;
|
||||
void* (*parse)(void*, int, token_t, lex_t*);
|
||||
|
||||
void accept(int token, const char* string = 0);
|
||||
void input(char *buf, int *result, int_max_size);
|
||||
void input(char *buf, int *result, int max_size);
|
||||
int line()const;
|
||||
const char* filename()const;
|
||||
private:
|
||||
const char* m_fileName;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef PYTHON_OUTPUT_H
|
||||
#define PYTHON_OUTPUT_H
|
||||
/*
|
||||
Copyright (C) 2006 Holger Hans Peter Freyther
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
This is the glue:
|
||||
It will be called from the lemon grammar and will call into
|
||||
python to set certain things.
|
||||
|
||||
*/
|
||||
|
||||
struct lex_t;
|
||||
|
||||
extern void e_assign(lex_t*, const char*, const char*);
|
||||
extern void e_export(lex_t*, const char*);
|
||||
extern void e_immediate(lex_t*, const char*, const char*);
|
||||
extern void e_cond(lex_t*, const char*, const char*);
|
||||
extern void e_assign(lex_t*, const char*, const char*);
|
||||
extern void e_prepend(lex_t*, const char*, const char*);
|
||||
extern void e_append(lex_t*, const char*, const char*);
|
||||
extern void e_addtask(lex_t*, const char*, const char*, const char*);
|
||||
extern void e_addhandler(lex_t*,const char*);
|
||||
extern void e_export_func(lex_t*, const char*);
|
||||
extern void e_inherit(lex_t*, const char*);
|
||||
extern void e_include(lex_t*, const char*);
|
||||
extern void e_require(lex_t*, const char*);
|
||||
extern void e_proc(lex_t*, const char*, const char*);
|
||||
extern void e_proc_python(lex_t*, const char*, const char*);
|
||||
extern void e_proc_fakeroot(lex_t*, const char*, const char*);
|
||||
extern void e_def(lex_t*, const char*, const char*, const char*);
|
||||
extern void e_parse_error(lex_t*);
|
||||
|
||||
#endif // PYTHON_OUTPUT_H
|
||||
@@ -24,13 +24,24 @@ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#ifndef TOKEN_H
|
||||
#define TOKEN_H
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#define PURE_METHOD
|
||||
|
||||
|
||||
/**
|
||||
* Special Value for End Of File Handling. We set it to
|
||||
* 1001 so we can have up to 1000 Terminal Symbols on
|
||||
* grammar. Currenlty we have around 20
|
||||
*/
|
||||
#define T_EOF 1001
|
||||
|
||||
struct token_t {
|
||||
const char* string()const PURE_METHOD;
|
||||
|
||||
static char* concatString(const char* l, const char* r);
|
||||
void assignString(const char* str);
|
||||
void assignString(char* str);
|
||||
void copyString(const char* str);
|
||||
|
||||
void release_this();
|
||||
@@ -51,15 +62,17 @@ inline const char* token_t::string()const
|
||||
inline char* token_t::concatString(const char* l, const char* r)
|
||||
{
|
||||
size_t cb = (l ? strlen (l) : 0) + strlen (r) + 1;
|
||||
r_sz = new char[cb];
|
||||
char *r_sz = new char[cb];
|
||||
*r_sz = 0;
|
||||
if (l) strcat (r_sz, l);
|
||||
|
||||
if (l)
|
||||
strcat (r_sz, l);
|
||||
strcat (r_sz, r);
|
||||
|
||||
return r_sz;
|
||||
}
|
||||
|
||||
inline void token_t::assignString(const char* str)
|
||||
inline void token_t::assignString(char* str)
|
||||
{
|
||||
m_string = str;
|
||||
m_stringLen = str ? strlen(str) : 0;
|
||||
@@ -70,7 +83,7 @@ inline void token_t::copyString(const char* str)
|
||||
if( str ) {
|
||||
m_stringLen = strlen(str);
|
||||
m_string = new char[m_stringLen+1];
|
||||
strcpy(m_string, str)
|
||||
strcpy(m_string, str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA."""
|
||||
|
||||
import re, bb, os, sys
|
||||
import bb.fetch, bb.build
|
||||
import bb.fetch, bb.build, bb.utils
|
||||
from bb import debug, data, fetch, fatal
|
||||
|
||||
from ConfHandler import include, localpath, obtain, init
|
||||
@@ -206,8 +206,8 @@ def feeder(lineno, s, fn, d):
|
||||
return
|
||||
else:
|
||||
text = '\n'.join(__body__)
|
||||
comp = compile(text, "<bb>", "exec")
|
||||
exec comp in __builtins__
|
||||
comp = bb.utils.better_compile(text, "<bb>", fn )
|
||||
bb.utils.better_exec(comp, __builtins__, text, fn)
|
||||
__body__ = []
|
||||
__inpython__ = False
|
||||
funcs = data.getVar('__functions__', d) or ""
|
||||
|
||||
Reference in New Issue
Block a user