From 05c9525fdce6db586fb9324dddc1ea39098d08c1 Mon Sep 17 00:00:00 2001 From: olsner Date: Sun, 12 Nov 2006 03:39:40 +0000 Subject: [PATCH] update-workspaces.sh: generate atlas makefiles by default *.lua: some extra libraries and options to make atlas work premake: - fixed #156 (creation of spurious dirs with strange permissions) - implemented the "run" project kind to run the tests automatically - changed the clean target for cxxtestgen projects to delete the generated .cpp files so that a make clean all actually regenerates the tests. This was SVN commit r4639. --- build/premake/extern_libs.lua | 17 +++++++--- build/premake/premake.lua | 48 ++++++++++++++++----------- build/premake/src/Src/gnu_cpp.c | 24 ++++++++++---- build/premake/src/Src/io.c | 8 +++-- build/workspaces/update-workspaces.sh | 2 +- 5 files changed, 64 insertions(+), 35 deletions(-) diff --git a/build/premake/extern_libs.lua b/build/premake/extern_libs.lua index 66d48bd5cb..72527d6b51 100644 --- a/build/premake/extern_libs.lua +++ b/build/premake/extern_libs.lua @@ -45,6 +45,7 @@ libraries_dir = "../../../libraries/" -- library installation rules. extern_lib_defs = { boost = { + unix_names = { "boost_signals" } }, cxxtest = { }, @@ -55,6 +56,7 @@ extern_lib_defs = { dbg_suffix = "", }, devil = { + unix_names = { "IL", "ILU" }, }, directx = { win_names = { "ddraw", "dsound" }, @@ -89,11 +91,16 @@ extern_lib_defs = { }, wxwidgets = { add_func = function() - tinsert(package.includepaths, libraries_dir.."wxwidgets/include/msvc") - tinsert(package.includepaths, libraries_dir.."wxwidgets/include") - tinsert(package.libpaths, libraries_dir.."wxwidgets/lib/vc_lib") - package.config["Debug" ].links = { "wxmsw26ud_gl" } - package.config["Release"].links = { "wxmsw26u_gl" } + if OS == "windows" then + tinsert(package.includepaths, libraries_dir.."wxwidgets/include/msvc") + tinsert(package.includepaths, libraries_dir.."wxwidgets/include") + tinsert(package.libpaths, libraries_dir.."wxwidgets/lib/vc_lib") + package.config["Debug" ].links = { "wxmsw26ud_gl" } + package.config["Release"].links = { "wxmsw26u_gl" } + else + tinsert(package.buildoptions, "`wx-config --cxxflags`") + tinsert(package.linkoptions, "`wx-config --libs std,gl,ogl,media`") + end end, }, xerces = { diff --git a/build/premake/premake.lua b/build/premake/premake.lua index 6f7e969dc4..5a1101b6f9 100755 --- a/build/premake/premake.lua +++ b/build/premake/premake.lua @@ -83,6 +83,13 @@ function package_set_build_flags() -- non-IEEE-conformant results, but haven't noticed any trouble so far. "-ffast-math", } + package.includepaths = { + "/usr/X11R6/include/X11", + "/usr/include/X11", + } + package.libpaths = { + "/usr/X11R6/lib" + } package.defines = { "__STDC_VERSION__=199901L", "CONFIG_USE_MMGR" @@ -102,6 +109,8 @@ function package_create(package_name, target_type) package.name = package_name package.kind = target_type + package.includepaths = {} + package_set_target(package_name) package_set_build_flags() @@ -125,8 +134,6 @@ function package_add_contents(source_root, rel_source_dirs, rel_include_dirs, ex package.trimprefix = source_root package.files = sourcesfromdirs(source_root, rel_source_dirs) - package.includepaths = {} - -- Put the project-specific PCH directory at the start of the -- include path, so '#include "precompiled.h"' will look in -- there first @@ -322,17 +329,13 @@ function setup_all_libs () "directx" } setup_static_lib_package("lowlevel", source_dirs, extern_libs, {}) - if OS == "windows" then - tinsert(package.files, sourcesfromdirs(source_root, {"lib/sysdep/win"})) + sysdep_dirs = { + linux = { "lib/sysdep/unix" }, -- note: RC file must be added to main_exe package. - elseif OS == "linux" then - tinsert(package.files, sourcesfromdirs(source_root, {"lib/sysdep/unix"})) - -- (X11 include path isn't standard across distributions) - tinsert(package.includepaths, "/usr/X11R6/include/X11" ) - tinsert(package.includepaths, "/usr/include/X11" ) - elseif OS == "macosx" then - tinsert(package.files, sourcesfromdirs(source_root, {"lib/sysdep/osx"})) - end + windows = { "lib/sysdep/win" }, + macosx = { "lib/sysdep/osx" }, + } + tinsert(package.files, sourcesfromdirs(source_root, sysdep_dirs[OS])); end @@ -422,9 +425,6 @@ function setup_main_exe () package.config["Debug"].linkoptions = { "-rdynamic" } package.config["Testing"].linkoptions = { "-rdynamic" } - - - tinsert(package.libpaths, "/usr/X11R6/lib") elseif OS == "macosx" then -- Libraries tinsert(package.links, { -- Utilities @@ -478,7 +478,8 @@ local function setup_atlas_package(package_name, target_type, rel_source_dirs, r end else -- Non-Windows, = Unix - -- TODO + tinsert(package.buildoptions, "-rdynamic") + tinsert(package.linkoptions, "-rdynamic") end end @@ -492,7 +493,8 @@ function setup_atlas_packages() "" },{ -- include },{ -- extern_libs - "xerces" + "xerces", + "wxwidgets" },{ -- extra_params }) @@ -526,7 +528,8 @@ function setup_atlas_packages() "ScenarioEditor/Tools/Common" },{ -- include "..", - "CustomControls" + "CustomControls", + "Misc" },{ -- extern_libs "boost", "devil", @@ -571,18 +574,22 @@ local function setup_atlas_frontend_package (package_name) package.trimprefix = source_root package.includepaths = { source_root .. ".." } + package_add_extern_libs(used_extern_libs) + -- Platform Specifics if OS == "windows" then tinsert(package.defines, "_UNICODE") - tinsert(package.links, "AtlasUI") -- required to use WinMain() on Windows, otherwise will default to main() tinsert(package.buildflags, "no-main") else -- Non-Windows, = Unix - -- TODO + tinsert(package.links, "DatafileIO") + tinsert(package.links, "AtlasObject") end + tinsert(package.links, "AtlasUI") + end function setup_atlas_frontends() @@ -686,6 +693,7 @@ function setup_tests() package.config["Testing"].linkoptions = { "-rdynamic" } + tinsert(package.includepaths, ".") tinsert(package.libpaths, "/usr/X11R6/lib") package.rootoptions = "--include=precompiled.h" diff --git a/build/premake/src/Src/gnu_cpp.c b/build/premake/src/Src/gnu_cpp.c index 7dfce0200b..ef14911cb6 100644 --- a/build/premake/src/Src/gnu_cpp.c +++ b/build/premake/src/Src/gnu_cpp.c @@ -56,6 +56,8 @@ int gnu_cpp() io_print("CxxTest Generator"); else if (prj_is_kind("lib")) io_print("Static Library"); + else if (prj_is_kind("run")) + io_print("Run Target"); io_print(" Makefile autogenerated by premake\n"); io_print("# Don't edit this file! Instead edit `premake.lua` then rerun `make`\n\n"); @@ -157,6 +159,8 @@ int gnu_cpp() io_print("ar -cr $(OUTDIR)/$(TARGET) $(OBJECTS); ranlib $(OUTDIR)/$(TARGET)"); else if (prj_is_kind("cxxtestgen")) io_print("true"); + else if (prj_is_kind("run")) + io_print("for a in $(LDDEPS); do echo Running $$a; $$a; done"); else io_print("$(%s) -o $(OUTDIR)/$(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES)", prj_is_lang("c") ? "CC" : "CXX"); io_print("\n"); @@ -211,7 +215,17 @@ int gnu_cpp() } io_print(": $(OBJECTS) $(LDDEPS) $(RESOURCES)\n"); - if (!prj_is_kind("cxxtestgen")) + if (prj_is_kind("cxxtestgen")) + { + io_print("\t@%s --root", prj_get_cxxtestpath()); + io_print(" %s ", prj_get_cxxtest_rootoptions()); + io_print(" -o %s\n\n", prj_get_cxxtest_rootfile()); + } + else if (prj_is_kind("run")) + { + io_print("\t%s$(BLDCMD)\n\n", prefix); + } + else { if (!g_verbose) io_print("\t@echo Linking %s\n", prj_get_pkgname()); @@ -222,12 +236,6 @@ int gnu_cpp() io_print("\t-%sif [ ! -d $(OUTDIR)/$(MACAPP)/MacOS ]; then mkdir -p $(OUTDIR)/$(MACAPP)/MacOS; fi\n", prefix); io_print("\t%s$(BLDCMD)\n\n", prefix); } - else - { - io_print("\t@%s --root", prj_get_cxxtestpath()); - io_print(" %s ", prj_get_cxxtest_rootoptions()); - io_print(" -o %s\n\n", prj_get_cxxtest_rootfile()); - } /* if (prj_is_kind("lib")) @@ -255,6 +263,8 @@ int gnu_cpp() { io_print("\t-%srm -rf $(OUTDIR)/$(TARGET).app $(OBJDIR)\n", prefix); } + else if (prj_is_kind("cxxtestgen")) + io_print("\t-%srm -f $(OBJECTS)\n", prefix); else { io_print("\t-%srm -rf $(OUTDIR)/$(TARGET) $(OBJDIR)\n", prefix); diff --git a/build/premake/src/Src/io.c b/build/premake/src/Src/io.c index 72406c1adf..cf7daebd48 100644 --- a/build/premake/src/Src/io.c +++ b/build/premake/src/Src/io.c @@ -120,14 +120,18 @@ int io_mkdir(const char* path) while (path != NULL) { - char* ptr = strchr(path, '/'); + // If this is the first time through, we want to ignore a possible first + // slash (absolute path). + // If this is the N'th time around (N > 1), path will point to the slash + // that was found. Skip it. + char* ptr = strchr(path+1, '/'); if (ptr != NULL) *ptr = '\0'; platform_mkdir(path); platform_chdir(path); - path = (ptr != NULL) ? ptr + 1 : NULL; + path = ptr; } /* Restore the original working directory */ diff --git a/build/workspaces/update-workspaces.sh b/build/workspaces/update-workspaces.sh index f17c28c7a2..5b504ca0aa 100755 --- a/build/workspaces/update-workspaces.sh +++ b/build/workspaces/update-workspaces.sh @@ -11,7 +11,7 @@ cd $premake_dir # build/premake/ mkdir -p $workspace_dir -./premake --target gnu --outpath $workspace_dir +./premake --target gnu --outpath $workspace_dir --atlas $* # These files need to be linked; premake makefiles assume that the # lua file is accessible from the makefile directory