From 5e17dfec188a10596d422ca2e07bc54c70787a24 Mon Sep 17 00:00:00 2001 From: Renaud Guillard Date: Thu, 5 Dec 2013 20:58:42 +0100 Subject: [PATCH 01/11] Check presence of ld.so.conf files. Add support of additional ld.so.conf in /opt path --- src/base/os.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/base/os.lua b/src/base/os.lua index f7fc7e16..d6f84844 100644 --- a/src/base/os.lua +++ b/src/base/os.lua @@ -67,8 +67,13 @@ formats = { "lib%s.so", "%s.so" } path = os.getenv("LD_LIBRARY_PATH") or "" - for _, v in ipairs(parse_ld_so_conf("/etc/ld.so.conf")) do - path = path .. ":" .. v + for _, prefix in ipairs({"", "/opt"}) do + local conf_file = prefix .. "/etc/ld.so.conf" + if os.isfile(conf_file) then + for _, v in ipairs(parse_ld_so_conf(conf_file)) do + path = path .. ":" .. v + end + end end end From 4e7dc976baabe7f324e65aeb6236d24c56ac084e Mon Sep 17 00:00:00 2001 From: Damien Courtois Date: Thu, 25 Sep 2014 10:41:27 +0200 Subject: [PATCH 02/11] added a buildinput command to add additional input dependencies to custom build commands. --- src/_premake_init.lua | 7 +++++++ src/actions/vstudio/vs2010_vcxproj.lua | 5 +++++ tests/actions/vstudio/vc2010/test_files.lua | 22 +++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/src/_premake_init.lua b/src/_premake_init.lua index 75fb6a5d..de6e6858 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -114,6 +114,13 @@ tokens = true, } + api.register { + name = "buildinputs", + scope = "config", + kind = "list:path", + tokens = true, + } + api.register { name = "buildrule", -- DEPRECATED scope = "config", diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua index 6fa59577..16e468e9 100644 --- a/src/actions/vstudio/vs2010_vcxproj.lua +++ b/src/actions/vstudio/vs2010_vcxproj.lua @@ -656,6 +656,11 @@ if filecfg.buildmessage then m.element("Message", condition, '%s', filecfg.buildmessage) end + + if filecfg.buildinputs and #filecfg.buildinputs > 0 then + local inputs = project.getrelative(prj, filecfg.buildinputs) + m.element("AdditionalInputs", condition, '%s', table.concat(inputs, " ")) + end end end diff --git a/tests/actions/vstudio/vc2010/test_files.lua b/tests/actions/vstudio/vc2010/test_files.lua index c9ce9bbe..a8aa06f9 100755 --- a/tests/actions/vstudio/vc2010/test_files.lua +++ b/tests/actions/vstudio/vc2010/test_files.lua @@ -115,6 +115,28 @@ ]] end + function suite.customBuild_onBuildRuleWithAdditionalInputs() + files { "hello.cg" } + filter "files:**.cg" + buildcommands { "cgc $(InputFile)" } + buildoutputs { "$(InputName).obj" } + buildinputs { "common.cg.inc" } + prepare() + test.capture [[ + + + Document + cgc $(InputFile) + $(InputName).obj + common.cg.inc + cgc $(InputFile) + $(InputName).obj + common.cg.inc + + + ]] + end + -- -- If a PCH source is specified, ensure it is included in the file configuration. From 39725134b7686ef655ce299def82e38345ac996a Mon Sep 17 00:00:00 2001 From: Damien Courtois Date: Thu, 25 Sep 2014 11:00:17 +0200 Subject: [PATCH 03/11] added support for buildinputs in vs200x generators --- src/actions/vstudio/vs200x_vcproj.lua | 5 ++++ tests/actions/vstudio/vc200x/test_files.lua | 29 +++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/actions/vstudio/vs200x_vcproj.lua b/src/actions/vstudio/vs200x_vcproj.lua index 69faf88d..fd056e63 100644 --- a/src/actions/vstudio/vs200x_vcproj.lua +++ b/src/actions/vstudio/vs200x_vcproj.lua @@ -1034,6 +1034,11 @@ local outputs = project.getrelative(filecfg.project, filecfg.buildoutputs) p.x('Outputs="%s"', table.concat(outputs, ' ')) + + if filecfg.buildinputs and #filecfg.buildinputs > 0 then + local inputs = project.getrelative(filecfg.project, filecfg.buildinputs) + p.x('AdditionalDependencies="%s"', table.concat(inputs, ';')) + end end end diff --git a/tests/actions/vstudio/vc200x/test_files.lua b/tests/actions/vstudio/vc200x/test_files.lua index 62a97e5f..38e9fa7d 100644 --- a/tests/actions/vstudio/vc200x/test_files.lua +++ b/tests/actions/vstudio/vc200x/test_files.lua @@ -375,6 +375,35 @@ ]] end + function suite.customBuildTool_onBuildRuleWithAdditionalInputs() + files { "hello.x" } + filter "files:**.x" + buildmessage "Compiling $(InputFile)" + buildcommands { + 'cxc -c "$(InputFile)" -o "$(IntDir)/$(InputName).xo"', + 'c2o -c "$(IntDir)/$(InputName).xo" -o "$(IntDir)/$(InputName).obj"' + } + buildoutputs { "$(IntDir)/$(InputName).obj" } + buildinputs { "common.x.inc" } + prepare() + test.capture [[ + + + + + + ]] + end + -- -- If two files at different folder levels have the same name, a different From 81158c0eb7c7043b28b344344cc24eca288bf8c8 Mon Sep 17 00:00:00 2001 From: Damien Courtois Date: Fri, 26 Sep 2014 15:16:02 +0200 Subject: [PATCH 04/11] fixed the vs201x generator (was using a space instead of a semi-colon) --- src/actions/vstudio/vs2010_vcxproj.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua index 16e468e9..f38725cc 100644 --- a/src/actions/vstudio/vs2010_vcxproj.lua +++ b/src/actions/vstudio/vs2010_vcxproj.lua @@ -659,7 +659,7 @@ if filecfg.buildinputs and #filecfg.buildinputs > 0 then local inputs = project.getrelative(prj, filecfg.buildinputs) - m.element("AdditionalInputs", condition, '%s', table.concat(inputs, " ")) + m.element("AdditionalInputs", condition, '%s', table.concat(inputs, ";")) end end end From 7c4eed3d1ccd909e6bea4c6cf60de0f6371d244a Mon Sep 17 00:00:00 2001 From: Damien Courtois Date: Fri, 26 Sep 2014 15:24:23 +0200 Subject: [PATCH 05/11] added buildinputs support to make action --- src/actions/make/make_cpp.lua | 7 +++++- tests/actions/make/cpp/test_file_rules.lua | 27 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/actions/make/make_cpp.lua b/src/actions/make/make_cpp.lua index 250eaf5f..4ecc583d 100644 --- a/src/actions/make/make_cpp.lua +++ b/src/actions/make/make_cpp.lua @@ -154,7 +154,12 @@ _x('ifeq ($(config),%s)', cfg.shortname) local output = project.getrelative(prj, filecfg.buildoutputs[1]) - _x('%s: %s', output, filecfg.relpath) + local dependencies = filecfg.relpath + if filecfg.buildinputs and #filecfg.buildinputs > 0 then + local inputs = project.getrelative(prj, filecfg.buildinputs) + dependencies = dependencies .. " " .. table.concat(inputs, " ") + end + _x('%s: %s', output, dependencies) _p('\t@echo "%s"', filecfg.buildmessage or ("Building " .. filecfg.relpath)) for _, cmd in ipairs(filecfg.buildcommands) do _p('\t$(SILENT) %s', cmd) diff --git a/tests/actions/make/cpp/test_file_rules.lua b/tests/actions/make/cpp/test_file_rules.lua index 402dc02f..b35431c4 100644 --- a/tests/actions/make/cpp/test_file_rules.lua +++ b/tests/actions/make/cpp/test_file_rules.lua @@ -92,3 +92,30 @@ obj/Release/hello.obj: hello.x endif ]] end + + function suite.customBuildRuleWithAdditionalInputs() + files { "hello.x" } + filter "files:**.x" + buildmessage "Compiling %{file.name}" + buildcommands { + 'cxc -c "%{file.path}" -o "%{cfg.objdir}/%{file.basename}.xo"', + 'c2o -c "%{cfg.objdir}/%{file.basename}.xo" -o "%{cfg.objdir}/%{file.basename}.obj"' + } + buildoutputs { "%{cfg.objdir}/%{file.basename}.obj" } + buildinputs { "%{file.path}.inc", "%{file.path}.inc2" } + prepare() + test.capture [[ +ifeq ($(config),debug) +obj/Debug/hello.obj: hello.x hello.x.inc hello.x.inc2 + @echo "Compiling hello.x" + $(SILENT) cxc -c "hello.x" -o "obj/Debug/hello.xo" + $(SILENT) c2o -c "obj/Debug/hello.xo" -o "obj/Debug/hello.obj" +endif +ifeq ($(config),release) +obj/Release/hello.obj: hello.x hello.x.inc hello.x.inc2 + @echo "Compiling hello.x" + $(SILENT) cxc -c "hello.x" -o "obj/Release/hello.xo" + $(SILENT) c2o -c "obj/Release/hello.xo" -o "obj/Release/hello.obj" +endif + ]] + end From e919f9e9f5e764f5c9ec57b61013cf3905edcc1f Mon Sep 17 00:00:00 2001 From: Damien Courtois Date: Fri, 26 Sep 2014 15:26:56 +0200 Subject: [PATCH 06/11] updated buildinputs tests to check the file separator --- tests/actions/vstudio/vc200x/test_files.lua | 4 ++-- tests/actions/vstudio/vc2010/test_files.lua | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/actions/vstudio/vc200x/test_files.lua b/tests/actions/vstudio/vc200x/test_files.lua index 38e9fa7d..261dff58 100644 --- a/tests/actions/vstudio/vc200x/test_files.lua +++ b/tests/actions/vstudio/vc200x/test_files.lua @@ -384,7 +384,7 @@ 'c2o -c "$(IntDir)/$(InputName).xo" -o "$(IntDir)/$(InputName).obj"' } buildoutputs { "$(IntDir)/$(InputName).obj" } - buildinputs { "common.x.inc" } + buildinputs { "common.x.inc", "common.x.inc2" } prepare() test.capture [[ @@ -398,7 +398,7 @@ Name="VCCustomBuildTool" CommandLine="cxc -c "$(InputFile)" -o "$(IntDir)/$(InputName).xo" c2o -c "$(IntDir)/$(InputName).xo" -o "$(IntDir)/$(InputName).obj"" Outputs="$(IntDir)/$(InputName).obj" - AdditionalDependencies="common.x.inc" + AdditionalDependencies="common.x.inc;common.x.inc2" /> ]] diff --git a/tests/actions/vstudio/vc2010/test_files.lua b/tests/actions/vstudio/vc2010/test_files.lua index a8aa06f9..ab95b583 100755 --- a/tests/actions/vstudio/vc2010/test_files.lua +++ b/tests/actions/vstudio/vc2010/test_files.lua @@ -120,7 +120,7 @@ filter "files:**.cg" buildcommands { "cgc $(InputFile)" } buildoutputs { "$(InputName).obj" } - buildinputs { "common.cg.inc" } + buildinputs { "common.cg.inc", "common.cg.inc2" } prepare() test.capture [[ @@ -128,10 +128,10 @@ Document cgc $(InputFile) $(InputName).obj - common.cg.inc + common.cg.inc;common.cg.inc2 cgc $(InputFile) $(InputName).obj - common.cg.inc + common.cg.inc;common.cg.inc2 ]] From 7937f5507396a780d8c9aa390f5978828706a6d8 Mon Sep 17 00:00:00 2001 From: Aleksi Juvani Date: Sat, 27 Sep 2014 11:16:41 +0000 Subject: [PATCH 07/11] Fix bootstrapping with premake4 --- premake4.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/premake4.lua b/premake4.lua index f5e3039b..15aeceed 100644 --- a/premake4.lua +++ b/premake4.lua @@ -29,6 +29,7 @@ excludes { + "src/host/lua-5.1.4/src/lauxlib.c", "src/host/lua-5.1.4/src/lua.c", "src/host/lua-5.1.4/src/luac.c", "src/host/lua-5.1.4/src/print.c", From 7640661f4b7462cb2de5f8e62f18fc1f117ced18 Mon Sep 17 00:00:00 2001 From: Aleksi Juvani Date: Sat, 27 Sep 2014 15:30:42 +0000 Subject: [PATCH 08/11] Fix per-file custom build commands in C++ gmake action --- src/actions/make/make_cpp.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/actions/make/make_cpp.lua b/src/actions/make/make_cpp.lua index 250eaf5f..436345a6 100644 --- a/src/actions/make/make_cpp.lua +++ b/src/actions/make/make_cpp.lua @@ -172,10 +172,10 @@ function make.cppObjects(prj) -- create lists for intermediate files, at the project level and -- for each configuration - local root = { objects={}, resources={} } + local root = { objects={}, resources={}, customfiles={} } local configs = {} for cfg in project.eachconfig(prj) do - configs[cfg] = { objects={}, resources={} } + configs[cfg] = { objects={}, resources={}, customfiles={} } end -- now walk the list of files in the project @@ -235,6 +235,8 @@ local output = project.getrelative(prj, filecfg.buildoutputs[1]) if path.isobjectfile(output) then table.insert(configs[cfg].objects, output) + else + table.insert(configs[cfg].customfiles, output) end end end @@ -254,11 +256,12 @@ listobjects('OBJECTS :=', root.objects, 'o') listobjects('RESOURCES :=', root.resources, 'res') + listobjects('CUSTOMFILES :=', root.customfiles) -- ...then individual configurations, as needed for cfg in project.eachconfig(prj) do local files = configs[cfg] - if #files.objects > 0 or #files.resources > 0 then + if #files.objects > 0 or #files.resources > 0 or #files.customfiles > 0 then _x('ifeq ($(config),%s)', cfg.shortname) if #files.objects > 0 then listobjects(' OBJECTS +=', files.objects) @@ -266,6 +269,9 @@ if #files.resources > 0 then listobjects(' RESOURCES +=', files.resources) end + if #files.customfiles > 0 then + listobjects(' CUSTOMFILES +=', files.customfiles) + end _p('endif') _p('') end @@ -332,7 +338,7 @@ function make.cppTargetRules(prj) - _p('$(TARGET): $(GCH) $(OBJECTS) $(LDDEPS) $(RESOURCES)') + _p('$(TARGET): $(GCH) $(OBJECTS) $(LDDEPS) $(RESOURCES) ${CUSTOMFILES}') _p('\t@echo Linking %s', prj.name) _p('\t$(SILENT) $(LINKCMD)') _p('\t$(POSTBUILDCMDS)') From d3396be99c657c74966eefa7e634102341f12c15 Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Sun, 28 Sep 2014 14:49:57 -0400 Subject: [PATCH 09/11] Fix unit tests broken by previous commit --- tests/actions/make/cpp/test_objects.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/actions/make/cpp/test_objects.lua b/tests/actions/make/cpp/test_objects.lua index e8e55d5a..179083e3 100644 --- a/tests/actions/make/cpp/test_objects.lua +++ b/tests/actions/make/cpp/test_objects.lua @@ -71,6 +71,8 @@ OBJECTS := \ RESOURCES := \ +CUSTOMFILES := \ + ifeq ($(config),debug) OBJECTS += \ $(OBJDIR)/hello_debug.o \ @@ -123,6 +125,8 @@ OBJECTS := \ RESOURCES := \ +CUSTOMFILES := \ + ifeq ($(config),debug) OBJECTS += \ obj/Debug/hello.obj \ @@ -147,6 +151,8 @@ OBJECTS := \ RESOURCES := \ +CUSTOMFILES := \ + ifeq ($(config),release) OBJECTS += \ $(OBJDIR)/hello.o \ @@ -166,6 +172,8 @@ OBJECTS := \ RESOURCES := \ +CUSTOMFILES := \ + ifeq ($(config),release) OBJECTS += \ $(OBJDIR)/hello.o \ From 157d96e39dcc43125d8a37f6c3bd343d7fc0c0e1 Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Thu, 2 Oct 2014 16:21:25 -0400 Subject: [PATCH 10/11] Modernize VC 201x project references generator --- src/actions/vstudio/vs2010_vcxproj.lua | 29 +++++++++++++------ .../vstudio/vc2010/test_project_refs.lua | 20 ++++++------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua index f38725cc..ab0d6e7b 100644 --- a/src/actions/vstudio/vs2010_vcxproj.lua +++ b/src/actions/vstudio/vs2010_vcxproj.lua @@ -821,17 +821,23 @@ -- Generate the list of project dependencies. -- + m.elements.projectReferences = function(prj, ref) + return { + m.projectReferenceProject, + } + end + function m.projectReferences(prj) - local deps = project.getdependencies(prj) - if #deps > 0 then - _p(1,'') - for _, dep in ipairs(deps) do - local relpath = project.getrelative(prj, vstudio.projectfile(dep)) - _x(2,'', path.translate(relpath)) - _p(3,'{%s}', dep.uuid) - _p(2,'') + local refs = project.getdependencies(prj) + if #refs > 0 then + p.push('') + for _, ref in ipairs(refs) do + local relpath = project.getrelative(prj, vstudio.projectfile(ref)) + p.push('', path.translate(relpath)) + p.callArray(m.elements.projectReferences, prj, ref) + p.pop('') end - _p(1,'') + p.pop('') end end @@ -1385,6 +1391,11 @@ end + function m.projectReferenceProject(prj, ref) + p.w('{%s}', ref.uuid) + end + + function m.propertyGroup(cfg, label) local cond if cfg then diff --git a/tests/actions/vstudio/vc2010/test_project_refs.lua b/tests/actions/vstudio/vc2010/test_project_refs.lua index dddf87f4..93e9ba8b 100644 --- a/tests/actions/vstudio/vc2010/test_project_refs.lua +++ b/tests/actions/vstudio/vc2010/test_project_refs.lua @@ -47,11 +47,11 @@ links { "MyProject" } prepare() test.capture [[ - - - {00112233-4455-6677-8888-99AABBCCDDEE} - - + + + {00112233-4455-6677-8888-99AABBCCDDEE} + + ]] end @@ -67,11 +67,11 @@ location "build/MyProject" prepare() test.capture [[ - - - {00112233-4455-6677-8888-99AABBCCDDEE} - - + + + {00112233-4455-6677-8888-99AABBCCDDEE} + + ]] end From 428b9cad2fad0cba96ce4b1aaf044b44c2c7b59d Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Thu, 2 Oct 2014 16:40:28 -0400 Subject: [PATCH 11/11] Fix managed C++ linking of unmanaged library dependencies --- src/actions/vstudio/vs2010_vcxproj.lua | 52 +++++++++++++++---- .../vstudio/vc2010/test_project_refs.lua | 22 ++++++++ 2 files changed, 65 insertions(+), 9 deletions(-) diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua index ab0d6e7b..f4465216 100644 --- a/src/actions/vstudio/vs2010_vcxproj.lua +++ b/src/actions/vstudio/vs2010_vcxproj.lua @@ -822,9 +822,20 @@ -- m.elements.projectReferences = function(prj, ref) - return { - m.projectReferenceProject, - } + if prj.flags.Managed then + return { + m.referenceProject, + m.referencePrivate, + m.referenceOutputAssembly, + m.referenceCopyLocalSatelliteAssemblies, + m.referenceLinkLibraryDependencies, + m.referenceUseLibraryDependences, + } + else + return { + m.referenceProject, + } + end end function m.projectReferences(prj) @@ -1391,11 +1402,6 @@ end - function m.projectReferenceProject(prj, ref) - p.w('{%s}', ref.uuid) - end - - function m.propertyGroup(cfg, label) local cond if cfg then @@ -1418,7 +1424,6 @@ end - function m.propertySheetGroup(prj) for cfg in project.eachconfig(prj) do m.propertySheets(cfg) @@ -1426,6 +1431,35 @@ end + function m.referenceCopyLocalSatelliteAssemblies(prj, ref) + p.w('false') + end + + + function m.referenceLinkLibraryDependencies(prj, ref) + p.w('true') + end + + + function m.referenceOutputAssembly(prj, ref) + p.w('true') + end + + + function m.referencePrivate(prj, ref) + p.w('true') + end + + + function m.referenceProject(prj, ref) + p.w('{%s}', ref.uuid) + end + + + function m.referenceUseLibraryDependences(prj, ref) + p.w('false') + end + function m.resourceAdditionalIncludeDirectories(cfg) m.additionalIncludeDirectories(cfg, table.join(cfg.includedirs, cfg.resincludedirs)) diff --git a/tests/actions/vstudio/vc2010/test_project_refs.lua b/tests/actions/vstudio/vc2010/test_project_refs.lua index 93e9ba8b..39e195e7 100644 --- a/tests/actions/vstudio/vc2010/test_project_refs.lua +++ b/tests/actions/vstudio/vc2010/test_project_refs.lua @@ -75,3 +75,25 @@ ]] end + +-- +-- Managed C++ projects write out references a little differently. +-- + + function suite.referencesAreRelative_onDifferentProjectLocation() + links { "MyProject" } + flags { "Managed" } + prepare() + test.capture [[ + + + {00112233-4455-6677-8888-99AABBCCDDEE} + true + true + false + true + false + + + ]] + end