Sfoglia il codice sorgente

[LibOS,Pal,Scripts] Add and use recipe to create manifest from template

Isaku Yamahata 4 anni fa
parent
commit
9ef2251d66

+ 0 - 4
LibOS/shim/test/benchmark/Makefile

@@ -6,10 +6,6 @@ target = manifest
 
 include ../../../../Scripts/Makefile.Test
 
-%.manifest: %.manifest.template
-	rm -rf $@
-	cp $@.template $@
-
 ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
 
 CFLAGS-rpc_latency.libos += $(CFLAGS-libos)

+ 2 - 3
Pal/regression/Makefile

@@ -52,11 +52,10 @@ manifest_rules = \
 	$(extra_rules)
 
 manifest: manifest.template
-	sed $(manifest_rules) $< >$@
+	$(call cmd,manifest,$(manifest_rules))
 
 %.manifest: %.manifest.template $(executables) $(pal_lib)
-	sed $(manifest_rules) $< >$@
-	(grep -q "#\!" $@ && chmod +x $@) || true
+	$(call cmd,manifest,$(manifest_rules))
 
 ../src/user_shared_start.o ../src/user_start.o: ../src/user_start.S
 	$(MAKE) -C ../src $(notdir $@)

+ 2 - 2
Pal/test/Makefile

@@ -39,10 +39,10 @@ pal_loader:
 	ln -sf ../../Runtime/pal_loader
 
 manifest: manifest.template
-	cp -f $< $@
+	$(call cmd,manifest)
 
 %.manifest: %.manifest.template
-	cp -f $< $@
+	$(call cmd,manifest)
 
 ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
 CFLAGS-Pie = -fPIC -pie

+ 4 - 10
Scripts/Makefile.Test

@@ -62,25 +62,19 @@ manifest_rules= \
 	-e 's:\$$(PAL):$(abspath $(RUNTIME))/$(PAL_LOADER):g' \
 	-e 's:\$$(PWD):$(PWD):g' \
 	-e 's:\$$(BIN):$(subst .manifest,,$(notdir $@)):g' \
-	-e 's:\$$(SHIMPATH):'$$RELDIR'$(RUNTIME)/libsysdb.so:g' \
-	-e 's:\$$(LIBCDIR):'$$RELDIR'$(RUNTIME):g' \
+	-e 's:\$$(SHIMPATH):$(RUNTIME)/libsysdb.so:g' \
+	-e 's:\$$(LIBCDIR):$(RUNTIME):g' \
 	$(extra_rules)
 endif
 
 pal_loader:
 	ln -sf $(RUNTIME)/pal_loader
 
-relative-to = $(shell python -c "import os.path; print os.path.relpath(\"$(abspath $2)\",\"$(abspath $1)\")")
-
 %.manifest: %.manifest.template
-	@echo [ $@ ]
-	RELDIR=$(filter-out ./,$(call relative-to,$(dir $@),$(shell pwd))/) && \
-	sed $(manifest_rules) $< > $@
-	(grep -q '^#!' $@ && chmod +x $@) || true
+	$(call cmd,manifest,$(manifest_rules))
 
 manifest: manifest.template
-	@echo [ $@ ]
-	sed $(manifest_rules) $< > $@
+	$(call cmd,manifest,$(manifest_rules))
 
 ifeq ($(filter %clean,$(MAKECMDGOALS)),)
 ifeq ($(SGX),1)

+ 6 - 0
Scripts/Makefile.rules

@@ -143,6 +143,12 @@ quiet_cmd_sgx_sign_depend_exec = [ $@ ]
 quiet_cmd_sgx_sign_depend = [ $@ ]
       cmd_sgx_sign_depend = $(SGX_SIGN) -depend -output $@ -manifest $<
 
+# manifest
+quiet_cmd_manifest = [ $@ ]
+      cmd_manifest = \
+	$(if $(2),sed $(2) $< > $@,cp -f $< $@); \
+	(grep -q "\#\\!" $@ && chmod +x $@) || true
+
 # pal map
 PAL_SYMBOL_FILE := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/../Pal/src/pal-symbols
 PAL_SYMBOLS = $(shell sed -e 's|$$|;|g' $(PAL_SYMBOL_FILE))