diff options
author | starkos <none@none> | 2008-08-09 04:15:17 +0400 |
---|---|---|
committer | starkos <none@none> | 2008-08-09 04:15:17 +0400 |
commit | 46cfd41699a47a4f24086fba5f8256eacace8e36 (patch) | |
tree | 2530dd167f06b1bdd9ce007a507ed8cf4bb50a18 | |
parent | 4c6ab4d573ade9239d78a6d54aed73edd5dd94bb (diff) |
Big refactoring and code consolidation (r464:478)
-rw-r--r-- | samples/vs2005/CppExe/CppExe.cpp | 7 | ||||
-rw-r--r-- | src/actions/actions.c | 9 | ||||
-rw-r--r-- | src/actions/actions.h | 29 | ||||
-rw-r--r-- | src/actions/make/gmake_project.c | 5 | ||||
-rw-r--r-- | src/actions/make/make.c | 36 | ||||
-rw-r--r-- | src/actions/make/make.h | 6 | ||||
-rw-r--r-- | src/actions/make/make_project.c | 92 | ||||
-rw-r--r-- | src/actions/make/make_project.h | 46 | ||||
-rw-r--r-- | src/actions/make/make_solution.c | 109 | ||||
-rw-r--r-- | src/actions/make/make_solution.h | 16 | ||||
-rw-r--r-- | src/actions/make/tests/make_config_tests.cpp | 24 | ||||
-rw-r--r-- | src/actions/make/tests/make_project_tests.cpp | 26 | ||||
-rw-r--r-- | src/actions/make/tests/make_solution_tests.cpp | 17 | ||||
-rw-r--r-- | src/actions/make/tests/make_tests.cpp | 10 | ||||
-rw-r--r-- | src/actions/support/sourcetree.c | 17 | ||||
-rw-r--r-- | src/actions/support/sourcetree.h | 7 | ||||
-rw-r--r-- | src/actions/tests/action_tests.h | 9 | ||||
-rw-r--r-- | src/actions/vs200x/tests/vs2002_solution_tests.cpp | 12 | ||||
-rw-r--r-- | src/actions/vs200x/tests/vs2003_solution_tests.cpp | 4 | ||||
-rw-r--r-- | src/actions/vs200x/tests/vs2005_solution_tests.cpp | 8 | ||||
-rw-r--r-- | src/actions/vs200x/tests/vs2008_solution_tests.cpp | 2 | ||||
-rw-r--r-- | src/actions/vs200x/tests/vs200x_compiler_tests.cpp | 17 | ||||
-rw-r--r-- | src/actions/vs200x/tests/vs200x_config_tests.cpp | 25 | ||||
-rw-r--r-- | src/actions/vs200x/tests/vs200x_linker_tests.cpp | 17 | ||||
-rw-r--r-- | src/actions/vs200x/tests/vs200x_project_tests.cpp | 143 | ||||
-rw-r--r-- | src/actions/vs200x/tests/vs200x_xml_tests.cpp | 39 | ||||
-rw-r--r-- | src/actions/vs200x/vs2002_solution.c | 43 | ||||
-rw-r--r-- | src/actions/vs200x/vs2003_solution.c | 14 | ||||
-rw-r--r-- | src/actions/vs200x/vs2005_solution.c | 28 | ||||
-rw-r--r-- | src/actions/vs200x/vs2008_solution.c | 7 | ||||
-rw-r--r-- | src/actions/vs200x/vs200x.c | 22 | ||||
-rw-r--r-- | src/actions/vs200x/vs200x.h | 11 | ||||
-rw-r--r-- | src/actions/vs200x/vs200x_config.c | 31 | ||||
-rw-r--r-- | src/actions/vs200x/vs200x_config.h | 12 | ||||
-rw-r--r-- | src/actions/vs200x/vs200x_project.c | 152 | ||||
-rw-r--r-- | src/actions/vs200x/vs200x_project.h | 60 | ||||
-rw-r--r-- | src/actions/vs200x/vs200x_solution.c | 8 | ||||
-rw-r--r-- | src/actions/vs200x/vs200x_solution.h | 30 | ||||
-rw-r--r-- | src/base/cstr.c | 65 | ||||
-rw-r--r-- | src/base/cstr.h | 1 | ||||
-rw-r--r-- | src/base/env.c | 98 | ||||
-rw-r--r-- | src/base/env.h | 41 | ||||
-rw-r--r-- | src/base/lua-5.1.2/COPYRIGHT (renamed from src/script/lua-5.1.2/COPYRIGHT) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/HISTORY (renamed from src/script/lua-5.1.2/HISTORY) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/INSTALL (renamed from src/script/lua-5.1.2/INSTALL) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/Makefile (renamed from src/script/lua-5.1.2/Makefile) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/PREMAKE_CHANGES.txt (renamed from src/script/lua-5.1.2/PREMAKE_CHANGES.txt) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/README (renamed from src/script/lua-5.1.2/README) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/doc/amazon.gif (renamed from src/script/lua-5.1.2/doc/amazon.gif) | bin | 797 -> 797 bytes | |||
-rw-r--r-- | src/base/lua-5.1.2/doc/contents.html (renamed from src/script/lua-5.1.2/doc/contents.html) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/doc/cover.png (renamed from src/script/lua-5.1.2/doc/cover.png) | bin | 3305 -> 3305 bytes | |||
-rw-r--r-- | src/base/lua-5.1.2/doc/logo.gif (renamed from src/script/lua-5.1.2/doc/logo.gif) | bin | 4232 -> 4232 bytes | |||
-rw-r--r-- | src/base/lua-5.1.2/doc/lua.1 (renamed from src/script/lua-5.1.2/doc/lua.1) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/doc/lua.css (renamed from src/script/lua-5.1.2/doc/lua.css) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/doc/lua.html (renamed from src/script/lua-5.1.2/doc/lua.html) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/doc/luac.1 (renamed from src/script/lua-5.1.2/doc/luac.1) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/doc/luac.html (renamed from src/script/lua-5.1.2/doc/luac.html) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/doc/manual.css (renamed from src/script/lua-5.1.2/doc/manual.css) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/doc/manual.html (renamed from src/script/lua-5.1.2/doc/manual.html) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/doc/readme.html (renamed from src/script/lua-5.1.2/doc/readme.html) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/etc/Makefile (renamed from src/script/lua-5.1.2/etc/Makefile) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/etc/README (renamed from src/script/lua-5.1.2/etc/README) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/etc/all.c (renamed from src/script/lua-5.1.2/etc/all.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/etc/lua.hpp (renamed from src/script/lua-5.1.2/etc/lua.hpp) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/etc/lua.ico (renamed from src/script/lua-5.1.2/etc/lua.ico) | bin | 1078 -> 1078 bytes | |||
-rw-r--r-- | src/base/lua-5.1.2/etc/lua.pc (renamed from src/script/lua-5.1.2/etc/lua.pc) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/etc/luavs.bat (renamed from src/script/lua-5.1.2/etc/luavs.bat) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/etc/min.c (renamed from src/script/lua-5.1.2/etc/min.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/etc/noparser.c (renamed from src/script/lua-5.1.2/etc/noparser.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/etc/strict.lua (renamed from src/script/lua-5.1.2/etc/strict.lua) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/Makefile (renamed from src/script/lua-5.1.2/src/Makefile) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lapi.c (renamed from src/script/lua-5.1.2/src/lapi.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lapi.h (renamed from src/script/lua-5.1.2/src/lapi.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lauxlib.c (renamed from src/script/lua-5.1.2/src/lauxlib.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lauxlib.h (renamed from src/script/lua-5.1.2/src/lauxlib.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lbaselib.c (renamed from src/script/lua-5.1.2/src/lbaselib.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lcode.c (renamed from src/script/lua-5.1.2/src/lcode.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lcode.h (renamed from src/script/lua-5.1.2/src/lcode.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/ldblib.c (renamed from src/script/lua-5.1.2/src/ldblib.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/ldebug.c (renamed from src/script/lua-5.1.2/src/ldebug.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/ldebug.h (renamed from src/script/lua-5.1.2/src/ldebug.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/ldo.c (renamed from src/script/lua-5.1.2/src/ldo.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/ldo.h (renamed from src/script/lua-5.1.2/src/ldo.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/ldump.c (renamed from src/script/lua-5.1.2/src/ldump.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lfunc.c (renamed from src/script/lua-5.1.2/src/lfunc.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lfunc.h (renamed from src/script/lua-5.1.2/src/lfunc.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lgc.c (renamed from src/script/lua-5.1.2/src/lgc.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lgc.h (renamed from src/script/lua-5.1.2/src/lgc.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/linit.c (renamed from src/script/lua-5.1.2/src/linit.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/liolib.c (renamed from src/script/lua-5.1.2/src/liolib.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/llex.c (renamed from src/script/lua-5.1.2/src/llex.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/llex.h (renamed from src/script/lua-5.1.2/src/llex.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/llimits.h (renamed from src/script/lua-5.1.2/src/llimits.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lmathlib.c (renamed from src/script/lua-5.1.2/src/lmathlib.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lmem.c (renamed from src/script/lua-5.1.2/src/lmem.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lmem.h (renamed from src/script/lua-5.1.2/src/lmem.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/loadlib.c (renamed from src/script/lua-5.1.2/src/loadlib.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lobject.c (renamed from src/script/lua-5.1.2/src/lobject.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lobject.h (renamed from src/script/lua-5.1.2/src/lobject.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lopcodes.c (renamed from src/script/lua-5.1.2/src/lopcodes.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lopcodes.h (renamed from src/script/lua-5.1.2/src/lopcodes.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/loslib.c (renamed from src/script/lua-5.1.2/src/loslib.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lparser.c (renamed from src/script/lua-5.1.2/src/lparser.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lparser.h (renamed from src/script/lua-5.1.2/src/lparser.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lstate.c (renamed from src/script/lua-5.1.2/src/lstate.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lstate.h (renamed from src/script/lua-5.1.2/src/lstate.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lstring.c (renamed from src/script/lua-5.1.2/src/lstring.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lstring.h (renamed from src/script/lua-5.1.2/src/lstring.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lstrlib.c (renamed from src/script/lua-5.1.2/src/lstrlib.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/ltable.c (renamed from src/script/lua-5.1.2/src/ltable.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/ltable.h (renamed from src/script/lua-5.1.2/src/ltable.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/ltablib.c (renamed from src/script/lua-5.1.2/src/ltablib.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/ltm.c (renamed from src/script/lua-5.1.2/src/ltm.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/ltm.h (renamed from src/script/lua-5.1.2/src/ltm.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lua.c (renamed from src/script/lua-5.1.2/src/lua.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lua.h (renamed from src/script/lua-5.1.2/src/lua.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/luac.c (renamed from src/script/lua-5.1.2/src/luac.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/luaconf.h (renamed from src/script/lua-5.1.2/src/luaconf.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lualib.h (renamed from src/script/lua-5.1.2/src/lualib.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lundump.c (renamed from src/script/lua-5.1.2/src/lundump.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lundump.h (renamed from src/script/lua-5.1.2/src/lundump.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lvm.c (renamed from src/script/lua-5.1.2/src/lvm.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lvm.h (renamed from src/script/lua-5.1.2/src/lvm.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lzio.c (renamed from src/script/lua-5.1.2/src/lzio.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/lzio.h (renamed from src/script/lua-5.1.2/src/lzio.h) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/src/print.c (renamed from src/script/lua-5.1.2/src/print.c) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/test/README (renamed from src/script/lua-5.1.2/test/README) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/test/bisect.lua (renamed from src/script/lua-5.1.2/test/bisect.lua) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/test/cf.lua (renamed from src/script/lua-5.1.2/test/cf.lua) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/test/echo.lua (renamed from src/script/lua-5.1.2/test/echo.lua) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/test/env.lua (renamed from src/script/lua-5.1.2/test/env.lua) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/test/factorial.lua (renamed from src/script/lua-5.1.2/test/factorial.lua) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/test/fib.lua (renamed from src/script/lua-5.1.2/test/fib.lua) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/test/fibfor.lua (renamed from src/script/lua-5.1.2/test/fibfor.lua) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/test/globals.lua (renamed from src/script/lua-5.1.2/test/globals.lua) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/test/hello.lua (renamed from src/script/lua-5.1.2/test/hello.lua) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/test/life.lua (renamed from src/script/lua-5.1.2/test/life.lua) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/test/luac.lua (renamed from src/script/lua-5.1.2/test/luac.lua) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/test/printf.lua (renamed from src/script/lua-5.1.2/test/printf.lua) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/test/readonly.lua (renamed from src/script/lua-5.1.2/test/readonly.lua) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/test/sieve.lua (renamed from src/script/lua-5.1.2/test/sieve.lua) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/test/sort.lua (renamed from src/script/lua-5.1.2/test/sort.lua) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/test/table.lua (renamed from src/script/lua-5.1.2/test/table.lua) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/test/trace-calls.lua (renamed from src/script/lua-5.1.2/test/trace-calls.lua) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/test/trace-globals.lua (renamed from src/script/lua-5.1.2/test/trace-globals.lua) | 0 | ||||
-rw-r--r-- | src/base/lua-5.1.2/test/xd.lua (renamed from src/script/lua-5.1.2/test/xd.lua) | 0 | ||||
-rw-r--r-- | src/base/luastate.c | 44 | ||||
-rw-r--r-- | src/base/luastate.h | 31 | ||||
-rw-r--r-- | src/base/tests/cstr_tests.cpp | 20 | ||||
-rw-r--r-- | src/base/tests/env_tests.cpp | 28 | ||||
-rw-r--r-- | src/host/host.c | 118 | ||||
-rw-r--r-- | src/host/host.h | 28 | ||||
-rw-r--r-- | src/host/tests/host_args_tests.cpp | 11 | ||||
-rw-r--r-- | src/host/tests/host_help_tests.cpp | 20 | ||||
-rw-r--r-- | src/host/tests/host_results_tests.cpp | 4 | ||||
-rw-r--r-- | src/host/tests/host_run_tests.cpp | 85 | ||||
-rw-r--r-- | src/host/tests/host_tests.cpp | 7 | ||||
-rw-r--r-- | src/objects/block.c (renamed from src/project/block.c) | 38 | ||||
-rw-r--r-- | src/objects/block.h (renamed from src/project/block.h) | 4 | ||||
-rw-r--r-- | src/objects/blocks.c (renamed from src/project/blocks.c) | 2 | ||||
-rw-r--r-- | src/objects/blocks.h (renamed from src/project/blocks.h) | 2 | ||||
-rw-r--r-- | src/objects/fields.c (renamed from src/project/fields.c) | 17 | ||||
-rw-r--r-- | src/objects/fields.h (renamed from src/project/fields.h) | 7 | ||||
-rw-r--r-- | src/objects/objects.h | 12 | ||||
-rw-r--r-- | src/objects/objects_internal.h (renamed from src/project/project_internal.h) | 5 | ||||
-rw-r--r-- | src/objects/project.c (renamed from src/project/project.c) | 115 | ||||
-rw-r--r-- | src/objects/project.h (renamed from src/project/project.h) | 20 | ||||
-rw-r--r-- | src/objects/session.c (renamed from src/session/session.c) | 128 | ||||
-rw-r--r-- | src/objects/session.h (renamed from src/session/session.h) | 46 | ||||
-rw-r--r-- | src/objects/solution.c (renamed from src/project/solution.c) | 72 | ||||
-rw-r--r-- | src/objects/solution.h (renamed from src/project/solution.h) | 10 | ||||
-rw-r--r-- | src/objects/tests/block_tests.cpp | 80 | ||||
-rw-r--r-- | src/objects/tests/fields_tests.cpp (renamed from src/project/tests/fields_tests.cpp) | 2 | ||||
-rw-r--r-- | src/objects/tests/objects_tests.cpp | 26 | ||||
-rw-r--r-- | src/objects/tests/project_config_tests.cpp (renamed from src/project/tests/project_config_tests.cpp) | 5 | ||||
-rw-r--r-- | src/objects/tests/project_tests.cpp | 118 | ||||
-rw-r--r-- | src/objects/tests/session_tests.cpp (renamed from src/session/tests/session_tests.cpp) | 125 | ||||
-rw-r--r-- | src/objects/tests/solution_tests.cpp (renamed from src/project/tests/solution_tests.cpp) | 78 | ||||
-rw-r--r-- | src/platform/platform.c | 55 | ||||
-rw-r--r-- | src/platform/platform.h | 36 | ||||
-rw-r--r-- | src/premake.c | 32 | ||||
-rw-r--r-- | src/premake.lua | 2 | ||||
-rw-r--r-- | src/project/filter.c | 116 | ||||
-rw-r--r-- | src/project/filter.h | 39 | ||||
-rw-r--r-- | src/project/tests/block_tests.cpp | 46 | ||||
-rw-r--r-- | src/project/tests/filter_tests.cpp | 84 | ||||
-rw-r--r-- | src/project/tests/project_tests.cpp | 217 | ||||
-rw-r--r-- | src/script/fn_accessor.c | 2 | ||||
-rw-r--r-- | src/script/fn_configuration.c | 6 | ||||
-rw-r--r-- | src/script/fn_configurations.c | 2 | ||||
-rw-r--r-- | src/script/fn_project.c | 4 | ||||
-rw-r--r-- | src/script/fn_solution.c | 2 | ||||
-rw-r--r-- | src/script/script.c | 58 | ||||
-rw-r--r-- | src/script/script.h | 5 | ||||
-rw-r--r-- | src/script/script_internal.h | 14 | ||||
-rw-r--r-- | src/script/tests/unload_tests.cpp | 44 | ||||
-rw-r--r-- | src/script/unload.c | 8 |
197 files changed, 1411 insertions, 2024 deletions
diff --git a/samples/vs2005/CppExe/CppExe.cpp b/samples/vs2005/CppExe/CppExe.cpp new file mode 100644 index 0000000..3770451 --- /dev/null +++ b/samples/vs2005/CppExe/CppExe.cpp @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main() +{ + puts(""#MSG); + return 0; +} diff --git a/src/actions/actions.c b/src/actions/actions.c index 78b0d67..f237ea1 100644 --- a/src/actions/actions.c +++ b/src/actions/actions.c @@ -9,7 +9,14 @@ #include "actions/actions.h" -SessionAction Actions[] = +int gmake_action (Session sess); +int vs2002_action(Session sess); +int vs2003_action(Session sess); +int vs2005_action(Session sess); +int vs2008_action(Session sess); + + +ActionInfo Actions[] = { { "gmake", "GNU Makefiles for POSIX, MinGW, and Cygwin", gmake_action }, { "vs2002", "Microsoft Visual Studio 2002", vs2002_action }, diff --git a/src/actions/actions.h b/src/actions/actions.h index 5bdc6a5..7b041cc 100644 --- a/src/actions/actions.h +++ b/src/actions/actions.h @@ -13,18 +13,33 @@ #if !defined(PREMAKE_ACTIONS_H) #define PREMAKE_ACTIONS_H -#include "session/session.h" +#include "objects/session.h" -int gmake_action (Session sess); -int vs2002_action(Session sess); -int vs2003_action(Session sess); -int vs2005_action(Session sess); -int vs2008_action(Session sess); +/** + * Callback signature for Premake action handlers, which will get triggered + * if user specifies that action on the command line for processing. + * \param sess The current execution session context. + * \returns OKAY If successful. + */ +typedef int (*ActionCallback)(Session sess); + + +/** + * Describe a Premake action, including the handler function and the metadata + * required to list it in the user help. + */ +typedef struct struct_ActionInfo +{ + const char* name; + const char* description; + ActionCallback callback; +} ActionInfo; /* the list of built-in Premake actions */ -extern SessionAction Actions[]; +extern ActionInfo Actions[]; + #endif diff --git a/src/actions/make/gmake_project.c b/src/actions/make/gmake_project.c index 3788e2d..970f04b 100644 --- a/src/actions/make/gmake_project.c +++ b/src/actions/make/gmake_project.c @@ -17,13 +17,10 @@ * This simplifies the code generation, and makes portable makefiles possible * (even though most will have platform-specific bits in them). */ -int gmake_project_shell_detect(Session sess, Project prj, Stream strm) +int gmake_project_shell_detect(Project prj, Stream strm) { int z = OKAY; - - UNUSED(sess); UNUSED(prj); - z |= stream_writeline(strm, "SHELLTYPE := msdos"); z |= stream_writeline(strm, "ifeq (,$(ComSpec)$(COMSPEC))"); z |= stream_writeline(strm, " SHELLTYPE := posix"); diff --git a/src/actions/make/make.c b/src/actions/make/make.c index 38e3942..4fd3e0c 100644 --- a/src/actions/make/make.c +++ b/src/actions/make/make.c @@ -54,22 +54,18 @@ const char* make_get_obj_filename(const char* filename) /** * Get the name of the project makefile for a particular project. - * \param sess The current execution session context. - * \param prj The project being requested. - * \returns If this project is the only object which will generate output to - * its target location, then this function will return "Makefile" as - * the filename. If any other object shares this output location, it - * will return "ProjectName.make" instead, so that both objects may - * coexist in the same directory. + * If this project is the only object which will generate output to + * its target location, then this function will return "Makefile" as + * the filename. If any other object shares this output location, it + * will return "ProjectName.make" instead, so that both objects may + * coexist in the same directory. */ -const char* make_get_project_makefile(Session sess, Project prj) +const char* make_get_project_makefile(Project prj) { const char* my_path; const char* their_path; int si, sn; - - assert(sess); - assert(prj); + Session sess = project_get_session(prj); /* get the full makefile path for this project */ my_path = project_get_filename(prj, "Makefile", NULL); @@ -137,22 +133,18 @@ Strings make_get_project_names(Solution sln) /** * Get the name of the solution makefile for a particular solution. - * \param sess The current execution session context. - * \param sln The solution being requested. - * \returns If this solution is the only object which will generate output to - * its target location, then this function will return "Makefile" as - * the filename. If any other solution shares this output location, it - * will return "SolutionName.make" instead, so that both objects may - * coexist in the same directory. + * If this solution is the only object which will generate output to + * its target location, then this function will return "Makefile" as + * the filename. If any other solution shares this output location, it + * will return "SolutionName.make" instead, so that both objects may + * coexist in the same directory. */ -const char* make_get_solution_makefile(Session sess, Solution sln) +const char* make_get_solution_makefile(Solution sln) { const char* my_path; const char* their_path; int i, n; - - assert(sess); - assert(sln); + Session sess = solution_get_session(sln); /* get the full makefile path for this solution */ my_path = solution_get_filename(sln, "Makefile", NULL); diff --git a/src/actions/make/make.h b/src/actions/make/make.h index 2937517..d69a2e1 100644 --- a/src/actions/make/make.h +++ b/src/actions/make/make.h @@ -6,13 +6,13 @@ #if !defined(PREMAKE_MAKE_H) #define PREMAKE_MAKE_H -#include "session/session.h" +#include "objects/project.h" const char* make_escape(const char* value); const char* make_get_obj_filename(const char* filename); -const char* make_get_project_makefile(Session sess, Project prj); +const char* make_get_project_makefile(Project prj); Strings make_get_project_names(Solution sln); -const char* make_get_solution_makefile(Session sess, Solution sln); +const char* make_get_solution_makefile(Solution sln); int make_write_escaped(Stream strm, const char* value); #endif diff --git a/src/actions/make/make_project.c b/src/actions/make/make_project.c index a10aaf3..1df4df1 100644 --- a/src/actions/make/make_project.c +++ b/src/actions/make/make_project.c @@ -16,10 +16,9 @@ /** * Write the rules to clean up output files on a `make clean`. */ -int make_project_clean_rules(Session sess, Project prj, Stream strm) +int make_project_clean_rules(Project prj, Stream strm) { int z = OKAY; - UNUSED(sess); z |= stream_writeline(strm, "clean:"); z |= stream_writeline(strm, "\t@echo Cleaning %s", project_get_name(prj)); z |= stream_writeline(strm, "ifeq (posix, $(SHELLTYPE))"); @@ -37,10 +36,9 @@ int make_project_clean_rules(Session sess, Project prj, Stream strm) /** * Write the opening conditional for a configuration block. */ -int make_project_config_conditional(Session sess, Project prj, Stream strm) +int make_project_config_conditional(Project prj, Stream strm) { - const char* cfg_name = project_get_configuration_filter(prj); - UNUSED(sess); + const char* cfg_name = project_get_config(prj); return stream_writeline(strm, "ifeq ($(CONFIG),%s)", cfg_name); } @@ -48,9 +46,8 @@ int make_project_config_conditional(Session sess, Project prj, Stream strm) /** * Write the CFLAGS configuration variable. */ -int make_project_config_cflags(Session sess, Project prj, Stream strm) +int make_project_config_cflags(Project prj, Stream strm) { - UNUSED(sess); UNUSED(prj); return stream_writeline(strm, " CFLAGS += $(CPPFLAGS) $(ARCHFLAGS)"); } @@ -59,17 +56,12 @@ int make_project_config_cflags(Session sess, Project prj, Stream strm) /** * Write the CPPFLAGS configuration variable. */ -int make_project_config_cppflags(Session sess, Project prj, Stream strm) +int make_project_config_cppflags(Project prj, Stream strm) { - Strings values; int z = OKAY; - UNUSED(sess); - + Strings values = project_get_config_values(prj, BlockDefines); z |= stream_write(strm, " CPPFLAGS += -MMD"); - - values = project_get_config_values(prj, BlockDefines); z |= stream_write_strings(strm, values, "", " -D \"", "\"", "", "", NULL); - z |= stream_writeline(strm, ""); return z; } @@ -78,9 +70,8 @@ int make_project_config_cppflags(Session sess, Project prj, Stream strm) /** * Write the CXXFLAGS configuration variable. */ -int make_project_config_cxxflags(Session sess, Project prj, Stream strm) +int make_project_config_cxxflags(Project prj, Stream strm) { - UNUSED(sess); UNUSED(prj); return stream_writeline(strm, " CXXFLAGS += $(CFLAGS)"); } @@ -89,12 +80,11 @@ int make_project_config_cxxflags(Session sess, Project prj, Stream strm) /** * Write the opening conditional for a configuration block. */ -int make_project_config_end(Session sess, Project prj, Stream strm) +int make_project_config_end(Project prj, Stream strm) { - int z; - UNUSED(sess); + int z = OKAY; UNUSED(prj); - z = stream_writeline(strm, "endif"); + z |= stream_writeline(strm, "endif"); z |= stream_writeline(strm, ""); return z; } @@ -103,9 +93,8 @@ int make_project_config_end(Session sess, Project prj, Stream strm) /** * Write the LDDEPS configuration variable. */ -int make_project_config_lddeps(Session sess, Project prj, Stream strm) +int make_project_config_lddeps(Project prj, Stream strm) { - UNUSED(sess); UNUSED(prj); return stream_writeline(strm, " LDDEPS :="); } @@ -114,9 +103,8 @@ int make_project_config_lddeps(Session sess, Project prj, Stream strm) /** * Write the LDFLAGS configuration variable. */ -int make_project_config_ldflags(Session sess, Project prj, Stream strm) +int make_project_config_ldflags(Project prj, Stream strm) { - UNUSED(sess); UNUSED(prj); return stream_writeline(strm, " LDFLAGS +="); } @@ -125,10 +113,9 @@ int make_project_config_ldflags(Session sess, Project prj, Stream strm) /** * Write the OBJDIR configuration variable. */ -int make_project_config_objdir(Session sess, Project prj, Stream strm) +int make_project_config_objdir(Project prj, Stream strm) { - const char* cfg_name = project_get_configuration_filter(prj); - UNUSED(sess); + const char* cfg_name = project_get_config(prj); return stream_writeline(strm, " OBJDIR := obj/%s", make_escape(cfg_name)); } @@ -136,9 +123,8 @@ int make_project_config_objdir(Session sess, Project prj, Stream strm) /** * Write the OUTDIR configuration variable. */ -int make_project_config_outdir(Session sess, Project prj, Stream strm) +int make_project_config_outdir(Project prj, Stream strm) { - UNUSED(sess); UNUSED(prj); return stream_writeline(strm, " OUTDIR := ."); } @@ -147,10 +133,9 @@ int make_project_config_outdir(Session sess, Project prj, Stream strm) /** * Write the OUTFILE configuration variable. */ -int make_project_config_outfile(Session sess, Project prj, Stream strm) +int make_project_config_outfile(Project prj, Stream strm) { const char* outfile = project_get_outfile(prj); - UNUSED(sess); return stream_writeline(strm, " OUTFILE := $(OUTDIR)/%s", make_escape(outfile)); } @@ -158,9 +143,8 @@ int make_project_config_outfile(Session sess, Project prj, Stream strm) /** * Write the RESFLAGS configuration variable. */ -int make_project_config_resflags(Session sess, Project prj, Stream strm) +int make_project_config_resflags(Project prj, Stream strm) { - UNUSED(sess); UNUSED(prj); return stream_writeline(strm, " RESFLAGS +="); } @@ -169,10 +153,10 @@ int make_project_config_resflags(Session sess, Project prj, Stream strm) /** * Create a new output stream for a project , and make it active for subsequent writes. */ -int make_project_create(Session sess, Project prj, Stream strm) +int make_project_create(Project prj, Stream strm) { /* create the makefile */ - const char* filename = make_get_project_makefile(sess, prj); + const char* filename = make_get_project_makefile(prj); strm = stream_create_file(filename); if (!strm) { @@ -180,7 +164,7 @@ int make_project_create(Session sess, Project prj, Stream strm) } /* make the stream active for the functions that come after */ - session_set_active_stream(sess, strm); + session_set_active_stream(project_get_session(prj), strm); return OKAY; } @@ -188,9 +172,8 @@ int make_project_create(Session sess, Project prj, Stream strm) /** * Include the auto-generated dependencies into the project makefile. */ -int make_project_include_dependencies(Session sess, Project prj, Stream strm) +int make_project_include_dependencies(Project prj, Stream strm) { - UNUSED(sess); UNUSED(prj); return stream_writeline(strm, "-include $(OBJECTS:%%.o=%%.d)"); } @@ -199,10 +182,9 @@ int make_project_include_dependencies(Session sess, Project prj, Stream strm) /** * Write the rules to create the output and object directories. */ -int make_project_mkdir_rules(Session sess, Project prj, Stream strm) +int make_project_mkdir_rules(Project prj, Stream strm) { int z = OKAY; - UNUSED(sess); UNUSED(prj); z |= stream_writeline(strm, "$(OUTDIR):"); z |= stream_writeline(strm, "\t@echo Creating $(OUTDIR)"); @@ -219,11 +201,10 @@ int make_project_mkdir_rules(Session sess, Project prj, Stream strm) /** * Write the OBJECTS project variable. */ -int make_project_objects(Session sess, Project prj, Stream strm) +int make_project_objects(Project prj, Stream strm) { Strings files; int i, n, z; - UNUSED(sess); z = stream_writeline(strm, "OBJECTS := \\"); @@ -247,12 +228,11 @@ int make_project_objects(Session sess, Project prj, Stream strm) /** * Write the .PHONY rule for a project. */ -int make_project_phony_rule(Session sess, Project prj, Stream strm) +int make_project_phony_rule(Project prj, Stream strm) { - int z; - UNUSED(sess); + int z = OKAY; UNUSED(prj); - z = stream_writeline(strm, ".PHONY: clean"); + z |= stream_writeline(strm, ".PHONY: clean"); z |= stream_writeline(strm, ""); return z; } @@ -261,12 +241,11 @@ int make_project_phony_rule(Session sess, Project prj, Stream strm) /** * Write the RESOURCES project variable. */ -int make_project_resources(Session sess, Project prj, Stream strm) +int make_project_resources(Project prj, Stream strm) { - int z; - UNUSED(sess); + int z = OKAY; UNUSED(prj); - z = stream_writeline(strm, "RESOURCES := \\"); + z |= stream_writeline(strm, "RESOURCES := \\"); z |= stream_writeline(strm, ""); return z; } @@ -275,12 +254,11 @@ int make_project_resources(Session sess, Project prj, Stream strm) /** * Write the project makefile signature. */ -int make_project_signature(Session sess, Project prj, Stream strm) +int make_project_signature(Project prj, Stream strm) { - int z; - UNUSED(sess); + int z = OKAY; UNUSED(prj); - z = stream_writeline(strm, "# GNU Makefile autogenerated by Premake"); + z |= stream_writeline(strm, "# GNU Makefile autogenerated by Premake"); z |= stream_writeline(strm, ""); return z; } @@ -289,11 +267,10 @@ int make_project_signature(Session sess, Project prj, Stream strm) /** * Write makefile rules for each source code file. */ -int make_project_source_rules(Session sess, Project prj, Stream strm) +int make_project_source_rules(Project prj, Stream strm) { Strings files; int i, n, z = OKAY; - UNUSED(sess); files = project_get_files(prj); n = strings_size(files); @@ -317,10 +294,9 @@ int make_project_source_rules(Session sess, Project prj, Stream strm) /** * Write the project output target rule. */ -int make_project_target(Session sess, Project prj, Stream strm) +int make_project_target(Project prj, Stream strm) { int z = OKAY; - UNUSED(sess); z |= stream_writeline(strm, "$(OUTFILE): $(OUTDIR) $(OBJDIR) $(OBJECTS) $(LDDEPS) $(RESOURCES)"); z |= stream_writeline(strm, "\t@echo Linking %s", project_get_name(prj)); z |= stream_writeline(strm, "\t@$(CXX) -o $@ $(LDFLAGS) $(ARCHFLAGS) $(OBJECTS) $(RESOURCES)"); diff --git a/src/actions/make/make_project.h b/src/actions/make/make_project.h index e8a3ef8..df37ac6 100644 --- a/src/actions/make/make_project.h +++ b/src/actions/make/make_project.h @@ -6,30 +6,30 @@ #if !defined(PREMAKE_MAKE_PROJECT_H) #define PREMAKE_MAKE_PROJECT_H -#include "session/session.h" +#include "objects/session.h" -int gmake_project_shell_detect(Session sess, Project prj, Stream strm); +int gmake_project_shell_detect(Project prj, Stream strm); -int make_project_clean_rules(Session sess, Project prj, Stream strm); -int make_project_config_conditional(Session sess, Project prj, Stream strm); -int make_project_config_cflags(Session sess, Project prj, Stream strm); -int make_project_config_cppflags(Session sess, Project prj, Stream strm); -int make_project_config_cxxflags(Session sess, Project prj, Stream strm); -int make_project_config_end(Session sess, Project prj, Stream strm); -int make_project_config_lddeps(Session sess, Project prj, Stream strm); -int make_project_config_ldflags(Session sess, Project prj, Stream strm); -int make_project_config_objdir(Session sess, Project prj, Stream strm); -int make_project_config_outdir(Session sess, Project prj, Stream strm); -int make_project_config_outfile(Session sess, Project prj, Stream strm); -int make_project_config_resflags(Session sess, Project prj, Stream strm); -int make_project_create(Session sess, Project prj, Stream strm); -int make_project_include_dependencies(Session sess, Project prj, Stream strm); -int make_project_mkdir_rules(Session sess, Project prj, Stream strm); -int make_project_objects(Session sess, Project prj, Stream strm); -int make_project_phony_rule(Session sess, Project prj, Stream strm); -int make_project_resources(Session sess, Project prj, Stream strm); -int make_project_signature(Session sess, Project prj, Stream strm); -int make_project_source_rules(Session sess, Project prj, Stream strm); -int make_project_target(Session sess, Project prj, Stream strm); +int make_project_clean_rules(Project prj, Stream strm); +int make_project_config_conditional(Project prj, Stream strm); +int make_project_config_cflags(Project prj, Stream strm); +int make_project_config_cppflags(Project prj, Stream strm); +int make_project_config_cxxflags(Project prj, Stream strm); +int make_project_config_end(Project prj, Stream strm); +int make_project_config_lddeps(Project prj, Stream strm); +int make_project_config_ldflags(Project prj, Stream strm); +int make_project_config_objdir(Project prj, Stream strm); +int make_project_config_outdir(Project prj, Stream strm); +int make_project_config_outfile(Project prj, Stream strm); +int make_project_config_resflags(Project prj, Stream strm); +int make_project_create(Project prj, Stream strm); +int make_project_include_dependencies(Project prj, Stream strm); +int make_project_mkdir_rules(Project prj, Stream strm); +int make_project_objects(Project prj, Stream strm); +int make_project_phony_rule(Project prj, Stream strm); +int make_project_resources(Project prj, Stream strm); +int make_project_signature(Project prj, Stream strm); +int make_project_source_rules(Project prj, Stream strm); +int make_project_target(Project prj, Stream strm); #endif diff --git a/src/actions/make/make_solution.c b/src/actions/make/make_solution.c index 111ec8d..ab99d3a 100644 --- a/src/actions/make/make_solution.c +++ b/src/actions/make/make_solution.c @@ -12,34 +12,26 @@ #include "actions/make/make_solution.h" #include "base/buffers.h" #include "base/cstr.h" +#include "base/env.h" #include "base/error.h" #include "base/path.h" -static const char* make_solution_project_rule(Session sess, Solution sln, Project prj); +static const char* make_solution_project_rule(Solution sln, Project prj); /** * Write the GNU solution makefile clean rules. - * \param sess The execution session context. - * \param sln The current solution. - * \param strm The currently active stream; set with session_set_active_stream(). - * \returns OKAY if successful. */ -int make_solution_clean_rule(Session sess, Solution sln, Stream strm) +int make_solution_clean_rule(Solution sln, Stream strm) { int i, n, z; - - assert(sess); - assert(sln); - assert(strm); - z = stream_writeline(strm, "clean:"); n = solution_num_projects(sln); for (i = 0; i < n; ++i) { Project prj = solution_get_project(sln, i); - const char* rule = make_solution_project_rule(sess, sln, prj); + const char* rule = make_solution_project_rule(sln, prj); z |= stream_writeline(strm, "%s clean", rule); } @@ -49,21 +41,11 @@ int make_solution_clean_rule(Session sess, Solution sln, Stream strm) /** * Write the makefile "all" rule. - * \param sess The execution session context. - * \param sln The current solution. - * \param strm The currently active stream; set with session_set_active_stream(). - * \returns OKAY if successful. */ -int make_solution_all_rule(Session sess, Solution sln, Stream strm) +int make_solution_all_rule(Solution sln, Stream strm) { - Strings prj_names; int z; - - UNUSED(sess); - assert(sln); - assert(strm); - - prj_names = make_get_project_names(sln); + Strings prj_names = make_get_project_names(sln); z = stream_writeline_strings(strm, prj_names, "all:", " ", "", "", "", make_write_escaped); z |= stream_writeline(strm, ""); strings_destroy(prj_names); @@ -73,15 +55,11 @@ int make_solution_all_rule(Session sess, Solution sln, Stream strm) /** * Create a new output stream for a solution, and make it active for subsequent writes. - * \param sess The execution session context. - * \param sln The current solution. - * \param strm The currently active stream; set with session_set_active_stream(). - * \returns OKAY if successful. */ -int make_solution_create(Session sess, Solution sln, Stream strm) +int make_solution_create(Solution sln, Stream strm) { /* create the makefile */ - const char* filename = make_get_solution_makefile(sess, sln); + const char* filename = make_get_solution_makefile(sln); strm = stream_create_file(filename); if (!strm) { @@ -89,29 +67,19 @@ int make_solution_create(Session sess, Solution sln, Stream strm) } /* make the stream active for the functions that come after */ - session_set_active_stream(sess, strm); + session_set_active_stream(solution_get_session(sln), strm); return OKAY; } /** * Write makefile rules to set a default build configuration. - * \param sess The execution session context. - * \param sln The current solution. - * \param strm The currently active stream; set with session_set_active_stream(). - * \returns OKAY if successful. */ -int make_solution_default_config(Session sess, Solution sln, Stream strm) +int make_solution_default_config(Solution sln, Stream strm) { - const char* default_config_name; - int z; - - UNUSED(sess); - assert(sln); - assert(strm); - - default_config_name = solution_get_config(sln, 0); - z = stream_writeline(strm, "ifndef CONFIG"); + int z = OKAY; + const char* default_config_name = solution_get_config(sln, 0); + z |= stream_writeline(strm, "ifndef CONFIG"); z |= stream_writeline(strm, " CONFIG=%s", default_config_name); z |= stream_writeline(strm, "endif"); z |= stream_writeline(strm, "export CONFIG"); @@ -122,22 +90,12 @@ int make_solution_default_config(Session sess, Solution sln, Stream strm) /** * Write the makefile .PHONY rule. - * \param sess The execution session context. - * \param sln The current solution. - * \param strm The currently active stream; set with session_set_active_stream(). - * \returns OKAY if successful. */ -int make_solution_phony_rule(Session sess, Solution sln, Stream strm) +int make_solution_phony_rule(Solution sln, Stream strm) { - Strings prj_names; - int z; - - UNUSED(sess); - assert(sln); - assert(strm); - - prj_names = make_get_project_names(sln); - z = stream_writeline_strings(strm, prj_names, ".PHONY: all clean", " ", "", "", "", make_write_escaped); + int z = OKAY; + Strings prj_names = make_get_project_names(sln); + z |= stream_writeline_strings(strm, prj_names, ".PHONY: all clean", " ", "", "", "", make_write_escaped); z |= stream_writeline(strm, ""); strings_destroy(prj_names); return z; @@ -147,19 +105,15 @@ int make_solution_phony_rule(Session sess, Solution sln, Stream strm) /** * Build the makefile rule to call an individual project. - * \param sess The current session context. - * \param sln The solution containing the project. - * \param prj The project to be built. - * \returns The makefile rule to trigger the project build. */ -const char* make_solution_project_rule(Session sess, Solution sln, Project prj) +const char* make_solution_project_rule(Solution sln, Project prj) { char* buffer = buffers_next(); /* project file paths are specified relative to the solution */ const char* sln_path = path_directory(solution_get_filename(sln, NULL, NULL)); - const char* prj_file = make_get_project_makefile(sess, prj); + const char* prj_file = make_get_project_makefile(prj); const char* prj_file_dir = path_directory(prj_file); const char* prj_file_name = path_filename(prj_file); prj_file_dir = path_relative(sln_path, prj_file_dir); @@ -182,25 +136,16 @@ const char* make_solution_project_rule(Session sess, Solution sln, Project prj) /** * Write the solution makefile project entries. - * \param sess The execution session context. - * \param sln The current solution. - * \param strm The currently active stream; set with session_set_active_stream(). - * \returns OKAY if successful. */ -int make_solution_projects(Session sess, Solution sln, Stream strm) +int make_solution_projects(Solution sln, Stream strm) { int i, n, z = OKAY; - - assert(sess); - assert(sln); - assert(strm); - n = solution_num_projects(sln); for (i = 0; i < n; ++i) { Project prj = solution_get_project(sln, i); const char* prj_name = project_get_name(prj); - const char* rule = make_solution_project_rule(sess, sln, prj); + const char* rule = make_solution_project_rule(sln, prj); z |= stream_writeline(strm, "%s:", make_escape(prj_name)); z |= stream_writeline(strm, "\t@echo ==== Building %s ====", prj_name); @@ -214,22 +159,14 @@ int make_solution_projects(Session sess, Solution sln, Stream strm) /** * Write the makefile solution file signature block. - * \param sess The execution session context. - * \param sln The current solution. - * \param strm The currently active stream; set with session_set_active_stream(). - * \returns OKAY if successful. */ -int make_solution_signature(Session sess, Solution sln, Stream strm) +int make_solution_signature(Solution sln, Stream strm) { const char* file_type; Strings config_names; int z; - assert(sess); - assert(sln); - assert(strm); - - if (cstr_eq(session_get_action(sess), "gmake")) + if (cstr_eq(env_get_action(), "gmake")) { file_type = "GNU Make"; } diff --git a/src/actions/make/make_solution.h b/src/actions/make/make_solution.h index 0ff86cd..f7f1311 100644 --- a/src/actions/make/make_solution.h +++ b/src/actions/make/make_solution.h @@ -6,14 +6,14 @@ #if !defined(PREMAKE_MAKE_SOLUTION_H) #define PREMAKE_MAKE_SOLUTION_H -#include "session/session.h" +#include "objects/session.h" -int make_solution_clean_rule(Session sess, Solution sln, Stream strm); -int make_solution_all_rule(Session sess, Solution sln, Stream strm); -int make_solution_create(Session sess, Solution sln, Stream strm); -int make_solution_default_config(Session sess, Solution sln, Stream strm); -int make_solution_phony_rule(Session sess, Solution sln, Stream strm); -int make_solution_projects(Session sess, Solution sln, Stream strm); -int make_solution_signature(Session sess, Solution sln, Stream strm); +int make_solution_clean_rule(Solution sln, Stream strm); +int make_solution_all_rule(Solution sln, Stream strm); +int make_solution_create(Solution sln, Stream strm); +int make_solution_default_config(Solution sln, Stream strm); +int make_solution_phony_rule(Solution sln, Stream strm); +int make_solution_projects(Solution sln, Stream strm); +int make_solution_signature(Solution sln, Stream strm); #endif diff --git a/src/actions/make/tests/make_config_tests.cpp b/src/actions/make/tests/make_config_tests.cpp index 8c7c424..cfe49a9 100644 --- a/src/actions/make/tests/make_config_tests.cpp +++ b/src/actions/make/tests/make_config_tests.cpp @@ -8,7 +8,7 @@ #include "actions/tests/action_tests.h" extern "C" { #include "actions/make/make_project.h" -#include "platform/platform.h" +#include "base/env.h" } SUITE(action) @@ -19,7 +19,7 @@ SUITE(action) TEST_FIXTURE(FxAction, MakeCppFlags_Defaults) { - make_project_config_cppflags(sess, prj, strm); + make_project_config_cppflags(prj, strm); CHECK_EQUAL( " CPPFLAGS += -MMD\n", buffer); @@ -29,7 +29,7 @@ SUITE(action) { char* defines[] = { "DEFINE0", "DEFINE1", NULL}; SetConfigField(prj, BlockDefines, defines); - make_project_config_cppflags(sess, prj, strm); + make_project_config_cppflags(prj, strm); CHECK_EQUAL( " CPPFLAGS += -MMD -D \"DEFINE0\" -D \"DEFINE1\"\n", buffer); @@ -42,7 +42,7 @@ SUITE(action) TEST_FIXTURE(FxAction, MakeProject_Config_CFlags) { - make_project_config_cflags(sess, prj, strm); + make_project_config_cflags(prj, strm); CHECK_EQUAL( " CFLAGS += $(CPPFLAGS) $(ARCHFLAGS)\n", buffer); @@ -55,7 +55,7 @@ SUITE(action) TEST_FIXTURE(FxAction, MakeProject_Config_CxxFlags) { - make_project_config_cxxflags(sess, prj, strm); + make_project_config_cxxflags(prj, strm); CHECK_EQUAL( " CXXFLAGS += $(CFLAGS)\n", buffer); @@ -68,7 +68,7 @@ SUITE(action) TEST_FIXTURE(FxAction, MakeProject_Config_LdDeps) { - make_project_config_lddeps(sess, prj, strm); + make_project_config_lddeps(prj, strm); CHECK_EQUAL( " LDDEPS :=\n", buffer); @@ -81,7 +81,7 @@ SUITE(action) TEST_FIXTURE(FxAction, MakeProject_Config_LdFlags) { - make_project_config_ldflags(sess, prj, strm); + make_project_config_ldflags(prj, strm); CHECK_EQUAL( " LDFLAGS +=\n", buffer); @@ -94,7 +94,7 @@ SUITE(action) TEST_FIXTURE(FxAction, MakeProject_Config_ObjDir) { - make_project_config_objdir(sess, prj, strm); + make_project_config_objdir(prj, strm); CHECK_EQUAL( " OBJDIR := obj/Debug\\ DLL\n", buffer); @@ -107,8 +107,8 @@ SUITE(action) TEST_FIXTURE(FxAction, MakeProject_Config_OutFile) { - platform_set(MacOSX); - make_project_config_outfile(sess, prj, strm); + env_set_os(MacOSX); + make_project_config_outfile(prj, strm); CHECK_EQUAL( " OUTFILE := $(OUTDIR)/My\\ Project\n", buffer); @@ -121,7 +121,7 @@ SUITE(action) TEST_FIXTURE(FxAction, MakeProject_Config_OutDir) { - make_project_config_outdir(sess, prj, strm); + make_project_config_outdir(prj, strm); CHECK_EQUAL( " OUTDIR := .\n", buffer); @@ -134,7 +134,7 @@ SUITE(action) TEST_FIXTURE(FxAction, MakeProject_Config_ResFlags) { - make_project_config_resflags(sess, prj, strm); + make_project_config_resflags(prj, strm); CHECK_EQUAL( " RESFLAGS +=\n", buffer); diff --git a/src/actions/make/tests/make_project_tests.cpp b/src/actions/make/tests/make_project_tests.cpp index 6a251fa..7f3982b 100644 --- a/src/actions/make/tests/make_project_tests.cpp +++ b/src/actions/make/tests/make_project_tests.cpp @@ -8,7 +8,7 @@ #include "actions/tests/action_tests.h" extern "C" { #include "actions/make/make_project.h" -#include "platform/platform.h" +#include "base/env.h" } SUITE(action) @@ -19,8 +19,8 @@ SUITE(action) TEST_FIXTURE(FxAction, MakeProject_SignatureIsCorrect_OnGmake) { - session_set_action(sess, "gmake"); - make_project_signature(sess, prj, strm); + env_set_action("gmake"); + make_project_signature(prj, strm); CHECK_EQUAL( "# GNU Makefile autogenerated by Premake\n" "\n", @@ -34,7 +34,7 @@ SUITE(action) TEST_FIXTURE(FxAction, MakeProject_Config_Conditional) { - make_project_config_conditional(sess, prj, strm); + make_project_config_conditional(prj, strm); CHECK_EQUAL( "ifeq ($(CONFIG),Debug DLL)\n", buffer); @@ -42,7 +42,7 @@ SUITE(action) TEST_FIXTURE(FxAction, MakeProject_Config_End) { - make_project_config_end(sess, prj, strm); + make_project_config_end(prj, strm); CHECK_EQUAL( "endif\n" "\n", @@ -58,7 +58,7 @@ SUITE(action) { char* files[] = { "Hello.cpp", "Good Bye.cpp", NULL }; SetField(prj, ProjectFiles, files); - make_project_objects(sess, prj, strm); + make_project_objects(prj, strm); CHECK_EQUAL( "OBJECTS := \\\n" "\t$(OBJDIR)/Hello.o \\\n" @@ -74,7 +74,7 @@ SUITE(action) TEST_FIXTURE(FxAction, MakeProject_Resources) { - make_project_resources(sess, prj, strm); + make_project_resources(prj, strm); CHECK_EQUAL( "RESOURCES := \\\n" "\n", @@ -88,7 +88,7 @@ SUITE(action) TEST_FIXTURE(FxAction, MakeProject_PhonyRule) { - make_project_phony_rule(sess, prj, strm); + make_project_phony_rule(prj, strm); CHECK_EQUAL( ".PHONY: clean\n" "\n", @@ -102,7 +102,7 @@ SUITE(action) TEST_FIXTURE(FxAction, MakeProject_OutputTarget) { - make_project_target(sess, prj, strm); + make_project_target(prj, strm); CHECK_EQUAL( "$(OUTFILE): $(OUTDIR) $(OBJDIR) $(OBJECTS) $(LDDEPS) $(RESOURCES)\n" "\t@echo Linking My Project\n" @@ -118,7 +118,7 @@ SUITE(action) TEST_FIXTURE(FxAction, MakeProject_MkdirRules) { - make_project_mkdir_rules(sess, prj, strm); + make_project_mkdir_rules(prj, strm); CHECK_EQUAL( "$(OUTDIR):\n" "\t@echo Creating $(OUTDIR)\n" @@ -138,7 +138,7 @@ SUITE(action) TEST_FIXTURE(FxAction, MakeProject_CleanRules) { - make_project_clean_rules(sess, prj, strm); + make_project_clean_rules(prj, strm); CHECK_EQUAL( "clean:\n" "\t@echo Cleaning My Project\n" @@ -162,7 +162,7 @@ SUITE(action) { char* files[] = { "Good Bye.cpp", NULL }; SetField(prj, ProjectFiles, files); - make_project_source_rules(sess, prj, strm); + make_project_source_rules(prj, strm); CHECK_EQUAL( "$(OBJDIR)/Good\\ Bye.o: Good\\ Bye.cpp\n" "\t@echo $(notdir $<)\n" @@ -178,7 +178,7 @@ SUITE(action) TEST_FIXTURE(FxAction, MakeProject_IncludeDependencies) { - make_project_include_dependencies(sess, prj, strm); + make_project_include_dependencies(prj, strm); CHECK_EQUAL( "-include $(OBJECTS:%.o=%.d)\n", buffer); diff --git a/src/actions/make/tests/make_solution_tests.cpp b/src/actions/make/tests/make_solution_tests.cpp index e9cca29..28f0655 100644 --- a/src/actions/make/tests/make_solution_tests.cpp +++ b/src/actions/make/tests/make_solution_tests.cpp @@ -8,6 +8,7 @@ #include "actions/tests/action_tests.h" extern "C" { #include "actions/make/make_solution.h" +#include "base/env.h" } @@ -19,8 +20,8 @@ SUITE(action) TEST_FIXTURE(FxAction, MakeSolution_SignatureIsCorrect_OnGmake) { - session_set_action(sess, "gmake"); - make_solution_signature(sess, sln, strm); + env_set_action("gmake"); + make_solution_signature(sln, strm); CHECK_EQUAL( "# GNU Make makefile autogenerated by Premake\n" "# Usage: make [ CONFIG=config_name ]\n" @@ -37,7 +38,7 @@ SUITE(action) TEST_FIXTURE(FxAction, MakeSolution_DefaultConfigIsCorrect) { - make_solution_default_config(sess, sln, strm); + make_solution_default_config(sln, strm); CHECK_EQUAL( "ifndef CONFIG\n" " CONFIG=Debug DLL\n" @@ -54,7 +55,7 @@ SUITE(action) TEST_FIXTURE(FxAction, MakeSolution_PhonyRuleIsCorrect) { - make_solution_phony_rule(sess, sln, strm); + make_solution_phony_rule(sln, strm); CHECK_EQUAL( ".PHONY: all clean My\\ Project\n" "\n", @@ -68,7 +69,7 @@ SUITE(action) TEST_FIXTURE(FxAction, MakeSolution_AllRuleIsCorrect) { - make_solution_all_rule(sess, sln, strm); + make_solution_all_rule(sln, strm); CHECK_EQUAL( "all: My\\ Project\n" "\n", @@ -83,7 +84,7 @@ SUITE(action) TEST_FIXTURE(FxAction, Make_ProjectEntry_InSameDirectory) { project_set_location(prj, ""); - make_solution_projects(sess, sln, strm); + make_solution_projects(sln, strm); CHECK_EQUAL( "My\\ Project:\n" "\t@echo ==== Building My Project ====\n" @@ -95,7 +96,7 @@ SUITE(action) TEST_FIXTURE(FxAction, Make_ProjectEntry_InDifferentDirectory) { project_set_location(prj, "My Project"); - make_solution_projects(sess, sln, strm); + make_solution_projects(sln, strm); CHECK_EQUAL( "My\\ Project:\n" "\t@echo ==== Building My Project ====\n" @@ -112,7 +113,7 @@ SUITE(action) TEST_FIXTURE(FxAction, Gmake_CleanRule_IsCorrect) { project_set_location(prj, ""); - make_solution_clean_rule(sess, sln, strm); + make_solution_clean_rule(sln, strm); CHECK_EQUAL( "clean:\n" "\t@$(MAKE) -f My\\ Project.make clean\n", diff --git a/src/actions/make/tests/make_tests.cpp b/src/actions/make/tests/make_tests.cpp index db4fe87..9f2c9a9 100644 --- a/src/actions/make/tests/make_tests.cpp +++ b/src/actions/make/tests/make_tests.cpp @@ -64,27 +64,27 @@ SUITE(action) TEST_FIXTURE(FxMake, GetSolutionMakefile_ReturnsMakefile_OnUniqueLocation) { solution_set_location(sln1, "MySolution"); - const char* result = make_get_solution_makefile(sess, sln1); + const char* result = make_get_solution_makefile(sln1); CHECK_EQUAL("./MySolution/Makefile", result); } TEST_FIXTURE(FxMake, GetSolutionMakefile_ReturnsDotMake_OnSharedLocation) { - const char* result = make_get_solution_makefile(sess, sln1); + const char* result = make_get_solution_makefile(sln1); CHECK_EQUAL("./MySolution1.make", result); } TEST_FIXTURE(FxMake, GetProjectMakefile_ReturnsMakefile_OnUniqueLocation) { project_set_location(prj1, "MyProject"); - const char* result = make_get_project_makefile(sess, prj1); + const char* result = make_get_project_makefile(prj1); CHECK_EQUAL("./MyProject/Makefile", result); } TEST_FIXTURE(FxMake, GetProjectMakefile_ReturnsDotMake_OnSharedWithSolution) { project_set_location(prj2, "MyProject"); - const char* result = make_get_project_makefile(sess, prj1); + const char* result = make_get_project_makefile(prj1); CHECK_EQUAL("./MyProject1.make", result); } @@ -92,7 +92,7 @@ SUITE(action) { project_set_location(prj1, "MyProject"); project_set_location(prj2, "MyProject"); - const char* result = make_get_project_makefile(sess, prj1); + const char* result = make_get_project_makefile(prj1); CHECK_EQUAL("./MyProject/MyProject1.make", result); } } diff --git a/src/actions/support/sourcetree.c b/src/actions/support/sourcetree.c index 7659dcf..b1bf7f1 100644 --- a/src/actions/support/sourcetree.c +++ b/src/actions/support/sourcetree.c @@ -12,26 +12,25 @@ #include "base/string.h" -static int sourcetree_do(Session sess, Project prj, Stream strm, SourceTreeCallback handler, const char* group); +static int sourcetree_do(Project prj, Stream strm, SourceTreeCallback handler, const char* group); /** * Walk a list of source files and pass them off, in nesting order, to * the specified callback. Handles the grouping of related files info * groups (by directory currently). - * \param sess The current execution session context. * \param prj The project containing the files to enumerate. * \param strm The active output stream. * \param handler The per-file handler function. * \returns OKAY on success. */ -int sourcetree_walk(Session sess, Project prj, Stream strm, SourceTreeCallback handler) +int sourcetree_walk(Project prj, Stream strm, SourceTreeCallback handler) { - return sourcetree_do(sess, prj, strm, handler, ""); + return sourcetree_do(prj, strm, handler, ""); } -static int sourcetree_do(Session sess, Project prj, Stream strm, SourceTreeCallback handler, const char* group) +static int sourcetree_do(Project prj, Stream strm, SourceTreeCallback handler, const char* group) { int i, n; unsigned group_len; @@ -44,7 +43,7 @@ static int sourcetree_do(Session sess, Project prj, Stream strm, SourceTreeCallb buffer = buffers_next(); strcpy(buffer, group); cstr_trim(buffer, '/'); - handler(sess, prj, strm, buffer, GroupStart); + handler(prj, strm, buffer, GroupStart); /* scan all files in this group and process any subdirectories (subgroups) */ files = project_get_files(prj); @@ -79,7 +78,7 @@ static int sourcetree_do(Session sess, Project prj, Stream strm, SourceTreeCallb { /* a new group, process it now */ String new_group = string_create(buffer); - int z = sourcetree_do(sess, prj, strm, handler, string_cstr(new_group)); + int z = sourcetree_do(prj, strm, handler, string_cstr(new_group)); string_destroy(new_group); if (z != OKAY) return !OKAY; } @@ -93,7 +92,7 @@ static int sourcetree_do(Session sess, Project prj, Stream strm, SourceTreeCallb const char* filename = strings_item(files, i); if (cstr_starts_with(filename, group) && strchr(filename + group_len, '/') == NULL) { - if (handler(sess, prj, strm, filename, SourceFile) != OKAY) + if (handler(prj, strm, filename, SourceFile) != OKAY) return !OKAY; } } @@ -102,7 +101,7 @@ static int sourcetree_do(Session sess, Project prj, Stream strm, SourceTreeCallb buffer = buffers_next(); strcpy(buffer, group); cstr_trim(buffer, '/'); - handler(sess, prj, strm, buffer, GroupEnd); + handler(prj, strm, buffer, GroupEnd); return OKAY; } diff --git a/src/actions/support/sourcetree.h b/src/actions/support/sourcetree.h index f39224f..504f052 100644 --- a/src/actions/support/sourcetree.h +++ b/src/actions/support/sourcetree.h @@ -6,7 +6,7 @@ #if !defined(PREMAKE_SOURCETREE_H) #define PREMAKE_SOURCETREE_H -#include "session/session.h" +#include "objects/project.h" /** @@ -22,17 +22,16 @@ enum SourceTreeState /** * Per-file callback signature for action_source_tree. - * \param sess The current execution state context. * \param prj The current project; contains the file being enumerated. * \param strm The active output stream; for writing the file markup. * \param filename The name of the file to process. * \param state One of the ActionSourceStates, enabling file grouping. * \returns OKAY if successful. */ -typedef int (*SourceTreeCallback)(Session sess, Project prj, Stream strm, const char* filename, int state); +typedef int (*SourceTreeCallback)(Project prj, Stream strm, const char* filename, int state); -int sourcetree_walk(Session sess, Project prj, Stream strm, SourceTreeCallback handler); +int sourcetree_walk(Project prj, Stream strm, SourceTreeCallback handler); #endif diff --git a/src/actions/tests/action_tests.h b/src/actions/tests/action_tests.h index 8989dea..97d49ad 100644 --- a/src/actions/tests/action_tests.h +++ b/src/actions/tests/action_tests.h @@ -6,8 +6,7 @@ #include "testing/testing.h" extern "C" { -#include "session/session.h" -#include "project/project.h" +#include "objects/session.h" } struct FxAction @@ -15,7 +14,6 @@ struct FxAction Session sess; Stream strm; Solution sln; - Filter flt; Project prj; char buffer[8192]; @@ -41,10 +39,7 @@ struct FxAction project_set_location(prj, "Project Folder"); project_set_guid(prj, "AE2461B7-236F-4278-81D3-F0D476F9A4C0"); project_set_language(prj, "c++"); - - flt = session_get_filter(sess); - filter_set_value(flt, FilterConfig, "Debug DLL"); - project_set_filter(prj, flt); + project_set_config(prj, "Debug DLL"); } ~FxAction() diff --git a/src/actions/vs200x/tests/vs2002_solution_tests.cpp b/src/actions/vs200x/tests/vs2002_solution_tests.cpp index 8852dee..c42db2a 100644 --- a/src/actions/vs200x/tests/vs2002_solution_tests.cpp +++ b/src/actions/vs200x/tests/vs2002_solution_tests.cpp @@ -19,7 +19,7 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs2002_Signature_IsCorrect) { - vs2002_solution_signature(sess, sln, strm); + vs2002_solution_signature(sln, strm); CHECK_EQUAL( "Microsoft Visual Studio Solution File, Format Version 7.00\r\n", buffer); @@ -32,7 +32,7 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs2002_ProjectEntry_UsesRelativePath) { - vs2002_solution_projects(sess, sln, strm); + vs2002_solution_projects(sln, strm); CHECK_EQUAL( "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"My Project\", \"Project Folder\\My Project.vcproj\", \"{AE2461B7-236F-4278-81D3-F0D476F9A4C0}\"\n" "EndProject\n", @@ -46,7 +46,7 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs2002_SolutionConfiguration_IsCorrect) { - vs2002_solution_configuration(sess, sln, strm); + vs2002_solution_configuration(sln, strm); CHECK_EQUAL( "Global\n" "\tGlobalSection(SolutionConfiguration) = preSolution\n" @@ -63,7 +63,7 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs2002_ProjectDependencies_IsCorrect) { - vs2002_solution_dependencies(sess, sln, strm); + vs2002_solution_dependencies(sln, strm); CHECK_EQUAL( "\tGlobalSection(ProjectDependencies) = postSolution\n" "\tEndGlobalSection\n", @@ -77,7 +77,7 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs2002_ProjectConfiguration_IsCorrect) { - vs2002_solution_project_configuration(sess, sln, strm); + vs2002_solution_project_configuration(sln, strm); CHECK_EQUAL( "\tGlobalSection(ProjectConfiguration) = postSolution\n" "\t\t{AE2461B7-236F-4278-81D3-F0D476F9A4C0}.Debug DLL.ActiveCfg = Debug DLL|Win32\n" @@ -95,7 +95,7 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs2002_Extensibility_IsCorrect) { - vs2002_solution_extensibility(sess, sln, strm); + vs2002_solution_extensibility(sln, strm); CHECK_EQUAL( "\tGlobalSection(ExtensibilityGlobals) = postSolution\n" "\tEndGlobalSection\n" diff --git a/src/actions/vs200x/tests/vs2003_solution_tests.cpp b/src/actions/vs200x/tests/vs2003_solution_tests.cpp index 8b54d5c..00aab54 100644 --- a/src/actions/vs200x/tests/vs2003_solution_tests.cpp +++ b/src/actions/vs200x/tests/vs2003_solution_tests.cpp @@ -19,7 +19,7 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs2003_Signature_IsCorrect) { - vs2003_solution_signature(sess, sln, strm); + vs2003_solution_signature(sln, strm); CHECK_EQUAL( "Microsoft Visual Studio Solution File, Format Version 8.00\r\n", buffer); @@ -32,7 +32,7 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs2003_SolutionConfiguration_IsCorrect) { - vs2003_solution_configuration(sess, sln, strm); + vs2003_solution_configuration(sln, strm); CHECK_EQUAL( "Global\n" "\tGlobalSection(SolutionConfiguration) = preSolution\n" diff --git a/src/actions/vs200x/tests/vs2005_solution_tests.cpp b/src/actions/vs200x/tests/vs2005_solution_tests.cpp index 05e6081..4707c6b 100644 --- a/src/actions/vs200x/tests/vs2005_solution_tests.cpp +++ b/src/actions/vs200x/tests/vs2005_solution_tests.cpp @@ -19,7 +19,7 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs2005_Signature_IsCorrect) { - vs2005_solution_signature(sess, sln, strm); + vs2005_solution_signature(sln, strm); CHECK_EQUAL( "\357\273\277\r\n" "Microsoft Visual Studio Solution File, Format Version 9.00\r\n" @@ -34,7 +34,7 @@ SUITE(action) TEST_FIXTURE(FxAction, Platforms_IsCorrect) { - vs2005_solution_platforms(sess, sln, strm); + vs2005_solution_platforms(sln, strm); CHECK_EQUAL( "Global\n" "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n" @@ -51,7 +51,7 @@ SUITE(action) TEST_FIXTURE(FxAction, ProjectPlatforms_IsCorrect) { - vs2005_solution_project_platforms(sess, sln, strm); + vs2005_solution_project_platforms(sln, strm); CHECK_EQUAL( "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n" "\t\t{AE2461B7-236F-4278-81D3-F0D476F9A4C0}.Debug DLL|Win32.ActiveCfg = Debug DLL|Win32\n" @@ -69,7 +69,7 @@ SUITE(action) TEST_FIXTURE(FxAction, Properties_IsCorrect) { - vs2005_solution_properties(sess, sln, strm); + vs2005_solution_properties(sln, strm); CHECK_EQUAL( "\tGlobalSection(SolutionProperties) = preSolution\n" "\t\tHideSolutionNode = FALSE\n" diff --git a/src/actions/vs200x/tests/vs2008_solution_tests.cpp b/src/actions/vs200x/tests/vs2008_solution_tests.cpp index 7495b97..4579be1 100644 --- a/src/actions/vs200x/tests/vs2008_solution_tests.cpp +++ b/src/actions/vs200x/tests/vs2008_solution_tests.cpp @@ -19,7 +19,7 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs2008_Signature_IsCorrect) { - vs2008_solution_signature(sess, sln, strm); + vs2008_solution_signature(sln, strm); CHECK_EQUAL( "\357\273\277\r\n" "Microsoft Visual Studio Solution File, Format Version 10.00\r\n" diff --git a/src/actions/vs200x/tests/vs200x_compiler_tests.cpp b/src/actions/vs200x/tests/vs200x_compiler_tests.cpp index 167ad30..2e68ff1 100644 --- a/src/actions/vs200x/tests/vs200x_compiler_tests.cpp +++ b/src/actions/vs200x/tests/vs200x_compiler_tests.cpp @@ -8,6 +8,7 @@ #include "actions/tests/action_tests.h" extern "C" { #include "actions/vs200x/vs200x_project.h" +#include "base/env.h" } SUITE(action) @@ -18,8 +19,8 @@ SUITE(action) TEST_FIXTURE(FxAction, VCCLCompilerTool_Defaults_OnVs2002) { - session_set_action(sess, "vs2002"); - vs200x_project_vc_cl_compiler_tool(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_vc_cl_compiler_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCCLCompilerTool\"\n" @@ -37,8 +38,8 @@ SUITE(action) TEST_FIXTURE(FxAction, VCCLCompilerTool_Defaults_OnVs2005) { - session_set_action(sess, "vs2005"); - vs200x_project_vc_cl_compiler_tool(sess, prj, strm); + env_set_action("vs2005"); + vs200x_project_vc_cl_compiler_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCCLCompilerTool\"\n" @@ -56,8 +57,8 @@ SUITE(action) TEST_FIXTURE(FxAction, VCCLCompilerTool_Defaults_OnVs2008) { - session_set_action(sess, "vs2008"); - vs200x_project_vc_cl_compiler_tool(sess, prj, strm); + env_set_action("vs2008"); + vs200x_project_vc_cl_compiler_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCCLCompilerTool\"\n" @@ -80,10 +81,10 @@ SUITE(action) TEST_FIXTURE(FxAction, VCCLCompilerTool_WithDefines) { - session_set_action(sess, "vs2002"); + env_set_action("vs2002"); char* defines[] = { "DEFINE0", "DEFINE1", NULL }; SetConfigField(prj, BlockDefines, defines); - vs200x_project_vc_cl_compiler_tool(sess, prj, strm); + vs200x_project_vc_cl_compiler_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCCLCompilerTool\"\n" diff --git a/src/actions/vs200x/tests/vs200x_config_tests.cpp b/src/actions/vs200x/tests/vs200x_config_tests.cpp index 7a8fbe9..2e80035 100644 --- a/src/actions/vs200x/tests/vs200x_config_tests.cpp +++ b/src/actions/vs200x/tests/vs200x_config_tests.cpp @@ -8,6 +8,7 @@ #include "actions/tests/action_tests.h" extern "C" { #include "actions/vs200x/vs200x_config.h" +#include "base/env.h" } SUITE(action) @@ -18,29 +19,29 @@ SUITE(action) TEST_FIXTURE(FxAction, VsCharacterSet_Defaults_OnVs2002) { - session_set_action(sess, "vs2002"); - vs200x_config_character_set(sess, strm); + env_set_action("vs2002"); + vs200x_config_character_set(strm); CHECK_EQUAL("\n\t\t\tCharacterSet=\"2\"", buffer); } TEST_FIXTURE(FxAction, VsCharacterSet_Defaults_OnVs2003) { - session_set_action(sess, "vs2003"); - vs200x_config_character_set(sess, strm); + env_set_action("vs2003"); + vs200x_config_character_set(strm); CHECK_EQUAL("\n\t\t\tCharacterSet=\"2\"", buffer); } TEST_FIXTURE(FxAction, VsCharacterSet_Defaults_OnVs2005) { - session_set_action(sess, "vs2005"); - vs200x_config_character_set(sess, strm); + env_set_action("vs2005"); + vs200x_config_character_set(strm); CHECK_EQUAL("\n\t\t\tCharacterSet=\"1\"", buffer); } TEST_FIXTURE(FxAction, VsCharacterSet_Defaults_OnVs2008) { - session_set_action(sess, "vs2008"); - vs200x_config_character_set(sess, strm); + env_set_action("vs2008"); + vs200x_config_character_set(strm); CHECK_EQUAL("\n\t\t\tCharacterSet=\"1\"", buffer); } @@ -51,17 +52,17 @@ SUITE(action) TEST_FIXTURE(FxAction, VsDefines_Empty_OnNoSymbols) { - session_set_action(sess, "vs2002"); - vs200x_config_defines(sess, strm, prj); + env_set_action("vs2002"); + vs200x_config_defines(strm, prj); CHECK_EQUAL("", buffer); } TEST_FIXTURE(FxAction, VsDefines_SemiSplitList) { - session_set_action(sess, "vs2002"); + env_set_action("vs2002"); char* values[] = { "DEFINE0", "DEFINE1", "DEFINE2", NULL }; SetConfigField(prj, BlockDefines, values); - vs200x_config_defines(sess, strm, prj); + vs200x_config_defines(strm, prj); CHECK_EQUAL("\n\t\t\t\tPreprocessorDefinitions=\"DEFINE0;DEFINE1;DEFINE2\"", buffer); } } diff --git a/src/actions/vs200x/tests/vs200x_linker_tests.cpp b/src/actions/vs200x/tests/vs200x_linker_tests.cpp index 10b8e01..358a352 100644 --- a/src/actions/vs200x/tests/vs200x_linker_tests.cpp +++ b/src/actions/vs200x/tests/vs200x_linker_tests.cpp @@ -8,6 +8,7 @@ #include "actions/tests/action_tests.h" extern "C" { #include "actions/vs200x/vs200x_project.h" +#include "base/env.h" } SUITE(action) @@ -18,8 +19,8 @@ SUITE(action) TEST_FIXTURE(FxAction, VCLinkerTool_Defaults_OnVs2002) { - session_set_action(sess, "vs2002"); - vs200x_project_vc_linker_tool(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_vc_linker_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCLinkerTool\"\n" @@ -33,8 +34,8 @@ SUITE(action) TEST_FIXTURE(FxAction, VCLinkerTool_Defaults_OnVs2003) { - session_set_action(sess, "vs2003"); - vs200x_project_vc_linker_tool(sess, prj, strm); + env_set_action("vs2003"); + vs200x_project_vc_linker_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCLinkerTool\"\n" @@ -48,8 +49,8 @@ SUITE(action) TEST_FIXTURE(FxAction, VCLinkerTool_Defaults_OnVs2005) { - session_set_action(sess, "vs2005"); - vs200x_project_vc_linker_tool(sess, prj, strm); + env_set_action("vs2005"); + vs200x_project_vc_linker_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCLinkerTool\"\n" @@ -64,8 +65,8 @@ SUITE(action) TEST_FIXTURE(FxAction, VCLinkerTool_Defaults_OnVs2008) { - session_set_action(sess, "vs2008"); - vs200x_project_vc_linker_tool(sess, prj, strm); + env_set_action("vs2008"); + vs200x_project_vc_linker_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCLinkerTool\"\n" diff --git a/src/actions/vs200x/tests/vs200x_project_tests.cpp b/src/actions/vs200x/tests/vs200x_project_tests.cpp index 7679685..6456637 100644 --- a/src/actions/vs200x/tests/vs200x_project_tests.cpp +++ b/src/actions/vs200x/tests/vs200x_project_tests.cpp @@ -8,6 +8,7 @@ #include "actions/tests/action_tests.h" extern "C" { #include "actions/vs200x/vs200x_project.h" +#include "base/env.h" } @@ -19,7 +20,7 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_Encoding) { - vs200x_project_encoding(sess, prj, strm); + vs200x_project_encoding(prj, strm); CHECK_EQUAL( "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n", buffer); @@ -32,8 +33,8 @@ SUITE(action) TEST_FIXTURE(FxAction, VsProject_OnVs2002) { - session_set_action(sess, "vs2002"); - vs200x_project_element(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_element(prj, strm); CHECK_EQUAL( "<VisualStudioProject\n" "\tProjectType=\"Visual C++\"\n" @@ -46,8 +47,8 @@ SUITE(action) TEST_FIXTURE(FxAction, VsProject_OnVs2003) { - session_set_action(sess, "vs2003"); - vs200x_project_element(sess, prj, strm); + env_set_action("vs2003"); + vs200x_project_element(prj, strm); CHECK_EQUAL( "<VisualStudioProject\n" "\tProjectType=\"Visual C++\"\n" @@ -60,8 +61,8 @@ SUITE(action) TEST_FIXTURE(FxAction, VsProject_OnVs2005) { - session_set_action(sess, "vs2005"); - vs200x_project_element(sess, prj, strm); + env_set_action("vs2005"); + vs200x_project_element(prj, strm); CHECK_EQUAL( "<VisualStudioProject\n" "\tProjectType=\"Visual C++\"\n" @@ -76,8 +77,8 @@ SUITE(action) TEST_FIXTURE(FxAction, VsProject_OnVs2008) { - session_set_action(sess, "vs2008"); - vs200x_project_element(sess, prj, strm); + env_set_action("vs2008"); + vs200x_project_element(prj, strm); CHECK_EQUAL( "<VisualStudioProject\n" "\tProjectType=\"Visual C++\"\n" @@ -98,8 +99,8 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_Platforms) { - session_set_action(sess, "vs2002"); - vs200x_project_platforms(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_platforms(prj, strm); CHECK_EQUAL( "\t<Platforms>\n" "\t\t<Platform\n" @@ -115,8 +116,8 @@ SUITE(action) TEST_FIXTURE(FxAction, VsToolFiles_Defaults_OnVs2002) { - session_set_action(sess, "vs2002"); - vs200x_project_tool_files(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_tool_files(prj, strm); CHECK_EQUAL( "\t<Configurations>\n", buffer); @@ -124,8 +125,8 @@ SUITE(action) TEST_FIXTURE(FxAction, VsToolFiles_Defaults_OnVs2003) { - session_set_action(sess, "vs2003"); - vs200x_project_tool_files(sess, prj, strm); + env_set_action("vs2003"); + vs200x_project_tool_files(prj, strm); CHECK_EQUAL( "\t<Configurations>\n", buffer); @@ -133,8 +134,8 @@ SUITE(action) TEST_FIXTURE(FxAction, VsToolFiles_Defaults_OnVs2005) { - session_set_action(sess, "vs2005"); - vs200x_project_tool_files(sess, prj, strm); + env_set_action("vs2005"); + vs200x_project_tool_files(prj, strm); CHECK_EQUAL( "\t<ToolFiles>\n" "\t</ToolFiles>\n" @@ -144,8 +145,8 @@ SUITE(action) TEST_FIXTURE(FxAction, VsToolFiles_Defaults_OnVs2008) { - session_set_action(sess, "vs2008"); - vs200x_project_tool_files(sess, prj, strm); + env_set_action("vs2008"); + vs200x_project_tool_files(prj, strm); CHECK_EQUAL( "\t<ToolFiles>\n" "\t</ToolFiles>\n" @@ -161,8 +162,8 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_Configuration) { - session_set_action(sess, "vs2002"); - vs200x_project_config_element(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_config_element(prj, strm); CHECK_EQUAL( "\t\t<Configuration\n" "\t\t\tName=\"Debug DLL|Win32\"\n" @@ -180,8 +181,8 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_VCALinkTool) { - session_set_action(sess, "vs2002"); - vs200x_project_vc_alink_tool(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_vc_alink_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCALinkTool\"/>\n", @@ -190,8 +191,8 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_VCAppVerifierTool) { - session_set_action(sess, "vs2002"); - vs200x_project_vc_app_verifier_tool(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_vc_app_verifier_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCAppVerifierTool\"/>\n", @@ -200,8 +201,8 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_VCBscMakeTool) { - session_set_action(sess, "vs2002"); - vs200x_project_vc_bsc_make_tool(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_vc_bsc_make_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCBscMakeTool\"/>\n", @@ -210,8 +211,8 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_VCCustomBuildTool) { - session_set_action(sess, "vs2002"); - vs200x_project_vc_custom_build_tool(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_vc_custom_build_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCCustomBuildTool\"/>\n", @@ -220,8 +221,8 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_VCFxCopTool) { - session_set_action(sess, "vs2002"); - vs200x_project_vc_fx_cop_tool(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_vc_fx_cop_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCFxCopTool\"/>\n", @@ -230,8 +231,8 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_VCManagedResourceCompilerTool) { - session_set_action(sess, "vs2002"); - vs200x_project_vc_managed_resource_compiler_tool(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_vc_managed_resource_compiler_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCManagedResourceCompilerTool\"/>\n", @@ -240,8 +241,8 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_VCManifestTool) { - session_set_action(sess, "vs2002"); - vs200x_project_vc_manifest_tool(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_vc_manifest_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCManifestTool\"/>\n", @@ -250,8 +251,8 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_VCMIDLTool) { - session_set_action(sess, "vs2002"); - vs200x_project_vc_midl_tool(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_vc_midl_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCMIDLTool\"/>\n", @@ -260,8 +261,8 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_VCPreBuildEventTool) { - session_set_action(sess, "vs2002"); - vs200x_project_vc_pre_build_event_tool(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_vc_pre_build_event_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCPreBuildEventTool\"/>\n", @@ -270,8 +271,8 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_VCPreLinkEventTool) { - session_set_action(sess, "vs2002"); - vs200x_project_vc_pre_link_event_tool(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_vc_pre_link_event_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCPreLinkEventTool\"/>\n", @@ -280,8 +281,8 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_VCPostBuildEventTool) { - session_set_action(sess, "vs2002"); - vs200x_project_vc_post_build_event_tool(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_vc_post_build_event_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCPostBuildEventTool\"/>\n", @@ -290,8 +291,8 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_VCResourceCompilerTool) { - session_set_action(sess, "vs2002"); - vs200x_project_vc_resource_compiler_tool(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_vc_resource_compiler_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCResourceCompilerTool\"/>\n", @@ -300,8 +301,8 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_VCWebDeploymentTool) { - session_set_action(sess, "vs2002"); - vs200x_project_vc_web_deployment_tool(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_vc_web_deployment_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCWebDeploymentTool\"/>\n", @@ -310,8 +311,8 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_VCWebServiceProxyGeneratorTool) { - session_set_action(sess, "vs2002"); - vs200x_project_vc_web_service_proxy_generator_tool(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_vc_web_service_proxy_generator_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\n", @@ -320,8 +321,8 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_VCXDCMakeTool) { - session_set_action(sess, "vs2002"); - vs200x_project_vc_xdc_make_tool(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_vc_xdc_make_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCXDCMakeTool\"/>\n", @@ -330,8 +331,8 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_VCXMLDataGeneratorTool) { - session_set_action(sess, "vs2002"); - vs200x_project_vc_xml_data_generator_tool(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_vc_xml_data_generator_tool(prj, strm); CHECK_EQUAL( "\t\t\t<Tool\n" "\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\n", @@ -345,8 +346,8 @@ SUITE(action) TEST_FIXTURE(FxAction, VsReferences_Defaults_OnVs2002) { - session_set_action(sess, "vs2002"); - vs200x_project_references(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_references(prj, strm); CHECK_EQUAL( "\t</Configurations>\n", buffer); @@ -354,8 +355,8 @@ SUITE(action) TEST_FIXTURE(FxAction, VsReferences_Defaults_OnVs2003) { - session_set_action(sess, "vs2003"); - vs200x_project_references(sess, prj, strm); + env_set_action("vs2003"); + vs200x_project_references(prj, strm); CHECK_EQUAL( "\t</Configurations>\n" "\t<References>\n" @@ -365,8 +366,8 @@ SUITE(action) TEST_FIXTURE(FxAction, VsReferences_Defaults_OnVs2005) { - session_set_action(sess, "vs2005"); - vs200x_project_references(sess, prj, strm); + env_set_action("vs2005"); + vs200x_project_references(prj, strm); CHECK_EQUAL( "\t</Configurations>\n" "\t<References>\n" @@ -376,8 +377,8 @@ SUITE(action) TEST_FIXTURE(FxAction, VsReferences_Defaults_OnVs2008) { - session_set_action(sess, "vs2008"); - vs200x_project_references(sess, prj, strm); + env_set_action("vs2008"); + vs200x_project_references(prj, strm); CHECK_EQUAL( "\t</Configurations>\n" "\t<References>\n" @@ -392,8 +393,8 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_Files_OnNoFiles) { - session_set_action(sess, "vs2002"); - vs200x_project_files(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_files(prj, strm); CHECK_EQUAL( "\t<Files>\n" "\t</Files>\n", @@ -402,10 +403,10 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_Files_OnSingleCppFile) { - session_set_action(sess, "vs2002"); + env_set_action("vs2002"); char* values[] = { "Hello.cpp", 0 }; SetField(prj, ProjectFiles, values); - vs200x_project_files(sess, prj, strm); + vs200x_project_files(prj, strm); CHECK_EQUAL( "\t<Files>\n" "\t\t<File\n" @@ -417,10 +418,10 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_Files_OnUpperDirectory) { - session_set_action(sess, "vs2002"); + env_set_action("vs2002"); char* values[] = { "../../Hello.cpp", 0 }; SetField(prj, ProjectFiles, values); - vs200x_project_files(sess, prj, strm); + vs200x_project_files(prj, strm); CHECK_EQUAL( "\t<Files>\n" "\t\t<File\n" @@ -432,10 +433,10 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_Files_OnGroupedCppFile) { - session_set_action(sess, "vs2002"); + env_set_action("vs2002"); char* values[] = { "Src/Hello.cpp", 0 }; SetField(prj, ProjectFiles, values); - vs200x_project_files(sess, prj, strm); + vs200x_project_files(prj, strm); CHECK_EQUAL( "\t<Files>\n" "\t\t<Filter\n" @@ -456,8 +457,8 @@ SUITE(action) TEST_FIXTURE(FxAction, Vs200x_Globals) { - session_set_action(sess, "vs2002"); - vs200x_project_globals(sess, prj, strm); + env_set_action("vs2002"); + vs200x_project_globals(prj, strm); CHECK_EQUAL( "\t<Globals>\n" "\t</Globals>\n" diff --git a/src/actions/vs200x/tests/vs200x_xml_tests.cpp b/src/actions/vs200x/tests/vs200x_xml_tests.cpp index 9616b99..cc9ce36 100644 --- a/src/actions/vs200x/tests/vs200x_xml_tests.cpp +++ b/src/actions/vs200x/tests/vs200x_xml_tests.cpp @@ -8,6 +8,7 @@ #include "actions/tests/action_tests.h" extern "C" { #include "actions/vs200x/vs200x.h" +#include "base/env.h" } @@ -19,57 +20,57 @@ SUITE(action) TEST_FIXTURE(FxAction, ElementEnd_SlashBracket_Vs2002) { - session_set_action(sess, "vs2002"); - vs200x_element_end(sess, strm, 0, "/>"); + env_set_action("vs2002"); + vs200x_element_end(strm, 0, "/>"); CHECK_EQUAL("/>\n", buffer); } TEST_FIXTURE(FxAction, ElementEnd_SlashBracket_Vs2003) { - session_set_action(sess, "vs2003"); - vs200x_element_end(sess, strm, 0, "/>"); + env_set_action("vs2003"); + vs200x_element_end(strm, 0, "/>"); CHECK_EQUAL("/>\n", buffer); } TEST_FIXTURE(FxAction, ElementEnd_SlashBracket_Vs2005) { - session_set_action(sess, "vs2005"); - vs200x_element_end(sess, strm, 0, "/>"); + env_set_action("vs2005"); + vs200x_element_end(strm, 0, "/>"); CHECK_EQUAL("\n/>\n", buffer); } TEST_FIXTURE(FxAction, ElementEnd_SlashBracket_Vs2008) { - session_set_action(sess, "vs2008"); - vs200x_element_end(sess, strm, 0, "/>"); + env_set_action("vs2008"); + vs200x_element_end(strm, 0, "/>"); CHECK_EQUAL("\n/>\n", buffer); } TEST_FIXTURE(FxAction, ElementEnd_Bracket_Vs2002) { - session_set_action(sess, "vs2002"); - vs200x_element_end(sess, strm, 0, ">"); + env_set_action("vs2002"); + vs200x_element_end(strm, 0, ">"); CHECK_EQUAL(">\n", buffer); } TEST_FIXTURE(FxAction, ElementEnd_Bracket_Vs2003) { - session_set_action(sess, "vs2003"); - vs200x_element_end(sess, strm, 0, ">"); + env_set_action("vs2003"); + vs200x_element_end(strm, 0, ">"); CHECK_EQUAL(">\n", buffer); } TEST_FIXTURE(FxAction, ElementEnd_Bracket_Vs2005) { - session_set_action(sess, "vs2005"); - vs200x_element_end(sess, strm, 0, ">"); + env_set_action("vs2005"); + vs200x_element_end(strm, 0, ">"); CHECK_EQUAL("\n\t>\n", buffer); } TEST_FIXTURE(FxAction, ElementEnd_Bracket_Vs2008) { - session_set_action(sess, "vs2008"); - vs200x_element_end(sess, strm, 0, ">"); + env_set_action("vs2008"); + vs200x_element_end(strm, 0, ">"); CHECK_EQUAL("\n\t>\n", buffer); } @@ -80,21 +81,21 @@ SUITE(action) TEST_FIXTURE(FxAction, Attribute_OnLevel0) { - session_set_action(sess, "vs2002"); + env_set_action("vs2002"); vs200x_attribute(strm, 0, "ProjectType", "Visual C++"); CHECK_EQUAL("\nProjectType=\"Visual C++\"", buffer); } TEST_FIXTURE(FxAction, Attribute_OnLevel3) { - session_set_action(sess, "vs2002"); + env_set_action("vs2002"); vs200x_attribute(strm, 3, "ProjectType", "Visual C++"); CHECK_EQUAL("\n\t\t\tProjectType=\"Visual C++\"", buffer); } TEST_FIXTURE(FxAction, Attribute_IsEscaped) { - session_set_action(sess, "vs2002"); + env_set_action("vs2002"); vs200x_attribute(strm, 1, "PreprocessorSymbols", "DEBUG;MSG=\"Hello\";TRACE"); CHECK_EQUAL("\n\tPreprocessorSymbols=\"DEBUG;MSG="Hello";TRACE\"", buffer); } diff --git a/src/actions/vs200x/vs2002_solution.c b/src/actions/vs200x/vs2002_solution.c index 7274eb7..5e01b22 100644 --- a/src/actions/vs200x/vs2002_solution.c +++ b/src/actions/vs200x/vs2002_solution.c @@ -15,15 +15,10 @@ /** * Create the Visual Studio 2002 solution configuration block. - * \param sess The execution session context. - * \param sln The current solution. - * \param strm The currently active stream; set with session_set_active_stream(). - * \returns OKAY if successful. */ -int vs2002_solution_configuration(Session sess, Solution sln, Stream strm) +int vs2002_solution_configuration(Solution sln, Stream strm) { int i, n, z; - UNUSED(sess); z = stream_writeline(strm, "Global"); z |= stream_writeline(strm, "\tGlobalSection(SolutionConfiguration) = preSolution"); @@ -42,15 +37,10 @@ int vs2002_solution_configuration(Session sess, Solution sln, Stream strm) /** * Create the Visual Studio 2002 project dependencies block. - * \param sess The execution session context. - * \param sln The current solution. - * \param strm The currently active stream; set with session_set_active_stream(). - * \returns OKAY if successful. */ -int vs2002_solution_dependencies(Session sess, Solution sln, Stream strm) +int vs2002_solution_dependencies(Solution sln, Stream strm) { int z; - UNUSED(sess); UNUSED(sln); z = stream_writeline(strm, "\tGlobalSection(ProjectDependencies) = postSolution"); z |= stream_writeline(strm, "\tEndGlobalSection"); @@ -60,15 +50,10 @@ int vs2002_solution_dependencies(Session sess, Solution sln, Stream strm) /** * Write out the Visual Studio 2002 solution extensibility block. - * \param sess The execution session context. - * \param sln The current solution. - * \param strm The currently active stream; set with session_set_active_stream(). - * \returns OKAY if successful. */ -int vs2002_solution_extensibility(Session sess, Solution sln, Stream strm) +int vs2002_solution_extensibility(Solution sln, Stream strm) { int z; - UNUSED(sess); UNUSED(sln); z = stream_writeline(strm, "\tGlobalSection(ExtensibilityGlobals) = postSolution"); z |= stream_writeline(strm, "\tEndGlobalSection"); @@ -81,15 +66,10 @@ int vs2002_solution_extensibility(Session sess, Solution sln, Stream strm) /** * Write out the Visual Studio 2002 project configurations block. - * \param sess The execution session context. - * \param sln The current solution. - * \param strm The currently active stream; set with session_set_active_stream(). - * \returns OKAY if successful. */ -int vs2002_solution_project_configuration(Session sess, Solution sln, Stream strm) +int vs2002_solution_project_configuration(Solution sln, Stream strm) { int pi, pn, z; - UNUSED(sess); z = stream_writeline(strm, "\tGlobalSection(ProjectConfiguration) = postSolution"); pn = solution_num_projects(sln); for (pi = 0; pi < pn; ++pi) @@ -113,18 +93,12 @@ int vs2002_solution_project_configuration(Session sess, Solution sln, Stream str /** * Write out the list of projects contained by the solution. - * \param sess The execution session context. - * \param sln The current solution. - * \param strm The currently active stream; set with session_set_active_stream(). - * \returns OKAY if successful. */ -int vs2002_solution_projects(Session sess, Solution sln, Stream strm) +int vs2002_solution_projects(Solution sln, Stream strm) { const char* sln_path; int i, n, z = OKAY; - UNUSED(sess); - /* project file paths are specified relative to the solution */ sln_path = path_directory(solution_get_filename(sln, NULL, NULL)); @@ -153,15 +127,10 @@ int vs2002_solution_projects(Session sess, Solution sln, Stream strm) /** * Write the Visual Studio 2002 solution file signature. - * \param sess The execution session context. - * \param sln The current solution. - * \param strm The currently active stream; set with session_set_active_stream(). - * \returns OKAY if successful. */ -int vs2002_solution_signature(Session sess, Solution sln, Stream strm) +int vs2002_solution_signature(Solution sln, Stream strm) { int z; - UNUSED(sess); UNUSED(sln); stream_set_newline(strm, "\r\n"); z = stream_writeline(strm, "Microsoft Visual Studio Solution File, Format Version 7.00"); diff --git a/src/actions/vs200x/vs2003_solution.c b/src/actions/vs200x/vs2003_solution.c index 1c1517c..448cc70 100644 --- a/src/actions/vs200x/vs2003_solution.c +++ b/src/actions/vs200x/vs2003_solution.c @@ -12,15 +12,10 @@ /** * Create the Visual Studio 2003 solution configuration block. - * \param sess The execution session context. - * \param sln The current solution. - * \param strm The currently active stream; set with session_set_active_stream(). - * \returns OKAY if successful. */ -int vs2003_solution_configuration(Session sess, Solution sln, Stream strm) +int vs2003_solution_configuration(Solution sln, Stream strm) { int i, n, z; - UNUSED(sess); z = stream_writeline(strm, "Global"); z |= stream_writeline(strm, "\tGlobalSection(SolutionConfiguration) = preSolution"); @@ -39,15 +34,10 @@ int vs2003_solution_configuration(Session sess, Solution sln, Stream strm) /** * Write the Visual Studio 2003 solution file signature. - * \param sess The execution session context. - * \param sln The current solution. - * \param strm The currently active stream; set with session_set_active_stream(). - * \returns OKAY if successful. */ -int vs2003_solution_signature(Session sess, Solution sln, Stream strm) +int vs2003_solution_signature(Solution sln, Stream strm) { int z; - UNUSED(sess); UNUSED(sln); stream_set_newline(strm, "\r\n"); z = stream_writeline(strm, "Microsoft Visual Studio Solution File, Format Version 8.00"); diff --git a/src/actions/vs200x/vs2005_solution.c b/src/actions/vs200x/vs2005_solution.c index 6f589ea..6a659d0 100644 --- a/src/actions/vs200x/vs2005_solution.c +++ b/src/actions/vs200x/vs2005_solution.c @@ -12,15 +12,10 @@ /** * Write out the Visual Studio solution-level platform configuration block. - * \param sess The execution session context. - * \param sln The current solution. - * \param strm The currently active stream; set with session_set_active_stream(). - * \returns OKAY if successful. */ -int vs2005_solution_platforms(Session sess, Solution sln, Stream strm) +int vs2005_solution_platforms(Solution sln, Stream strm) { int i, n, z; - UNUSED(sess); z = stream_writeline(strm, "Global"); z |= stream_writeline(strm, "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution"); @@ -39,15 +34,10 @@ int vs2005_solution_platforms(Session sess, Solution sln, Stream strm) /** * Write out the Visual Studio 2005 project-level platform configurations block. - * \param sess The execution session context. - * \param sln The current solution. - * \param strm The currently active stream; set with session_set_active_stream(). - * \returns OKAY if successful. */ -int vs2005_solution_project_platforms(Session sess, Solution sln, Stream strm) +int vs2005_solution_project_platforms(Solution sln, Stream strm) { int pi, pn, z; - UNUSED(sess); z = stream_writeline(strm, "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution"); pn = solution_num_projects(sln); for (pi = 0; pi < pn; ++pi) @@ -71,15 +61,10 @@ int vs2005_solution_project_platforms(Session sess, Solution sln, Stream strm) /** * Write out the Visual Studio 2005 solution properties block. - * \param sess The execution session context. - * \param sln The current solution. - * \param strm The currently active stream; set with session_set_active_stream(). - * \returns OKAY if successful. */ -int vs2005_solution_properties(Session sess, Solution sln, Stream strm) +int vs2005_solution_properties(Solution sln, Stream strm) { int z; - UNUSED(sess); UNUSED(sln); z = stream_writeline(strm, "\tGlobalSection(SolutionProperties) = preSolution"); z |= stream_writeline(strm, "\t\tHideSolutionNode = FALSE"); @@ -91,15 +76,10 @@ int vs2005_solution_properties(Session sess, Solution sln, Stream strm) /** * Write the Visual Studio 2005 solution file signature. - * \param sess The execution session context. - * \param sln The current solution. - * \param strm The currently active stream; set with session_set_active_stream(). - * \returns OKAY if successful. */ -int vs2005_solution_signature(Session sess, Solution sln, Stream strm) +int vs2005_solution_signature(Solution sln, Stream strm) { int z; - UNUSED(sess); UNUSED(sln); stream_set_newline(strm, "\r\n"); z = stream_write_unicode_marker(strm); diff --git a/src/actions/vs200x/vs2008_solution.c b/src/actions/vs200x/vs2008_solution.c index 856bd51..d116a53 100644 --- a/src/actions/vs200x/vs2008_solution.c +++ b/src/actions/vs200x/vs2008_solution.c @@ -10,15 +10,10 @@ /** * Write the Visual Studio 2008 solution file signature. - * \param sess The execution session context. - * \param sln The current solution. - * \param strm The currently active stream; set with session_set_active_stream(). - * \returns OKAY if successful. */ -int vs2008_solution_signature(Session sess, Solution sln, Stream strm) +int vs2008_solution_signature(Solution sln, Stream strm) { int z; - UNUSED(sess); UNUSED(sln); stream_set_newline(strm, "\r\n"); z = stream_write_unicode_marker(strm); diff --git a/src/actions/vs200x/vs200x.c b/src/actions/vs200x/vs200x.c index 91b4cfb..9273c19 100644 --- a/src/actions/vs200x/vs200x.c +++ b/src/actions/vs200x/vs200x.c @@ -11,6 +11,7 @@ #include "vs200x.h" #include "base/buffers.h" #include "base/cstr.h" +#include "base/env.h" #include "base/error.h" @@ -65,16 +66,16 @@ int vs200x_list_attribute(Stream strm, int indent_size, const char* name, String /** * Write the ending part of an XML tag, adjust for the differing Visual Studio formats. - * \param sess The current execution session. * \param strm The output stream. * \param level The XML element nesting level. * \param markup The end tag markup. * \returns OKAY if successful. */ -int vs200x_element_end(Session sess, Stream strm, int level, const char* markup) +int vs200x_element_end(Stream strm, int level, const char* markup) { - int z; - int version = vs200x_get_target_version(sess); + int z, version; + + version = vs200x_get_target_version(); if (version >= 2005) { z = stream_writeline(strm, ""); @@ -97,21 +98,20 @@ int vs200x_element_end(Session sess, Stream strm, int level, const char* markup) * Return the Visual Studio version appropriate version of the string for a false * value. Before 2005 this was "FALSE", after it is "false". */ -const char* vs200x_false(Session sess) +const char* vs200x_false(void) { - int version = vs200x_get_target_version(sess); + int version = vs200x_get_target_version(); return (version < 2005) ? "FALSE" : "false"; } /** * Converts the session action string to a Visual Studio version number. - * \param sess The current execution session. * \returns The Visual Studio version number corresponding to the current action. */ -int vs200x_get_target_version(Session sess) +int vs200x_get_target_version(void) { - const char* action = session_get_action(sess); + const char* action = env_get_action(); if (cstr_eq(action, "vs2002")) { return 2002; @@ -183,8 +183,8 @@ const char* vs200x_tool_guid(const char* language) * Return the Visual Studio version appropriate version of the string for a true * value. Before 2005 this was "TRUE", after it is "true". */ -const char* vs200x_true(Session sess) +const char* vs200x_true(void) { - int version = vs200x_get_target_version(sess); + int version = vs200x_get_target_version(); return (version < 2005) ? "TRUE" : "true"; } diff --git a/src/actions/vs200x/vs200x.h b/src/actions/vs200x/vs200x.h index b99c2f5..3069b8d 100644 --- a/src/actions/vs200x/vs200x.h +++ b/src/actions/vs200x/vs200x.h @@ -6,16 +6,17 @@ #if !defined(PREMAKE_VS200X_H) #define PREMAKE_VS200X_H -#include "session/session.h" +#include "objects/project.h" +#include "base/stream.h" int vs200x_attribute(Stream strm, int indent_size, const char* name, const char* value, ...); int vs200x_list_attribute(Stream strm, int indent_size, const char* name, Strings values); -int vs200x_element_end(Session sess, Stream strm, int level, const char* markup); -const char* vs200x_false(Session sess); -int vs200x_get_target_version(Session sess); +int vs200x_element_end(Stream strm, int level, const char* markup); +const char* vs200x_false(void); +int vs200x_get_target_version(void); const char* vs200x_project_file_extension(Project prj); const char* vs200x_tool_guid(const char* language); -const char* vs200x_true(Session sess); +const char* vs200x_true(void); #endif diff --git a/src/actions/vs200x/vs200x_config.c b/src/actions/vs200x/vs200x_config.c index 3e94305..4848169 100644 --- a/src/actions/vs200x/vs200x_config.c +++ b/src/actions/vs200x/vs200x_config.c @@ -9,10 +9,9 @@ #include "vs200x_config.h" -int vs200x_config_character_set(Session sess, Stream strm) +int vs200x_config_character_set(Stream strm) { - int version = vs200x_get_target_version(sess); - return vs200x_attribute(strm, 3, "CharacterSet", version > 2003 ? "1" : "2"); + return vs200x_attribute(strm, 3, "CharacterSet", vs200x_get_target_version() > 2003 ? "1" : "2"); } @@ -20,45 +19,39 @@ int vs200x_config_character_set(Session sess, Stream strm) * Write out the list of preprocessor symbols as defined by the configuration. * This entry is only written if there are values to write. */ -int vs200x_config_defines(Session sess, Stream strm, Project prj) +int vs200x_config_defines(Stream strm, Project prj) { Strings values = project_get_config_values(prj, BlockDefines); - UNUSED(sess); if (strings_size(values) > 0) { return vs200x_list_attribute(strm, 4, "PreprocessorDefinitions", values); } + return OKAY; } -int vs200x_config_detect_64bit_portability(Session sess, Stream strm, Project prj) +int vs200x_config_detect_64bit_portability(Stream strm) { - int version = vs200x_get_target_version(sess); - UNUSED(prj); - if (version < 2008) + if (vs200x_get_target_version() < 2008) { - return vs200x_attribute(strm, 4, "Detect64BitPortabilityProblems", vs200x_true(sess)); + return vs200x_attribute(strm, 4, "Detect64BitPortabilityProblems", vs200x_true()); } return OKAY; } -int vs200x_config_runtime_type_info(Session sess, Stream strm, Project prj) +int vs200x_config_runtime_type_info(Stream strm) { - int version = vs200x_get_target_version(sess); - UNUSED(prj); - if (version < 2005) + if (vs200x_get_target_version() < 2005) { - return vs200x_attribute(strm, 4, "RuntimeTypeInfo", vs200x_true(sess)); + return vs200x_attribute(strm, 4, "RuntimeTypeInfo", vs200x_true()); } return OKAY; } -int vs200x_config_use_precompiled_header(Session sess, Stream strm, Project prj) +int vs200x_config_use_precompiled_header(Stream strm) { - int version = vs200x_get_target_version(sess); - UNUSED(prj); - return vs200x_attribute(strm, 4, "UsePrecompiledHeader", (version > 2003) ? "0" : "2"); + return vs200x_attribute(strm, 4, "UsePrecompiledHeader", vs200x_get_target_version() > 2003 ? "0" : "2"); } diff --git a/src/actions/vs200x/vs200x_config.h b/src/actions/vs200x/vs200x_config.h index 53172e9..8c8909d 100644 --- a/src/actions/vs200x/vs200x_config.h +++ b/src/actions/vs200x/vs200x_config.h @@ -6,12 +6,10 @@ #if !defined(PREMAKE_VS200X_CONFIG_H) #define PREMAKE_VS200X_CONFIG_H -#include "session/session.h" - -int vs200x_config_character_set(Session sess, Stream strm); -int vs200x_config_defines(Session sess, Stream strm, Project prj); -int vs200x_config_detect_64bit_portability(Session sess, Stream strm, Project prj); -int vs200x_config_runtime_type_info(Session sess, Stream strm, Project prj); -int vs200x_config_use_precompiled_header(Session sess, Stream strm, Project prj); +int vs200x_config_character_set(Stream strm); +int vs200x_config_defines(Stream strm, Project prj); +int vs200x_config_detect_64bit_portability(Stream strm); +int vs200x_config_runtime_type_info(Stream strm); +int vs200x_config_use_precompiled_header(Stream strm); #endif diff --git a/src/actions/vs200x/vs200x_project.c b/src/actions/vs200x/vs200x_project.c index 2fda5ad..c34c974 100644 --- a/src/actions/vs200x/vs200x_project.c +++ b/src/actions/vs200x/vs200x_project.c @@ -18,17 +18,18 @@ /** * Write the opening [Configuration] element and attributes. */ -int vs200x_project_config_element(Session sess, Project prj, Stream strm) +int vs200x_project_config_element(Project prj, Stream strm) { int z = OKAY; - const char* cfg_name = project_get_configuration_filter(prj); + const char* cfg_name = project_get_config(prj); + z |= stream_write(strm, "\t\t<Configuration"); z |= vs200x_attribute(strm, 3, "Name", "%s|Win32", cfg_name); z |= vs200x_attribute(strm, 3, "OutputDirectory", "$(SolutionDir)$(ConfigurationName)"); z |= vs200x_attribute(strm, 3, "IntermediateDirectory", "$(ConfigurationName)"); z |= vs200x_attribute(strm, 3, "ConfigurationType", "1"); - z |= vs200x_config_character_set(sess, strm); - z |= vs200x_element_end(sess, strm, 2, ">"); + z |= vs200x_config_character_set(strm); + z |= vs200x_element_end(strm, 2, ">"); return z; } @@ -36,9 +37,8 @@ int vs200x_project_config_element(Session sess, Project prj, Stream strm) /** * Write the closing [Configuration] element. */ -int vs200x_project_config_end(Session sess, Project prj, Stream strm) +int vs200x_project_config_end(Project prj, Stream strm) { - UNUSED(sess); UNUSED(prj); return stream_writeline(strm, "\t\t</Configuration>"); } @@ -47,7 +47,7 @@ int vs200x_project_config_end(Session sess, Project prj, Stream strm) /** * Create a new output stream for a project, and make it active for subsequent writes. */ -int vs200x_project_create(Session sess, Project prj, Stream strm) +int vs200x_project_create(Project prj, Stream strm) { /* create the project file */ const char* extension = vs200x_project_file_extension(prj); @@ -59,7 +59,7 @@ int vs200x_project_create(Session sess, Project prj, Stream strm) } /* make the stream active for the functions that come after */ - session_set_active_stream(sess, strm); + session_set_active_stream(project_get_session(prj), strm); return OKAY; } @@ -67,14 +67,14 @@ int vs200x_project_create(Session sess, Project prj, Stream strm) /** * Write the root [VisualStudioProject] element and attributes. */ -int vs200x_project_element(Session sess, Project prj, Stream strm) +int vs200x_project_element(Project prj, Stream strm) { int version, z; const char* prj_ver; const char* prj_name = project_get_name(prj); const char* prj_guid = project_get_guid(prj); - version = vs200x_get_target_version(sess); + version = vs200x_get_target_version(); switch (version) { default: @@ -101,7 +101,8 @@ int vs200x_project_element(Session sess, Project prj, Stream strm) { z |= vs200x_attribute(strm, 1, "TargetFrameworkVersion", "196613"); } - z |= vs200x_element_end(sess, strm, 0, ">"); + z |= vs200x_element_end(strm, 0, ">"); + return z; } @@ -109,10 +110,9 @@ int vs200x_project_element(Session sess, Project prj, Stream strm) /** * Write the file encoding at the start of the project file. */ -int vs200x_project_encoding(Session sess, Project prj, Stream strm) +int vs200x_project_encoding(Project prj, Stream strm) { int z; - UNUSED(sess); UNUSED(prj); stream_set_newline(strm, "\r\n"); @@ -123,14 +123,13 @@ int vs200x_project_encoding(Session sess, Project prj, Stream strm) /** * Write an individual file entry to the project file; callback for sourcetree_walk(). - * \param sess The current execution session context. * \param prj The current project; contains the file being enumerated. * \param strm The active output stream; for writing the file markup. * \param filename The name of the file to process. * \param state One of the ActionSourceStates, enabling file grouping. * \returns OKAY if successful. */ -int vs200x_project_file(Session sess, Project prj, Stream strm, const char* filename, int state) +int vs200x_project_file(Project prj, Stream strm, const char* filename, int state) { const char* name; const char* ptr; @@ -167,7 +166,7 @@ int vs200x_project_file(Session sess, Project prj, Stream strm, const char* file z |= stream_write(strm, "<Filter"); z |= vs200x_attribute(strm, depth + 1, "Name", name); z |= vs200x_attribute(strm, depth + 1, "Filter", ""); - z |= vs200x_element_end(sess, strm, depth, ">"); + z |= vs200x_element_end(strm, depth, ">"); } break; @@ -184,7 +183,7 @@ int vs200x_project_file(Session sess, Project prj, Stream strm, const char* file z |= stream_write(strm, "<File"); ptr = (filename[0] == '.') ? "" : ".\\"; z |= vs200x_attribute(strm, depth + 1, "RelativePath", "%s%s", ptr, filename); - z |= vs200x_element_end(sess, strm, depth, ">"); + z |= vs200x_element_end(strm, depth, ">"); z |= stream_write_n(strm, "\t", depth); z |= stream_writeline(strm, "</File>"); break; @@ -198,11 +197,11 @@ int vs200x_project_file(Session sess, Project prj, Stream strm, const char* file /** * Write out the [Files] element. */ -int vs200x_project_files(Session sess, Project prj, Stream strm) +int vs200x_project_files(Project prj, Stream strm) { int z = OKAY; z |= stream_writeline(strm, "\t<Files>"); - z |= sourcetree_walk(sess, prj, strm, vs200x_project_file); + z |= sourcetree_walk(prj, strm, vs200x_project_file); z |= stream_writeline(strm, "\t</Files>"); return z; } @@ -211,10 +210,9 @@ int vs200x_project_files(Session sess, Project prj, Stream strm) /** * Write out the [Globals] element. */ -int vs200x_project_globals(Session sess, Project prj, Stream strm) +int vs200x_project_globals(Project prj, Stream strm) { int z = OKAY; - UNUSED(sess); UNUSED(prj); z |= stream_writeline(strm, "\t<Globals>"); z |= stream_writeline(strm, "\t</Globals>"); @@ -226,14 +224,14 @@ int vs200x_project_globals(Session sess, Project prj, Stream strm) /** * Write out the platforms section of a project file. */ -int vs200x_project_platforms(Session sess, Project prj, Stream strm) +int vs200x_project_platforms(Project prj, Stream strm) { int z = OKAY; UNUSED(prj); z |= stream_writeline(strm, "\t<Platforms>"); z |= stream_write(strm, "\t\t<Platform"); z |= vs200x_attribute(strm, 3, "Name", "Win32"); - z |= vs200x_element_end(sess, strm, 2, "/>"); + z |= vs200x_element_end(strm, 2, "/>"); z |= stream_writeline(strm, "\t</Platforms>"); return OKAY; } @@ -242,12 +240,13 @@ int vs200x_project_platforms(Session sess, Project prj, Stream strm) /** * Write out the [References] element and attributes. */ -int vs200x_project_references(Session sess, Project prj, Stream strm) +int vs200x_project_references(Project prj, Stream strm) { int z; UNUSED(prj); + z = stream_writeline(strm, "\t</Configurations>"); - if (vs200x_get_target_version(sess) > 2002) + if (vs200x_get_target_version() > 2002) { z |= stream_writeline(strm, "\t<References>"); z |= stream_writeline(strm, "\t</References>"); @@ -259,13 +258,12 @@ int vs200x_project_references(Session sess, Project prj, Stream strm) /** * Write out the [ToolFiles] section of a Visual Studio project. */ -int vs200x_project_tool_files(Session sess, Project prj, Stream strm) +int vs200x_project_tool_files(Project prj, Stream strm) { - int version, z = OKAY; + int z = OKAY; UNUSED(prj); - version = vs200x_get_target_version(sess); - if (version > 2003) + if (vs200x_get_target_version() > 2003) { z |= stream_writeline(strm, "\t<ToolFiles>"); z |= stream_writeline(strm, "\t</ToolFiles>"); @@ -278,13 +276,13 @@ int vs200x_project_tool_files(Session sess, Project prj, Stream strm) /** * Common function to write an empty [Tool] element. */ -static int vs200x_project_vc_empty_tool(Session sess, Project prj, Stream strm, const char* name) +static int vs200x_project_vc_empty_tool(Project prj, Stream strm, const char* name) { - int z; + int z = OKAY; UNUSED(prj); - z = stream_write(strm, "\t\t\t<Tool"); + z |= stream_write(strm, "\t\t\t<Tool"); z |= vs200x_attribute(strm, 4, "Name", name); - z |= vs200x_element_end(sess, strm, 3, "/>"); + z |= vs200x_element_end(strm, 3, "/>"); return z; } @@ -292,49 +290,49 @@ static int vs200x_project_vc_empty_tool(Session sess, Project prj, Stream strm, /** * Write the VCALinkTool [Tool] element and attributes. */ -int vs200x_project_vc_alink_tool(Session sess, Project prj, Stream strm) +int vs200x_project_vc_alink_tool(Project prj, Stream strm) { - return vs200x_project_vc_empty_tool(sess, prj, strm, "VCALinkTool"); + return vs200x_project_vc_empty_tool(prj, strm, "VCALinkTool"); } /** * Write the VCAppVerifierTool [Tool] element and attributes. */ -int vs200x_project_vc_app_verifier_tool(Session sess, Project prj, Stream strm) +int vs200x_project_vc_app_verifier_tool(Project prj, Stream strm) { - return vs200x_project_vc_empty_tool(sess, prj, strm, "VCAppVerifierTool"); + return vs200x_project_vc_empty_tool(prj, strm, "VCAppVerifierTool"); } /** * Write the VCBscMakeTool [Tool] element and attributes. */ -int vs200x_project_vc_bsc_make_tool(Session sess, Project prj, Stream strm) +int vs200x_project_vc_bsc_make_tool(Project prj, Stream strm) { - return vs200x_project_vc_empty_tool(sess, prj, strm, "VCBscMakeTool"); + return vs200x_project_vc_empty_tool(prj, strm, "VCBscMakeTool"); } /** * Write the VCCLCompilerTool [Tool] element and attributes. */ -int vs200x_project_vc_cl_compiler_tool(Session sess, Project prj, Stream strm) +int vs200x_project_vc_cl_compiler_tool(Project prj, Stream strm) { int z = OKAY; z |= stream_write(strm, "\t\t\t<Tool"); z |= vs200x_attribute(strm, 4, "Name", "VCCLCompilerTool"); z |= vs200x_attribute(strm, 4, "Optimization", "0"); - z |= vs200x_config_defines(sess, strm, prj); - z |= vs200x_attribute(strm, 4, "MinimalRebuild", vs200x_true(sess)); + z |= vs200x_config_defines(strm, prj); + z |= vs200x_attribute(strm, 4, "MinimalRebuild", vs200x_true()); z |= vs200x_attribute(strm, 4, "BasicRuntimeChecks", "3"); z |= vs200x_attribute(strm, 4, "RuntimeLibrary", "3"); - z |= vs200x_config_runtime_type_info(sess, strm, prj); - z |= vs200x_config_use_precompiled_header(sess, strm, prj); + z |= vs200x_config_runtime_type_info(strm); + z |= vs200x_config_use_precompiled_header(strm); z |= vs200x_attribute(strm, 4, "WarningLevel", "3"); - z |= vs200x_config_detect_64bit_portability(sess, strm, prj); + z |= vs200x_config_detect_64bit_portability(strm); z |= vs200x_attribute(strm, 4, "DebugInformationFormat", "4"); - z |= vs200x_element_end(sess, strm, 3, "/>"); + z |= vs200x_element_end(strm, 3, "/>"); return z; } @@ -342,36 +340,36 @@ int vs200x_project_vc_cl_compiler_tool(Session sess, Project prj, Stream strm) /** * Write the VCCustomBuildTool [Tool] element and attributes. */ -int vs200x_project_vc_custom_build_tool(Session sess, Project prj, Stream strm) +int vs200x_project_vc_custom_build_tool(Project prj, Stream strm) { - return vs200x_project_vc_empty_tool(sess, prj, strm, "VCCustomBuildTool"); + return vs200x_project_vc_empty_tool(prj, strm, "VCCustomBuildTool"); } /** * Write the VCFxCopTool [Tool] element and attributes. */ -int vs200x_project_vc_fx_cop_tool(Session sess, Project prj, Stream strm) +int vs200x_project_vc_fx_cop_tool(Project prj, Stream strm) { - return vs200x_project_vc_empty_tool(sess, prj, strm, "VCFxCopTool"); + return vs200x_project_vc_empty_tool(prj, strm, "VCFxCopTool"); } /** * Write the VCLinkerTool [Tool] element and attributes. */ -int vs200x_project_vc_linker_tool(Session sess, Project prj, Stream strm) +int vs200x_project_vc_linker_tool(Project prj, Stream strm) { - int z; + int z = OKAY; UNUSED(prj); - z = stream_write(strm, "\t\t\t<Tool"); + z |= stream_write(strm, "\t\t\t<Tool"); z |= vs200x_attribute(strm, 4, "Name", "VCLinkerTool"); z |= vs200x_attribute(strm, 4, "LinkIncremental", "2"); - z |= vs200x_attribute(strm, 4, "GenerateDebugInformation", vs200x_true(sess)); + z |= vs200x_attribute(strm, 4, "GenerateDebugInformation", vs200x_true()); z |= vs200x_attribute(strm, 4, "SubSystem", "1"); z |= vs200x_attribute(strm, 4, "EntryPointSymbol", "mainCRTStartup"); z |= vs200x_attribute(strm, 4, "TargetMachine", "1"); - z |= vs200x_element_end(sess, strm, 3, "/>"); + z |= vs200x_element_end(strm, 3, "/>"); return z; } @@ -379,97 +377,97 @@ int vs200x_project_vc_linker_tool(Session sess, Project prj, Stream strm) /** * Write the VCManagedResourceCompilerTool [Tool] element and attributes. */ -int vs200x_project_vc_managed_resource_compiler_tool(Session sess, Project prj, Stream strm) +int vs200x_project_vc_managed_resource_compiler_tool(Project prj, Stream strm) { - return vs200x_project_vc_empty_tool(sess, prj, strm, "VCManagedResourceCompilerTool"); + return vs200x_project_vc_empty_tool(prj, strm, "VCManagedResourceCompilerTool"); } /** * Write the VCManifestTool [Tool] element and attributes. */ -int vs200x_project_vc_manifest_tool(Session sess, Project prj, Stream strm) +int vs200x_project_vc_manifest_tool(Project prj, Stream strm) { - return vs200x_project_vc_empty_tool(sess, prj, strm, "VCManifestTool"); + return vs200x_project_vc_empty_tool(prj, strm, "VCManifestTool"); } /** * Write the VCMIDLTool [Tool] element and attributes. */ -int vs200x_project_vc_midl_tool(Session sess, Project prj, Stream strm) +int vs200x_project_vc_midl_tool(Project prj, Stream strm) { - return vs200x_project_vc_empty_tool(sess, prj, strm, "VCMIDLTool"); + return vs200x_project_vc_empty_tool(prj, strm, "VCMIDLTool"); } /** * Write the VCPreBuildEventTool [Tool] element and attributes. */ -int vs200x_project_vc_pre_build_event_tool(Session sess, Project prj, Stream strm) +int vs200x_project_vc_pre_build_event_tool(Project prj, Stream strm) { - return vs200x_project_vc_empty_tool(sess, prj, strm, "VCPreBuildEventTool"); + return vs200x_project_vc_empty_tool(prj, strm, "VCPreBuildEventTool"); } /** * Write the VCPreLinkEventTool [Tool] element and attributes. */ -int vs200x_project_vc_pre_link_event_tool(Session sess, Project prj, Stream strm) +int vs200x_project_vc_pre_link_event_tool(Project prj, Stream strm) { - return vs200x_project_vc_empty_tool(sess, prj, strm, "VCPreLinkEventTool"); + return vs200x_project_vc_empty_tool(prj, strm, "VCPreLinkEventTool"); } /** * Write the VCPostBuildEventTool [Tool] element and attributes. */ -int vs200x_project_vc_post_build_event_tool(Session sess, Project prj, Stream strm) +int vs200x_project_vc_post_build_event_tool(Project prj, Stream strm) { - return vs200x_project_vc_empty_tool(sess, prj, strm, "VCPostBuildEventTool"); + return vs200x_project_vc_empty_tool(prj, strm, "VCPostBuildEventTool"); } /** * Write the VCResourceCompiler [Tool] element and attributes. */ -int vs200x_project_vc_resource_compiler_tool(Session sess, Project prj, Stream strm) +int vs200x_project_vc_resource_compiler_tool(Project prj, Stream strm) { - return vs200x_project_vc_empty_tool(sess, prj, strm, "VCResourceCompilerTool"); + return vs200x_project_vc_empty_tool(prj, strm, "VCResourceCompilerTool"); } /** * Write the VCWebDeploymentTool [Tool] element and attributes. */ -int vs200x_project_vc_web_deployment_tool(Session sess, Project prj, Stream strm) +int vs200x_project_vc_web_deployment_tool(Project prj, Stream strm) { - return vs200x_project_vc_empty_tool(sess, prj, strm, "VCWebDeploymentTool"); + return vs200x_project_vc_empty_tool(prj, strm, "VCWebDeploymentTool"); } /** * Write the VCWebServiceProxyGeneratorTool [Tool] element and attributes. */ -int vs200x_project_vc_web_service_proxy_generator_tool(Session sess, Project prj, Stream strm) +int vs200x_project_vc_web_service_proxy_generator_tool(Project prj, Stream strm) { - return vs200x_project_vc_empty_tool(sess, prj, strm, "VCWebServiceProxyGeneratorTool"); + return vs200x_project_vc_empty_tool(prj, strm, "VCWebServiceProxyGeneratorTool"); } /** * Write the VCXDCMakeTool [Tool] element and attributes. */ -int vs200x_project_vc_xdc_make_tool(Session sess, Project prj, Stream strm) +int vs200x_project_vc_xdc_make_tool(Project prj, Stream strm) { - return vs200x_project_vc_empty_tool(sess, prj, strm, "VCXDCMakeTool"); + return vs200x_project_vc_empty_tool(prj, strm, "VCXDCMakeTool"); } /** * Write the VCXMLDataGeneratorTool [Tool] element and attributes. */ -int vs200x_project_vc_xml_data_generator_tool(Session sess, Project prj, Stream strm) +int vs200x_project_vc_xml_data_generator_tool(Project prj, Stream strm) { - return vs200x_project_vc_empty_tool(sess, prj, strm, "VCXMLDataGeneratorTool"); + return vs200x_project_vc_empty_tool(prj, strm, "VCXMLDataGeneratorTool"); } diff --git a/src/actions/vs200x/vs200x_project.h b/src/actions/vs200x/vs200x_project.h index a4950f9..020cdea 100644 --- a/src/actions/vs200x/vs200x_project.h +++ b/src/actions/vs200x/vs200x_project.h @@ -6,36 +6,34 @@ #if !defined(PREMAKE_VS200X_PROJECT_H) #define PREMAKE_VS200X_PROJECT_H -#include "session/session.h" - -int vs200x_project_config_element(Session sess, Project prj, Stream strm); -int vs200x_project_config_end(Session sess, Project prj, Stream strm); -int vs200x_project_create(Session sess, Project prj, Stream strm); -int vs200x_project_element(Session sess, Project prj, Stream strm); -int vs200x_project_encoding(Session sess, Project prj, Stream strm); -int vs200x_project_file(Session sess, Project prj, Stream strm, const char* filename, int state); -int vs200x_project_files(Session sess, Project prj, Stream strm); -int vs200x_project_globals(Session sess, Project prj, Stream strm); -int vs200x_project_platforms(Session sess, Project prj, Stream strm); -int vs200x_project_references(Session sess, Project prj, Stream strm); -int vs200x_project_tool_files(Session sess, Project prj, Stream strm); -int vs200x_project_vc_alink_tool(Session sess, Project prj, Stream strm); -int vs200x_project_vc_app_verifier_tool(Session sess, Project prj, Stream strm); -int vs200x_project_vc_bsc_make_tool(Session sess, Project prj, Stream strm); -int vs200x_project_vc_cl_compiler_tool(Session sess, Project prj, Stream strm); -int vs200x_project_vc_custom_build_tool(Session sess, Project prj, Stream strm); -int vs200x_project_vc_fx_cop_tool(Session sess, Project prj, Stream strm); -int vs200x_project_vc_midl_tool(Session sess, Project prj, Stream strm); -int vs200x_project_vc_linker_tool(Session sess, Project prj, Stream strm); -int vs200x_project_vc_managed_resource_compiler_tool(Session sess, Project prj, Stream strm); -int vs200x_project_vc_manifest_tool(Session sess, Project prj, Stream strm); -int vs200x_project_vc_pre_build_event_tool(Session sess, Project prj, Stream strm); -int vs200x_project_vc_pre_link_event_tool(Session sess, Project prj, Stream strm); -int vs200x_project_vc_post_build_event_tool(Session sess, Project prj, Stream strm); -int vs200x_project_vc_resource_compiler_tool(Session sess, Project prj, Stream strm); -int vs200x_project_vc_web_deployment_tool(Session sess, Project prj, Stream strm); -int vs200x_project_vc_web_service_proxy_generator_tool(Session sess, Project prj, Stream strm); -int vs200x_project_vc_xdc_make_tool(Session sess, Project prj, Stream strm); -int vs200x_project_vc_xml_data_generator_tool(Session sess, Project prj, Stream strm); +int vs200x_project_config_element(Project prj, Stream strm); +int vs200x_project_config_end(Project prj, Stream strm); +int vs200x_project_create(Project prj, Stream strm); +int vs200x_project_element(Project prj, Stream strm); +int vs200x_project_encoding(Project prj, Stream strm); +int vs200x_project_file(Project prj, Stream strm, const char* filename, int state); +int vs200x_project_files(Project prj, Stream strm); +int vs200x_project_globals(Project prj, Stream strm); +int vs200x_project_platforms(Project prj, Stream strm); +int vs200x_project_references(Project prj, Stream strm); +int vs200x_project_tool_files(Project prj, Stream strm); +int vs200x_project_vc_alink_tool(Project prj, Stream strm); +int vs200x_project_vc_app_verifier_tool(Project prj, Stream strm); +int vs200x_project_vc_bsc_make_tool(Project prj, Stream strm); +int vs200x_project_vc_cl_compiler_tool(Project prj, Stream strm); +int vs200x_project_vc_custom_build_tool(Project prj, Stream strm); +int vs200x_project_vc_fx_cop_tool(Project prj, Stream strm); +int vs200x_project_vc_midl_tool(Project prj, Stream strm); +int vs200x_project_vc_linker_tool(Project prj, Stream strm); +int vs200x_project_vc_managed_resource_compiler_tool(Project prj, Stream strm); +int vs200x_project_vc_manifest_tool(Project prj, Stream strm); +int vs200x_project_vc_pre_build_event_tool(Project prj, Stream strm); +int vs200x_project_vc_pre_link_event_tool(Project prj, Stream strm); +int vs200x_project_vc_post_build_event_tool(Project prj, Stream strm); +int vs200x_project_vc_resource_compiler_tool(Project prj, Stream strm); +int vs200x_project_vc_web_deployment_tool(Project prj, Stream strm); +int vs200x_project_vc_web_service_proxy_generator_tool(Project prj, Stream strm); +int vs200x_project_vc_xdc_make_tool(Project prj, Stream strm); +int vs200x_project_vc_xml_data_generator_tool(Project prj, Stream strm); #endif diff --git a/src/actions/vs200x/vs200x_solution.c b/src/actions/vs200x/vs200x_solution.c index 6578bd4..23faa42 100644 --- a/src/actions/vs200x/vs200x_solution.c +++ b/src/actions/vs200x/vs200x_solution.c @@ -12,12 +12,8 @@ /** * Create a new output stream for a solution, and make it active for subsequent writes. - * \param sess The execution session context. - * \param sln The current solution. - * \param strm The currently active stream; set with session_set_active_stream(). - * \returns OKAY if successful. */ -int vs200x_solution_create(Session sess, Solution sln, Stream strm) +int vs200x_solution_create(Solution sln, Stream strm) { /* create the solution file */ const char* filename = solution_get_filename(sln, NULL, ".sln"); @@ -28,6 +24,6 @@ int vs200x_solution_create(Session sess, Solution sln, Stream strm) } /* make the stream active for the functions that come after */ - session_set_active_stream(sess, strm); + session_set_active_stream(solution_get_session(sln), strm); return OKAY; } diff --git a/src/actions/vs200x/vs200x_solution.h b/src/actions/vs200x/vs200x_solution.h index 18683c4..0917ca9 100644 --- a/src/actions/vs200x/vs200x_solution.h +++ b/src/actions/vs200x/vs200x_solution.h @@ -6,25 +6,25 @@ #if !defined(PREMAKE_VS200X_SOLUTION_H) #define PREMAKE_VS200X_SOLUTION_H -#include "session/session.h" +#include "objects/solution.h" -int vs2002_solution_configuration(Session sess, Solution sln, Stream strm); -int vs2002_solution_dependencies(Session sess, Solution sln, Stream strm); -int vs2002_solution_extensibility(Session sess, Solution sln, Stream strm); -int vs2002_solution_project_configuration(Session sess, Solution sln, Stream strm); -int vs2002_solution_projects(Session sess, Solution sln, Stream strm); -int vs2002_solution_signature(Session sess, Solution sln, Stream strm); +int vs2002_solution_configuration(Solution sln, Stream strm); +int vs2002_solution_dependencies(Solution sln, Stream strm); +int vs2002_solution_extensibility(Solution sln, Stream strm); +int vs2002_solution_project_configuration(Solution sln, Stream strm); +int vs2002_solution_projects(Solution sln, Stream strm); +int vs2002_solution_signature(Solution sln, Stream strm); -int vs2003_solution_configuration(Session sess, Solution sln, Stream strm); -int vs2003_solution_signature(Session sess, Solution sln, Stream strm); +int vs2003_solution_configuration(Solution sln, Stream strm); +int vs2003_solution_signature(Solution sln, Stream strm); -int vs2005_solution_platforms(Session sess, Solution sln, Stream strm); -int vs2005_solution_project_platforms(Session sess, Solution sln, Stream strm); -int vs2005_solution_properties(Session sess, Solution sln, Stream strm); -int vs2005_solution_signature(Session sess, Solution sln, Stream strm); +int vs2005_solution_platforms(Solution sln, Stream strm); +int vs2005_solution_project_platforms(Solution sln, Stream strm); +int vs2005_solution_properties(Solution sln, Stream strm); +int vs2005_solution_signature(Solution sln, Stream strm); -int vs2008_solution_signature(Session sess, Solution sln, Stream strm); +int vs2008_solution_signature(Solution sln, Stream strm); -int vs200x_solution_create(Session sess, Solution sln, Stream strm); +int vs200x_solution_create(Solution sln, Stream strm); #endif diff --git a/src/base/cstr.c b/src/base/cstr.c index dfaf348..4fa588d 100644 --- a/src/base/cstr.c +++ b/src/base/cstr.c @@ -12,6 +12,7 @@ #include "premake.h" #include "base/buffers.h" #include "base/cstr.h" +#include "base/luastate.h" /** @@ -112,6 +113,70 @@ char* cstr_format(const char* format, ...) /** + * Compares a string value with a pattern, using the Lua pattern syntax, and + * returns true if there is a match. + */ +int cstr_matches_pattern(const char* str, const char* pattern) +{ + lua_State* L; + char* buffer; + int i, escaped, top, result, is_my_state = 0; + + assert(str); + assert(pattern); + + /* convert pattern to match any case, each non-escaped letter A becomes [Aa] */ + buffer = buffers_next(); + i = 0; + escaped = 0; + while (*pattern != '\0') + { + if (isalpha(*pattern) && !escaped) + { + buffer[i++] = '['; + buffer[i++] = (char)toupper(*pattern); + buffer[i++] = (char)tolower(*pattern); + buffer[i++] = ']'; + } + else + { + escaped = (*pattern == '%'); + buffer[i++] = *pattern; + } + + pattern++; + } + buffer[i] = '\0'; + + /* connect to Lua so I can call the match() function */ + L = luastate_get_current(); + is_my_state = (L == NULL); + if (is_my_state) + { + L = luastate_create(); + } + top = lua_gettop(L); + + /* retrieve the match() function and call it */ + lua_getglobal(L, "string"); + lua_getfield(L, -1, "match"); + lua_pushstring(L, str); + lua_pushstring(L, buffer); + lua_call(L, 2, 1); + result = cstr_eq(str, lua_tostring(L,-1)); + + /* clean up and return the result */ + lua_settop(L, top); + if (is_my_state) + { + luastate_destroy(L); + } + + return result; +} + + +/** * Determines if the given C string starts with a particular sequence. * \param str The string to test. * \param expected The sequence for which to look. diff --git a/src/base/cstr.h b/src/base/cstr.h index b03c9da..fdf7e00 100644 --- a/src/base/cstr.h +++ b/src/base/cstr.h @@ -18,6 +18,7 @@ int cstr_ends_with(const char* str, const char* expected); int cstr_eq(const char* str, const char* expected); int cstr_eqi(const char* str, const char* expected); char* cstr_format(const char* format, ...); +int cstr_matches_pattern(const char* str, const char* pattern); int cstr_starts_with(const char* str, const char* expected); char* cstr_to_identifier(const char* str); void cstr_trim(char* str, char ch); diff --git a/src/base/env.c b/src/base/env.c new file mode 100644 index 0000000..1774c98 --- /dev/null +++ b/src/base/env.c @@ -0,0 +1,98 @@ +/** + * \file env.c + * \brief Manage the runtime environment state. + * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project + */ + +#include <assert.h> +#include <stdlib.h> +#include "premake.h" +#include "env.h" +#include "platform/platform.h" + + +static enum OS CurrentOS = UnknownOS; +static const char* Action = NULL; + + +/** + * Retrieve the current action being targeted. Will return NULL if no action + * has been set. + */ +const char* env_get_action(void) +{ + return Action; +} + + +/** + * Identify the target OS. This value will be set to the current OS by default, + * but can be overridden by calling env_set_os_by_name(). + */ +enum OS env_get_os(void) +{ + if (CurrentOS == UnknownOS) + { +#if defined(PLATFORM_BSD) + CurrentOS = BSD; +#elif defined(PLATFORM_LINUX) + CurrentOS = Linux; +#elif defined(PLATFORM_MACOSX) + CurrentOS = MacOSX; +#else + CurrentOS = Windows; +#endif + } + return CurrentOS; +} + + +/** + * Identify the target OS with a string name. This value will be set to the current + * OS by default, but can be overridden by calling env_set_os_by_name(). + */ +const char* env_get_os_name(void) +{ + switch (env_get_os()) + { + case BSD: + return "BSD"; + case Linux: + return "Linux"; + case MacOSX: + return "MacOSX"; + case Windows: + return "Windows"; + default: + assert(0); + return 0; + } +} + + +/** + * Returns true if the current OS matches the one provided. + */ +int env_is_os(enum OS id) +{ + return (env_get_os() == id); +} + + +/** + * Set the action being targeted in this run. + */ +void env_set_action(const char* action) +{ + Action = action; +} + + +/** + * Override the default OS identification, allowing generation of project files + * targeted for other platforms (like cross-compiling). + */ +void env_set_os(enum OS id) +{ + CurrentOS = id; +} diff --git a/src/base/env.h b/src/base/env.h new file mode 100644 index 0000000..09d1b46 --- /dev/null +++ b/src/base/env.h @@ -0,0 +1,41 @@ +/** + * \file env.h + * \brief Manage the runtime environment state. + * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project + * + * \defgroup env Runtime Environment + * \ingroup base + * + * Manage the runtime environment state, getting and setting such values as + * the target action and the operating system. + * + * @{ + */ +#if !defined(PREMAKE_ENV_H) +#define PREMAKE_ENV_H + +/** + * The currently supported operating systems. + * \note If you add to this list, be sure to also update the detection + * and string translation logic. + */ +enum OS +{ + UnknownOS, + BSD, + Linux, + MacOSX, + Windows +}; + + +const char* env_get_action(void); +enum OS env_get_os(void); +const char* env_get_os_name(void); +int env_is_os(enum OS id); +void env_set_action(const char* action); +void env_set_os(enum OS id); + + +#endif +/** @} */ diff --git a/src/script/lua-5.1.2/COPYRIGHT b/src/base/lua-5.1.2/COPYRIGHT index a54a16e..a54a16e 100644 --- a/src/script/lua-5.1.2/COPYRIGHT +++ b/src/base/lua-5.1.2/COPYRIGHT diff --git a/src/script/lua-5.1.2/HISTORY b/src/base/lua-5.1.2/HISTORY index ce0c95b..ce0c95b 100644 --- a/src/script/lua-5.1.2/HISTORY +++ b/src/base/lua-5.1.2/HISTORY diff --git a/src/script/lua-5.1.2/INSTALL b/src/base/lua-5.1.2/INSTALL index 17eb8ae..17eb8ae 100644 --- a/src/script/lua-5.1.2/INSTALL +++ b/src/base/lua-5.1.2/INSTALL diff --git a/src/script/lua-5.1.2/Makefile b/src/base/lua-5.1.2/Makefile index c5ec666..c5ec666 100644 --- a/src/script/lua-5.1.2/Makefile +++ b/src/base/lua-5.1.2/Makefile diff --git a/src/script/lua-5.1.2/PREMAKE_CHANGES.txt b/src/base/lua-5.1.2/PREMAKE_CHANGES.txt index ca2f322..ca2f322 100644 --- a/src/script/lua-5.1.2/PREMAKE_CHANGES.txt +++ b/src/base/lua-5.1.2/PREMAKE_CHANGES.txt diff --git a/src/script/lua-5.1.2/README b/src/base/lua-5.1.2/README index 11b4dff..11b4dff 100644 --- a/src/script/lua-5.1.2/README +++ b/src/base/lua-5.1.2/README diff --git a/src/script/lua-5.1.2/doc/amazon.gif b/src/base/lua-5.1.2/doc/amazon.gif Binary files differindex f2586d5..f2586d5 100644 --- a/src/script/lua-5.1.2/doc/amazon.gif +++ b/src/base/lua-5.1.2/doc/amazon.gif diff --git a/src/script/lua-5.1.2/doc/contents.html b/src/base/lua-5.1.2/doc/contents.html index 01b069f..01b069f 100644 --- a/src/script/lua-5.1.2/doc/contents.html +++ b/src/base/lua-5.1.2/doc/contents.html diff --git a/src/script/lua-5.1.2/doc/cover.png b/src/base/lua-5.1.2/doc/cover.png Binary files differindex 2dbb198..2dbb198 100644 --- a/src/script/lua-5.1.2/doc/cover.png +++ b/src/base/lua-5.1.2/doc/cover.png diff --git a/src/script/lua-5.1.2/doc/logo.gif b/src/base/lua-5.1.2/doc/logo.gif Binary files differindex 2f5e4ac..2f5e4ac 100644 --- a/src/script/lua-5.1.2/doc/logo.gif +++ b/src/base/lua-5.1.2/doc/logo.gif diff --git a/src/script/lua-5.1.2/doc/lua.1 b/src/base/lua-5.1.2/doc/lua.1 index 24809cc..24809cc 100644 --- a/src/script/lua-5.1.2/doc/lua.1 +++ b/src/base/lua-5.1.2/doc/lua.1 diff --git a/src/script/lua-5.1.2/doc/lua.css b/src/base/lua-5.1.2/doc/lua.css index 039cf11..039cf11 100644 --- a/src/script/lua-5.1.2/doc/lua.css +++ b/src/base/lua-5.1.2/doc/lua.css diff --git a/src/script/lua-5.1.2/doc/lua.html b/src/base/lua-5.1.2/doc/lua.html index 1d435ab..1d435ab 100644 --- a/src/script/lua-5.1.2/doc/lua.html +++ b/src/base/lua-5.1.2/doc/lua.html diff --git a/src/script/lua-5.1.2/doc/luac.1 b/src/base/lua-5.1.2/doc/luac.1 index d814678..d814678 100644 --- a/src/script/lua-5.1.2/doc/luac.1 +++ b/src/base/lua-5.1.2/doc/luac.1 diff --git a/src/script/lua-5.1.2/doc/luac.html b/src/base/lua-5.1.2/doc/luac.html index 179ffe8..179ffe8 100644 --- a/src/script/lua-5.1.2/doc/luac.html +++ b/src/base/lua-5.1.2/doc/luac.html diff --git a/src/script/lua-5.1.2/doc/manual.css b/src/base/lua-5.1.2/doc/manual.css index 93f1ab2..93f1ab2 100644 --- a/src/script/lua-5.1.2/doc/manual.css +++ b/src/base/lua-5.1.2/doc/manual.css diff --git a/src/script/lua-5.1.2/doc/manual.html b/src/base/lua-5.1.2/doc/manual.html index 6b137ff..6b137ff 100644 --- a/src/script/lua-5.1.2/doc/manual.html +++ b/src/base/lua-5.1.2/doc/manual.html diff --git a/src/script/lua-5.1.2/doc/readme.html b/src/base/lua-5.1.2/doc/readme.html index 28b1d14..28b1d14 100644 --- a/src/script/lua-5.1.2/doc/readme.html +++ b/src/base/lua-5.1.2/doc/readme.html diff --git a/src/script/lua-5.1.2/etc/Makefile b/src/base/lua-5.1.2/etc/Makefile index 6d00008..6d00008 100644 --- a/src/script/lua-5.1.2/etc/Makefile +++ b/src/base/lua-5.1.2/etc/Makefile diff --git a/src/script/lua-5.1.2/etc/README b/src/base/lua-5.1.2/etc/README index 5149fc9..5149fc9 100644 --- a/src/script/lua-5.1.2/etc/README +++ b/src/base/lua-5.1.2/etc/README diff --git a/src/script/lua-5.1.2/etc/all.c b/src/base/lua-5.1.2/etc/all.c index dab68fa..dab68fa 100644 --- a/src/script/lua-5.1.2/etc/all.c +++ b/src/base/lua-5.1.2/etc/all.c diff --git a/src/script/lua-5.1.2/etc/lua.hpp b/src/base/lua-5.1.2/etc/lua.hpp index ec417f5..ec417f5 100644 --- a/src/script/lua-5.1.2/etc/lua.hpp +++ b/src/base/lua-5.1.2/etc/lua.hpp diff --git a/src/script/lua-5.1.2/etc/lua.ico b/src/base/lua-5.1.2/etc/lua.ico Binary files differindex ccbabc4..ccbabc4 100644 --- a/src/script/lua-5.1.2/etc/lua.ico +++ b/src/base/lua-5.1.2/etc/lua.ico diff --git a/src/script/lua-5.1.2/etc/lua.pc b/src/base/lua-5.1.2/etc/lua.pc index 03a2e68..03a2e68 100644 --- a/src/script/lua-5.1.2/etc/lua.pc +++ b/src/base/lua-5.1.2/etc/lua.pc diff --git a/src/script/lua-5.1.2/etc/luavs.bat b/src/base/lua-5.1.2/etc/luavs.bat index 6b1120b..6b1120b 100644 --- a/src/script/lua-5.1.2/etc/luavs.bat +++ b/src/base/lua-5.1.2/etc/luavs.bat diff --git a/src/script/lua-5.1.2/etc/min.c b/src/base/lua-5.1.2/etc/min.c index 404bd50..404bd50 100644 --- a/src/script/lua-5.1.2/etc/min.c +++ b/src/base/lua-5.1.2/etc/min.c diff --git a/src/script/lua-5.1.2/etc/noparser.c b/src/base/lua-5.1.2/etc/noparser.c index 13ba546..13ba546 100644 --- a/src/script/lua-5.1.2/etc/noparser.c +++ b/src/base/lua-5.1.2/etc/noparser.c diff --git a/src/script/lua-5.1.2/etc/strict.lua b/src/base/lua-5.1.2/etc/strict.lua index 16ee26b..16ee26b 100644 --- a/src/script/lua-5.1.2/etc/strict.lua +++ b/src/base/lua-5.1.2/etc/strict.lua diff --git a/src/script/lua-5.1.2/src/Makefile b/src/base/lua-5.1.2/src/Makefile index cd7f6ba..cd7f6ba 100644 --- a/src/script/lua-5.1.2/src/Makefile +++ b/src/base/lua-5.1.2/src/Makefile diff --git a/src/script/lua-5.1.2/src/lapi.c b/src/base/lua-5.1.2/src/lapi.c index 7c532b8..7c532b8 100644 --- a/src/script/lua-5.1.2/src/lapi.c +++ b/src/base/lua-5.1.2/src/lapi.c diff --git a/src/script/lua-5.1.2/src/lapi.h b/src/base/lua-5.1.2/src/lapi.h index 9d1d435..9d1d435 100644 --- a/src/script/lua-5.1.2/src/lapi.h +++ b/src/base/lua-5.1.2/src/lapi.h diff --git a/src/script/lua-5.1.2/src/lauxlib.c b/src/base/lua-5.1.2/src/lauxlib.c index 96a6b85..96a6b85 100644 --- a/src/script/lua-5.1.2/src/lauxlib.c +++ b/src/base/lua-5.1.2/src/lauxlib.c diff --git a/src/script/lua-5.1.2/src/lauxlib.h b/src/base/lua-5.1.2/src/lauxlib.h index 1f34308..1f34308 100644 --- a/src/script/lua-5.1.2/src/lauxlib.h +++ b/src/base/lua-5.1.2/src/lauxlib.h diff --git a/src/script/lua-5.1.2/src/lbaselib.c b/src/base/lua-5.1.2/src/lbaselib.c index 147a727..147a727 100644 --- a/src/script/lua-5.1.2/src/lbaselib.c +++ b/src/base/lua-5.1.2/src/lbaselib.c diff --git a/src/script/lua-5.1.2/src/lcode.c b/src/base/lua-5.1.2/src/lcode.c index 9ce515a..9ce515a 100644 --- a/src/script/lua-5.1.2/src/lcode.c +++ b/src/base/lua-5.1.2/src/lcode.c diff --git a/src/script/lua-5.1.2/src/lcode.h b/src/base/lua-5.1.2/src/lcode.h index c02cb2b..c02cb2b 100644 --- a/src/script/lua-5.1.2/src/lcode.h +++ b/src/base/lua-5.1.2/src/lcode.h diff --git a/src/script/lua-5.1.2/src/ldblib.c b/src/base/lua-5.1.2/src/ldblib.c index 26a19b6..26a19b6 100644 --- a/src/script/lua-5.1.2/src/ldblib.c +++ b/src/base/lua-5.1.2/src/ldblib.c diff --git a/src/script/lua-5.1.2/src/ldebug.c b/src/base/lua-5.1.2/src/ldebug.c index 9c8bdf2..9c8bdf2 100644 --- a/src/script/lua-5.1.2/src/ldebug.c +++ b/src/base/lua-5.1.2/src/ldebug.c diff --git a/src/script/lua-5.1.2/src/ldebug.h b/src/base/lua-5.1.2/src/ldebug.h index 9c76aa1..9c76aa1 100644 --- a/src/script/lua-5.1.2/src/ldebug.h +++ b/src/base/lua-5.1.2/src/ldebug.h diff --git a/src/script/lua-5.1.2/src/ldo.c b/src/base/lua-5.1.2/src/ldo.c index ab86fb7..ab86fb7 100644 --- a/src/script/lua-5.1.2/src/ldo.c +++ b/src/base/lua-5.1.2/src/ldo.c diff --git a/src/script/lua-5.1.2/src/ldo.h b/src/base/lua-5.1.2/src/ldo.h index b2de92b..b2de92b 100644 --- a/src/script/lua-5.1.2/src/ldo.h +++ b/src/base/lua-5.1.2/src/ldo.h diff --git a/src/script/lua-5.1.2/src/ldump.c b/src/base/lua-5.1.2/src/ldump.c index f08277d..f08277d 100644 --- a/src/script/lua-5.1.2/src/ldump.c +++ b/src/base/lua-5.1.2/src/ldump.c diff --git a/src/script/lua-5.1.2/src/lfunc.c b/src/base/lua-5.1.2/src/lfunc.c index 05bd5ff..05bd5ff 100644 --- a/src/script/lua-5.1.2/src/lfunc.c +++ b/src/base/lua-5.1.2/src/lfunc.c diff --git a/src/script/lua-5.1.2/src/lfunc.h b/src/base/lua-5.1.2/src/lfunc.h index 2e02419..2e02419 100644 --- a/src/script/lua-5.1.2/src/lfunc.h +++ b/src/base/lua-5.1.2/src/lfunc.h diff --git a/src/script/lua-5.1.2/src/lgc.c b/src/base/lua-5.1.2/src/lgc.c index 2d24a12..2d24a12 100644 --- a/src/script/lua-5.1.2/src/lgc.c +++ b/src/base/lua-5.1.2/src/lgc.c diff --git a/src/script/lua-5.1.2/src/lgc.h b/src/base/lua-5.1.2/src/lgc.h index 5f69acb..5f69acb 100644 --- a/src/script/lua-5.1.2/src/lgc.h +++ b/src/base/lua-5.1.2/src/lgc.h diff --git a/src/script/lua-5.1.2/src/linit.c b/src/base/lua-5.1.2/src/linit.c index 483d9c8..483d9c8 100644 --- a/src/script/lua-5.1.2/src/linit.c +++ b/src/base/lua-5.1.2/src/linit.c diff --git a/src/script/lua-5.1.2/src/liolib.c b/src/base/lua-5.1.2/src/liolib.c index be60972..be60972 100644 --- a/src/script/lua-5.1.2/src/liolib.c +++ b/src/base/lua-5.1.2/src/liolib.c diff --git a/src/script/lua-5.1.2/src/llex.c b/src/base/lua-5.1.2/src/llex.c index 1c07cad..1c07cad 100644 --- a/src/script/lua-5.1.2/src/llex.c +++ b/src/base/lua-5.1.2/src/llex.c diff --git a/src/script/lua-5.1.2/src/llex.h b/src/base/lua-5.1.2/src/llex.h index ff07e83..ff07e83 100644 --- a/src/script/lua-5.1.2/src/llex.h +++ b/src/base/lua-5.1.2/src/llex.h diff --git a/src/script/lua-5.1.2/src/llimits.h b/src/base/lua-5.1.2/src/llimits.h index b03221a..b03221a 100644 --- a/src/script/lua-5.1.2/src/llimits.h +++ b/src/base/lua-5.1.2/src/llimits.h diff --git a/src/script/lua-5.1.2/src/lmathlib.c b/src/base/lua-5.1.2/src/lmathlib.c index d181a73..d181a73 100644 --- a/src/script/lua-5.1.2/src/lmathlib.c +++ b/src/base/lua-5.1.2/src/lmathlib.c diff --git a/src/script/lua-5.1.2/src/lmem.c b/src/base/lua-5.1.2/src/lmem.c index cef2bc5..cef2bc5 100644 --- a/src/script/lua-5.1.2/src/lmem.c +++ b/src/base/lua-5.1.2/src/lmem.c diff --git a/src/script/lua-5.1.2/src/lmem.h b/src/base/lua-5.1.2/src/lmem.h index 19df1fb..19df1fb 100644 --- a/src/script/lua-5.1.2/src/lmem.h +++ b/src/base/lua-5.1.2/src/lmem.h diff --git a/src/script/lua-5.1.2/src/loadlib.c b/src/base/lua-5.1.2/src/loadlib.c index 808368b..808368b 100644 --- a/src/script/lua-5.1.2/src/loadlib.c +++ b/src/base/lua-5.1.2/src/loadlib.c diff --git a/src/script/lua-5.1.2/src/lobject.c b/src/base/lua-5.1.2/src/lobject.c index acde82c..acde82c 100644 --- a/src/script/lua-5.1.2/src/lobject.c +++ b/src/base/lua-5.1.2/src/lobject.c diff --git a/src/script/lua-5.1.2/src/lobject.h b/src/base/lua-5.1.2/src/lobject.h index 8ce4405..8ce4405 100644 --- a/src/script/lua-5.1.2/src/lobject.h +++ b/src/base/lua-5.1.2/src/lobject.h diff --git a/src/script/lua-5.1.2/src/lopcodes.c b/src/base/lua-5.1.2/src/lopcodes.c index bf9cd52..bf9cd52 100644 --- a/src/script/lua-5.1.2/src/lopcodes.c +++ b/src/base/lua-5.1.2/src/lopcodes.c diff --git a/src/script/lua-5.1.2/src/lopcodes.h b/src/base/lua-5.1.2/src/lopcodes.h index 48105f1..48105f1 100644 --- a/src/script/lua-5.1.2/src/lopcodes.h +++ b/src/base/lua-5.1.2/src/lopcodes.h diff --git a/src/script/lua-5.1.2/src/loslib.c b/src/base/lua-5.1.2/src/loslib.c index fdda474..fdda474 100644 --- a/src/script/lua-5.1.2/src/loslib.c +++ b/src/base/lua-5.1.2/src/loslib.c diff --git a/src/script/lua-5.1.2/src/lparser.c b/src/base/lua-5.1.2/src/lparser.c index 6c473c4..6c473c4 100644 --- a/src/script/lua-5.1.2/src/lparser.c +++ b/src/base/lua-5.1.2/src/lparser.c diff --git a/src/script/lua-5.1.2/src/lparser.h b/src/base/lua-5.1.2/src/lparser.h index e5b5b57..e5b5b57 100644 --- a/src/script/lua-5.1.2/src/lparser.h +++ b/src/base/lua-5.1.2/src/lparser.h diff --git a/src/script/lua-5.1.2/src/lstate.c b/src/base/lua-5.1.2/src/lstate.c index 4bcb759..4bcb759 100644 --- a/src/script/lua-5.1.2/src/lstate.c +++ b/src/base/lua-5.1.2/src/lstate.c diff --git a/src/script/lua-5.1.2/src/lstate.h b/src/base/lua-5.1.2/src/lstate.h index d296a4c..d296a4c 100644 --- a/src/script/lua-5.1.2/src/lstate.h +++ b/src/base/lua-5.1.2/src/lstate.h diff --git a/src/script/lua-5.1.2/src/lstring.c b/src/base/lua-5.1.2/src/lstring.c index 4319930..4319930 100644 --- a/src/script/lua-5.1.2/src/lstring.c +++ b/src/base/lua-5.1.2/src/lstring.c diff --git a/src/script/lua-5.1.2/src/lstring.h b/src/base/lua-5.1.2/src/lstring.h index 1d2e91e..1d2e91e 100644 --- a/src/script/lua-5.1.2/src/lstring.h +++ b/src/base/lua-5.1.2/src/lstring.h diff --git a/src/script/lua-5.1.2/src/lstrlib.c b/src/base/lua-5.1.2/src/lstrlib.c index fc7ae48..fc7ae48 100644 --- a/src/script/lua-5.1.2/src/lstrlib.c +++ b/src/base/lua-5.1.2/src/lstrlib.c diff --git a/src/script/lua-5.1.2/src/ltable.c b/src/base/lua-5.1.2/src/ltable.c index bc91cac..bc91cac 100644 --- a/src/script/lua-5.1.2/src/ltable.c +++ b/src/base/lua-5.1.2/src/ltable.c diff --git a/src/script/lua-5.1.2/src/ltable.h b/src/base/lua-5.1.2/src/ltable.h index 09193cd..09193cd 100644 --- a/src/script/lua-5.1.2/src/ltable.h +++ b/src/base/lua-5.1.2/src/ltable.h diff --git a/src/script/lua-5.1.2/src/ltablib.c b/src/base/lua-5.1.2/src/ltablib.c index 453b23b..453b23b 100644 --- a/src/script/lua-5.1.2/src/ltablib.c +++ b/src/base/lua-5.1.2/src/ltablib.c diff --git a/src/script/lua-5.1.2/src/ltm.c b/src/base/lua-5.1.2/src/ltm.c index 097b815..097b815 100644 --- a/src/script/lua-5.1.2/src/ltm.c +++ b/src/base/lua-5.1.2/src/ltm.c diff --git a/src/script/lua-5.1.2/src/ltm.h b/src/base/lua-5.1.2/src/ltm.h index 866c796..866c796 100644 --- a/src/script/lua-5.1.2/src/ltm.h +++ b/src/base/lua-5.1.2/src/ltm.h diff --git a/src/script/lua-5.1.2/src/lua.c b/src/base/lua-5.1.2/src/lua.c index 5cee7fa..5cee7fa 100644 --- a/src/script/lua-5.1.2/src/lua.c +++ b/src/base/lua-5.1.2/src/lua.c diff --git a/src/script/lua-5.1.2/src/lua.h b/src/base/lua-5.1.2/src/lua.h index 2865a7f..2865a7f 100644 --- a/src/script/lua-5.1.2/src/lua.h +++ b/src/base/lua-5.1.2/src/lua.h diff --git a/src/script/lua-5.1.2/src/luac.c b/src/base/lua-5.1.2/src/luac.c index d070173..d070173 100644 --- a/src/script/lua-5.1.2/src/luac.c +++ b/src/base/lua-5.1.2/src/luac.c diff --git a/src/script/lua-5.1.2/src/luaconf.h b/src/base/lua-5.1.2/src/luaconf.h index cfc12dc..cfc12dc 100644 --- a/src/script/lua-5.1.2/src/luaconf.h +++ b/src/base/lua-5.1.2/src/luaconf.h diff --git a/src/script/lua-5.1.2/src/lualib.h b/src/base/lua-5.1.2/src/lualib.h index 0c76232..0c76232 100644 --- a/src/script/lua-5.1.2/src/lualib.h +++ b/src/base/lua-5.1.2/src/lualib.h diff --git a/src/script/lua-5.1.2/src/lundump.c b/src/base/lua-5.1.2/src/lundump.c index 7fc635e..7fc635e 100644 --- a/src/script/lua-5.1.2/src/lundump.c +++ b/src/base/lua-5.1.2/src/lundump.c diff --git a/src/script/lua-5.1.2/src/lundump.h b/src/base/lua-5.1.2/src/lundump.h index 58cca5d..58cca5d 100644 --- a/src/script/lua-5.1.2/src/lundump.h +++ b/src/base/lua-5.1.2/src/lundump.h diff --git a/src/script/lua-5.1.2/src/lvm.c b/src/base/lua-5.1.2/src/lvm.c index 08802f4..08802f4 100644 --- a/src/script/lua-5.1.2/src/lvm.c +++ b/src/base/lua-5.1.2/src/lvm.c diff --git a/src/script/lua-5.1.2/src/lvm.h b/src/base/lua-5.1.2/src/lvm.h index 788423f..788423f 100644 --- a/src/script/lua-5.1.2/src/lvm.h +++ b/src/base/lua-5.1.2/src/lvm.h diff --git a/src/script/lua-5.1.2/src/lzio.c b/src/base/lua-5.1.2/src/lzio.c index 5121ada..5121ada 100644 --- a/src/script/lua-5.1.2/src/lzio.c +++ b/src/base/lua-5.1.2/src/lzio.c diff --git a/src/script/lua-5.1.2/src/lzio.h b/src/base/lua-5.1.2/src/lzio.h index 8f403b8..8f403b8 100644 --- a/src/script/lua-5.1.2/src/lzio.h +++ b/src/base/lua-5.1.2/src/lzio.h diff --git a/src/script/lua-5.1.2/src/print.c b/src/base/lua-5.1.2/src/print.c index e240cfc..e240cfc 100644 --- a/src/script/lua-5.1.2/src/print.c +++ b/src/base/lua-5.1.2/src/print.c diff --git a/src/script/lua-5.1.2/test/README b/src/base/lua-5.1.2/test/README index 0c7f38b..0c7f38b 100644 --- a/src/script/lua-5.1.2/test/README +++ b/src/base/lua-5.1.2/test/README diff --git a/src/script/lua-5.1.2/test/bisect.lua b/src/base/lua-5.1.2/test/bisect.lua index f91e69b..f91e69b 100644 --- a/src/script/lua-5.1.2/test/bisect.lua +++ b/src/base/lua-5.1.2/test/bisect.lua diff --git a/src/script/lua-5.1.2/test/cf.lua b/src/base/lua-5.1.2/test/cf.lua index 8cda54b..8cda54b 100644 --- a/src/script/lua-5.1.2/test/cf.lua +++ b/src/base/lua-5.1.2/test/cf.lua diff --git a/src/script/lua-5.1.2/test/echo.lua b/src/base/lua-5.1.2/test/echo.lua index 4313439..4313439 100644 --- a/src/script/lua-5.1.2/test/echo.lua +++ b/src/base/lua-5.1.2/test/echo.lua diff --git a/src/script/lua-5.1.2/test/env.lua b/src/base/lua-5.1.2/test/env.lua index 9e62a57..9e62a57 100644 --- a/src/script/lua-5.1.2/test/env.lua +++ b/src/base/lua-5.1.2/test/env.lua diff --git a/src/script/lua-5.1.2/test/factorial.lua b/src/base/lua-5.1.2/test/factorial.lua index 7c4cf0f..7c4cf0f 100644 --- a/src/script/lua-5.1.2/test/factorial.lua +++ b/src/base/lua-5.1.2/test/factorial.lua diff --git a/src/script/lua-5.1.2/test/fib.lua b/src/base/lua-5.1.2/test/fib.lua index 97a921b..97a921b 100644 --- a/src/script/lua-5.1.2/test/fib.lua +++ b/src/base/lua-5.1.2/test/fib.lua diff --git a/src/script/lua-5.1.2/test/fibfor.lua b/src/base/lua-5.1.2/test/fibfor.lua index 8bbba39..8bbba39 100644 --- a/src/script/lua-5.1.2/test/fibfor.lua +++ b/src/base/lua-5.1.2/test/fibfor.lua diff --git a/src/script/lua-5.1.2/test/globals.lua b/src/base/lua-5.1.2/test/globals.lua index d4c20e1..d4c20e1 100644 --- a/src/script/lua-5.1.2/test/globals.lua +++ b/src/base/lua-5.1.2/test/globals.lua diff --git a/src/script/lua-5.1.2/test/hello.lua b/src/base/lua-5.1.2/test/hello.lua index 0925498..0925498 100644 --- a/src/script/lua-5.1.2/test/hello.lua +++ b/src/base/lua-5.1.2/test/hello.lua diff --git a/src/script/lua-5.1.2/test/life.lua b/src/base/lua-5.1.2/test/life.lua index 911d9fe..911d9fe 100644 --- a/src/script/lua-5.1.2/test/life.lua +++ b/src/base/lua-5.1.2/test/life.lua diff --git a/src/script/lua-5.1.2/test/luac.lua b/src/base/lua-5.1.2/test/luac.lua index 96a0a97..96a0a97 100644 --- a/src/script/lua-5.1.2/test/luac.lua +++ b/src/base/lua-5.1.2/test/luac.lua diff --git a/src/script/lua-5.1.2/test/printf.lua b/src/base/lua-5.1.2/test/printf.lua index 58c63ff..58c63ff 100644 --- a/src/script/lua-5.1.2/test/printf.lua +++ b/src/base/lua-5.1.2/test/printf.lua diff --git a/src/script/lua-5.1.2/test/readonly.lua b/src/base/lua-5.1.2/test/readonly.lua index 85c0b4e..85c0b4e 100644 --- a/src/script/lua-5.1.2/test/readonly.lua +++ b/src/base/lua-5.1.2/test/readonly.lua diff --git a/src/script/lua-5.1.2/test/sieve.lua b/src/base/lua-5.1.2/test/sieve.lua index 0871bb2..0871bb2 100644 --- a/src/script/lua-5.1.2/test/sieve.lua +++ b/src/base/lua-5.1.2/test/sieve.lua diff --git a/src/script/lua-5.1.2/test/sort.lua b/src/base/lua-5.1.2/test/sort.lua index 0bcb15f..0bcb15f 100644 --- a/src/script/lua-5.1.2/test/sort.lua +++ b/src/base/lua-5.1.2/test/sort.lua diff --git a/src/script/lua-5.1.2/test/table.lua b/src/base/lua-5.1.2/test/table.lua index 235089c..235089c 100644 --- a/src/script/lua-5.1.2/test/table.lua +++ b/src/base/lua-5.1.2/test/table.lua diff --git a/src/script/lua-5.1.2/test/trace-calls.lua b/src/base/lua-5.1.2/test/trace-calls.lua index 6d7a7b3..6d7a7b3 100644 --- a/src/script/lua-5.1.2/test/trace-calls.lua +++ b/src/base/lua-5.1.2/test/trace-calls.lua diff --git a/src/script/lua-5.1.2/test/trace-globals.lua b/src/base/lua-5.1.2/test/trace-globals.lua index 295e670..295e670 100644 --- a/src/script/lua-5.1.2/test/trace-globals.lua +++ b/src/base/lua-5.1.2/test/trace-globals.lua diff --git a/src/script/lua-5.1.2/test/xd.lua b/src/base/lua-5.1.2/test/xd.lua index ebc3eff..ebc3eff 100644 --- a/src/script/lua-5.1.2/test/xd.lua +++ b/src/base/lua-5.1.2/test/xd.lua diff --git a/src/base/luastate.c b/src/base/luastate.c new file mode 100644 index 0000000..981ca9e --- /dev/null +++ b/src/base/luastate.c @@ -0,0 +1,44 @@ +/** + * \file luastate.c + * \brief An accessor for a Lua runtime state object. + * \author Copyright (c) 2008 Jason Perkins and the Premake project + */ + +#include <assert.h> +#include "luastate.h" + +static lua_State* Current = NULL; + + +/** + * Create a new Lua state object and set the current global state. + */ +lua_State* luastate_create(void) +{ + Current = lua_open(); + luaL_openlibs(Current); + return Current; +} + + +/** + * Destroy a Lua state object and clear the current global state. + */ +void luastate_destroy(lua_State* L) +{ + assert(L); + lua_close(L); + if (Current == L) Current = NULL; +} + + +/** + * Return the current global Lua state, or NULL if there is no currently active state. + */ +lua_State* luastate_get_current(void) +{ + return Current; +} + + + diff --git a/src/base/luastate.h b/src/base/luastate.h new file mode 100644 index 0000000..acd879b --- /dev/null +++ b/src/base/luastate.h @@ -0,0 +1,31 @@ +/** + * \file luastate.h + * \brief An accessor for a Lua runtime state object. + * \author Copyright (c) 2008 Jason Perkins and the Premake project + * + * \defgroup luastate Lua State + * \ingroup base + * + * A wrapper around a global Lua state object, allowing the state to be + * shared between the main scripting engine object and the cstr_matches_pattern() + * function (which is in turn used by the project object). + * + * @{ + */ +#if !defined(PREMAKE_LUASTATE_H) +#define PREMAKE_LUASTATE_H + +#define lua_c +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + + +lua_State* luastate_create(void); +void luastate_destroy(lua_State* L); +lua_State* luastate_get_current(void); + + +#endif +/** @} */ + diff --git a/src/base/tests/cstr_tests.cpp b/src/base/tests/cstr_tests.cpp index 470cce8..5a82fdb 100644 --- a/src/base/tests/cstr_tests.cpp +++ b/src/base/tests/cstr_tests.cpp @@ -119,6 +119,26 @@ SUITE(cstr) /************************************************************************** + * cstr_matches_pattern() tests + **************************************************************************/ + + TEST(CStrMatchesPattern_ReturnsTrue_OnMatch) + { + CHECK(cstr_matches_pattern("01234", "%d*")); + } + + TEST(CStrMatchesPattern_ReturnsFalse_OnNonMatch) + { + CHECK(!cstr_matches_pattern("01234", "%a*")); + } + + TEST(CStrMatchesPattern_ReturnsTrue_OnCaseMismatch) + { + CHECK(cstr_matches_pattern("Debug", "debug")); + } + + + /************************************************************************** * cstr_starts_with() tests **************************************************************************/ diff --git a/src/base/tests/env_tests.cpp b/src/base/tests/env_tests.cpp new file mode 100644 index 0000000..8d6fb55 --- /dev/null +++ b/src/base/tests/env_tests.cpp @@ -0,0 +1,28 @@ +/** + * \file env_tests.cpp + * \brief Automated tests from runtime environment state. + * \author Copyright (c) 2008 Jason Perkins and the Premake project + */ + +#include "premake.h" +#include "testing/testing.h" +extern "C" { +#include "base/env.h" +} + + +SUITE(base) +{ + TEST(EnvGetOs_IsNotUnknown) + { + enum OS os = env_get_os(); + CHECK(os != UnknownOS); + } + + TEST(EnvGetOsName_DoesNotExplode) + { + const char* name = env_get_os_name(); + CHECK(name != NULL); + } +} + diff --git a/src/host/host.c b/src/host/host.c index aa89b4c..4175d15 100644 --- a/src/host/host.c +++ b/src/host/host.c @@ -8,24 +8,61 @@ #include <stdlib.h> #include "premake.h" #include "host/host.h" +#include "script/script.h" #include "actions/actions.h" #include "base/cstr.h" +#include "base/env.h" #include "base/error.h" #include "base/file.h" -/** argv, as passed into main(), stored here to be accessible to all host functions. */ -static const char** Args = NULL; +DEFINE_CLASS(Host) +{ + Script script; + const char** args; +}; + + +/** + * Create a new Premake host object. + * \returns A new session object, or NULL if the scripting engine fails to start. + */ +Host host_create() +{ + Host host; + + Script script = script_create(); + if (script == NULL) + { + return NULL; + } + + host = ALLOC_CLASS(Host); + host->script = script; + host->args = NULL; + return host; +} + + +/** + * Destroy a Premake host object and release the associated memory. + */ +void host_destroy(Host host) +{ + assert(host); + script_destroy(host->script); + free(host); +} /** * Initial processing and validation of the command line arguments. - * \param sess The current execution session. * \returns OKAY on success. */ -int host_parse_argv(Session sess) +int host_parse_argv(Host host) { - session_set_action(sess, Args[0]); + script_set_action(host->script, host->args[0]); + env_set_action(host->args[0]); return OKAY; } @@ -34,33 +71,29 @@ int host_parse_argv(Session sess) * Display the results of the application run. * Any errors returned during the run will be written to stderr; otherwise, a * success message is written to stdout. - * \param sess The current execution session. - * \returns OKAY. */ -int host_report_results(Session sess) +int host_report_results() { const char* error = error_get(); if (error) { stream_writeline(Console, "Error: %s", error); } - - sess = 0; /* unused */ return OKAY; } /** * Run the action specified by the user on the command line. - * \param sess The execution session context. * \returns OKAY on success. */ -int host_run_action(Session sess) +int host_run_action(Host host) { + Session sess; const char* action; - int i; + int i, z = OKAY; - assert(sess); + assert(host); /* there must be a project file defined or I can go no further */ if (!file_exists(DEFAULT_SCRIPT_NAME)) @@ -69,13 +102,22 @@ int host_run_action(Session sess) return !OKAY; } + /* unload the defined objects from the script */ + sess = script_unload(host->script); + if (sess == NULL) + { + return !OKAY; + } + /* find the action in the master list and execute the associated callback */ - action = Args[0]; + action = host->args[0]; for (i = 0; Actions[i].name != NULL; ++i) { if (cstr_eq(Actions[i].name, action)) { - return Actions[i].callback(sess); + z = Actions[i].callback(sess); + session_destroy(sess); + return z; } } @@ -87,18 +129,17 @@ int host_run_action(Session sess) /** * Find and execute the project script file. - * \param sess The session object. * \returns OKAY on success. */ -int host_run_script(Session sess) +int host_run_script(Host host) { - assert(sess); + assert(host); /* run the default file for now. If the script file doesn't exist let execution * continue so I can display help, etc. */ if (file_exists(DEFAULT_SCRIPT_NAME)) { - session_run_file(sess, DEFAULT_SCRIPT_NAME); + script_run_file(host->script, DEFAULT_SCRIPT_NAME); return (error_get() == NULL) ? OKAY : !OKAY; } else @@ -109,37 +150,13 @@ int host_run_script(Session sess) /** - * Run a list of steps, in order, checking status at each step. - * \param sess The current session state. - * \param steps A null-terminated list of step functions. - * \returns OKAY on success. - */ -int host_run_steps(Session sess, HostExecutionStep* steps) -{ - int i, status; - - assert(sess); - assert(steps); - - status = OKAY; - for (i = 0; status == OKAY && steps[i] != NULL; ++i) - { - status = steps[i](sess); - } - - return status; -} - - -/** * Remember the list of command-line parameters for subsequent calls * to the other host functions later in the processing steps. - * \param argv The argv variable is passed to main(). */ -void host_set_argv(const char** argv) +void host_set_argv(Host host, const char** argv) { /* skip over the progam name in argv[0] and just store the arguments */ - Args = &argv[1]; + host->args = &argv[1]; } @@ -148,21 +165,16 @@ void host_set_argv(const char** argv) * shown, execution of the main step loop will be stopped and the application * will exit (this seems to be the standard behavior of POSIX apps when * help is requested). - * \param sess The current execution session context. * \returns OKAY is no help information was required, !OKAY to stop the loop. */ -int host_show_help(Session sess) +int host_show_help(Host host) { - assert(Args); - - sess = 0; /* unused */ - /* while (arg is option) { */ /* if (/version) ... */ /* if (/help) ... */ /* if no action was specified give the user a clue */ - if (Args[0] == NULL) + if (host->args[0] == NULL) { stream_writeline(Console, HOST_SHORT_HELP); return !OKAY; diff --git a/src/host/host.h b/src/host/host.h index 6849d11..d4ca24b 100644 --- a/src/host/host.h +++ b/src/host/host.h @@ -13,7 +13,10 @@ #if !defined(PREMAKE_HOST_H) #define PREMAKE_HOST_H -#include "session/session.h" +#include "objects/session.h" + +DECLARE_CLASS(Host) + /** * The short help message, displayed if Premake is run with no arguments. @@ -21,22 +24,15 @@ #define HOST_SHORT_HELP "Type 'premake --help' for help." -/** - * Abstract out one step in the process, so I can treat them all identically. - * This lets me unit test the higher-level logic. - * \param sess The current session state. - * \returns OKAY if successful. - */ -typedef int (*HostExecutionStep)(Session sess); - +Host host_create(); +void host_destroy(Host host); -int host_parse_argv(Session sess); -int host_report_results(Session sess); -int host_run_action(Session sess); -int host_run_script(Session sess); -int host_run_steps(Session sess, HostExecutionStep* steps); -void host_set_argv(const char** argv); -int host_show_help(Session sess); +int host_parse_argv(Host host); +int host_report_results(void); +int host_run_action(Host host); +int host_run_script(Host host); +void host_set_argv(Host host, const char** argv); +int host_show_help(Host host); int host_tests(void); #endif diff --git a/src/host/tests/host_args_tests.cpp b/src/host/tests/host_args_tests.cpp index 8e47d5d..3eb29ab 100644 --- a/src/host/tests/host_args_tests.cpp +++ b/src/host/tests/host_args_tests.cpp @@ -8,17 +8,20 @@ #include "testing/testing.h" extern "C" { #include "host/host.h" +#include "base/env.h" #include "base/error.h" #include "base/stream.h" } struct FxHostArgs { + Host host; Session sess; char buffer[8192]; FxHostArgs() { + host = host_create(); sess = session_create(); stream_set_buffer(Console, buffer); } @@ -26,8 +29,8 @@ struct FxHostArgs ~FxHostArgs() { session_destroy(sess); + host_destroy(host); error_clear(); - host_set_argv(NULL); } }; @@ -37,8 +40,8 @@ SUITE(host) TEST_FIXTURE(FxHostArgs, ParseArgv_SetsAction_OnAction) { const char* argv[] = { "premake", "action", NULL }; - host_set_argv(argv); - host_parse_argv(sess); - CHECK_EQUAL("action", session_get_action(sess)); + host_set_argv(host, argv); + host_parse_argv(host); + CHECK_EQUAL("action", env_get_action()); } } diff --git a/src/host/tests/host_help_tests.cpp b/src/host/tests/host_help_tests.cpp index 20fd77e..5917a5a 100644 --- a/src/host/tests/host_help_tests.cpp +++ b/src/host/tests/host_help_tests.cpp @@ -14,11 +14,13 @@ extern "C" { struct FxHostHelp { + Host host; Session sess; char buffer[8192]; FxHostHelp() { + host = host_create(); sess = session_create(); stream_set_buffer(Console, buffer); } @@ -26,8 +28,8 @@ struct FxHostHelp ~FxHostHelp() { session_destroy(sess); + host_destroy(host); error_clear(); - host_set_argv(NULL); } }; @@ -41,16 +43,16 @@ SUITE(host) TEST_FIXTURE(FxHostHelp, Help_ReturnsOkay_OnAction) { const char* argv[] = { "premake", "vs2005", NULL }; - host_set_argv(argv); - int result = host_show_help(sess); + host_set_argv(host, argv); + int result = host_show_help(host); CHECK(result == OKAY); } TEST_FIXTURE(FxHostHelp, Help_PrintsNothing_OnAction) { const char* argv[] = { "premake", "vs2005", NULL }; - host_set_argv(argv); - host_show_help(sess); + host_set_argv(host, argv); + host_show_help(host); CHECK_EQUAL("", buffer); } @@ -62,16 +64,16 @@ SUITE(host) TEST_FIXTURE(FxHostHelp, Help_ReturnsNotOkay_OnNoAction) { const char* argv[] = { "premake", NULL }; - host_set_argv(argv); - int result = host_show_help(sess); + host_set_argv(host, argv); + int result = host_show_help(host); CHECK(result != OKAY); } TEST_FIXTURE(FxHostHelp, Help_ShowsShortHelp_OnNoAction) { const char* argv[] = { "premake", NULL }; - host_set_argv(argv); - host_show_help(sess); + host_set_argv(host, argv); + host_show_help(host); CHECK_EQUAL(HOST_SHORT_HELP "\n", buffer); } } diff --git a/src/host/tests/host_results_tests.cpp b/src/host/tests/host_results_tests.cpp index 64ca4e1..599763d 100644 --- a/src/host/tests/host_results_tests.cpp +++ b/src/host/tests/host_results_tests.cpp @@ -35,14 +35,14 @@ SUITE(host) { TEST_FIXTURE(FxResults, ReportResults_NoMessage_OnNoError) { - host_report_results(sess); + host_report_results(); CHECK_EQUAL("", buffer); } TEST_FIXTURE(FxResults, ReportResults_ErrorMessage_OnError) { error_set("an error occurred"); - host_report_results(sess); + host_report_results(); CHECK_EQUAL("Error: an error occurred\n", buffer); } } diff --git a/src/host/tests/host_run_tests.cpp b/src/host/tests/host_run_tests.cpp index f3635d8..0ee7391 100644 --- a/src/host/tests/host_run_tests.cpp +++ b/src/host/tests/host_run_tests.cpp @@ -12,39 +12,20 @@ extern "C" { #include "base/error.h" } -/* Mock steps for testing host_run_steps */ - -static int num_step_calls; - -static int MockStepOkay(Session sess) -{ - sess = 0; - num_step_calls++; - return OKAY; -} - -static int MockStepFail(Session sess) -{ - sess = 0; - return !OKAY; -} - - struct FxHostRun { - Session sess; + Host host; FxHostRun() { - num_step_calls = 0; - sess = session_create(); + host = host_create(); dir_set_current("testing/test_files"); } ~FxHostRun() { dir_set_current("../.."); - session_destroy(sess); + host_destroy(host); error_clear(); } }; @@ -52,74 +33,22 @@ struct FxHostRun SUITE(host) { /********************************************************************** - * host_run_script() tests - **********************************************************************/ - - TEST_FIXTURE(FxHostRun, HostRunScript_ReturnsOkay_OnSuccess) - { - int result = host_run_script(sess); - CHECK(result == OKAY); - } - - TEST_FIXTURE(FxHostRun, HostRunScript_RunsDefaultFile_OnNoFileArg) - { - host_run_script(sess); - const char* result = session_run_string(sess, - "return script_has_run"); - CHECK_EQUAL("true", result); - } - - - /********************************************************************** - * host_run_steps() tests - **********************************************************************/ - - TEST_FIXTURE(FxHostRun, HostRunSteps_ReturnsOkay_OnAllStepsSucceed) - { - HostExecutionStep steps[] = { MockStepOkay, NULL }; - int result = host_run_steps(sess, steps); - CHECK(result == OKAY); - } - - TEST_FIXTURE(FxHostRun, HostRunSteps_RunsAllSteps) - { - HostExecutionStep steps[] = { MockStepOkay, MockStepOkay, MockStepOkay, NULL }; - host_run_steps(sess, steps); - CHECK(num_step_calls == 3); - } - - TEST_FIXTURE(FxHostRun, HostRunSteps_ReturnsNotOkay_OnError) - { - HostExecutionStep steps[] = { MockStepFail, NULL }; - int result = host_run_steps(sess, steps); - CHECK(result != OKAY); - } - - TEST_FIXTURE(FxHostRun, HostRunSteps_StopsRunning_OnError) - { - HostExecutionStep steps[] = { MockStepOkay, MockStepFail, MockStepOkay, NULL }; - host_run_steps(sess, steps); - CHECK(num_step_calls == 1); - } - - - /********************************************************************** * host_run_action() tests **********************************************************************/ TEST_FIXTURE(FxHostRun, HostRunAction_ReturnsNotOkay_OnInvalidAction) { const char* argv[] = { "premake", "nonesuch", NULL }; - host_set_argv(argv); - int result = host_run_action(sess); + host_set_argv(host, argv); + int result = host_run_action(host); CHECK(result != OKAY); } TEST_FIXTURE(FxHostRun, HostRunAction_SetsError_OnInvalidAction) { const char* argv[] = { "premake", "nonesuch", NULL }; - host_set_argv(argv); - host_run_action(sess); + host_set_argv(host, argv); + host_run_action(host); CHECK_EQUAL("invalid action 'nonesuch'", error_get()); } } diff --git a/src/host/tests/host_tests.cpp b/src/host/tests/host_tests.cpp index 6b3535c..870ce5e 100644 --- a/src/host/tests/host_tests.cpp +++ b/src/host/tests/host_tests.cpp @@ -8,6 +8,9 @@ #include "testing/testing.h" extern "C" { #include "host/host.h" +#include "base/base.h" +#include "script/script.h" +#include "objects/objects.h" } @@ -19,7 +22,9 @@ extern "C" { int host_tests() { int z = OKAY; - if (z == OKAY) z = session_tests(); + if (z == OKAY) z = base_tests(); + if (z == OKAY) z = script_tests(); + if (z == OKAY) z = objects_tests(); if (z == OKAY) z = tests_run_suite("action"); if (z == OKAY) z = tests_run_suite("host"); return z; diff --git a/src/project/block.c b/src/objects/block.c index 7d2dd92..db73d05 100644 --- a/src/project/block.c +++ b/src/objects/block.c @@ -7,7 +7,9 @@ #include <assert.h> #include <stdlib.h> #include "premake.h" -#include "project/block.h" +#include "block.h" +#include "base/cstr.h" +#include "base/env.h" struct FieldInfo BlockFieldInfo[] = @@ -27,7 +29,6 @@ DEFINE_CLASS(Block) /** * Create and initialize a new configuration block. - * \returns A new configuration block. */ Block block_create() { @@ -39,7 +40,6 @@ Block block_create() /** * Destroy a configuration block and release the associated memory. - * \param blk The configuration block to destroy. */ void block_destroy(Block blk) { @@ -50,6 +50,38 @@ void block_destroy(Block blk) /** + * Checks the block's list of terms to see if this block applies to + * the current environment. All of the block's terms must find a match + * among the keyword sources, which include the current OS, the action, + * and the provided configuration name. + * \param blk The block to test. + * \param cfg_name The name of the active configuration. + * \returns True if every term in the block finds a keyword match. + */ +int block_applies_to(Block blk, const char* cfg_name) +{ + int i, n; + Strings terms = block_get_values(blk, BlockTerms); + n = strings_size(terms); + for (i = 0; i < n; ++i) + { + const char* term = strings_item(terms, i); + if ((cfg_name != NULL && cstr_matches_pattern(cfg_name, term)) || + cstr_matches_pattern(env_get_os_name(), term) || + cstr_matches_pattern(env_get_action(), term)) + { + continue; + } + + /* no match was found for this term */ + return 0; + } + + return 1; +} + + +/** * Retrieve the fields object for this block; used to unload values from the script. */ Fields block_get_fields(Block blk) diff --git a/src/project/block.h b/src/objects/block.h index 5b3f385..9ba9b03 100644 --- a/src/project/block.h +++ b/src/objects/block.h @@ -3,7 +3,8 @@ * \brief Configuration blocks API. * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project * - * \addtogroup project + * \defgroup block Configuration Block + * \ingroup objects * @{ */ #if !defined(PREMAKE_BLOCK_H) @@ -32,6 +33,7 @@ DECLARE_CLASS(Block) Block block_create(void); void block_destroy(Block blk); +int block_applies_to(Block blk, const char* cfg_name); Fields block_get_fields(Block blk); Strings block_get_values(Block blk, enum BlockField which); void block_set_values(Block blk, enum BlockField which, Strings strs); diff --git a/src/project/blocks.c b/src/objects/blocks.c index 7ff81bd..cff37d1 100644 --- a/src/project/blocks.c +++ b/src/objects/blocks.c @@ -7,7 +7,7 @@ #include <assert.h> #include <stdlib.h> #include "premake.h" -#include "project/blocks.h" +#include "blocks.h" #include "base/array.h" diff --git a/src/project/blocks.h b/src/objects/blocks.h index 1bf7887..f6532d5 100644 --- a/src/project/blocks.h +++ b/src/objects/blocks.h @@ -3,7 +3,7 @@ * \brief A list of configuration blocks. * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project * - * \addtogroup project + * \addtogroup block * @{ */ #if !defined(PREMAKE_BLOCKS_H) diff --git a/src/project/fields.c b/src/objects/fields.c index 49e131d..fe27f1b 100644 --- a/src/project/fields.c +++ b/src/objects/fields.c @@ -20,7 +20,7 @@ DEFINE_CLASS(Fields) /** * Create a new, empty collection of fields. - * \param info Metadata about the field collection. + * \param info Metadata about the field collection. * \returns A new collection of fields. */ Fields fields_create(struct FieldInfo* info) @@ -49,7 +49,6 @@ Fields fields_create(struct FieldInfo* info) /** * Destroy a collection of fields and release the associated memory. - * \param fields The collection of fields to destroy. */ void fields_destroy(Fields fields) { @@ -68,9 +67,6 @@ void fields_destroy(Fields fields) /** * Add a new value to the end of an existing list. - * \param fields The collection of fields. - * \param index The index of the list to contain the new value. - * \param value The value to add. */ void fields_add_value(Fields fields, int index, const char* value) { @@ -82,8 +78,6 @@ void fields_add_value(Fields fields, int index, const char* value) /** * Retrieve the value of a string (single value) field. - * \param fields The collection of fields. - * \param index The index of the field to query. * \returns The field value if set, or NULL. */ const char* fields_get_value(Fields fields, int index) @@ -106,9 +100,6 @@ const char* fields_get_value(Fields fields, int index) /** * Retrieve the list of values for a field. - * \param fields The collection of fields. - * \param index The index of fields to query. - * \returns The list of values stored in the field. */ Strings fields_get_values(Fields fields, int index) { @@ -120,9 +111,6 @@ Strings fields_get_values(Fields fields, int index) /** * Sets the value of a string (single value) field. - * \param fields The collection of fields. - * \param index The index of the field to set. - * \param value The new value of the field. */ void fields_set_value(Fields fields, int index, const char* value) { @@ -147,9 +135,6 @@ void fields_set_value(Fields fields, int index, const char* value) /** * Sets the list of values associated with a field. The field will subsequently * "own" the list, and take responsibility for destroying it with the field set. - * \param fields The collection of fields. - * \param index The index of the field to set. - * \param values The list of new values for the field. */ void fields_set_values(Fields fields, int index, Strings values) { diff --git a/src/project/fields.h b/src/objects/fields.h index 1f4f416..c4401c7 100644 --- a/src/project/fields.h +++ b/src/objects/fields.h @@ -3,7 +3,12 @@ * \brief Project object fields enumeration and handling. * \author Copyright (c) 2007-2008 Jason Perkins and the Premake project * - * \addtogroup project + * \defgroup fields Object Fields + * \ingroup objects + * + * The fields class implements a generic collection of string, list, and + * files fields which are reused by the other project objects. + * * @{ */ #if !defined(PREMAKE_FIELDS_H) diff --git a/src/objects/objects.h b/src/objects/objects.h new file mode 100644 index 0000000..d9126ff --- /dev/null +++ b/src/objects/objects.h @@ -0,0 +1,12 @@ +/** + * \file objects.h + * \brief Premake project-related objects. + * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project + * + * \defgroup objects Objects + * + * This component defines all of the project-related objects: solution, project, + * and configuration blocks as well as the supporting fields class. + */ + +int objects_tests(); diff --git a/src/project/project_internal.h b/src/objects/objects_internal.h index 2f365a7..9ae707c 100644 --- a/src/project/project_internal.h +++ b/src/objects/objects_internal.h @@ -1,8 +1,9 @@ /** - * \file project_internal.h - * \brief The project object's internal APIs, for communicating connectivity. + * \file objects_internal.h + * \brief An internal API for inter-object data shuffling. * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project */ Solution project_get_solution(Project prj); void project_set_solution(Project prj, Solution sln); +void solution_set_session(Solution sln, Session sess); diff --git a/src/project/project.c b/src/objects/project.c index 84d4b93..643ca29 100644 --- a/src/project/project.c +++ b/src/objects/project.c @@ -8,14 +8,13 @@ #include <stdlib.h> #include <string.h> #include "premake.h" -#include "project/project.h" -#include "project/solution.h" +#include "solution.h" #include "base/buffers.h" #include "base/cstr.h" +#include "base/env.h" #include "base/guid.h" #include "base/path.h" #include "base/strings.h" -#include "platform/platform.h" struct FieldInfo ProjectFieldInfo[] = @@ -35,14 +34,13 @@ DEFINE_CLASS(Project) Solution solution; Blocks blocks; Fields fields; - Filter filter; Strings config_cache[NumBlockFields]; + const char* active_config; }; /** * Create and initialize a new project object. - * \returns A new project object. */ Project project_create() { @@ -52,7 +50,7 @@ Project project_create() prj->solution = NULL; prj->blocks = blocks_create(); prj->fields = fields_create(ProjectFieldInfo); - prj->filter = NULL; + prj->active_config = NULL; for (i = 0; i < NumBlockFields; ++i) { @@ -65,7 +63,6 @@ Project project_create() /** * Destroy a project object and release the associated memory. - * \param prj The project object to destroy. */ void project_destroy(Project prj) { @@ -83,11 +80,10 @@ void project_destroy(Project prj) } + /** * Get the base directory for the project; any properties containing relative * paths are relative to this location. - * \param prj The project object to query. - * \returns The base directory, or NULL if no directory has been set. */ const char* project_get_base_dir(Project prj) { @@ -97,8 +93,6 @@ const char* project_get_base_dir(Project prj) /** * Retrieve the list of configuration blocks associated with a project. - * \param prj The project to query. - * \returns A list of configuration blocks. */ Blocks project_get_blocks(Project prj) { @@ -110,9 +104,6 @@ Blocks project_get_blocks(Project prj) /** * Scans a list of blocks and appends any values found to the provided list. - * \param values The resulting list of values. - * \param blks The list of blocks to scan. - * \param field The field to query. */ static void project_get_values_from_blocks(Project prj, Strings values, Blocks blks, enum BlockField field) { @@ -121,11 +112,8 @@ static void project_get_values_from_blocks(Project prj, Strings values, Blocks b { Block blk = blocks_item(blks, i); - /* make sure this block fits through the current filter */ - Strings terms = block_get_values(blk, BlockTerms); - if ((prj->filter == NULL && strings_size(terms) == 0) || (filter_is_match(prj->filter, terms))) + if (block_applies_to(blk, prj->active_config)) { - /* block matches filter; add values to results */ Strings block_values = block_get_values(blk, field); strings_append(values, block_values); } @@ -134,10 +122,20 @@ static void project_get_values_from_blocks(Project prj, Strings values, Blocks b /** + * Retrieve the currently active configuration name; only settings contained by + * blocks targeted to this configuration will be accessible. Returns NULL if no + * configuration has been selected, in which case only global settings will + * be available. + */ +const char* project_get_config(Project prj) +{ + assert(prj); + return prj->active_config; +} + + +/** * Retrieve a list value from the project configuration, respecting the current filter set. - * \param prj The project to query. - * \param field Which field to retrieve. - * \returns The list of values stored in that field. */ Strings project_get_config_values(Project prj, enum BlockField field) { @@ -165,26 +163,6 @@ Strings project_get_config_values(Project prj, enum BlockField field) /** - * Retrieve the current configuration filter. All subsequent requests for configuration - * values will return settings from this configuration only. - * \param prj The project object to query. - * \returns The current configuration filter, or NULL if no filter has been set. - */ -const char* project_get_configuration_filter(Project prj) -{ - assert(prj); - if (prj->filter) - { - return filter_get_value(prj->filter, FilterConfig); - } - else - { - return NULL; - } -} - - -/** * Retrieve the list of preprocessor defines, using the current configuration filter. */ Strings project_get_defines(Project prj) @@ -255,15 +233,12 @@ Strings project_get_files(Project prj) */ const char* project_get_guid(Project prj) { - assert(prj); return project_get_value(prj, ProjectGuid); } /** * Get the programming language used by the project. - * \param prj The project object to query. - * \returns The language used by the project, or NULL if no language has been set. */ const char* project_get_language(Project prj) { @@ -279,8 +254,6 @@ const char* project_get_language(Project prj) /** * Retrieve the output location (the relative path from the base directory to the * target output directory) for this project. - * \param prj The project object to modify. - * \returns The project output location, or NULL if no location has been set. */ const char* project_get_location(Project prj) { @@ -290,7 +263,6 @@ const char* project_get_location(Project prj) /** * Get the name of the project. - * \returns The name, if set, NULL otherwise. */ const char* project_get_name(Project prj) { @@ -308,7 +280,7 @@ const char* project_get_outfile(Project prj) { char* buffer = buffers_next(); strcpy(buffer, project_get_name(prj)); - if (platform_get() == Windows) + if (env_is_os(Windows)) { strcat(buffer, ".exe"); } @@ -317,9 +289,17 @@ const char* project_get_outfile(Project prj) /** + * Retrieve the session which contains this project. + */ +Session project_get_session(Project prj) +{ + assert(prj); + return solution_get_session(prj->solution); +} + + +/** * Retrieve the solution associated with this project (internal). - * \param prj The project to query. - * \returns The associated solution, or NULL if no association has been made. */ Solution project_get_solution(Project prj) { @@ -329,9 +309,6 @@ Solution project_get_solution(Project prj) /** * Retrieve a string (single value) fields from a project, using the field indices. - * \param prj The project object to query. - * \param field The index of the field to query. - * \returns The value of the field if set, of NULL. */ const char* project_get_value(Project prj, enum ProjectField field) { @@ -343,8 +320,6 @@ const char* project_get_value(Project prj, enum ProjectField field) /** * Returns true if the specified language is recognized. Current valid language strings * are 'c', 'c++', and 'c#'. - * \param language The language string. - * \returns True if the language string is recognized. */ int project_is_valid_language(const char* language) { @@ -356,8 +331,6 @@ int project_is_valid_language(const char* language) /** * Set the base directory of the project. - * \param prj The project object to modify. - * \param base_dir The new base directory. */ void project_set_base_dir(Project prj, const char* base_dir) { @@ -366,24 +339,20 @@ void project_set_base_dir(Project prj, const char* base_dir) /** - * Set the current configuration filter. All subsequent requests for configuration - * values will return settings from this configuration only. - * \param prj The project object to query. - * \param flt The current filter. + * Selects a particular configuration; any subsequent calls to retrieve settings will + * only return values which are part of this configuration. A value of NULL will clear + * the configuration, and only return global settings. */ -void project_set_filter(Project prj, Filter flt) +void project_set_config(Project prj, const char* cfg_name) { assert(prj); - assert(flt); - prj->filter = flt; + prj->active_config = cfg_name; } /** * Set the GUID associated with a project. The GUID is required by the Visual * Studio generators, and must be unique per project. - * \param prj The project to modify. - * \param guid The new project GUID. */ void project_set_guid(Project prj, const char* guid) { @@ -393,8 +362,6 @@ void project_set_guid(Project prj, const char* guid) /** * Set the programming language used by a project. - * \param prj The project to modify. - * \param language The programming language used by the project. */ void project_set_language(Project prj, const char* language) { @@ -405,8 +372,6 @@ void project_set_language(Project prj, const char* language) /** * Set the output location (the relative path from the base directory to the * target output directory) for this project. - * \param prj The project object to modify. - * \param location The new output location. */ void project_set_location(Project prj, const char* location) { @@ -416,8 +381,6 @@ void project_set_location(Project prj, const char* location) /** * Set the name of the project. - * \param prj The project object. - * \param name The new for the project. */ void project_set_name(Project prj, const char* name) { @@ -427,8 +390,6 @@ void project_set_name(Project prj, const char* name) /** * Associate a solution with this project (internal). - * \param prj The project to modify. - * \param sln The solution to associate with this project. */ void project_set_solution(Project prj, Solution sln) { @@ -439,9 +400,6 @@ void project_set_solution(Project prj, Solution sln) /** * Set a string (single value) field on a project, using the field indices. - * \param prj The project object. - * \param field The field to set. - * \param value The new value for the field. */ void project_set_value(Project prj, enum ProjectField field, const char* value) { @@ -453,9 +411,6 @@ void project_set_value(Project prj, enum ProjectField field, const char* value) /** * Sets the list of values associated with a field. The field will subsequently * "own" the list, and take responsibility to destroying it with the field set. - * \param prj The project object. - * \param field The index of the field to set. - * \param values The list of new values for the field. */ void project_set_values(Project prj, enum ProjectField field, Strings values) { diff --git a/src/project/project.h b/src/objects/project.h index dde57d4..ec41a5c 100644 --- a/src/project/project.h +++ b/src/objects/project.h @@ -1,20 +1,21 @@ /** * \file project.h - * \brief Project objects API. + * \brief Project object API. * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project * - * \defgroup project Project Objects - * - * Project objects: solutions, projects, and configurations. + * \defgroup project Project + * \ingroup objects * * @{ */ #if !defined(PREMAKE_PROJECT_H) #define PREMAKE_PROJECT_H +DECLARE_CLASS(Project) + +#include "session.h" #include "fields.h" #include "blocks.h" -#include "filter.h" /** @@ -35,15 +36,13 @@ enum ProjectField extern struct FieldInfo ProjectFieldInfo[]; -DECLARE_CLASS(Project) - Project project_create(void); void project_destroy(Project prj); const char* project_get_base_dir(Project prj); Blocks project_get_blocks(Project prj); +const char* project_get_config(Project prj); Strings project_get_config_values(Project prj, enum BlockField field); -const char* project_get_configuration_filter(Project prj); Fields project_get_fields(Project prj); const char* project_get_filename(Project prj, const char* basename, const char* ext); Strings project_get_files(Project prj); @@ -52,17 +51,18 @@ const char* project_get_language(Project prj); const char* project_get_location(Project prj); const char* project_get_name(Project prj); const char* project_get_outfile(Project prj); +Session project_get_session(Project prj); const char* project_get_value(Project prj, enum ProjectField field); int project_is_valid_language(const char* language); void project_set_base_dir(Project prj, const char* base_dir); -void project_set_filter(Project prj, Filter flt); +void project_set_config(Project prj, const char* cfg_name); void project_set_guid(Project prj, const char* guid); void project_set_language(Project prj, const char* language); void project_set_location(Project prj, const char* location); void project_set_name(Project prj, const char* name); void project_set_value(Project prj, enum ProjectField field, const char* value); void project_set_values(Project prj, enum ProjectField field, Strings values); -int project_tests(void); + #endif /** @} */ diff --git a/src/session/session.c b/src/objects/session.c index 77f9352..77e1a0b 100644 --- a/src/session/session.c +++ b/src/objects/session.c @@ -11,18 +11,16 @@ #include <string.h> #include "premake.h" #include "session.h" -#include "script/script.h" +#include "objects_internal.h" #include "base/array.h" #include "base/cstr.h" +#include "base/env.h" #include "base/error.h" -#include "platform/platform.h" DEFINE_CLASS(Session) { - Script script; Array solutions; - Filter filter; Stream active_stream; }; @@ -33,25 +31,9 @@ DEFINE_CLASS(Session) */ Session session_create(void) { - Session sess; - - /* create an instance of the project scripting engine */ - Script script = script_create(); - if (script == NULL) - { - return NULL; - } - - /* create the session object */ - sess = ALLOC_CLASS(Session); - sess->script = script; + Session sess = ALLOC_CLASS(Session); sess->solutions = array_create(); - sess->filter = filter_create(script); sess->active_stream = NULL; - - /* initialize the filter */ - filter_set_value(sess->filter, FilterOS, platform_get_name()); - return sess; } @@ -73,9 +55,7 @@ void session_destroy(Session sess) solution_destroy(sln); } - script_destroy(sess->script); array_destroy(sess->solutions); - filter_destroy(sess->filter); free(sess); } @@ -90,6 +70,7 @@ void session_add_solution(Session sess, Solution sln) assert(sess); assert(sln); array_add(sess->solutions, sln); + solution_set_session(sln, sess); } @@ -97,14 +78,9 @@ void session_add_solution(Session sess, Solution sln) * A bit of black magic: this function acts as a special token for the project handler * function list to indicate where configurations should appear. For more details, see * the implementation of session_enumerate_objects(). - * \param sess The session object. - * \param prj The target project. - * \param strm The currently active output stream. - * \returns OKAY. */ -int session_enumerate_configurations(Session sess, Project prj, Stream strm) +int session_enumerate_configurations(Project prj, Stream strm) { - UNUSED(sess); UNUSED(prj); UNUSED(strm); return OKAY; @@ -138,7 +114,7 @@ int session_enumerate_objects(Session sess, SessionSolutionCallback* sln_funcs, Solution sln = session_get_solution(sess, si); for (fi = 0; result == OKAY && sln_funcs[fi] != NULL; ++fi) { - result = sln_funcs[fi](sess, sln, sess->active_stream); + result = sln_funcs[fi](sln, sess->active_stream); } /* enumerate projects */ @@ -146,7 +122,6 @@ int session_enumerate_objects(Session sess, SessionSolutionCallback* sln_funcs, for (pi = 0; pi < pn; ++pi) { Project prj = solution_get_project(sln, pi); - project_set_filter(prj, sess->filter); for (fi = 0; result == OKAY && prj_funcs[fi]; ++fi) { @@ -160,21 +135,21 @@ int session_enumerate_objects(Session sess, SessionSolutionCallback* sln_funcs, for (ci = 0; result == OKAY && ci < cn; ++ci) { int cfi; - - /* Make this the active configuration in the value filter */ const char* cfg_name = solution_get_config(sln, ci); - filter_set_value(sess->filter, FilterConfig, cfg_name); + project_set_config(prj, cfg_name); /* enumerate configurations */ for (cfi = 0; result == OKAY && cfg_funcs[cfi]; ++cfi) { - result = cfg_funcs[cfi](sess, prj, sess->active_stream); + result = cfg_funcs[cfi](prj, sess->active_stream); } + + project_set_config(prj, NULL); } } else { - result = prj_funcs[fi](sess, prj, sess->active_stream); + result = prj_funcs[fi](prj, sess->active_stream); } } } @@ -191,18 +166,6 @@ int session_enumerate_objects(Session sess, SessionSolutionCallback* sln_funcs, /** - * Get the action name to be performed by this execution run. - * \param sess The session object. - * \returns The action name if set, or NULL. - */ -const char* session_get_action(Session sess) -{ - assert(sess); - return script_get_action(sess->script); -} - - -/** * Retrieve the currently active output stream. * \param sess The session object. * \return The currently active stream, or NULL if no stream is active. @@ -215,18 +178,6 @@ Stream session_get_active_stream(Session sess) /** - * Retrieve the active configuration filter. - * \param sess The session object. - * \returns The active configuration filter. - */ -Filter session_get_filter(Session sess) -{ - assert(sess); - return sess->filter; -} - - -/** * Retrieve the contained solution at the given index in the solution list. * \param sess The session object. * \param index The index of the solution to return. @@ -252,50 +203,6 @@ int session_num_solutions(Session sess) /** - * Execute a script stored in a file. - * \param sess The session object. - * \param filename The name of the file containing the script code to be executed. - * \returns If the script returns a value, it is converted to a string and returned. - * If the script does not return a value, NULL is returned. If an error - * occurs in the script, the error message is returned. - */ -const char* session_run_file(Session sess, const char* filename) -{ - assert(sess); - return script_run_file(sess->script, filename); -} - - -/** - * Execute a bit of script stored in a string. - * \param sess The session object. - * \param code The string containing the script code to be executed. - * \returns If the script returns a value, it is converted to a string and returned. - * If the script does not return a value, NULL is returned. If an error - * occurs in the script, the error message is returned. - */ -const char* session_run_string(Session sess, const char* code) -{ - assert(sess); - return script_run_string(sess->script, code); -} - - -/** - * Set the action name to be performed on this execution pass. The action name will - * be placed in the _ACTION script environment global. - * \param sess The current execution session context. - * \param action The name of the action to be performed. - */ -void session_set_action(Session sess, const char* action) -{ - assert(sess); - script_set_action(sess->script, action); - filter_set_value(sess->filter, FilterAction, action); -} - - -/** * Set the active output stream, which will be passed to subsequent callbacks during * object processing by session_enumerate_objects(). If there is an existing active * stream it will be released before setting the new stream. @@ -315,19 +222,6 @@ void session_set_active_stream(Session sess, Stream strm) /** - * Copy project information out of the scripting environment and into C objects that - * can be more easily manipulated by the action code. - * \param sess The session object which contains the scripted project objects. - * \returns OKAY if successful. - */ -int session_unload(Session sess) -{ - assert(sess); - return script_unload(sess->script, sess->solutions); -} - - -/** * Make sure that all required objects and values have been defined by the project script. * \param sess The session to validate. * \param features The features (language, kind, etc.) supported by the current action. diff --git a/src/session/session.h b/src/objects/session.h index a421f0f..fc57989 100644 --- a/src/session/session.h +++ b/src/objects/session.h @@ -4,32 +4,22 @@ * \author Copyright (c) 2008 Jason Perkins and the Premake project * * \defgroup session Session + * \ingroup objects * - * Premake is essentially a long chain of sequential actions; the Session object - * tracks the application state through this chain, and provides the context - * necessary for actions to do their work. It's a glorified global, essentially. + * The session is the top-level object, providing containment and enumeration + * of a set of solutions (and their contained projects, etc.) * * @{ */ #if !defined(PREMAKE_SESSION_H) #define PREMAKE_SESSION_H -#include "base/stream.h" -#include "project/solution.h" -#include "project/project.h" -#include "project/block.h" -#include "project/filter.h" - DECLARE_CLASS(Session) +#include "base/stream.h" +#include "objects/solution.h" +#include "objects/project.h" -/** - * Callback signature for Premake action handlers, which will get triggered - * if user specifies that action on the command line for processing. - * \param sess The current execution session context. - * \returns OKAY If successful. - */ -typedef int (*SessionActionCallback)(Session sess); /** @@ -40,7 +30,7 @@ typedef int (*SessionActionCallback)(Session sess); * \param strm The currently active stream; set with session_set_active_stream(). May be NULL. * \returns OKAY if successful. */ -typedef int (*SessionSolutionCallback)(Session sess, Solution sln, Stream strm); +typedef int (*SessionSolutionCallback)(Solution sln, Stream strm); /** @@ -51,19 +41,7 @@ typedef int (*SessionSolutionCallback)(Session sess, Solution sln, Stream strm); * \param strm The currently active stream; set with session_set_active_stream(). May be NULL. * \returns OKAY if successful. */ -typedef int (*SessionProjectCallback)(Session sess, Project prj, Stream strm); - - -/** - * Describe a Premake action, including the handler function and the metadata - * required to list it in the user help. - */ -typedef struct struct_SessionAction -{ - const char* name; - const char* description; - SessionActionCallback callback; -} SessionAction; +typedef int (*SessionProjectCallback)(Project prj, Stream strm); /** @@ -80,19 +58,13 @@ typedef struct struct_SessionFeatures Session session_create(void); void session_destroy(Session sess); void session_add_solution(Session sess, Solution sln); -int session_enumerate_configurations(Session sess, Project prj, Stream strm); +int session_enumerate_configurations(Project prj, Stream strm); int session_enumerate_objects(Session sess, SessionSolutionCallback* sln_funcs, SessionProjectCallback* prj_funcs, SessionProjectCallback* cfg_funcs); -const char* session_get_action(Session sess); Stream session_get_active_stream(Session sess); -Filter session_get_filter(Session sess); Solution session_get_solution(Session sess, int index); int session_num_solutions(Session sess); -const char* session_run_file(Session sess, const char* filename); -const char* session_run_string(Session sess, const char* code); -void session_set_action(Session sess, const char* action); void session_set_active_stream(Session sess, Stream strm); int session_tests(void); -int session_unload(Session sess); int session_validate(Session sess, SessionFeatures* features); #endif diff --git a/src/project/solution.c b/src/objects/solution.c index e5cbab4..05f003b 100644 --- a/src/project/solution.c +++ b/src/objects/solution.c @@ -7,8 +7,9 @@ #include <assert.h> #include <stdlib.h> #include "premake.h" -#include "project/solution.h" -#include "project/project_internal.h" +#include "solution.h" +#include "session.h" +#include "objects_internal.h" #include "base/array.h" #include "base/path.h" #include "base/strings.h" @@ -27,6 +28,7 @@ struct FieldInfo SolutionFieldInfo[] = DEFINE_CLASS(Solution) { + Session session; Fields fields; Array projects; Blocks blocks; @@ -35,12 +37,12 @@ DEFINE_CLASS(Solution) /** * Create and initialize a new solution object. - * \returns A new solution object. */ Solution solution_create() { - Solution sln = ALLOC_CLASS(Solution); - sln->fields = fields_create(SolutionFieldInfo); + Solution sln = ALLOC_CLASS(Solution); + sln->session = NULL; + sln->fields = fields_create(SolutionFieldInfo); sln->projects = array_create(); sln->blocks = blocks_create(); return sln; @@ -49,7 +51,6 @@ Solution solution_create() /** * Destroy a solution object and release the associated memory. - * \param sln The solution object to destroy. */ void solution_destroy(Solution sln) { @@ -73,8 +74,6 @@ void solution_destroy(Solution sln) /** * Add a configuration name to a solution. - * \param sln The solution to contain the project. - * \param config_name The name of the configuration add. */ void solution_add_config(Solution sln, const char* config_name) { @@ -86,8 +85,6 @@ void solution_add_config(Solution sln, const char* config_name) /** * Add a project to a solution. - * \param sln The solution to contain the project. - * \param prj The project to add. */ void solution_add_project(Solution sln, Project prj) { @@ -101,8 +98,6 @@ void solution_add_project(Solution sln, Project prj) /** * Get the base directory for the solution; any properties containing relative * paths are relative to this location. - * \param sln The solution object to query. - * \returns The base directory, or NULL if no directory has been set. */ const char* solution_get_base_dir(Solution sln) { @@ -112,8 +107,6 @@ const char* solution_get_base_dir(Solution sln) /** * Retrieve the list of configuration blocks associated with a solution. - * \param sln The solution to query. - * \returns A list of configuration blocks. */ Blocks solution_get_blocks(Solution sln) { @@ -124,9 +117,6 @@ Blocks solution_get_blocks(Solution sln) /** * Get the configuration name at a given index. - * \param sln The solution to query. - * \param index The configuration index to query. - * \returns The configuration name at the given index. */ const char* solution_get_config(Solution sln, int index) { @@ -141,8 +131,6 @@ const char* solution_get_config(Solution sln, int index) /** * Get the list of configuration names. - * \param sln The solution to query. - * \returns The configuration name at the given index. */ Strings solution_get_configs(Solution sln) { @@ -198,8 +186,6 @@ const char* solution_get_filename(Solution sln, const char* basename, const char /** * Get the programming language set globally for the solution. - * \param sln The solution object to modify. - * \returns The language set for the solution, or NULL if no language has been set. */ const char* solution_get_language(Solution sln) { @@ -210,8 +196,6 @@ const char* solution_get_language(Solution sln) /** * Retrieve the output location (the relative path from the base directory to the * target output directory) for this solution. - * \param sln The solution object to modify. - * \returns The solution output location, or NULL if no location has been set. */ const char* solution_get_location(Solution sln) { @@ -221,7 +205,6 @@ const char* solution_get_location(Solution sln) /** * Get the name of the solution. - * \returns The name, if set, NULL otherwise. */ const char* solution_get_name(Solution sln) { @@ -231,9 +214,6 @@ const char* solution_get_name(Solution sln) /** * Retrieve a project from the solution. - * \param sln The solution to query. - * \param index The index of the project to retreive. - * \returns The project at the given index within the solution. */ Project solution_get_project(Solution sln, int index) { @@ -247,10 +227,17 @@ Project solution_get_project(Solution sln, int index) /** + * Retrieve the session which contains this solution. + */ +Session solution_get_session(Solution sln) +{ + assert(sln); + return sln->session; +} + + +/** * Retrieve a string (single value) fields from a solution, using the field indices. - * \param sln The solution object to query. - * \param field The index of the field to query. - * \returns The value of the field if set, of NULL. */ const char* solution_get_value(Solution sln, enum SolutionField field) { @@ -261,8 +248,6 @@ const char* solution_get_value(Solution sln, enum SolutionField field) /** * Return the number of configurations contained by this solution. - * \param sln The solution to query. - * \returns The number of configurations contained by the solution. */ int solution_num_configs(Solution sln) { @@ -275,8 +260,6 @@ int solution_num_configs(Solution sln) /** * Return the number of projects contained by this solution. - * \param sln The solution to query. - * \returns The number of projects contained by the solution. */ int solution_num_projects(Solution sln) { @@ -287,8 +270,6 @@ int solution_num_projects(Solution sln) /** * Set the base directory of the solution. - * \param sln The solution object to modify. - * \param base_dir The new base directory. */ void solution_set_base_dir(Solution sln, const char* base_dir) { @@ -298,8 +279,6 @@ void solution_set_base_dir(Solution sln, const char* base_dir) /** * Set the global programming language for the solution. - * \param sln The solution to modify. - * \param language The programming language to set globally for the solution. */ void solution_set_language(Solution sln, const char* language) { @@ -310,8 +289,6 @@ void solution_set_language(Solution sln, const char* language) /* * Set the output location (the relative path from the base directory to the * target output directory) for this solution. - * \param sln The solution object to modify. - * \param location The new output location. */ void solution_set_location(Solution sln, const char* location) { @@ -321,8 +298,6 @@ void solution_set_location(Solution sln, const char* location) /** * Set the name of the solution. - * \param sln The solution object. - * \param name The new for the solution. */ void solution_set_name(Solution sln, const char* name) { @@ -331,10 +306,17 @@ void solution_set_name(Solution sln, const char* name) /** + * Associate this solution with a session (internal). + */ +void solution_set_session(Solution sln, Session sess) +{ + assert(sln); + sln->session = sess; +} + + +/** * Set a string (single value) field on a solution, using the field indices. - * \param sln The solution object. - * \param field The field to set. - * \param value The new value for the field. */ void solution_set_value(Solution sln, enum SolutionField field, const char* value) { diff --git a/src/project/solution.h b/src/objects/solution.h index 2ebecc2..90e72ab 100644 --- a/src/project/solution.h +++ b/src/objects/solution.h @@ -3,14 +3,19 @@ * \brief The Solution class, representing the top-level container for projects. * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project * - * \addtogroup project + * \defgroup solution Solution + * \ingroup objects + * * @{ */ #if !defined(PREMAKE_SOLUTION_H) #define PREMAKE_SOLUTION_H +DECLARE_CLASS(Solution) + #include "fields.h" #include "project.h" +#include "blocks.h" #include "base/strings.h" @@ -31,8 +36,6 @@ enum SolutionField extern struct FieldInfo SolutionFieldInfo[]; -DECLARE_CLASS(Solution) - Solution solution_create(void); void solution_destroy(Solution sln); @@ -48,6 +51,7 @@ const char* solution_get_language(Solution sln); const char* solution_get_location(Solution sln); const char* solution_get_name(Solution sln); Project solution_get_project(Solution sln, int index); +Session solution_get_session(Solution sln); const char* solution_get_value(Solution sln, enum SolutionField field); int solution_num_configs(Solution sln); int solution_num_projects(Solution sln); diff --git a/src/objects/tests/block_tests.cpp b/src/objects/tests/block_tests.cpp new file mode 100644 index 0000000..3b83a8e --- /dev/null +++ b/src/objects/tests/block_tests.cpp @@ -0,0 +1,80 @@ +/** + * \file block_tests.cpp + * \brief Automated tests for the configuration blocks API. + * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project + */ + +#include "premake.h" +#include "testing/testing.h" +extern "C" { +#include "objects/solution.h" +#include "objects/block.h" +#include "base/env.h" +} + + +struct FxBlock +{ + Block blk; + Strings terms; + + FxBlock() + { + blk = block_create(); + terms = strings_create(); + block_set_values(blk, BlockTerms, terms); + } + + ~FxBlock() + { + block_destroy(blk); + } +}; + + +SUITE(project) +{ + TEST_FIXTURE(FxBlock, Create_ReturnsObject_OnSuccess) + { + CHECK(blk != NULL); + } + + TEST_FIXTURE(FxBlock, AppliesTo_CanMatchOS) + { + env_set_os(MacOSX); + strings_add(terms, "macosx"); + CHECK(block_applies_to(blk, "Debug")); + } + + TEST_FIXTURE(FxBlock, AppliesTo_CanMatchAction) + { + env_set_action("vs2005"); + strings_add(terms, "vs2005"); + CHECK(block_applies_to(blk, "Debug")); + } + + TEST_FIXTURE(FxBlock, AppliesTo_CanMatchConfig) + { + strings_add(terms, "debug"); + CHECK(block_applies_to(blk, "Debug")); + } + + TEST_FIXTURE(FxBlock, AppliesTo_AcceptsPatterns) + { + strings_add(terms, "Debug .*"); + CHECK(block_applies_to(blk, "Debug DLL")); + } + + TEST_FIXTURE(FxBlock, AppliesTo_AcceptsNullConfig) + { + CHECK(block_applies_to(blk, NULL)); + } + + TEST_FIXTURE(FxBlock, AppliesTo_ReturnsFalse_OnUnmatchedTerm) + { + strings_add(terms, "NoSuchKeyword"); + CHECK(!block_applies_to(blk, "Debug")); + } +} + + diff --git a/src/project/tests/fields_tests.cpp b/src/objects/tests/fields_tests.cpp index 8d50ba2..7be0fb7 100644 --- a/src/project/tests/fields_tests.cpp +++ b/src/objects/tests/fields_tests.cpp @@ -7,7 +7,7 @@ #include "premake.h" #include "testing/testing.h" extern "C" { -#include "project/fields.h" +#include "objects/fields.h" } enum TestFields diff --git a/src/objects/tests/objects_tests.cpp b/src/objects/tests/objects_tests.cpp new file mode 100644 index 0000000..9ef0e56 --- /dev/null +++ b/src/objects/tests/objects_tests.cpp @@ -0,0 +1,26 @@ +/** + * \file objects_tests.cpp + * \brief Automated tests for the project-related objects. + * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project + */ + +#include "premake.h" +#include "testing/testing.h" +extern "C" { +#include "objects/objects.h" +} + + +/** + * \brief Run the objects library automated tests. + * \returns OKAY if all tests completed successfully. + */ +int objects_tests() +{ + int z = OKAY; + if (z == OKAY) z = tests_run_suite("fields"); + if (z == OKAY) z = tests_run_suite("project"); + if (z == OKAY) z = tests_run_suite("project_config"); + if (z == OKAY) z = tests_run_suite("session"); + return z; +} diff --git a/src/project/tests/project_config_tests.cpp b/src/objects/tests/project_config_tests.cpp index 630de68..16d3d03 100644 --- a/src/project/tests/project_config_tests.cpp +++ b/src/objects/tests/project_config_tests.cpp @@ -7,9 +7,8 @@ #include "premake.h" #include "testing/testing.h" extern "C" { -#include "project/solution.h" -#include "project/project.h" -#include "project/project_internal.h" +#include "objects/solution.h" +#include "objects/objects_internal.h" } diff --git a/src/objects/tests/project_tests.cpp b/src/objects/tests/project_tests.cpp new file mode 100644 index 0000000..ad2a2d7 --- /dev/null +++ b/src/objects/tests/project_tests.cpp @@ -0,0 +1,118 @@ +/** + * \file project_tests.cpp + * \brief Automated tests for the project objects API. + * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project + */ + +#include "premake.h" +#include "testing/testing.h" +extern "C" { +#include "objects/solution.h" +#include "objects/objects_internal.h" +#include "base/env.h" +} + + +struct FxProject +{ + Solution sln; + Project prj; + + FxProject() + { + sln = solution_create(); + prj = project_create(); + } + + ~FxProject() + { + project_destroy(prj); + solution_destroy(sln); + } +}; + + +SUITE(project) +{ + TEST_FIXTURE(FxProject, Create_ReturnsObject_OnSuccess) + { + CHECK(prj != NULL); + } + + + /********************************************************************** + * Filename tests + **********************************************************************/ + + TEST_FIXTURE(FxProject, GetFilename_ReturnsFullPath_OnNoLocation) + { + project_set_name(prj, "MyProject"); + project_set_base_dir(prj, "/BaseDir"); + const char* filename = project_get_filename(prj, NULL, ".xyz"); + CHECK_EQUAL("/BaseDir/MyProject.xyz", filename); + } + + TEST_FIXTURE(FxProject, GetFilename_ReturnsFullPath_OnLocation) + { + project_set_name(prj, "MyProject"); + project_set_base_dir(prj, "/BaseDir"); + project_set_location(prj, "Location"); + const char* filename = project_get_filename(prj, NULL, ".xyz"); + CHECK_EQUAL("/BaseDir/Location/MyProject.xyz", filename); + } + + + + /********************************************************************** + * Language tests + **********************************************************************/ + + TEST_FIXTURE(FxProject, GetLanguage_ReturnsSolutionLanguage_OnNoProjectLanguage) + { + project_set_solution(prj, sln); + solution_set_language(sln, "c#"); + const char* result = project_get_language(prj); + CHECK_EQUAL("c#", result); + } + + + /********************************************************************** + * Output file tests + **********************************************************************/ + + TEST_FIXTURE(FxProject, GetOutFile_ReturnsProjectName_OnNoTargetAndNotWindows) + { + env_set_os(MacOSX); + project_set_name(prj, "MyProject"); + const char* result = project_get_outfile(prj); + CHECK_EQUAL("MyProject", result); + } + + TEST_FIXTURE(FxProject, GetOutFile_AddsExe_OnNoTargetAndWindows) + { + env_set_os(Windows); + project_set_name(prj, "MyProject"); + const char* result = project_get_outfile(prj); + CHECK_EQUAL("MyProject.exe", result); + } + + + /********************************************************************** + * Solution tests + **********************************************************************/ + + TEST_FIXTURE(FxProject, GetSolution_ReturnsNull_OnStartup) + { + Solution result = project_get_solution(prj); + CHECK(result == NULL); + } + + TEST_FIXTURE(FxProject, SetSolution_CanRoundtrip) + { + project_set_solution(prj, sln); + CHECK(sln == project_get_solution(prj)); + } + +} + + diff --git a/src/session/tests/session_tests.cpp b/src/objects/tests/session_tests.cpp index 0a98b9c..f3e9790 100644 --- a/src/session/tests/session_tests.cpp +++ b/src/objects/tests/session_tests.cpp @@ -7,26 +7,10 @@ #include "premake.h" #include "testing/testing.h" extern "C" { -#include "session/session.h" -#include "script/script.h" +#include "objects/session.h" #include "base/base.h" #include "base/error.h" -#include "platform/platform.h" -} - - -/** - * \brief Run the engine automated tests. - * \returns OKAY if all tests completed successfully. - * \note Also runs the tests for all dependencies (everything but the host executable). - */ -int session_tests() -{ - int z = base_tests(); - if (z == OKAY) z = project_tests(); - if (z == OKAY) z = script_tests(); - if (z == OKAY) z = tests_run_suite("session"); - return z; +#include "base/env.h" } @@ -48,37 +32,37 @@ static int num_config_calls; static const char* last_config_filter; -static int test_solution_okay(Session sess, Solution sln, Stream strm) +static int test_solution_okay(Solution sln, Stream strm) { - UNUSED(sess); UNUSED(sln); UNUSED(strm); + UNUSED(sln); UNUSED(strm); num_solution_calls++; return OKAY; } -static int test_solution_fail(Session sess, Solution sln, Stream strm) +static int test_solution_fail(Solution sln, Stream strm) { - UNUSED(sess); UNUSED(sln); UNUSED(strm); + UNUSED(sln); UNUSED(strm); return !OKAY; } -static int test_project_okay(Session sess, Project prj, Stream strm) +static int test_project_okay(Project prj, Stream strm) { - UNUSED(sess); UNUSED(prj); UNUSED(strm); + UNUSED(prj); UNUSED(strm); num_project_calls++; return OKAY; } -static int test_project_fail(Session sess, Project prj, Stream strm) +static int test_project_fail(Project prj, Stream strm) { - UNUSED(sess); UNUSED(prj); UNUSED(strm); + UNUSED(prj); UNUSED(strm); return !OKAY; } -static int test_config_okay(Session sess, Project prj, Stream strm) +static int test_config_okay(Project prj, Stream strm) { - UNUSED(sess); UNUSED(strm); + UNUSED(strm); num_config_calls++; - last_config_filter = project_get_configuration_filter(prj); + last_config_filter = project_get_config(prj); return OKAY; } @@ -135,78 +119,6 @@ SUITE(session) /********************************************************************** - * Script execution tests - **********************************************************************/ - - TEST_FIXTURE(FxSession, RunString_ReturnsValue_OnString) - { - const char* result = session_run_string(sess, "return 'string value'"); - CHECK_EQUAL("string value", result); - } - - TEST_FIXTURE(FxSession, RunString_ReturnsValue_OnInteger) - { - const char* result = session_run_string(sess, "return 18"); - CHECK_EQUAL("18", result); - } - - TEST_FIXTURE(FxSession, RunString_ReturnsValue_OnBoolean) - { - const char* result = session_run_string(sess, "return true"); - CHECK_EQUAL("true", result); - } - - TEST_FIXTURE(FxSession, RunFile_ReturnsValue_OnValidFile) - { - const char* result = session_run_file(sess, "testing/test_files/true.lua"); - CHECK_EQUAL("true", result); - } - - - /********************************************************************** - * Action handling tests - **********************************************************************/ - - TEST_FIXTURE(FxSession, SetAction_SetScriptVar) - { - session_set_action(sess, "MyAction"); - const char* result = session_run_string(sess, "return _ACTION"); - CHECK_EQUAL("MyAction", result); - } - - TEST_FIXTURE(FxSession, GetAction_ReturnsNull_OnNoAction) - { - const char* result = session_get_action(sess); - CHECK(result == NULL); - } - - TEST_FIXTURE(FxSession, GetAction_GetsFromScriptVar) - { - session_run_string(sess, "_ACTION = 'SomeAction'"); - const char* result = session_get_action(sess); - CHECK_EQUAL("SomeAction", result); - } - - - /********************************************************************** - * Configuration filtering tests - **********************************************************************/ - - TEST_FIXTURE(FxSession, SetAction_UpdatesFilter) - { - session_set_action(sess, "MyAction"); - Filter filter = session_get_filter(sess); - CHECK_EQUAL("MyAction", filter_get_value(filter, FilterAction)); - } - - TEST_FIXTURE(FxSession, Ctor_SetsOSFilter) - { - Filter filter = session_get_filter(sess); - CHECK_EQUAL(platform_get_name(), filter_get_value(filter, FilterOS)); - } - - - /********************************************************************** * Solution containment tests **********************************************************************/ @@ -357,17 +269,6 @@ SUITE(session) /********************************************************************** - * Unload tests - most unload testing is done elsewhere - **********************************************************************/ - - TEST_FIXTURE(FxSession, Unload_ReturnsOkay_OnNoProjectInfo) - { - int result = session_unload(sess); - CHECK(result == OKAY); - } - - - /********************************************************************** * Session validation tests **********************************************************************/ diff --git a/src/project/tests/solution_tests.cpp b/src/objects/tests/solution_tests.cpp index 0078b00..aba736b 100644 --- a/src/project/tests/solution_tests.cpp +++ b/src/objects/tests/solution_tests.cpp @@ -7,9 +7,8 @@ #include "premake.h" #include "testing/testing.h" extern "C" { -#include "project/solution.h" -#include "project/project.h" -#include "project/project_internal.h" +#include "objects/solution.h" +#include "objects/objects_internal.h" #include "base/strings.h" } @@ -38,43 +37,6 @@ SUITE(project) CHECK(sln != NULL); } - - /********************************************************************** - * Name tests - **********************************************************************/ - - TEST_FIXTURE(FxSolution, GetName_ReturnsNull_OnStartup) - { - const char* name = solution_get_name(sln); - CHECK(name == NULL); - } - - TEST_FIXTURE(FxSolution, SetName_CanRoundtrip) - { - solution_set_name(sln, "MySolution"); - const char* name = solution_get_name(sln); - CHECK_EQUAL("MySolution", name); - } - - - /********************************************************************** - * Base directory tests - **********************************************************************/ - - TEST_FIXTURE(FxSolution, GetBaseDir_ReturnsNull_OnStartup) - { - const char* result = solution_get_base_dir(sln); - CHECK(result == NULL); - } - - TEST_FIXTURE(FxSolution, SetBaseDir_CanRoundtrip) - { - solution_set_base_dir(sln, "BaseDir"); - const char* result = solution_get_base_dir(sln); - CHECK_EQUAL("BaseDir", result); - } - - /********************************************************************** * Configuration containment tests **********************************************************************/ @@ -114,42 +76,6 @@ SUITE(project) /********************************************************************** - * Language tests - **********************************************************************/ - - TEST_FIXTURE(FxSolution, GetLanguage_ReturnsNull_OnStartup) - { - const char* result = solution_get_language(sln); - CHECK(result == NULL); - } - - TEST_FIXTURE(FxSolution, SetLanguage_CanRoundtrip) - { - solution_set_language(sln, "c++"); - const char* result = solution_get_language(sln); - CHECK_EQUAL("c++", result); - } - - - /********************************************************************** - * Location tests - **********************************************************************/ - - TEST_FIXTURE(FxSolution, GetLocation_ReturnsNull_OnStartup) - { - const char* result = solution_get_location(sln); - CHECK(result == NULL); - } - - TEST_FIXTURE(FxSolution, SetLocation_CanRoundtrip) - { - solution_set_location(sln, "Location"); - const char* result = solution_get_location(sln); - CHECK_EQUAL("Location", result); - } - - - /********************************************************************** * Filename tests **********************************************************************/ diff --git a/src/platform/platform.c b/src/platform/platform.c deleted file mode 100644 index 157fed4..0000000 --- a/src/platform/platform.c +++ /dev/null @@ -1,55 +0,0 @@ -/** - * \file platform.c - * \brief Platform abstraction API. - * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project - */ - -#include <assert.h> -#include "premake.h" -#include "platform.h" - -static enum Platform CurrentPlatform = Unknown; - - -enum Platform platform_get() -{ - if (CurrentPlatform == Unknown) - { -#if defined(PLATFORM_BSD) - CurrentPlatform = BSD; -#elif defined(PLATFORM_LINUX) - CurrentPlatform = Linux; -#elif defined(PLATFORM_MACOSX) - CurrentPlatform = MacOSX; -#else - CurrentPlatform = Windows; -#endif - } - return CurrentPlatform; -} - - -const char* platform_get_name(void) -{ - enum Platform id = platform_get(); - switch (id) - { - case BSD: - return "BSD"; - case Linux: - return "Linux"; - case MacOSX: - return "MacOSX"; - case Windows: - return "Windows"; - default: - assert(0); - return 0; - } -} - - -void platform_set(enum Platform id) -{ - CurrentPlatform = id; -} diff --git a/src/platform/platform.h b/src/platform/platform.h index 91feea0..a3a740d 100644 --- a/src/platform/platform.h +++ b/src/platform/platform.h @@ -13,21 +13,6 @@ #define PREMAKE_PLATFORM_H -/** - * The currently support platforms. If you add to this list be sure to - * also update the platform detection logic below, and the platform - * identifier initialization in platform.c. - */ -enum Platform -{ - Unknown, - BSD, - Linux, - MacOSX, - Windows -}; - - #if defined(__linux__) #define PLATFORM_LINUX (1) #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) @@ -38,6 +23,7 @@ enum Platform #define PLATFORM_WINDOWS (1) #endif + DECLARE_CLASS(PlatformSearch) @@ -73,18 +59,6 @@ int platform_dir_set_current(const char* path); /** - * Retrieve the current platform identifier. - */ -enum Platform platform_get(void); - - -/** - * Retrieve the current platform identifier as a string value. - */ -const char* platform_get_name(void); - - -/** * Create a new platform file search context. */ PlatformSearch platform_search_create(const char* mask); @@ -115,13 +89,5 @@ int platform_search_is_file(PlatformSearch search); int platform_search_next(PlatformSearch search); -/** - * Set the platform identification string, forcing a platform-specific - * behavior regardless of the actual current platform. - * \param id One of the platform identifiers. - */ -void platform_set(enum Platform id); - - #endif /** @} */ diff --git a/src/premake.c b/src/premake.c index 6a4cf65..63e4668 100644 --- a/src/premake.c +++ b/src/premake.c @@ -11,25 +11,12 @@ /** - * These are the steps in the process; each function runs one part of the whole. - */ -static HostExecutionStep Steps[] = -{ - host_parse_argv, /* process the command line arguments */ - host_run_script, /* run the main script (i.e. premake4.lua) */ - session_unload, /* unload the objects built by the script into more accessible C data structures */ - host_show_help, /* show help and version messages as appropriate; may end processing here */ - host_run_action, /* run the action specified on the command line */ - NULL /* all done! */ -}; - - -/** * \brief Program entry point. */ int main(int argc, const char** argv) { - Session sess; + Host host; + int z = OKAY; /* If testing is enabled, calling premake.exe with no arguments will * trigger a call to the automated tests. This is used by a post-build @@ -44,15 +31,18 @@ int main(int argc, const char** argv) #endif /* initialize */ - host_set_argv(argv); - sess = session_create(); + host = host_create(); + host_set_argv(host, argv); /* run */ - host_run_steps(sess, Steps); + if (z == OKAY) z = host_parse_argv(host); + if (z == OKAY) z = host_run_script(host); + if (z == OKAY) z = host_show_help(host); + if (z == OKAY) z = host_run_action(host); /* report back to the user and clean up */ - host_report_results(sess); - session_destroy(sess); - return OKAY; + host_report_results(); + host_destroy(host); + return z; } diff --git a/src/premake.lua b/src/premake.lua index 688862c..d4059b5 100644 --- a/src/premake.lua +++ b/src/premake.lua @@ -3,7 +3,7 @@ package.target = "premake4" package.language = "c" package.kind = "exe" - local lua = "script/lua-5.1.2" + local lua = "base/lua-5.1.2" local unittest = "testing/UnitTest++/src" diff --git a/src/project/filter.c b/src/project/filter.c deleted file mode 100644 index 87291a9..0000000 --- a/src/project/filter.c +++ /dev/null @@ -1,116 +0,0 @@ -/** - * \file filter.c - * \brief Configuration filter settings. - * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project - */ - -#include <assert.h> -#include <stdlib.h> -#include "premake.h" -#include "project/filter.h" -#include "base/cstr.h" - - -DEFINE_CLASS(Filter) -{ - const char* values[NumFilters]; - Script script; -}; - - -/** - * Create and initialize a new configuration filter. - * \param script A scripting object; used for script_is_match(). - * \returns A new configuration filter. - */ -Filter filter_create(Script script) -{ - int i; - - Filter flt = ALLOC_CLASS(Filter); - for (i = 0; i < NumFilters; ++i) - { - flt->values[i] = NULL; - } - flt->script = script; - return flt; -} - - -/** - * Destroy a configuration filter and release the associated memory. - * \param flt The configuration filter to destroy. - */ -void filter_destroy(Filter flt) -{ - assert(flt); - free(flt); -} - - -/** - * Retrieve a filter value. - * \param flt The configuration filter to query. - * \param key The value key to query. - * \returns The current value of the key. - */ -const char* filter_get_value(Filter flt, enum FilterKey key) -{ - assert(flt); - assert(key >= 0 && key < NumFilters); - return flt->values[key]; -} - - -/** - * Determines if the filter includes the specified list of terms. All terms in the - * list must be included in the filter. - * \param flt The configuration filter to query. - * \param terms The list of terms to check. - * \returns True is the list of terms is included in the filter. - */ -int filter_is_match(Filter flt, Strings terms) -{ - int ti, tn; - - assert(flt); - assert(terms); - - tn = strings_size(terms); - for (ti = 0; ti < tn; ++ti) - { - int ki, is_match = 0; - - const char* term = strings_item(terms, ti); - for (ki = 0; ki < NumFilters; ++ki) - { - const char* key = flt->values[ki]; - if (key != NULL && script_is_match(flt->script, key, term)) - { - is_match = 1; - break; - } - } - - if (!is_match) - { - return 0; - } - } - - return 1; -} - - -/** - * Set a filter value. - * \param flt The configuration filter to set. - * \param key The value key to set. - * \param value The new value for the key. - */ -void filter_set_value(Filter flt, enum FilterKey key, const char* value) -{ - assert(flt); - assert(key >= 0 && key < NumFilters); - flt->values[key] = value; -} diff --git a/src/project/filter.h b/src/project/filter.h deleted file mode 100644 index 43979b5..0000000 --- a/src/project/filter.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * \file filter.h - * \brief Configuration filter settings. - * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project - * - * \addtogroup project - * @{ - */ -#if !defined(PREMAKE_FILTER_H) -#define PREMAKE_FILTER_H - -#include "base/strings.h" -#include "script/script.h" - - -/** - * Configuration filter keys. - */ -enum FilterKey -{ - FilterAction, - FilterConfig, - FilterOS, - NumFilters -}; - - -DECLARE_CLASS(Filter) - -Filter filter_create(Script script); -void filter_destroy(Filter flt); - -const char* filter_get_value(Filter flt, enum FilterKey key); -int filter_is_match(Filter flt, Strings terms); -void filter_set_value(Filter flt, enum FilterKey key, const char* value); - - -#endif -/** @} */ diff --git a/src/project/tests/block_tests.cpp b/src/project/tests/block_tests.cpp deleted file mode 100644 index ae75305..0000000 --- a/src/project/tests/block_tests.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/** - * \file block_tests.cpp - * \brief Automated tests for the configuration blocks API. - * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project - */ - -#include "premake.h" -#include "testing/testing.h" -extern "C" { -#include "project/solution.h" -#include "project/project.h" -#include "project/block.h" -} - - -struct FxBlock -{ - Solution sln; - Project prj; - Block blk; - - FxBlock() - { - sln = solution_create(); - prj = project_create(); - blk = block_create(); - } - - ~FxBlock() - { - block_destroy(blk); - project_destroy(prj); - solution_destroy(sln); - } -}; - - -SUITE(project) -{ - TEST_FIXTURE(FxBlock, Create_ReturnsObject_OnSuccess) - { - CHECK(blk != NULL); - } -} - - diff --git a/src/project/tests/filter_tests.cpp b/src/project/tests/filter_tests.cpp deleted file mode 100644 index bb5315a..0000000 --- a/src/project/tests/filter_tests.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/** - * \file filter_tests.cpp - * \brief Automated tests for the configuration filters API. - * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project - */ - -#include "premake.h" -#include "testing/testing.h" -extern "C" { -#include "session/session.h" -} - - -struct FxFilter -{ - Session sess; - Filter flt; - Strings terms; - - FxFilter() - { - sess = session_create(); - flt = session_get_filter(sess); - terms = strings_create(); - } - - ~FxFilter() - { - session_destroy(sess); - strings_destroy(terms); - } -}; - - -SUITE(project) -{ - TEST_FIXTURE(FxFilter, Create_ReturnsObject_OnSuccess) - { - CHECK(flt != NULL); - } - - TEST_FIXTURE(FxFilter, SetValue_CanRoundtrip) - { - filter_set_value(flt, FilterConfig, "Debug"); - const char* result = filter_get_value(flt, FilterConfig); - CHECK_EQUAL("Debug", result); - } - - TEST_FIXTURE(FxFilter, IsMatch_ReturnsTrue_OnValueMatch) - { - filter_set_value(flt, FilterConfig, "Debug"); - strings_add(terms, "Debug"); - CHECK(filter_is_match(flt, terms)); - } - - TEST_FIXTURE(FxFilter, IsMatch_ReturnsFalse_OnNullKey) - { - strings_add(terms, "Debug"); - CHECK(!filter_is_match(flt, terms)); - } - - TEST_FIXTURE(FxFilter, IsMatch_ReturnsFalse_OnValueMismatch) - { - filter_set_value(flt, FilterConfig, "Release"); - strings_add(terms, "Debug"); - CHECK(!filter_is_match(flt, terms)); - } - - TEST_FIXTURE(FxFilter, IsMatch_ReturnsTrue_OnWildcardMatch) - { - filter_set_value(flt, FilterConfig, "DebugDLL"); - strings_add(terms, "Debug.*"); - CHECK(filter_is_match(flt, terms)); - } - - TEST_FIXTURE(FxFilter, IsMatch_ReturnsTrue_OnSetMatch) - { - filter_set_value(flt, FilterAction, "vs2008"); - strings_add(terms, "vs200[58]"); - CHECK(filter_is_match(flt, terms)); - } -} - - diff --git a/src/project/tests/project_tests.cpp b/src/project/tests/project_tests.cpp deleted file mode 100644 index 96d5acf..0000000 --- a/src/project/tests/project_tests.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/** - * \file project_tests.cpp - * \brief Automated tests for the project objects API. - * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project - */ - -#include "premake.h" -#include "testing/testing.h" -extern "C" { -#include "project/solution.h" -#include "project/project.h" -#include "project/project_internal.h" -#include "platform/platform.h" -} - - -/** - * \brief Run the project API automated tests. - * \returns OKAY if all tests completed successfully. - */ -int project_tests() -{ - int status = tests_run_suite("fields"); - if (status == OKAY) status = tests_run_suite("project"); - if (status == OKAY) status = tests_run_suite("project_config"); - return status; -} - - -struct FxProject -{ - Solution sln; - Project prj; - - FxProject() - { - sln = solution_create(); - prj = project_create(); - } - - ~FxProject() - { - project_destroy(prj); - solution_destroy(sln); - } -}; - - -SUITE(project) -{ - TEST_FIXTURE(FxProject, Create_ReturnsObject_OnSuccess) - { - CHECK(prj != NULL); - } - - - /********************************************************************** - * Base directory tests - **********************************************************************/ - - TEST_FIXTURE(FxProject, GetBaseDir_ReturnsNull_OnStartup) - { - const char* result = project_get_base_dir(prj); - CHECK(result == NULL); - } - - TEST_FIXTURE(FxProject, SetBaseDir_CanRoundtrip) - { - project_set_base_dir(prj, "BaseDir"); - const char* result = project_get_base_dir(prj); - CHECK_EQUAL("BaseDir", result); - } - - - /********************************************************************** - * Filename tests - **********************************************************************/ - - TEST_FIXTURE(FxProject, GetFilename_ReturnsFullPath_OnNoLocation) - { - project_set_name(prj, "MyProject"); - project_set_base_dir(prj, "/BaseDir"); - const char* filename = project_get_filename(prj, NULL, ".xyz"); - CHECK_EQUAL("/BaseDir/MyProject.xyz", filename); - } - - TEST_FIXTURE(FxProject, GetFilename_ReturnsFullPath_OnLocation) - { - project_set_name(prj, "MyProject"); - project_set_base_dir(prj, "/BaseDir"); - project_set_location(prj, "Location"); - const char* filename = project_get_filename(prj, NULL, ".xyz"); - CHECK_EQUAL("/BaseDir/Location/MyProject.xyz", filename); - } - - - - /********************************************************************** - * GUID tests - **********************************************************************/ - - TEST_FIXTURE(FxProject, GetGuid_ReturnsNull_OnStartup) - { - const char* result = project_get_guid(prj); - CHECK(result == NULL); - } - - TEST_FIXTURE(FxProject, SetGuid_CanRoundtrip) - { - project_set_guid(prj, "AE2461B7-236F-4278-81D3-F0D476F9A4C0"); - const char* result = project_get_guid(prj); - CHECK_EQUAL("AE2461B7-236F-4278-81D3-F0D476F9A4C0", result); - } - - - /********************************************************************** - * Language tests - **********************************************************************/ - - TEST_FIXTURE(FxProject, GetLanguage_ReturnsNull_OnStartup) - { - const char* result = project_get_language(prj); - CHECK(result == NULL); - } - - TEST_FIXTURE(FxProject, SetLanguage_CanRoundtrip) - { - project_set_language(prj, "c++"); - const char* result = project_get_language(prj); - CHECK_EQUAL("c++", result); - } - - TEST_FIXTURE(FxProject, GetLanguage_ReturnsSolutionLanguage_OnNoProjectLanguage) - { - project_set_solution(prj, sln); - solution_set_language(sln, "c#"); - const char* result = project_get_language(prj); - CHECK_EQUAL("c#", result); - } - - - /********************************************************************** - * Location tests - **********************************************************************/ - - TEST_FIXTURE(FxProject, GetLocation_ReturnsNull_OnStartup) - { - const char* result = project_get_location(prj); - CHECK(result == NULL); - } - - TEST_FIXTURE(FxProject, SetLocation_CanRoundtrip) - { - project_set_location(prj, "Location"); - const char* result = project_get_location(prj); - CHECK_EQUAL("Location", result); - } - - - /********************************************************************** - * Name tests - **********************************************************************/ - - TEST_FIXTURE(FxProject, GetName_ReturnsNull_OnStartup) - { - const char* name = project_get_name(prj); - CHECK(name == NULL); - } - - TEST_FIXTURE(FxProject, SetName_CanRoundtrip) - { - project_set_name(prj, "MyProject"); - const char* name = project_get_name(prj); - CHECK_EQUAL("MyProject", name); - } - - - /********************************************************************** - * Output file tests - **********************************************************************/ - - TEST_FIXTURE(FxProject, GetOutFile_ReturnsProjectName_OnNoTargetAndNotWindows) - { - platform_set(MacOSX); - project_set_name(prj, "MyProject"); - const char* result = project_get_outfile(prj); - CHECK_EQUAL("MyProject", result); - } - - TEST_FIXTURE(FxProject, GetOutFile_AddsExe_OnNoTargetAndWindows) - { - platform_set(Windows); - project_set_name(prj, "MyProject"); - const char* result = project_get_outfile(prj); - CHECK_EQUAL("MyProject.exe", result); - } - - - /********************************************************************** - * Solution tests - **********************************************************************/ - - TEST_FIXTURE(FxProject, GetSolution_ReturnsNull_OnStartup) - { - Solution result = project_get_solution(prj); - CHECK(result == NULL); - } - - TEST_FIXTURE(FxProject, SetSolution_CanRoundtrip) - { - project_set_solution(prj, sln); - CHECK(sln == project_get_solution(prj)); - } - -} - - diff --git a/src/script/fn_accessor.c b/src/script/fn_accessor.c index 40013be..68e2db8 100644 --- a/src/script/fn_accessor.c +++ b/src/script/fn_accessor.c @@ -109,7 +109,7 @@ int fn_accessor(lua_State* L) /* get the required container object */ container_type = lua_tointeger(L, lua_upvalueindex(1)); - if (!script_internal_get_active_object(L, container_type, REQUIRED)) + if (!script_internal_get_active_object(L, container_type, IS_REQUIRED)) { return 0; } diff --git a/src/script/fn_configuration.c b/src/script/fn_configuration.c index c32d142..4a6154c 100644 --- a/src/script/fn_configuration.c +++ b/src/script/fn_configuration.c @@ -17,7 +17,7 @@ int fn_configuration(lua_State* L) if (lua_gettop(L) > 0) { /* get the active object, which will contain this new configuration */ - if (!script_internal_get_active_object(L, SolutionObject | ProjectObject, REQUIRED)) + if (!script_internal_get_active_object(L, SolutionObject | ProjectObject, IS_REQUIRED)) { return 0; } @@ -26,11 +26,11 @@ int fn_configuration(lua_State* L) script_internal_create_block(L); /* populate the list of terms from the arguments */ - script_internal_get_active_object(L, BlockObject, REQUIRED); + script_internal_get_active_object(L, BlockObject, IS_REQUIRED); fn_accessor_set_list_value(L, &BlockFieldInfo[BlockTerms]); } - script_internal_get_active_object(L, BlockObject, OPTIONAL); + script_internal_get_active_object(L, BlockObject, IS_OPTIONAL); return 1; } diff --git a/src/script/fn_configurations.c b/src/script/fn_configurations.c index 249805f..9574774 100644 --- a/src/script/fn_configurations.c +++ b/src/script/fn_configurations.c @@ -15,7 +15,7 @@ int fn_configurations(lua_State* L) { struct FieldInfo* field; - if (!script_internal_get_active_object(L, SolutionObject, REQUIRED)) + if (!script_internal_get_active_object(L, SolutionObject, IS_REQUIRED)) { return 0; } diff --git a/src/script/fn_project.c b/src/script/fn_project.c index 761356c..acb7aae 100644 --- a/src/script/fn_project.c +++ b/src/script/fn_project.c @@ -19,12 +19,12 @@ int fn_project(lua_State* L) /* if there are no parameters, return the active project */ if (lua_gettop(L) == 0) { - script_internal_get_active_object(L, ProjectObject, OPTIONAL); + script_internal_get_active_object(L, ProjectObject, IS_OPTIONAL); return 1; } /* get the active solution, which will contain this project */ - if (!script_internal_get_active_object(L, SolutionObject, REQUIRED)) + if (!script_internal_get_active_object(L, SolutionObject, IS_REQUIRED)) { return 0; } diff --git a/src/script/fn_solution.c b/src/script/fn_solution.c index 67d1014..c4cd93f 100644 --- a/src/script/fn_solution.c +++ b/src/script/fn_solution.c @@ -18,7 +18,7 @@ int fn_solution(lua_State* L) /* if there are no parameters, return the active solution */ if (lua_gettop(L) == 0) { - script_internal_get_active_object(L, SolutionObject, OPTIONAL); + script_internal_get_active_object(L, SolutionObject, IS_OPTIONAL); return 1; } diff --git a/src/script/script.c b/src/script/script.c index 0e5bd0e..bfcce58 100644 --- a/src/script/script.c +++ b/src/script/script.c @@ -47,7 +47,7 @@ Script script_create(void) Script script; /* create a new Lua scripting environment */ - lua_State* L = lua_open(); + lua_State* L = luastate_create(); if (L == NULL) { error_set("failed to start Lua scripting engine"); @@ -82,7 +82,7 @@ Script script_create(void) void script_destroy(Script script) { assert(script); - lua_close(script->L); + luastate_destroy(script->L); free(script); } @@ -115,38 +115,6 @@ lua_State* script_get_lua(Script script) } -/** - * Uses Lua's pattern matching functions to test match a value. This is used by - * the configuration filter functions (see filter.c). - * \param script The script engine instance. - * \param str The string to test match. - * \param pattern The Lua pattern to match against. - * \returns True if the string value matches the pattern. - */ -int script_is_match(Script script, const char* str, const char* pattern) -{ - const char* match; - int top, z; - assert(script); - assert(str); - assert(pattern); - - top = lua_gettop(script->L); - - lua_getglobal(script->L, "string"); - lua_getfield(script->L, -1, "match"); - lua_pushstring(script->L, str); - lua_pushstring(script->L, pattern); - lua_call(script->L, 2, 1); - - match = lua_tostring(script->L, -1); - z = cstr_eq(str, match); - - lua_settop(script->L, top); - return z; -} - - /** * Internal shared implementation for script_run_file() and script_run_string(). * \param L The Lua scripting environment. @@ -277,23 +245,31 @@ void script_set_action(Script script, const char* action) /** * Copy project information out of the scripting environment and into C objects that * can be more easily manipulated by the action code. - * \param script The project scripting engine instance. - * \param slns An array to hold the list of unloaded solutions. - * \returns OKAY if successful. + * \returns A new session object if successful (which must be destroyed by the caller), or NULL. */ -int script_unload(Script script, Array slns) +Session script_unload(Script script) { struct UnloadFuncs funcs; + Session sess; int result; assert(script); - assert(slns); funcs.unload_solution = unload_solution; funcs.unload_project = unload_project; funcs.unload_block = unload_block; - result = unload_all(script->L, slns, &funcs); - return result; + + sess = session_create(); + result = unload_all(script->L, sess, &funcs); + if (result != OKAY) + { + session_destroy(sess); + return NULL; + } + else + { + return sess; + } } diff --git a/src/script/script.h b/src/script/script.h index 9259d01..04ab922 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -12,19 +12,18 @@ #if !defined(PREMAKE_SCRIPT_H) #define PREMAKE_SCRIPT_H -#include "base/array.h" +#include "objects/session.h" DECLARE_CLASS(Script) Script script_create(void); void script_destroy(Script script); const char* script_get_action(Script script); -int script_is_match(Script script, const char* str, const char* pattern); const char* script_run_file(Script script, const char* filename); const char* script_run_string(Script script, const char* code); void script_set_action(Script script, const char* action); int script_tests(void); -int script_unload(Script script, Array slns); +Session script_unload(Script script); #endif /** @} */ diff --git a/src/script/script_internal.h b/src/script/script_internal.h index 3839457..f64e5df 100644 --- a/src/script/script_internal.h +++ b/src/script/script_internal.h @@ -7,12 +7,8 @@ #define PREMAKE_SCRIPT_INTERNAL_H #include "script.h" -#include "session/session.h" - -#define lua_c -#include "lua.h" -#include "lauxlib.h" -#include "lualib.h" +#include "objects/session.h" +#include "base/luastate.h" /* string constants for script variables and functions */ @@ -34,8 +30,8 @@ enum ObjectType BlockObject = 0x04 }; -#define OPTIONAL (0) -#define REQUIRED (1) +#define IS_OPTIONAL (0) +#define IS_REQUIRED (1) lua_State* script_get_lua(Script script); @@ -72,7 +68,7 @@ struct UnloadFuncs int (*unload_block)(lua_State* L, Block blk); }; -int unload_all(lua_State* L, Array slns, struct UnloadFuncs* funcs); +int unload_all(lua_State* L, Session sess, struct UnloadFuncs* funcs); int unload_solution(lua_State* L, Solution sln); int unload_project(lua_State* L, Project prj); int unload_block(lua_State* L, Block blk); diff --git a/src/script/tests/unload_tests.cpp b/src/script/tests/unload_tests.cpp index 572fd3a..8c348bc 100644 --- a/src/script/tests/unload_tests.cpp +++ b/src/script/tests/unload_tests.cpp @@ -62,8 +62,8 @@ static int stub_block_fail_func(lua_State* L, Block blk) struct FxUnload { Script script; + Session sess; lua_State* L; - Array slns; UnloadFuncs funcs; FxUnload() @@ -71,7 +71,7 @@ struct FxUnload script = script_create(); L = script_get_lua(script); - slns = array_create(); + sess = session_create(); funcs.unload_solution = stub_solution_func; funcs.unload_project = stub_project_func; @@ -83,7 +83,7 @@ struct FxUnload ~FxUnload() { - array_destroy(slns); + session_destroy(sess); script_destroy(script); } }; @@ -108,20 +108,20 @@ SUITE(unload) { TEST_FIXTURE(FxUnload, Unload_ReturnsOkay_OnEmptySession) { - int result = unload_all(L, slns, &funcs); + int result = unload_all(L, sess, &funcs); CHECK(result == OKAY); } TEST_FIXTURE(FxUnload, Unload_ReturnsEmptySession_OnEmptySession) { - unload_all(L, slns, &funcs); - int n = array_size(slns); + unload_all(L, sess, &funcs); + int n = session_num_solutions(sess); CHECK(n == 0); } TEST_FIXTURE(FxUnload2, Unload_ReturnsOkay_OnNonEmptySession) { - int result = unload_all(L, slns, &funcs); + int result = unload_all(L, sess, &funcs); CHECK(result == OKAY); } @@ -132,28 +132,28 @@ SUITE(unload) TEST_FIXTURE(FxUnload2, Unload_AddsSolutions_OnNonEmptySession) { - unload_all(L, slns, &funcs); - int n = array_size(slns); + unload_all(L, sess, &funcs); + int n = session_num_solutions(sess); CHECK(n == 2); } TEST_FIXTURE(FxUnload2, Unload_CallsSolutionFunc_OnEachSolution) { - unload_all(L, slns, &funcs); + unload_all(L, sess, &funcs); CHECK(num_solution_calls == 2); } TEST_FIXTURE(FxUnload2, Unload_ReturnsNotOkay_OnSolutionFailure) { funcs.unload_solution = stub_solution_fail_func; - int result = unload_all(L, slns, &funcs); + int result = unload_all(L, sess, &funcs); CHECK(result != OKAY); } TEST_FIXTURE(FxUnload2, Unload_AbortsSolutionLoop_OnNotOkay) { funcs.unload_solution = stub_solution_fail_func; - unload_all(L, slns, &funcs); + unload_all(L, sess, &funcs); CHECK(num_solution_calls == 1); } @@ -164,29 +164,29 @@ SUITE(unload) TEST_FIXTURE(FxUnload2, Unload_AddsProjects_OnNonEmptySession) { - unload_all(L, slns, &funcs); - Solution sln = (Solution)array_item(slns, 0); + unload_all(L, sess, &funcs); + Solution sln = session_get_solution(sess, 0); int n = solution_num_projects(sln); CHECK(n == 2); } TEST_FIXTURE(FxUnload2, Unload_CallsProjectFunc_OnEachProject) { - unload_all(L, slns, &funcs); + unload_all(L, sess, &funcs); CHECK(num_project_calls == 2); } TEST_FIXTURE(FxUnload2, Unload_ReturnsNotOkay_OnProjectFailure) { funcs.unload_project = stub_project_fail_func; - int result = unload_all(L, slns, &funcs); + int result = unload_all(L, sess, &funcs); CHECK(result != OKAY); } TEST_FIXTURE(FxUnload2, Unload_AbortsProjectLoop_OnNotOkay) { funcs.unload_project = stub_project_fail_func; - unload_all(L, slns, &funcs); + unload_all(L, sess, &funcs); CHECK(num_project_calls == 1); } @@ -197,29 +197,29 @@ SUITE(unload) TEST_FIXTURE(FxUnload2, Unload_AddsBlocks_OnNonEmptySession) { - unload_all(L, slns, &funcs); - Solution sln = (Solution)array_item(slns, 0); + unload_all(L, sess, &funcs); + Solution sln = session_get_solution(sess, 0); int n = blocks_size(solution_get_blocks(sln)); CHECK(n == 1); } TEST_FIXTURE(FxUnload2, Unload_CallsBlockFunc_OnEachConfig) { - unload_all(L, slns, &funcs); + unload_all(L, sess, &funcs); CHECK(num_block_calls == 5); } TEST_FIXTURE(FxUnload2, Unload_ReturnsNotOkay_OnBlockFailure) { funcs.unload_block = stub_block_fail_func; - int result = unload_all(L, slns, &funcs); + int result = unload_all(L, sess, &funcs); CHECK(result != OKAY); } TEST_FIXTURE(FxUnload2, Unload_AbortsBlockLoop_OnNotOkay) { funcs.unload_block = stub_block_fail_func; - unload_all(L, slns, &funcs); + unload_all(L, sess, &funcs); CHECK(num_block_calls == 1); } diff --git a/src/script/unload.c b/src/script/unload.c index 269adb7..70e4f24 100644 --- a/src/script/unload.c +++ b/src/script/unload.c @@ -17,16 +17,16 @@ static int unload_projects(lua_State* L, struct UnloadFuncs* funcs, Solution sln * Copy project information out of the scripting environment and into C objects that * can be more easily manipulated by the action code. * \param L The Lua scripting engine state. - * \param slns An array to contain the list of unloaded solutions. + * \param sess The session will contain the unloaded objects. * \param funcs The unloading "interface", providing an opportunity to mock for automated testing. * \returns OKAY if successful. */ -int unload_all(lua_State* L, Array slns, struct UnloadFuncs* funcs) +int unload_all(lua_State* L, Session sess, struct UnloadFuncs* funcs) { int si, sn, z = OKAY; assert(L); - assert(slns); + assert(sess); assert(funcs); assert(funcs->unload_solution); assert(funcs->unload_project); @@ -39,7 +39,7 @@ int unload_all(lua_State* L, Array slns, struct UnloadFuncs* funcs) { /* add a new solution to the master list */ Solution sln = solution_create(); - array_add(slns, sln); + session_add_solution(sess, sln); /* get the scripted solution object from the solutions list */ lua_rawgeti(L, -1, si); |