Skip to content

Commit

Permalink
Merge pull request #1404 from Mikhael-Danilov/master
Browse files Browse the repository at this point in the history
Place all generated files in separate GENERATED list, so they all can…
  • Loading branch information
starkos authored Mar 22, 2020
2 parents 6ca1219 + 7c0c02a commit 5b2f92c
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/gmake2/gmake2_cpp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@
table.insert(fileset, filename)
cfg._gmake.filesets[kind] = fileset

local generatedKind = "GENERATED"
local generatedFileset = cfg._gmake.filesets[generatedKind] or {}
table.insert(generatedFileset, filename)
cfg._gmake.filesets[generatedKind] = generatedFileset

-- recursively setup rules.
cpp.addRuleFile(cfg, node)
end
Expand Down Expand Up @@ -715,9 +720,11 @@
_p('\t@echo Cleaning %s', cfg.project.name)
_p('ifeq (posix,$(SHELLTYPE))')
_p('\t$(SILENT) rm -f $(TARGET)')
_p('\t$(SILENT) rm -rf $(GENERATED)')
_p('\t$(SILENT) rm -rf $(OBJDIR)')
_p('else')
_p('\t$(SILENT) if exist $(subst /,\\\\,$(TARGET)) del $(subst /,\\\\,$(TARGET))')
_p('\t$(SILENT) if exist $(subst /,\\\\,$(GENERATED)) rmdir /s /q $(subst /,\\\\,$(GENERATED))')
_p('\t$(SILENT) if exist $(subst /,\\\\,$(OBJDIR)) rmdir /s /q $(subst /,\\\\,$(OBJDIR))')
_p('endif')
_p('')
Expand Down
79 changes: 79 additions & 0 deletions modules/gmake2/tests/test_gmake2_objects.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@
# File sets
# #############################################
GENERATED :=
OBJECTS :=
GENERATED += $(OBJDIR)/hello.o
OBJECTS += $(OBJDIR)/hello.o
]]
Expand All @@ -60,8 +62,10 @@ OBJECTS += $(OBJDIR)/hello.o
# File sets
# #############################################
GENERATED :=
OBJECTS :=
GENERATED += $(OBJDIR)/hello.o
OBJECTS += $(OBJDIR)/hello.o
]]
Expand All @@ -82,12 +86,15 @@ OBJECTS += $(OBJDIR)/hello.o
# File sets
# #############################################
GENERATED :=
OBJECTS :=
ifeq ($(config),debug)
GENERATED += $(OBJDIR)/hello_debug.o
OBJECTS += $(OBJDIR)/hello_debug.o
else ifeq ($(config),release)
GENERATED += $(OBJDIR)/hello_release.o
OBJECTS += $(OBJDIR)/hello_release.o
endif
Expand All @@ -107,8 +114,11 @@ endif
# File sets
# #############################################
GENERATED :=
OBJECTS :=
GENERATED += $(OBJDIR)/hello.o
GENERATED += $(OBJDIR)/hello1.o
OBJECTS += $(OBJDIR)/hello.o
OBJECTS += $(OBJDIR)/hello1.o
Expand All @@ -122,8 +132,12 @@ OBJECTS += $(OBJDIR)/hello1.o
# File sets
# #############################################
GENERATED :=
OBJECTS :=
GENERATED += $(OBJDIR)/hello.o
GENERATED += $(OBJDIR)/hello1.o
GENERATED += $(OBJDIR)/hello11.o
OBJECTS += $(OBJDIR)/hello.o
OBJECTS += $(OBJDIR)/hello1.o
OBJECTS += $(OBJDIR)/hello11.o
Expand All @@ -143,15 +157,20 @@ OBJECTS += $(OBJDIR)/hello11.o
# File sets
# #############################################
GENERATED :=
OBJECTS :=
GENERATED += $(OBJDIR)/hello.o
GENERATED += $(OBJDIR)/hello11.o
OBJECTS += $(OBJDIR)/hello.o
OBJECTS += $(OBJDIR)/hello11.o
ifeq ($(config),debug)
GENERATED += $(OBJDIR)/hello111.o
OBJECTS += $(OBJDIR)/hello111.o
else ifeq ($(config),release)
GENERATED += $(OBJDIR)/hello1.o
OBJECTS += $(OBJDIR)/hello1.o
endif
Expand All @@ -170,8 +189,11 @@ endif
# File sets
# #############################################
GENERATED :=
OBJECTS :=
GENERATED += $(OBJDIR)/Hello1.o
GENERATED += $(OBJDIR)/hello.o
OBJECTS += $(OBJDIR)/Hello1.o
OBJECTS += $(OBJDIR)/hello.o
Expand All @@ -185,8 +207,12 @@ OBJECTS += $(OBJDIR)/hello.o
# File sets
# #############################################
GENERATED :=
OBJECTS :=
GENERATED += $(OBJDIR)/Hello11.o
GENERATED += $(OBJDIR)/hello.o
GENERATED += $(OBJDIR)/hello1.o
OBJECTS += $(OBJDIR)/Hello11.o
OBJECTS += $(OBJDIR)/hello.o
OBJECTS += $(OBJDIR)/hello1.o
Expand All @@ -206,15 +232,20 @@ OBJECTS += $(OBJDIR)/hello1.o
# File sets
# #############################################
GENERATED :=
OBJECTS :=
GENERATED += $(OBJDIR)/Hello11.o
GENERATED += $(OBJDIR)/hello.o
OBJECTS += $(OBJDIR)/Hello11.o
OBJECTS += $(OBJDIR)/hello.o
ifeq ($(config),debug)
GENERATED += $(OBJDIR)/Hello111.o
OBJECTS += $(OBJDIR)/Hello111.o
else ifeq ($(config),release)
GENERATED += $(OBJDIR)/hello1.o
OBJECTS += $(OBJDIR)/hello1.o
endif
Expand All @@ -223,6 +254,38 @@ endif
end


