Skip to content

Commit

Permalink
[cmake][make] Automatically generate bug chunk of the modulemap.
Browse files Browse the repository at this point in the history
Our two build systems can generate almost entirely a modulemap file laying out
one module per library. Due to some non-modular implementation in ROOT's core we
still need to treat some header files specially.

This patch appends modular header files to the modulemap while skipping the
predefined ones. Configure-make relates all headers that are installed in
$ROOTSYS/include to their library whereas relates only headers which are part of
library's dictionary.
  • Loading branch information
vgvassilev committed Dec 14, 2016
1 parent a5a19c2 commit ca144df
Show file tree
Hide file tree
Showing 125 changed files with 1,431 additions and 2,225 deletions.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 198,13 @@ if(cxxmodules)
DEPENDS build/unix/module.modulemap
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/build/unix/module.modulemap ${CMAKE_BINARY_DIR}/include/module.modulemap
)
add_dependencies(copymodulemap move_headers)
get_property(__modulemap_extra_content GLOBAL PROPERTY ROOT_CXXMODULES_EXTRA_MODULEMAP_CONTENT)
string(REPLACE ";" "" __modulemap_extra_content "module ROOT {\\n ${__modulemap_extra_content} \\n }")
add_custom_command(TARGET copymodulemap POST_BUILD
COMMAND echo ${__modulemap_extra_content} >> ${CMAKE_BINARY_DIR}/include/module.modulemap
VERBATIM
)
add_dependencies(move_headers copymodulemap)
endif(cxxmodules)

#---hsimple.root---------(use the executable for clearer dependencies and proper return code)---
Expand Down
39 changes: 38 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 592,11 @@ endif
##### all #####
ALLHDRS :=
ifeq ($(CXXMODULES),yes)
# Add the ROOT Core module. It is organized differently and we cannot do it in
# a Module.mk
CXXMODULES_HEADERS :=
CXXMODULES_MODULEMAP_CONTENTS :=

# Copy the modulemap in $ROOTSYS/include first.
ALLHDRS := include/module.modulemap
ROOT_CXXMODULES_CXXFLAGS = -fmodules -fcxx-modules -fmodules-cache-path=$(ROOT_OBJDIR)/include/pcms/
Expand Down Expand Up @@ -832,8 837,40 @@ $(COMPILEDATA): $(ROOT_SRCDIR)/config/Makefile.$(ARCH) config/Makefile.comp Make
"$(EXPLICITLINK)"

ifeq ($(CXXMODULES),yes)
include/module.modulemap: $(ROOT_SRCDIR)/build/unix/module.modulemap

