From: Gordon Hecker Date: Mon, 11 May 2009 18:15:19 +0000 (+0200) Subject: move build time configuration to buildconfig.lua X-Git-Tag: e2factory-2.3.1pre1~23 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=9e7a4c31b52132186ab019d5788bfe6a015f83bf;p=e2factory.git move build time configuration to buildconfig.lua Signed-off-by: Gordon Hecker --- diff --git a/Makefile b/Makefile index 99bb0eb..6fbe57d 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ TOPLEVEL = . include $(TOPLEVEL)/make.vars -CLEAN_FILES = *~ E2_COMMIT +CLEAN_FILES = *~ E2_COMMIT buildconfig.lua .PHONY: all e2commit install install-local clean local localdist uninstall \ @@ -40,7 +40,19 @@ CLEAN_FILES = *~ E2_COMMIT help: @cat INSTALL -all: e2commit +buildconfig.lua: Makefile + echo 'module ("buildconfig")' > $@ + echo 'PREFIX="$(PREFIX)"' >>$@ + echo 'BINDIR="$(BINDIR)"' >>$@ + echo 'LIBDIR="$(LIBDIR)"' >>$@ + echo 'TOOLDIR="$(TOOLDIR)"' >>$@ + echo 'E2="$(E2)"' >>$@ + echo 'LUA="$(LUA)"' >>$@ + echo 'E2_VERSION="$(E2_VERSION)"' >>$@ + echo 'E2_COMMIT="$(E2_COMMIT)"' >>$@ + echo 'E2_SYNTAX="$(E2_SYNTAX)"' >>$@ + +all: e2commit buildconfig.lua $(MAKE) -C lua $(MAKE) -C generic $(MAKE) -C global @@ -65,6 +77,7 @@ install: all mkdir -p $(DESTDIR)$(INCDIR) mkdir -p $(DESTDIR)$(MANDIR) mkdir -p $(DESTDIR)$(TOOLDIR) + install -m 644 buildconfig.lua $(DESTDIR)$(LIBDIR) $(MAKE) -C lua install $(MAKE) -C generic install $(MAKE) -C global install @@ -80,7 +93,7 @@ uninstall: $(MAKE) -C templates uninstall $(MAKE) -C local uninstall -local: e2commit +local: e2commit buildconfig.lua $(MAKE) -C generic local $(MAKE) -C local $(MAKE) -C templates local @@ -90,6 +103,7 @@ install-local: $(MAKE) -C generic install-local $(MAKE) -C local install-local $(MAKE) -C templates install-local + install -m 644 buildconfig.lua $(LOCALLIBDIR) doc: for s in $(SUBDIRS) ; do \ diff --git a/generic/e2hook.lua b/generic/e2hook.lua index 6d7321f..9928bce 100644 --- a/generic/e2hook.lua +++ b/generic/e2hook.lua @@ -70,7 +70,7 @@ function e2hook.run_hook(info, hookname, arguments, toolname) if info then hfile = info.root .. "/proj/hooks/" .. hookname else - hfile = E2_PREFIX .. "/share/e2/hooks/" .. hookname + hfile = buildconfig.PREFIX .. "/share/e2/hooks/" .. hookname end if e2util.exists(hfile) then e2lib.log(3, "running hook `" .. hookname .. "' ...") diff --git a/generic/e2lib.lua b/generic/e2lib.lua index 77637ff..5cddca0 100644 --- a/generic/e2lib.lua +++ b/generic/e2lib.lua @@ -26,7 +26,7 @@ ]] _version = "e2factory, the emlix embedded build system, version " .. - E2_VERSION + buildconfig.E2_VERSION _licence = [[ e2factory is free software: you can redistribute it and/or modify @@ -79,7 +79,7 @@ e2lib = { default_e2 = { local_branch = "master", local_tag = "^", - local_syntax = E2_SYNTAX, + local_syntax = buildconfig.E2_SYNTAX, }, local_e2_branch = nil, local_e2_tag = nil, @@ -449,8 +449,8 @@ function e2lib.log_invocation(info, args) end local logstring = string.format( "%s %s %s/%s %s \"%s %s\"\n", - pname, os.date(), E2_VERSION, E2_COMMIT, e2lib.username, - arg[0], table.concat(args, " ")) + pname, os.date(), buildconfig.E2_VERSION, buildconfig.E2_COMMIT, + e2lib.username, arg[0], table.concat(args, " ")) -- always log to the user logfile local ulogdir = string.format("%s/.e2", e2lib.homedir) diff --git a/generic/lua-version-map.lua.in b/generic/lua-version-map.lua.in index 8630fd7..2356682 100644 --- a/generic/lua-version-map.lua.in +++ b/generic/lua-version-map.lua.in @@ -35,7 +35,7 @@ lua_versions = { } function lua_versions.get_version(e2_version) - local v = e2_version or E2_VERSION + local v = e2_version or buildconfig.E2_VERSION local lv = lua_versions[ v ] return lv or lua_versions.latest end diff --git a/generic/transport.lua b/generic/transport.lua index 659e83d..037d396 100644 --- a/generic/transport.lua +++ b/generic/transport.lua @@ -25,6 +25,8 @@ along with this program. If not, see . ]] +require("buildconfig") + local tools = { which = { name = "which", flags = "", optional = false }, curl = { name = "curl", flags = "", optional = false }, @@ -49,10 +51,10 @@ local tools = { touch = { name = "touch", flags = "", optional = false }, uname = { name = "uname", flags = "", optional = false }, patch = { name = "patch", flags = "", optional = false }, - ["e2-su"] = { name = E2_PREFIX .. "/bin/e2-su", flags = "", - optional = false }, - ["e2-su-2.2"] = { name = E2_PREFIX .. "/bin/e2-su-2.2", flags = "", + ["e2-su"] = { name = buildconfig.PREFIX .. "/bin/e2-su", flags = "", optional = false }, + ["e2-su-2.2"] = { name = buildconfig.PREFIX .. "/bin/e2-su-2.2", + flags = "", optional = false }, } diff --git a/global/Makefile b/global/Makefile index ee7f339..ee23657 100644 --- a/global/Makefile +++ b/global/Makefile @@ -38,7 +38,7 @@ CLEAN_FILES = *~ $(GLOBALTOOLS) *.lc e2 $(SCRIPTS) *.lua e2-su *.sh e2.conf .PHONY: all install uninstall clean -all: e2 e2-root e2global.lc $(SCRIPTS) e2-su $(GLOBALLUATOOLS:=.lc) \ +all: e2 e2-root $(SCRIPTS) e2-su $(GLOBALLUATOOLS:=.lc) \ $(GLOBALSHTOOLS:=.sh) e2.conf install: all @@ -52,7 +52,6 @@ install: all install -m 755 e2-root $(DESTDIR)$(TOOLDIR)/ install -m 4754 -o root -g $(E2_GROUP) e2-su $(DESTDIR)$(BINDIR)/ install -m 755 e2 $(DESTDIR)$(BINDIR)/ - install -m 644 e2global.lc $(DESTDIR)$(LIBDIR)/ install -d $(DESTDIR)$(SYSCONFDIR) if [ ! -f "$(DESTDIR)$(SYSCONFDIR)/e2.conf" ] ; then \ install -m 644 e2.conf $(DESTDIR)$(SYSCONFDIR)/e2.conf ; \ @@ -71,7 +70,6 @@ uninstall: rm -f $(DESTDIR)$(TOOLDIR)/e2-root rm -f $(DESTDIR)$(BINDIR)/e2-su rm -f $(DESTDIR)$(BINDIR)/e2 - rm -f $(DESTDIR)$(LIBDIR)/e2global.lc doc: for s in $(SUBDIRS) ; do \ @@ -86,9 +84,6 @@ install-doc: clean: rm -f $(CLEAN_FILES) -e2global.lc: config.lua e2global.lua - $(BUILD_LUAC) -o $@ $^ - %.lua: %.lua.in $(TOPLEVEL)/scripts/genscript.sh $< $@ diff --git a/global/config.lua.in b/global/config.lua.in deleted file mode 100644 index feef1e9..0000000 --- a/global/config.lua.in +++ /dev/null @@ -1,60 +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 . -]] - ---[[ - 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 . -]] - --- Program configuration - -E2_VERSION = "@E2_VERSION@" -E2_COMMIT = "@E2_COMMIT@" -E2_PREFIX = "@E2_PREFIX@" -E2_SYNTAX = "@E2_SYNTAX@" diff --git a/global/e2-create-project.lua.in b/global/e2-create-project.lua.in index 802623a..0e10a7c 100755 --- a/global/e2-create-project.lua.in +++ b/global/e2-create-project.lua.in @@ -25,7 +25,9 @@ along with this program. If not, see . ]] -require("e2global") +require("buildconfig") +require("e2generic_global") + e2lib.init() local doc = [[ diff --git a/global/e2-fetch-project.lua.in b/global/e2-fetch-project.lua.in index 56c9534..4f24f1c 100755 --- a/global/e2-fetch-project.lua.in +++ b/global/e2-fetch-project.lua.in @@ -25,7 +25,8 @@ along with this program. If not, see . ]] -require("e2global") +require("buildconfig") +require("e2generic_global") e2lib.init() local e = new_error("fetching project failed") @@ -180,7 +181,7 @@ end -- call e2-install-e2 e2_install_e2 = string.format("'%s' '%s/e2-install-e2'", - getinstallpath("LUA"), getinstallpath("TOOLDIR")) + buildconfig.LUA, buildconfig.TOOLDIR) rc, re = e2lib.callcmd_log(e2_install_e2) if not rc then e:append("installing local e2 failed") diff --git a/global/e2-install-e2.lua.in b/global/e2-install-e2.lua.in index 66e2fc3..4423870 100755 --- a/global/e2-install-e2.lua.in +++ b/global/e2-install-e2.lua.in @@ -25,9 +25,10 @@ along with this program. If not, see . ]] -require("e2global") +require("buildconfig") +require("e2generic_global") -install_prefix = getinstallpath("PREFIX") +install_prefix = buildconfig.PREFIX e2lib.init() diff --git a/global/e2.lua.in b/global/e2.lua.in index 40ce7f8..609c6e0 100755 --- a/global/e2.lua.in +++ b/global/e2.lua.in @@ -28,7 +28,8 @@ package.path = "@LIBDIR@/?.lc;@LIBDIR@/?.lua" package.cpath = "@LIBDIR@/?.so" -require("e2global") +require("buildconfig") +require("e2generic_global") e2lib.init() e2option.documentation = [[ @@ -42,7 +43,7 @@ ing on whether the invocation took place inside or outside a project tree. e2option.flag("prefix", "print installation prefix", function() - print("@E2_PREFIX@") + print(buildconfig.PREFIX) os.exit(0) end) @@ -71,19 +72,17 @@ else e2call.arg_string = quoteargs(table.concat(arg, "' '", 1)) end --- provide install paths in the environment -setinstallpaths() - -e2call.globaltool = getinstallpath("TOOLDIR") .. "/" .. e2call.toolname +e2call.globaltool = buildconfig.TOOLDIR .. "/" .. e2call.toolname if root then e2call.localtool = root .. "/.e2/bin/" .. e2call.toolname end if e2util.stat(e2call.globaltool) then e2call.tool = e2call.globaltool - env = "LUA_PATH='@LIBDIR@/?.lc;@LIBDIR@/?.lua'" .. - "LUA_CPATH='@LIBDIR@/?.so'" - lua = "@LIBEXECDIR@/e2-lua-@LUA_VERSION@" + env = string.format("LUA_PATH='%s/?.lc;%s/?.lua' " .. + "LUA_CPATH='%s/?.so'", buildconfig.LIBDIR, buildconfig.LIBDIR, + buildconfig.LIBDIR) + lua = buildconfig.LUA cmd = string.format("%s %s %s %s", env, lua, e2call.tool, e2call.arg_string) elseif not root then e2lib.abort(e2call.toolname .. diff --git a/global/e2global.lua.in b/global/e2global.lua.in deleted file mode 100644 index 8ec353b..0000000 --- a/global/e2global.lua.in +++ /dev/null @@ -1,113 +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 . -]] - -package.path="@LIBDIR@/?.lc;@LIBDIR@/?.lua;" .. package.path -package.cpath="@LIBDIR@/?.so;" .. package.cpath - -require("e2generic_global") - --- project --- .name --- .path --- .checkout_path --- .server_versionfile --- .versionfile --- .version --- .e2versionfile --- .e2version - - -local install = {} -install [ "PREFIX" ] = "@E2_PREFIX@" -install [ "BINDIR" ] = "@BINDIR@" -install [ "LIBDIR" ] = "@LIBDIR@" -install [ "LIBEXECDIR" ] = "@LIBEXECDIR@" -install [ "TOOLDIR" ] = "@TOOLDIR@" -install [ "LUA" ] = "@LIBEXECDIR@/e2-lua-@LUA_VERSION@" - --- getinstallpath(var) --- --- lookup an installation path from the install table. - -function getinstallpath(var) - if install [ var ] == nil then - e2lib.abort("querying non-existent variable in getinstallpath()") - end - return install[var] -end - --- setinstallpaths() --- --- set all installation paths in the environment. That enables the local --- tools to call the correct e2-su global tools. - -function setinstallpaths() - for var,val in pairs(install) do - e2util.setenv(var, val, true) - end -end - --- e2generic table: holds functions that must work across all future --- e2 versions - -e2generic = {} - ---- get the project version from the server --- @param a project description table --- @return string: the project version, or nil --- @return an error object on failure -function e2generic.getprojectversionfromserver(project) - local e = new_error("getting project version from server failed") - local tmpdir = e2lib.mktempdir() - local location = string.format("%s/%s", project.location, - project.server_versionfile) - local rc, re = transport.fetch_file(project.surl, location, tmpdir, nil) - if not rc then - return nil, e:cat(re) - end - local vfile = string.format("%s/%s", tmpdir, project.server_versionfile) - local v = e2lib.parse_versionfile(vfile) - if not v then - return nil, e:cat("can't parse version file") - end - e2lib.rmtempdir(tmpdir) - return v, nil -end - -function e2generic.getprojectversionfromproject(project) - return e2lib.parse_versionfile("./" .. project.versionfile) -end - -function e2generic.gete2versionfromproject(project) - return e2lib.parse_e2versionfile(project.checkout_path .. "/" .. project.e2versionfile) -end - -e2lib.module("e2generic", e2generic) - --- V table: holds functions implementing the global tool interfaces for each version - -V = {} diff --git a/local/Makefile b/local/Makefile index 8800d3e..cd878d0 100644 --- a/local/Makefile +++ b/local/Makefile @@ -32,7 +32,7 @@ TOPLEVEL = .. include $(TOPLEVEL)/make.vars -CLEAN_FILES = *~ *.so linux32 config.lua *.lc *.o +CLEAN_FILES = *~ *.so linux32 *.lc *.o CFLAGS += -I. -I$(DESTDIR)$(INCDIR) -I$(DESTDIR)$(INCDIR)/lua-$(LUA_VERSION) \ -I../lua/lua-$(LUA_VERSION)/src -fPIC LDFLAGS += -L. -L../lua/lua-$(LUA_VERSION)/src -Wl,-R$(LIBDIR) @@ -107,7 +107,7 @@ clean: %.lc: %.lua $(LUAC) -o $@ $< -e2local.lc: config.lua $(TOPLEVEL)/generic/strict.lua \ +e2local.lc: $(TOPLEVEL)/generic/strict.lua \ result.lua \ loader.lua \ $(TOPLEVEL)/generic/scm.git.lua \ diff --git a/local/config.lua.in b/local/config.lua.in deleted file mode 100644 index 060f9ee..0000000 --- a/local/config.lua.in +++ /dev/null @@ -1,37 +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 . -]] - --- config.lua -*- lua -*- --- --- Program configuration - -E2_VERSION = "@E2_VERSION@" -E2_COMMIT = "@E2_COMMIT@" -E2_PREFIX = "@E2_PREFIX@" -E2_SYNTAX = "@E2_SYNTAX@" - -require("e2util_local") diff --git a/local/e2tool.lua b/local/e2tool.lua index 6b51a64..d977009 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -36,7 +36,7 @@ e2tool = e2lib.module("e2tool") -- first, to maintain correct error messages local config_syntax_compat = { - E2_SYNTAX, -- keep this one, it holds the current syntax. + buildconfig.E2_SYNTAX, -- keep this one, it holds the current syntax. "2_2_0", } @@ -1066,7 +1066,7 @@ function e2tool.projid(info) end hc:hash_line(info.release_id) hc:hash_line(info.project.chroot_arch) - hc:hash_line(E2_VERSION) + hc:hash_line(buildconfig.E2_VERSION) info.projid = hc:hash_finish() return info.projid end diff --git a/make.vars b/make.vars index 641610c..4548231 100644 --- a/make.vars +++ b/make.vars @@ -32,6 +32,7 @@ export LOCALPREFIX LOCALBINDIR LOCALLIBDIR LOCALMAKDIR ARCH = $(shell uname -m) LUA_VERSION = 5.1.3 LUA_ALL_VERSIONS = 5.1.2 5.1.3 +LUA = $(LIBEXECDIR)/e2-lua-$(LUA_VERSION) LUAC = $(LIBEXECDIR)/e2-luac-$(LUA_VERSION) ifdef LUA_UNPACK_PATH BUILD_LUAC = $(LUA_UNPACK_PATH)/lua-$(LUA_VERSION)/src/luac