--
-- If there's a custom rule which generate C++ sources build outputs should be placed
-- in separate list so they can be cleaned up properly.
--

function suite.customBuildCommand_generatedCpp()
files { "interface.pkg","source.cpp" }
filter "files:**.pkg"
buildmessage "Binding pkg: %{file.name}"
buildcommands './tolua -o %{file.basename}.cpp -H %{file.basename}.h -n %{file.basename}} %{file.abspath}'
buildoutputs { '%{file.basename}.cpp','%{file.basename}.h' }
prepare()
test.capture [[
# File sets
# #############################################
CUSTOM :=
GENERATED :=
OBJECTS :=
SOURCES :=
CUSTOM += interface.h
GENERATED += $(OBJDIR)/interface.o
GENERATED += $(OBJDIR)/source.o
GENERATED += interface.cpp
GENERATED += interface.h
OBJECTS += $(OBJDIR)/interface.o
OBJECTS += $(OBJDIR)/source.o
SOURCES += interface.cpp
]]
end

--
-- If there's a custom rule for a non-C++ file extension, make sure that those
-- files are included in the build.
Expand All @@ -242,12 +305,15 @@ endif
# #############################################
CUSTOM :=
GENERATED :=
ifeq ($(config),debug)
CUSTOM += obj/Debug/hello.luac
GENERATED += obj/Debug/hello.luac
else ifeq ($(config),release)
CUSTOM += obj/Release/hello.luac
GENERATED += obj/Release/hello.luac
endif
]]
Expand All @@ -273,12 +339,15 @@ endif
# File sets
# #############################################
GENERATED :=
OBJECTS :=
ifeq ($(config),debug)
GENERATED += obj/Debug/hello.obj
OBJECTS += obj/Debug/hello.obj
else ifeq ($(config),release)
GENERATED += obj/Release/hello.obj
OBJECTS += obj/Release/hello.obj
endif
Expand Down Expand Up @@ -306,12 +375,15 @@ endif
# File sets
# #############################################
GENERATED :=
OBJECTS :=
ifeq ($(config),debug)
GENERATED += obj/Debug/hello.obj
OBJECTS += obj/Debug/hello.obj
else ifeq ($(config),release)
GENERATED += obj/Release/hello.obj
OBJECTS += obj/Release/hello.obj
endif
Expand Down Expand Up @@ -340,12 +412,15 @@ endif
# #############################################
CUSTOM :=
GENERATED :=
ifeq ($(config),debug)
CUSTOM += obj/Debug/hello.obj
GENERATED += obj/Debug/hello.obj
else ifeq ($(config),release)
CUSTOM += obj/Release/hello.obj
GENERATED += obj/Release/hello.obj
endif
]]
Expand All @@ -365,9 +440,11 @@ endif
# File sets
# #############################################
GENERATED :=
OBJECTS :=
ifeq ($(config),release)
GENERATED += $(OBJDIR)/hello.o
OBJECTS += $(OBJDIR)/hello.o
endif
Expand All @@ -384,9 +461,11 @@ endif
# File sets
# #############################################
GENERATED :=
OBJECTS :=
ifeq ($(config),release)
GENERATED += $(OBJDIR)/hello.o
OBJECTS += $(OBJDIR)/hello.o
endif
Expand Down

0 comments on commit 5b2f92c

Please sign in to comment.