# We cannot use the usual way of setting CXXMODULES_MODULEMAP_CONTENTS for core,
# because we require information from the core submodules. Thus we have to access
# the information at the target.
#
# We use the relative path of COREDICT.
# FIXME: We probably should be chaning the COREDICTH to use relative paths, too.
# COREDICTH = $(BASEDICTH) $(CONTH) $(METADICTH) $(SYSTEMDICTH) \
# $(ZIPDICTH) $(CLIBHH) $(METAUTILSH) $(TEXTINPUTH)
include/module.modulemap:
COREDICTH_REL := $(BASEH_REL) $(CONTH_REL) $(METAH_REL) $(METAUTILSH_REL)
COREDICTH_REL := $(patsubst include/%,%, $(COREDICTH_REL))
CXXMODULES_CORE_EXCLUDE := RConversionRuleParser.h RConfig.h RVersion.h RtypesImp.h \
Rtypes.h RtypesCore.h TClassEdit.h TMetaUtils.h \
TSchemaType.h DllImport.h Rtypeinfo.h TGenericClassInfo.h \
TSchemaHelper.h ESTLType.h RStringView.h Varargs.h \
RootMetaSelection.h TString.h Riosfwd.h TMathBase.h \
RWrap_libcpp_string_view.h TAtomicCountGcc.h \
TException.h ROOT/TThreadExecutor.hxx TBranchProxyTemplate.h \
TGLIncludes.h TGLWSIncludes.h snprintf.h strlcpy.h
COREDICTH_REL := $(filter-out $(CXXMODULES_CORE_EXCLUDE),$(COREDICTH_REL))
CXXMODULES_CORE_HEADERS := $(patsubst %,header \"%\"\\n, $(COREDICTH_REL))
CXXMODULES_CORE_MODULEMAP_CONTENTS := module Core { \\n \
requires cplusplus \\n \
$(CXXMODULES_CORE_HEADERS) \
export * \\n \
link \"$(CORELIB)\" \\n \
} \\n
include/module.modulemap: $(ROOT_SRCDIR)/build/unix/module.modulemap
cp $< $@
@echo "module ROOT {\\n" >> $@
@echo "$(CXXMODULES_CORE_MODULEMAP_CONTENTS)" >> $@
@echo "$(CXXMODULES_MODULEMAP_CONTENTS)" >> $@
@echo "} //module ROOT \\n" >> $@
endif

# We rebuild GITCOMMITH only when we would re-link libCore anyway.
Expand Down
11 changes: 10 additions & 1 deletion bindings/pyroot/Module.mk
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 61,18 @@ ROOTAASC := $(ROOTAAS:.py=.pyc)
ROOTAASO := $(ROOTAAS:.py=.pyo)

# used in the main Makefile
ALLHDRS = $(patsubst $(MODDIRI)/%.h,include/%.h,$(PYROOTH))
PYROOTH_REL := $(patsubst $(MODDIRI)/%.h,include/%.h,$(PYROOTH))
ALLHDRS = $(PYROOTH_REL)
ALLLIBS = $(PYROOTLIB)
ALLMAPS = $(PYROOTMAP)
ifeq ($(CXXMODULES),yes)
CXXMODULES_HEADERS := $(patsubst include/%,header \"%\"\\n,$(PYROOTH_REL))
CXXMODULES_MODULEMAP_CONTENTS = module $(MODNAME) { \\n
CXXMODULES_MODULEMAP_CONTENTS = $(CXXMODULES_HEADERS)
CXXMODULES_MODULEMAP_CONTENTS = "export \* \\n"
CXXMODULES_MODULEMAP_CONTENTS = link \"$(PYROOTLIB)\" \\n
CXXMODULES_MODULEMAP_CONTENTS = } \\n
endif

# include all dependency files
INCLUDEFILES = $(PYROOTDEP)
Expand Down
11 changes: 10 additions & 1 deletion bindings/r/Module.mk
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 48,18 @@ RLIB := $(LPATH)/libRInterface.$(SOEXT)
RMAP := $(RLIB:.$(SOEXT)=.rootmap)

# used in the main Makefile
ALLHDRS = $(patsubst $(MODDIRI)/%.h,include/%.h,$(RH))
RH_REL := $(patsubst $(MODDIRI)/%.h,include/%.h,$(RH))
ALLHDRS = $(RH_REL)
ALLLIBS = $(RLIB)
ALLMAPS = $(RMAP)
ifeq ($(CXXMODULES),yes)
CXXMODULES_HEADERS := $(patsubst include/%,header \"%\"\\n,$(RH_REL))
CXXMODULES_MODULEMAP_CONTENTS = module $(MODNAME) { \\n
CXXMODULES_MODULEMAP_CONTENTS = $(CXXMODULES_HEADERS)
CXXMODULES_MODULEMAP_CONTENTS = "export \* \\n"
CXXMODULES_MODULEMAP_CONTENTS = link \"$(RLIB)\" \\n
CXXMODULES_MODULEMAP_CONTENTS = } \\n
endif

# include all dependency files
INCLUDEFILES = $(RDEP)
Expand Down
12 changes: 11 additions & 1 deletion bindings/ruby/Module.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 28,19 @@ RUBYROOTLIB := $(LPATH)/libRuby.$(SOEXT)
RUBYROOTMAP := $(RUBYROOTLIB:.$(SOEXT)=.rootmap)

# used in the main Makefile
ALLHDRS = $(patsubst $(MODDIRI)/%.h,include/%.h,$(RUBYROOTH))
RUBYROOTH_REL := $(patsubst $(MODDIRI)/%.h,include/%.h,$(RUBYROOTH))
ALLHDRS = $(RUBYROOTH_REL)
ALLLIBS = $(RUBYROOTLIB)
ALLMAPS = $(RUBYROOTMAP)
ifeq ($(CXXMODULES),yes)
CXXMODULES_HEADERS := $(patsubst include/%,header \"%\"\\n,$(RUBYROOTH_REL))
CXXMODULES_MODULEMAP_CONTENTS = module $(MODNAME) { \\n
CXXMODULES_MODULEMAP_CONTENTS = $(CXXMODULES_HEADERS)
CXXMODULES_MODULEMAP_CONTENTS = "export \* \\n"
CXXMODULES_MODULEMAP_CONTENTS = link \"$(RUBYROOTLIB)\" \\n
CXXMODULES_MODULEMAP_CONTENTS = } \\n
endif


# include all dependency files
INCLUDEFILES = $(RUBYROOTDEP)
Expand Down
Loading

0 comments on commit ca144df

Please sign in to comment.