From 663c70ce271915160168cffa4d1ade215dab082c Mon Sep 17 00:00:00 2001 From: Gordon Hecker Date: Wed, 20 Jan 2010 18:22:19 +0100 Subject: [PATCH] cleanup: remove unused e2api code Signed-off-by: Gordon Hecker --- local/Makefile | 18 +----- local/e2api.c | 139 ---------------------------------------------- local/e2api.h | 56 ------------------- local/e2api.lua | 45 --------------- local/testapi.c | 74 ------------------------ local/testapi.lua | 39 ------------- 6 files changed, 2 insertions(+), 369 deletions(-) delete mode 100644 local/e2api.c delete mode 100644 local/e2api.h delete mode 100644 local/e2api.lua delete mode 100644 local/testapi.c delete mode 100644 local/testapi.lua diff --git a/local/Makefile b/local/Makefile index 243b185..d944cd9 100644 --- a/local/Makefile +++ b/local/Makefile @@ -48,9 +48,9 @@ SYMLINKS_2_1 = lookup-server use-source prepare-cargo sync-results cleanup \ .PHONY: all install uninstall install install-local doc install-doc -all: linux32 e2local.lc $(LOCALLUATOOLS:=.lc) libe2api.so +all: linux32 e2local.lc $(LOCALLUATOOLS:=.lc) -install: libe2api.so +install: # install symlinks for e2-2.1 compatibility for i in $(SYMLINKS_2_1); do \ ln -sf e2 $(DESTDIR)$(BINDIR)/e2-$$i ; \ @@ -58,9 +58,6 @@ install: libe2api.so for i in $(LOCALTOOLS); do \ ln -sf e2 $(DESTDIR)$(BINDIR)/e2-$$i ; \ done - install -m755 libe2api.so $(DESTDIR)$(LIBDIR)/ - install -m644 e2api.h $(DESTDIR)$(INCDIR)/ - install -m644 e2api.lua $(DESTDIR)$(LIBDIR)/ install-local: all test -n "$(PROJECTDIR)" @@ -94,9 +91,6 @@ uninstall: for i in $(LOCALTOOLS); do \ rm -f $(DESTDIR)$(BINDIR)/e2-$$i ; \ done - rm -f $(DESTDIR)$(LIBDIR)/libe2api.so - rm -f $(DESTDIR)$(INCDIR)/e2api.h - rm -f $(DESTDIR)$(LIBDIR)/e2api.lua clean: rm -f $(CLEAN_FILES) @@ -129,11 +123,3 @@ e2local.lc: $(TOPLEVEL)/generic/strict.lua \ $(LUAC) -o $@ $^ linux32: linux32.c - -libe2api.so: e2api.o - $(CC) -shared -o $@ $^ -I../lua/lua-$(LUA_VERSION)/src -I. $(CFLAGS) - -e2api.o: e2api.h - -testapi: testapi.o libe2api.so - $(CC) -o $@ $< -le2api $(LDFLAGS) -llua -lm -ldl -export-dynamic diff --git a/local/e2api.c b/local/e2api.c deleted file mode 100644 index 8ea0c02..0000000 --- a/local/e2api.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - e2factory, the emlix embedded build system - - Copyright (C) 2007-2009 Gordon Hecker , emlix GmbH - Copyright (C) 2007-2009 Oskar Schirmer , emlix GmbH - Copyright (C) 2007-2008 Felix Winkelmann, emlix GmbH - - For more information have a look at http://www.e2factory.org - - e2factory is a registered trademark by emlix GmbH. - - This file is part of e2factory, the emlix embedded build system. - - e2factory is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/* - e2api.c - - C-API for accessing project information -*/ - - -#include -#include -#include -#include -#include - -#include "e2api.h" - - -static char *error_message = NULL; - - -lua_State * -e2_init(char *project_path) -{ - char rpath[ PATH_MAX + 1 ]; - char buffer[ PATH_MAX + 1 ]; - lua_State *lua; - - if(realpath(project_path, rpath) == NULL) { - free(error_message); - error_message = strdup(strerror(errno)); - return NULL; - } - - strcpy(buffer, rpath); - strcat(buffer, "/.e2/lib/e2/?.lc;"); - strcat(buffer, rpath); - strcat(buffer, "/.e2/lib/e2/?.lua"); - setenv("LUA_PATH", buffer, 1); - strcpy(buffer, rpath); - strcat(buffer, "/.e2/lib/e2/?.so"); - setenv("LUA_CPATH", buffer, 1); - lua = lua_open(); - luaL_openlibs(lua); - lua_newtable(lua); - lua_setglobal(lua, "arg"); - lua_pushstring(lua, rpath); - lua_setglobal(lua, "e2api_rpath"); - strcpy(buffer, rpath); - strcat(buffer, "/.e2/lib/e2/e2local.lc"); - - if(luaL_loadfile(lua, buffer) != 0) { - free(error_message); - error_message = strdup(lua_tostring(lua, -1)); - lua_close(lua); - return NULL; - } - - if(lua_pcall(lua, 0, 0, 0) != 0) { - free(error_message); - error_message = strdup(lua_tostring(lua, -1)); - lua_close(lua); - return NULL; - } - - return lua; -} - - -void -e2_exit(lua_State *lua) -{ - free(error_message); - lua_close(lua); -} - - -static int -exit_handler(lua_State *lua) -{ - free(error_message); - error_message = strdup(lua_tostring(lua, -1)); - return luaL_error(lua, error_message); -} - - -int -e2_info(lua_State *lua) -{ - lua_getglobal(lua, "e2lib"); - lua_pushstring(lua, "abort_with_message"); - lua_pushcfunction(lua, exit_handler); - lua_rawset(lua, -3); - lua_getglobal(lua, "e2tool"); - lua_pushstring(lua, "collect_project_info"); - lua_rawget(lua, -2); - lua_remove(lua, -2); /* remove e2tool table */ - lua_getglobal(lua, "e2api_rpath"); - - if(lua_pcall(lua, 1, 1, 0) != 0) { - free(error_message); - error_message = strdup(lua_tostring(lua, -1)); - return 0; - } - - return 1; -} - - -char * -e2_error(void) -{ - return error_message; -} diff --git a/local/e2api.h b/local/e2api.h deleted file mode 100644 index 98ee945..0000000 --- a/local/e2api.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - e2factory, the emlix embedded build system - - Copyright (C) 2007-2009 Gordon Hecker , emlix GmbH - Copyright (C) 2007-2009 Oskar Schirmer , emlix GmbH - Copyright (C) 2007-2008 Felix Winkelmann, emlix GmbH - - For more information have a look at http://www.e2factory.org - - e2factory is a registered trademark by emlix GmbH. - - This file is part of e2factory, the emlix embedded build system. - - e2factory is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/* - e2api.h -*/ - - -#ifndef E2API_H -#define E2API_H - - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - - - extern lua_State *e2_init(char *project_path); - extern void e2_exit(lua_State *state); - extern int e2_info(lua_State *state); - extern char *e2_error(void); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/local/e2api.lua b/local/e2api.lua deleted file mode 100644 index fae87a8..0000000 --- a/local/e2api.lua +++ /dev/null @@ -1,45 +0,0 @@ ---[[ - e2factory, the emlix embedded build system - - Copyright (C) 2007-2009 Gordon Hecker , emlix GmbH - Copyright (C) 2007-2009 Oskar Schirmer , emlix GmbH - Copyright (C) 2007-2008 Felix Winkelmann, emlix GmbH - - For more information have a look at http://www.e2factory.org - - e2factory is a registered trademark by emlix GmbH. - - This file is part of e2factory, the emlix embedded build system. - - e2factory is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -]] - --- e2api.lua --- Use e2 from a Lua program. - - -e2api = {} - -function e2api.init(project_path) - package.path = project_path .. "/.e2/lib/e2/?.lc;" .. - project_path .. "/.e2/lib/e2/?.lua;" .. package.path - package.cpath = project_path .. "/.e2/lib/e2/?.so;" .. package.cpath - e2api.rpath = project_path - require("e2local") - e2lib.abort_with_message = error -end - -function e2api.info() - return e2tool.collect_project_info(e2api.rpath) -end diff --git a/local/testapi.c b/local/testapi.c deleted file mode 100644 index 4495828..0000000 --- a/local/testapi.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - e2factory, the emlix embedded build system - - Copyright (C) 2007-2009 Gordon Hecker , emlix GmbH - Copyright (C) 2007-2009 Oskar Schirmer , emlix GmbH - Copyright (C) 2007-2008 Felix Winkelmann, emlix GmbH - - For more information have a look at http://www.e2factory.org - - e2factory is a registered trademark by emlix GmbH. - - This file is part of e2factory, the emlix embedded build system. - - e2factory is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/* - testapi.c -*/ - - -#include -#include -#include -#include - -#include "e2api.h" - - -int -main(int argc, char *argv[]) -{ - lua_State *lua; - char rpath[ PATH_MAX + 1 ]; - - if(argc > 1) strcpy(rpath, argv[ 1 ]); - else strcpy(rpath, "."); - - lua = e2_init(rpath); - - if(lua == NULL) { - fprintf(stderr, "[e2api] Error: %s\n", e2_error()); - exit(EXIT_FAILURE); - } - - if(e2_info(lua)) { - lua_pushnil(lua); - - while (lua_next(lua, -2) != 0) { - printf("%s: %s\n", lua_tostring(lua, -2), lua_typename(lua, lua_type(lua, -1))); - lua_pop(lua, 1); - } - - lua_pop(lua, 1); - } - else { - fprintf(stderr, "[e2api] Error: %s\n", e2_error()); - exit(EXIT_FAILURE); - } - - e2_exit(lua); - return 0; -} diff --git a/local/testapi.lua b/local/testapi.lua deleted file mode 100644 index c494162..0000000 --- a/local/testapi.lua +++ /dev/null @@ -1,39 +0,0 @@ ---[[ - e2factory, the emlix embedded build system - - Copyright (C) 2007-2009 Gordon Hecker , emlix GmbH - Copyright (C) 2007-2009 Oskar Schirmer , emlix GmbH - Copyright (C) 2007-2008 Felix Winkelmann, emlix GmbH - - For more information have a look at http://www.e2factory.org - - e2factory is a registered trademark by emlix GmbH. - - This file is part of e2factory, the emlix embedded build system. - - e2factory is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -]] - --- testapi.lua --- --- Test Lua e2 api - - -dofile("e2api.lua") - -e2api.init(arg[ 1 ] or error("usage: lua e2api.lua PATH")) -table.foreach(e2api.info(), print) - -rc = e2lib.callcmd_capture("exit 3") -print(rc) -- 2.39.5