diff options
author | sbc@chromium.org <sbc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-17 23:10:40 +0000 |
---|---|---|
committer | sbc@chromium.org <sbc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-17 23:10:40 +0000 |
commit | 79750d73189b07e8f7e930f8658a8059d8d44767 (patch) | |
tree | af348339cff7e1b9f1e7b04dc87f3a7ceef60636 /native_client_sdk | |
parent | e217c7ed61a1eea1b64a42ba3106409b11cfb3a0 (diff) | |
download | chromium_src-79750d73189b07e8f7e930f8658a8059d8d44767.zip chromium_src-79750d73189b07e8f7e930f8658a8059d8d44767.tar.gz chromium_src-79750d73189b07e8f7e930f8658a8059d8d44767.tar.bz2 |
[NaCl SDK] Add create_html support for common.mk.
Add CREATE_HTML macro to common.mk that allows developers to
automaticlly create html and nmf files for thier binaries.
Also add nexe targets to 'all' so that nexe's will get built
in all cases, not only when nmf/html target depends on them.
Also, cleanup some whitespace in .mk files and generated
Makefiles.
R=binji@chromium.org
Review URL: https://codereview.chromium.org/17130002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206825 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk')
-rw-r--r-- | native_client_sdk/src/build_tools/template.mk | 8 | ||||
-rw-r--r-- | native_client_sdk/src/examples/tutorial/debugging/example.dsc | 4 | ||||
-rw-r--r-- | native_client_sdk/src/tools/common.mk | 4 | ||||
-rwxr-xr-x | native_client_sdk/src/tools/create_html.py | 56 | ||||
-rw-r--r-- | native_client_sdk/src/tools/host_gcc.mk | 5 | ||||
-rw-r--r-- | native_client_sdk/src/tools/host_vc.mk | 9 | ||||
-rw-r--r-- | native_client_sdk/src/tools/nacl_gcc.mk | 103 | ||||
-rw-r--r-- | native_client_sdk/src/tools/nacl_llvm.mk | 14 | ||||
-rwxr-xr-x | native_client_sdk/src/tools/tests/create_html_test.py | 2 |
9 files changed, 121 insertions, 84 deletions
diff --git a/native_client_sdk/src/build_tools/template.mk b/native_client_sdk/src/build_tools/template.mk index 1b3e5fe..19583ea 100644 --- a/native_client_sdk/src/build_tools/template.mk +++ b/native_client_sdk/src/build_tools/template.mk @@ -6,7 +6,6 @@ # GNU Make based build file. For details on GNU Make see: # http://www.gnu.org/software/make/manual/make.html # -# # @@ -18,9 +17,7 @@ # toolchain we use by default will be the first valid one listed VALID_TOOLCHAINS:={{' '.join(tools)}} - {{pre}} - # # Get pepper directory for toolchain and includes. # @@ -105,7 +102,4 @@ endif # # Specify the NMF to be created with no additional arguments. # -$(eval $(call NMF_RULE,$(TARGET),)) - -{{post}} - +$(eval $(call NMF_RULE,$(TARGET),)){{post}} diff --git a/native_client_sdk/src/examples/tutorial/debugging/example.dsc b/native_client_sdk/src/examples/tutorial/debugging/example.dsc index 49e31ba..607ec32 100644 --- a/native_client_sdk/src/examples/tutorial/debugging/example.dsc +++ b/native_client_sdk/src/examples/tutorial/debugging/example.dsc @@ -19,11 +19,11 @@ ], 'POST': """ + # # Specify the MAP files to be created. # -$(eval $(call MAP_RULE,$(TARGET),$(TARGET))) -""", +$(eval $(call MAP_RULE,$(TARGET),$(TARGET)))""", 'DATA': [ 'example.js', ], diff --git a/native_client_sdk/src/tools/common.mk b/native_client_sdk/src/tools/common.mk index f9e13ce..058af1b 100644 --- a/native_client_sdk/src/tools/common.mk +++ b/native_client_sdk/src/tools/common.mk @@ -245,12 +245,12 @@ else endif all: rebuild_$(1) -$(STAMPDIR)/$(1).stamp : rebuild_$(1) +$(STAMPDIR)/$(1).stamp: rebuild_$(1) else .PHONY: $(STAMPDIR)/$(1).stamp -$(STAMPDIR)/$(1).stamp : +$(STAMPDIR)/$(1).stamp: @echo Ignore $(1) endif endef diff --git a/native_client_sdk/src/tools/create_html.py b/native_client_sdk/src/tools/create_html.py index b981aac..c0d1eb4 100755 --- a/native_client_sdk/src/tools/create_html.py +++ b/native_client_sdk/src/tools/create_html.py @@ -3,7 +3,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -"""Script for creating HTML needed to run a NaCl module. +"""Creates simple HTML for running a NaCl module. This script is designed to make the process of creating running Native Client executables in the browers simple by creating @@ -99,25 +99,41 @@ def Log(msg): Log.enabled = False -def CreateHTML(filename, options): - if not os.path.exists(filename): - raise Error('file not found: %s' % filename) +def CreateHTML(filenames, options): + nmf = None - if not os.path.isfile(filename): - raise Error('specified input is not a file: %s' % filename) + for filename in filenames: + if not os.path.exists(filename): + raise Error('file not found: %s' % filename) - basename, ext = os.path.splitext(filename) - if ext not in ('.nexe', '.pexe', '.nmf'): - raise Error('input file must be .nexe, .pexe or .nmf: %s' % filename) + if not os.path.isfile(filename): + raise Error('specified input is not a file: %s' % filename) - if ext in ('.nexe', '.pexe'): - nmf = basename + '.nmf' + basename, ext = os.path.splitext(filename) + if ext not in ('.nexe', '.pexe', '.nmf'): + raise Error('input file must be .nexe, .pexe or .nmf: %s' % filename) + + if ext == '.nmf': + if len(filenames) > 1: + raise Error('Only one .nmf argument can be specified') + nmf = filename + elif len(filenames) > 1 and not options.output: + raise Error('When specifying muliple input files -o must' + ' also be specified.') + + htmlfile = options.output + if not htmlfile: + htmlfile = basename + '.html' + basename = os.path.splitext(os.path.basename(htmlfile))[0] + + if not nmf: + nmf = os.path.splitext(htmlfile)[0] + '.nmf' Log('creating nmf: %s' % nmf) create_nmf = os.path.join(SCRIPT_DIR, 'create_nmf.py') staging = os.path.dirname(nmf) if not staging: staging = '.' - cmd = [create_nmf, '-s', staging, '-o', nmf, filename] + cmd = [create_nmf, '-s', staging, '-o', nmf] + filenames if options.verbose: cmd.append('-v') Log(cmd) @@ -125,25 +141,21 @@ def CreateHTML(filename, options): subprocess.check_call(cmd) except subprocess.CalledProcessError: raise Error('create_nmf failed') - else: - nmf = filename - - htmlfile = options.output - if not htmlfile: - htmlfile = basename + '.html' Log('creating html: %s' % htmlfile) with open(htmlfile, 'w') as outfile: args = {} args['title'] = basename args['module_name'] = basename - args['nmf'] = nmf + args['nmf'] = os.path.basename(nmf) outfile.write(HTML_TEMPLATE % args) def main(argv): usage = 'Usage: %prog [options] <.nexe/.pexe or .nmf>' - parser = optparse.OptionParser(usage) + description = __doc__ + epilog = 'Example: create_html.py -o index.html my_nexe.nexe' + parser = optparse.OptionParser(usage, description=description, epilog=epilog) parser.add_option('-v', '--verbose', action='store_true', help='Verbose output') parser.add_option('-o', '--output', dest='output', @@ -152,8 +164,6 @@ def main(argv): metavar='FILE') options, args = parser.parse_args(argv) - if len(args) > 1: - parser.error('more than one input file specified') if not args: parser.error('no input file specified') @@ -161,7 +171,7 @@ def main(argv): if options.verbose: Log.enabled = True - CreateHTML(args[0], options) + CreateHTML(args, options) return 0 diff --git a/native_client_sdk/src/tools/host_gcc.mk b/native_client_sdk/src/tools/host_gcc.mk index 36447bc..61b4a7e 100644 --- a/native_client_sdk/src/tools/host_gcc.mk +++ b/native_client_sdk/src/tools/host_gcc.mk @@ -6,7 +6,6 @@ # GNU Make based build file. For details on GNU Make see: # http://www.gnu.org/software/make/manual/make.html # -# # @@ -88,7 +87,7 @@ $(STAMPDIR)/$(1).stamp: $(LIBDIR)/$(OSNAME)_host/$(CONFIG)/lib$(1).a @echo "TOUCHED $$@" > $(STAMPDIR)/$(1).stamp all: $(LIBDIR)/$(OSNAME)_host/$(CONFIG)/lib$(1).a -$(LIBDIR)/$(OSNAME)_host/$(CONFIG)/lib$(1).a : $(foreach src,$(2),$(call SRC_TO_OBJ,$(src))) +$(LIBDIR)/$(OSNAME)_host/$(CONFIG)/lib$(1).a: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src))) $(MKDIR) -p $$(dir $$@) $(call LOG,LIB,$$@,$(HOST_LIB) -cr $$@ $$^) endef @@ -125,7 +124,7 @@ define LINK_RULE $(call LINKER_RULE,$(OUTDIR)/$(1)$(HOST_EXT),$(foreach src,$(2),$(call SRC_TO_OBJ,$(src))),$(filter-out pthread,$(3)),$(4),$(LIB_PATHS),$(5)) endef -all : $(LIB_LIST) $(DEPS_LIST) +all: $(LIB_LIST) $(DEPS_LIST) # diff --git a/native_client_sdk/src/tools/host_vc.mk b/native_client_sdk/src/tools/host_vc.mk index d41629b..8ed51d4 100644 --- a/native_client_sdk/src/tools/host_vc.mk +++ b/native_client_sdk/src/tools/host_vc.mk @@ -6,7 +6,6 @@ # GNU Make based build file. For details on GNU Make see: # http://www.gnu.org/software/make/manual/make.html # -# # @@ -74,11 +73,11 @@ endef # # define LIB_RULE -$(STAMPDIR)/$(1).stamp : $(LIBDIR)/$(OSNAME)_x86_32_host/$(CONFIG)/$(1).lib +$(STAMPDIR)/$(1).stamp: $(LIBDIR)/$(OSNAME)_x86_32_host/$(CONFIG)/$(1).lib @echo "TOUCHED $$@" > $(STAMPDIR)/$(1).stamp all:$(LIBDIR)/$(OSNAME)_x86_32_host/$(CONFIG)/$(1).lib -$(LIBDIR)/$(OSNAME)_x86_32_host/$(CONFIG)/$(1).lib : $(foreach src,$(2),$(OUTDIR)/$(basename $(src)).o) +$(LIBDIR)/$(OSNAME)_x86_32_host/$(CONFIG)/$(1).lib: $(foreach src,$(2),$(OUTDIR)/$(basename $(src)).o) $(MKDIR) -p $$(dir $$@) $(call LOG,LIB,$$@,$(HOST_LIB) /OUT:$$@ $$^ $(WIN_LDFLAGS)) endef @@ -96,7 +95,7 @@ endef # define LINKER_RULE all: $(1) -$(1) : $(2) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp) +$(1): $(2) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp) $(call LOG,LINK,$$@,$(HOST_LINK) /DLL /OUT:$(1) /PDB:$(1).pdb $(2) /DEBUG $(foreach path,$(5),/LIBPATH:$(path)/$(OSNAME)_x86_32_host/$(CONFIG)) $(foreach lib,$(3),$(lib).lib) $(6)) endef @@ -130,4 +129,4 @@ $(OUTDIR)/$(1)$(HOST_EXT): $(OUTDIR)/$(2)$(HOST_EXT) $(call LOG,COPY,$$@,$(CP) $$^ $$@) endef -all : $(LIB_LIST) $(DEPS_LIST) +all: $(LIB_LIST) $(DEPS_LIST) diff --git a/native_client_sdk/src/tools/nacl_gcc.mk b/native_client_sdk/src/tools/nacl_gcc.mk index a68d230..57fc1ab 100644 --- a/native_client_sdk/src/tools/nacl_gcc.mk +++ b/native_client_sdk/src/tools/nacl_gcc.mk @@ -6,13 +6,11 @@ # GNU Make based build file. For details on GNU Make see: # http://www.gnu.org/software/make/manual/make.html # -# # -# Default Paths +# Default library paths # - LD_X86_32 := -L$(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_x86_32/$(CONFIG) LD_X86_64 := -L$(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_x86_64/$(CONFIG) LD_ARM := -L$(NACL_SDK_ROOT)/lib/$(TOOLCHAIN)_arm/$(CONFIG) @@ -175,13 +173,13 @@ endef # $4 = VC Link Flags (unused) # define LIB_RULE -$(STAMPDIR)/$(1).stamp : $(OUTDIR)/lib$(1)_x86_32.a -$(STAMPDIR)/$(1).stamp : $(OUTDIR)/lib$(1)_x86_64.a +$(STAMPDIR)/$(1).stamp: $(OUTDIR)/lib$(1)_x86_32.a +$(STAMPDIR)/$(1).stamp: $(OUTDIR)/lib$(1)_x86_64.a ifneq ($(TOOLCHAIN),glibc) -$(STAMPDIR)/$(1).stamp : $(OUTDIR)/lib$(1)_arm.a +$(STAMPDIR)/$(1).stamp: $(OUTDIR)/lib$(1)_arm.a endif -$(STAMPDIR)/$(1).stamp : +$(STAMPDIR)/$(1).stamp: @echo "TOUCHED $$@" > $(STAMPDIR)/$(1).stamp @@ -218,6 +216,24 @@ $(LIBDIR)/$(TOOLCHAIN)_arm/$(CONFIG)/lib$(1).a: $(OUTDIR)/lib$(1)_arm.a endif endef +# +# Determine which architectures to build for. The user can set NACL_ARCH or +# ARCHES in the environment to control this. +# +VALID_ARCHES := x86_32 x86_64 +ifeq (newlib,$(TOOLCHAIN)) +VALID_ARCHES += arm +endif + +ifdef NACL_ARCH +ifeq (,$(findstring $(NACL_ARCH),$(VALID_ARCHES))) +$(error Invalid arch specified in NACL_ARCH: $(NACL_ARCH). Valid values are: $(VALID_ARCHES)) +endif +ARCHES = ${NACL_ARCH} +else +ARCHES ?= ${VALID_ARCHES} +endif + # # Specific Link Macro @@ -230,14 +246,23 @@ endef # $6 = Library Paths # define LINKER_RULE -$(OUTDIR)/$(1)_x86_32.nexe : $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_32)) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp) +ifneq (,$(findstring x86_32,$(ARCHES))) +all: $(OUTDIR)/$(1)_x86_32.nexe +$(OUTDIR)/$(1)_x86_32.nexe: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_32)) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp) $(call LOG,LINK,$$@,$(X86_32_LINK) -o $$@ $$(filter %.o,$$^) $(NACL_LDFLAGS) $(foreach path,$(6),-L$(path)/$(TOOLCHAIN)_x86_32/$(CONFIG)) $(foreach lib,$(3),-l$(lib)) $(5)) +endif -$(OUTDIR)/$(1)_x86_64.nexe : $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_64)) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp) +ifneq (,$(findstring x86_64,$(ARCHES))) +all: $(OUTDIR)/$(1)_x86_64.nexe +$(OUTDIR)/$(1)_x86_64.nexe: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_64)) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp) $(call LOG,LINK,$$@,$(X86_64_LINK) -o $$@ $$(filter %.o,$$^) $(NACL_LDFLAGS) $(foreach path,$(6),-L$(path)/$(TOOLCHAIN)_x86_64/$(CONFIG)) $(foreach lib,$(3),-l$(lib)) $(5)) +endif -$(OUTDIR)/$(1)_arm.nexe : $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_arm)) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp) +ifneq (,$(findstring arm,$(ARCHES))) +all: $(OUTDIR)/$(1)_arm.nexe +$(OUTDIR)/$(1)_arm.nexe: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_arm)) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp) $(call LOG,LINK,$$@,$(ARM_LINK) -o $$@ $$(filter %.o,$$^) $(NACL_LDFLAGS) $(foreach path,$(6),-L$(path)/$(TOOLCHAIN)_arm/$(CONFIG)) $(foreach lib,$(3),-l$(lib)) $(5)) +endif endef @@ -263,14 +288,20 @@ endef # $2 = Source Name # define STRIP_ALL_RULE -$(OUTDIR)/$(1)_x86_32.nexe : $(OUTDIR)/$(2)_x86_32.nexe +ifneq (,$(findstring x86_32,$(ARCHES))) +$(OUTDIR)/$(1)_x86_32.nexe: $(OUTDIR)/$(2)_x86_32.nexe $(call LOG,STRIP,$$@,$(X86_32_STRIP) -o $$@ $$^) +endif -$(OUTDIR)/$(1)_x86_64.nexe : $(OUTDIR)/$(2)_x86_64.nexe +ifneq (,$(findstring x86_64,$(ARCHES))) +$(OUTDIR)/$(1)_x86_64.nexe: $(OUTDIR)/$(2)_x86_64.nexe $(call LOG,STRIP,$$@,$(X86_64_STRIP) -o $$@ $$^) +endif -$(OUTDIR)/$(1)_arm.nexe : $(OUTDIR)/$(2)_arm.nexe +ifneq (,$(findstring arm,$(ARCHES))) +$(OUTDIR)/$(1)_arm.nexe: $(OUTDIR)/$(2)_arm.nexe $(call LOG,STRIP,$$@,$(ARM_STRIP) -o $$@ $$^) +endif endef @@ -292,13 +323,13 @@ endef # $2 = Source Name # define MAP_ALL_RULE -$(OUTDIR)/$(1)_x86_32.map : $(OUTDIR)/$(2)_x86_32.nexe +$(OUTDIR)/$(1)_x86_32.map: $(OUTDIR)/$(2)_x86_32.nexe $(call LOG,MAP,$$@,$(X86_32_NM) -l $$^ > $$@) -$(OUTDIR)/$(1)_x86_64.map : $(OUTDIR)/$(2)_x86_64.nexe +$(OUTDIR)/$(1)_x86_64.map: $(OUTDIR)/$(2)_x86_64.nexe $(call LOG,MAP,$$@,$(X86_64_NM) -l $$^ > $$@) -$(OUTDIR)/$(1)_arm.map : $(OUTDIR)/$(2)_arm.nexe +$(OUTDIR)/$(1)_arm.map: $(OUTDIR)/$(2)_arm.nexe $(call LOG,MAP,$$@,$(ARM_NM) -l $$^ > $$@ ) all: $(OUTDIR)/$(1)_x86_32.map $(OUTDIR)/$(1)_x86_64.map $(OUTDIR)/$(1)_arm.map @@ -317,28 +348,10 @@ endef # -# Determine which architectures to build for. The user can set NACL_ARCH or -# ARCHES in the environment to control this. +# Generate ARCH_SUFFIXES, a list of suffixes for executables corresponding to all +# the architectures in the current build. # -VALID_ARCHES := x86_32 x86_64 -ifeq (newlib,$(TOOLCHAIN)) -VALID_ARCHES += arm -endif - -ifdef NACL_ARCH -ifeq (,$(findstring $(NACL_ARCH),$(VALID_ARCHES))) -$(error Invalid arch specified in NACL_ARCH: $(NACL_ARCH). Valid values are: $(VALID_ARCHES)) -endif -ARCHES = ${NACL_ARCH} -else -ARCHES ?= ${VALID_ARCHES} -endif - - -# -# Generate NMF_ARCHES -# -NMF_ARCHES := $(foreach arch,$(ARCHES),_$(arch).nexe) +ARCH_SUFFIXES := $(foreach arch,$(ARCHES),_$(arch).nexe) # @@ -357,9 +370,21 @@ ifeq ($(CONFIG),Debug) NMF_FLAGS += --debug-libs endif +EXECUTABLES=$(foreach arch,$(ARCH_SUFFIXES),$(OUTDIR)/$(1)$(arch)) $(GLIBC_SO_LIST) define NMF_RULE -all:$(OUTDIR)/$(1).nmf -$(OUTDIR)/$(1).nmf : $(foreach arch,$(NMF_ARCHES),$(OUTDIR)/$(1)$(arch)) $(GLIBC_SO_LIST) +all: $(OUTDIR)/$(1).nmf +$(OUTDIR)/$(1).nmf: $(EXECUTABLES) $(call LOG,CREATE_NMF,$$@,$(NMF) $(NMF_FLAGS) -o $$@ $$^ $(GLIBC_PATHS) -s $(OUTDIR) $(2) $(GLIBC_REMAP)) endef + +# +# HTML file generation +# +CREATE_HTML := python $(NACL_SDK_ROOT)/tools/create_html.py + +define HTML_RULE +all: $(OUTDIR)/$(1).html +$(OUTDIR)/$(1).html: $(EXECUTABLES) + $(call LOG,CREATE_HTML,$$@,$(CREATE_HTML) -o $$@ $$^) +endef diff --git a/native_client_sdk/src/tools/nacl_llvm.mk b/native_client_sdk/src/tools/nacl_llvm.mk index 70a6e8c..fe9762b 100644 --- a/native_client_sdk/src/tools/nacl_llvm.mk +++ b/native_client_sdk/src/tools/nacl_llvm.mk @@ -6,7 +6,6 @@ # GNU Make based build file. For details on GNU Make see: # http://www.gnu.org/software/make/manual/make.html # -# # @@ -141,6 +140,17 @@ NMF:=python $(NACL_SDK_ROOT)/tools/create_nmf.py define NMF_RULE all: $(OUTDIR)/$(1).nmf -$(OUTDIR)/$(1).nmf : $(OUTDIR)/$(1).pexe +$(OUTDIR)/$(1).nmf: $(OUTDIR)/$(1).pexe $(call LOG,CREATE_NMF,$$@,$(NMF) -o $$@ $$^ -s $(OUTDIR) $(2)) endef + +# +# HTML file generation +# +CREATE_HTML := python $(NACL_SDK_ROOT)/tools/create_html.py + +define HTML_RULE +all: $(OUTDIR)/$(1).html +$(OUTDIR)/$(1).html: $(foreach arch,$(ARCH_SUFFIXES),$(OUTDIR)/$(1)$(arch)) $(GLIBC_SO_LIST) + $(call LOG,CREATE_HTML,$$@,$(CREATE_HTML) -o $$@ $$^) +endef diff --git a/native_client_sdk/src/tools/tests/create_html_test.py b/native_client_sdk/src/tools/tests/create_html_test.py index 91e6ca6..a02b720 100755 --- a/native_client_sdk/src/tools/tests/create_html_test.py +++ b/native_client_sdk/src/tools/tests/create_html_test.py @@ -44,7 +44,7 @@ class TestCreateHtml(unittest.TestCase): with mock.patch('os.path.isfile'): options = mock.MagicMock(return_value=False) options.output = None - create_html.CreateHTML(nmf_file, options) + create_html.CreateHTML([nmf_file], options) # Assert that the file was created self.assertTrue(os.path.exists(expected_html)) # Assert that nothing else was created |