[scripts][build] Make scripts magenta-friendly

Allows scripts to run under dash in magenta.

Change-Id: I2913871ae92c8ca259fd00300e2171330782421e
Esse commit está contido em:
Josh Conner
2017-03-13 07:02:27 -07:00
commit de Joshua Conner
commit bb5242c8e4
11 arquivos alterados com 51 adições e 32 exclusões
+2 -2
Ver Arquivo
@@ -633,9 +633,9 @@ endif
# Regenerate this every time, but if it comes out identical then
# don't touch the file so gratuitous recompiles won't be triggered.
$(GIT_VERSION_HEADER): $(call SCRIPTNAME, scripts/git-version.sh) FORCE
$(GIT_VERSION_HEADER): scripts/git-version.sh FORCE
@echo generating $@
$(NOECHO)$< $@.new
$(NOECHO)$(SHELLEXEC) $< $@.new
$(NOECHO)if cmp -s $@.new $@; then rm $@.new; else mv -f $@.new $@; fi
# make all object files depend on any targets in GLOBAL_SRCDEPS
+2 -3
Ver Arquivo
@@ -23,11 +23,10 @@ MODULE_SRCDEPS += $(userboot-filename).strip
# This generated header file tells the userboot.cpp code
# where the segment boundaries and entry points are.
MODULE_SRCDEPS += $(BUILDDIR)/$(LOCAL_DIR)/userboot-code.h
$(BUILDDIR)/$(LOCAL_DIR)/userboot-code.h: \
$(call SCRIPTNAME, scripts/gen-rodso-code.sh) $(userboot-filename)
$(BUILDDIR)/$(LOCAL_DIR)/userboot-code.h: scripts/gen-rodso-code.sh $(userboot-filename)
@$(MKDIR)
@echo generating $@
$(NOECHO)$< '$(NM)' USERBOOT $(userboot-filename) > $@.new
$(NOECHO)$(SHELLEXEC) $< '$(NM)' $@.new USERBOOT $(userboot-filename)
@mv -f $@.new $@
GENERATED += $(BUILDDIR)/$(LOCAL_DIR)/userboot-code.h
MODULE_COMPILEFLAGS += -I$(BUILDDIR)/$(LOCAL_DIR)
+2 -2
Ver Arquivo
@@ -24,10 +24,10 @@ MODULE_SRCDEPS += $(vdso-filename).strip
# This generated header file tells the vdso.cpp code
# where the segment boundaries and entry points are.
MODULE_SRCDEPS += $(BUILDDIR)/$(LOCAL_DIR)/vdso-code.h
$(BUILDDIR)/$(LOCAL_DIR)/vdso-code.h: $(call SCRIPTNAME, scripts/gen-rodso-code.sh) $(vdso-filename)
$(BUILDDIR)/$(LOCAL_DIR)/vdso-code.h: scripts/gen-rodso-code.sh $(vdso-filename)
@$(MKDIR)
@echo generating $@
$(NOECHO)$< '$(NM)' VDSO $(vdso-filename) > $@.new
$(NOECHO)$(SHELLEXEC) $< '$(NM)' $@.new VDSO $(vdso-filename)
@mv -f $@.new $@
GENERATED += $(BUILDDIR)/$(LOCAL_DIR)/vdso-code.h
MODULE_COMPILEFLAGS += -I$(BUILDDIR)/$(LOCAL_DIR)
+2 -2
Ver Arquivo
@@ -9,7 +9,7 @@
GIT_REV="git-$(git rev-parse HEAD 2>/dev/null)"
# Is there a .git or revision?
if [[ $? -eq 0 ]]; then
if [ $? -eq 0 ]; then
if [ -n "$(git status --porcelain 2>/dev/null)" ]; then
GIT_REV+="-dirty"
fi
@@ -17,7 +17,7 @@ else
GIT_REV="unknown"
fi
if [[ $# -eq 1 ]]; then
if [ $# -eq 1 ]; then
cat > "$1" <<END
#ifndef __BUILDID_H
#define __BUILDID_H
+5 -5
Ver Arquivo
@@ -33,7 +33,7 @@ $(OUTLKELF): $(ALLMODULE_OBJS) $(EXTRA_OBJS) $(LINKER_SCRIPT)
$(NOECHO)$(SIZECMD) -t --common $(sort $(ALLMODULE_OBJS)) $(EXTRA_OBJS)
$(NOECHO)$(SIZECMD) $@
$(OUTLKELF)-gdb.py: $(call SCRIPTNAME, scripts/$(LKNAME).elf-gdb.py)
$(OUTLKELF)-gdb.py: scripts/$(LKNAME).elf-gdb.py
@echo generating $@
$(NOECHO)cp -f $< $@
@@ -90,7 +90,7 @@ $(BUILDDIR)/%.size: $(BUILDDIR)/%
$(NOECHO)$(NM) -S --size-sort $< > $@
$(BUILDDIR)/%.id: $(BUILDDIR)/%
$(NOECHO)env READELF="$(READELF)" $(call SCRIPTNAME, scripts/get-build-id) $< > $@
$(NOECHO)env READELF="$(READELF)" scripts/get-build-id $< > $@
ifneq ($(USER_AUTORUN),)
USER_MANIFEST_LINES += autorun=$(USER_AUTORUN)
@@ -106,7 +106,7 @@ $(USER_MANIFEST): usermanifestfile $(USER_MANIFEST_DEBUG_INPUTS)
@$(MKDIR)
$(NOECHO)echo $(USER_MANIFEST_LINES) | tr ' ' '\n' | sort > $@.tmp
$(NOECHO)for f in $(USER_MANIFEST_DEBUG_INPUTS) ; do \
echo debug/$$(env READELF=$(READELF) $(call SCRIPTNAME, scripts/get-build-id) $$f).debug=$$f >> $@.tmp ; \
echo debug/$$(env READELF=$(READELF) $(SHELLEXEC) scripts/get-build-id $$f).debug=$$f >> $@.tmp ; \
done
$(NOECHO)$(call TESTANDREPLACEFILE,$@.tmp,$@)
@@ -144,7 +144,7 @@ ifneq ($(wildcard $(LKMAKEROOT)/prebuilt/config.mk),)
ifeq ($(PREBUILT_TOOLCHAINS),)
$(info WARNING:)
$(info WARNING: prebuilt/config.mk is out of date)
$(info WARNING: run $(call SCRIPTNAME, scripts/download-toolchain))
$(info WARNING: run scripts/download-toolchain)
$(info WARNING:)
else
# For each prebuilt toolchain, check if the shafile (checked in)
@@ -160,7 +160,7 @@ ifneq ($(PREBUILT_STALE),)
$(info WARNING:)
$(foreach tool,$(PREBUILT_STALE),\
$(info WARNING: toolchain $(tool) is out of date))
$(info WARNING: run $(call SCRIPTNAME, scripts/download-toolchain))
$(info WARNING: run scripts/download-toolchain)
$(info WARNING:)
endif
endif
+5 -1
Ver Arquivo
@@ -120,5 +120,9 @@ endef
copy-dst-src = $(eval $(call generate-copy-dst-src,$(strip $1),$(strip $2)))
UNAME := $(shell uname)
SCRIPTNAME = $(firstword $(wildcard $1.$(UNAME)) $(wildcard $1))
ifeq ($(UNAME), Magenta)
SHELLEXEC = /boot/bin/sh
else
SHELLEXEC =
endif
+6 -6
Ver Arquivo
@@ -78,13 +78,13 @@ $(MODULE_LIBNAME).so.abi: $(MODULE_LIBNAME).abi.stamp ;
$(MODULE_LIBNAME).abi.stamp: _SONAME := lib$(MODULE_SO_NAME).so
$(MODULE_LIBNAME).abi.stamp: _LIBS := $(MODULE_SOLIBS)
$(MODULE_LIBNAME).abi.stamp: $(MODULE_LIBNAME).abi.o $(MODULE_SOLIBS) \
$(MODULE_LIBNAME).abi.h $(call SCRIPTNAME, scripts/shlib-symbols)
$(MODULE_LIBNAME).abi.h scripts/shlib-symbols
@echo generating ABI stub $(@:.abi.stamp=.so.abi)
$(NOECHO)$(USER_LD) $(GLOBAL_LDFLAGS) --no-gc-sections \
-shared -soname $(_SONAME) -s \
$< $(_LIBS) -o $(@:.abi.stamp=.so.abi).new
# Sanity check that the ABI stub really matches the actual DSO.
$(NOECHO)$(call SCRIPTNAME, scripts/shlib-symbols) '$(NM)' $(@:.abi.stamp=.so.abi).new | \
$(NOECHO)$(SHELLEXEC) scripts/shlib-symbols '$(NM)' $(@:.abi.stamp=.so.abi).new | \
diff -U0 $(<:.o=.h) -
# Move it into place only if it's changed.
$(NOECHO)\
@@ -95,12 +95,12 @@ $(MODULE_LIBNAME).abi.stamp: $(MODULE_LIBNAME).abi.o $(MODULE_SOLIBS) \
fi
$(NOECHO)touch $@
$(MODULE_LIBNAME).abi.h: $(MODULE_LIBNAME).so $(call SCRIPTNAME, scripts/shlib-symbols)
$(NOECHO)$(call SCRIPTNAME, scripts/shlib-symbols) -z '$(NM)' $< > $@
$(MODULE_LIBNAME).abi.h: $(MODULE_LIBNAME).so scripts/shlib-symbols
$(NOECHO)$(SHELLEXEC) scripts/shlib-symbols -z '$(NM)' $< > $@
$(MODULE_LIBNAME).abi.o: $(MODULE_LIBNAME).abi.h $(call SCRIPTNAME, scripts/dso-abi.h)
$(MODULE_LIBNAME).abi.o: $(MODULE_LIBNAME).abi.h scripts/dso-abi.h
$(NOECHO)$(CC) $(GLOBAL_COMPILEFLAGS) $(ARCH_COMPILEFLAGS) \
$(ARCH_CFLAGS) -c -include $(call SCRIPTNAME, scripts/dso-abi.h) \
$(ARCH_CFLAGS) -c -include scripts/dso-abi.h \
-xassembler-with-cpp $< -o $@
ALLUSER_LIBS += $(MODULE)
+14 -7
Ver Arquivo
@@ -17,7 +17,7 @@
# of entries in the table.
usage() {
echo >&2 "Usage: $0 NM {NAME DSO}..."
echo >&2 "Usage: $0 NM OUTFILE {NAME DSO}..."
exit 2
}
@@ -27,8 +27,15 @@ fi
NM="$1"
shift
OUTFILE="$1"
shift
set -o pipefail -e
if [ "$(basename $0)" = "sh" ]
then
set -e
else
set -o pipefail -e
fi
grok_code_symbols() {
local symbol type addr size rest
@@ -38,10 +45,10 @@ grok_code_symbols() {
if [ "$symbol" = _start ]; then
symbol=ENTRY
fi
echo "#define ${1}_${symbol} 0x${addr}"
echo "#define ${1}_${symbol} 0x${addr}" >> $OUTFILE
case "$size" in
''|0|0x0) ;;
*) echo "#define ${1}_${symbol}_SIZE 0x${size}"
*) echo "#define ${1}_${symbol}_SIZE 0x${size}" >> $OUTFILE
esac
status=0
;;
@@ -59,11 +66,11 @@ grok_dynsym_slots() {
local symbol rest
while read symbol rest; do
let symno++ 1
echo "#define ${1}_DYNSYM_${symbol} ${symno}"
echo "#define ${1}_DYNSYM_${symbol} ${symno}" >> $OUTFILE
done
if [ $symno -gt 0 ]; then
let symno++ 1
echo "#define ${1}_DYNSYM_COUNT ${symno}"
echo "#define ${1}_DYNSYM_COUNT ${symno}" >> $OUTFILE
fi
}
@@ -75,7 +82,7 @@ while [ $# -gt 0 ]; do
if [ $# -lt 2 ]; then
usage
fi
echo "#define ${1}_FILENAME \"${2}\""
echo "#define ${1}_FILENAME \"${2}\"" > $OUTFILE
find_code_symbols "$1" "$2"
find_dynsym_slots "$1" "$2"
shift 2
+6 -2
Ver Arquivo
@@ -1,8 +1,12 @@
#!/bin/sh
REV=`git rev-parse HEAD 2> /dev/null`
if [ -n "`git diff-index --name-only HEAD 2> /dev/null`" ]; then
REV="${REV}-dirty"
if [ "$?" -eq 0 ]; then
if [ -n "`git diff-index --name-only HEAD 2> /dev/null`" ]; then
REV="${REV}-dirty"
fi
else
REV="unknown"
fi
cat > "$1" <<EOF
+6 -1
Ver Arquivo
@@ -28,7 +28,12 @@
# ELF symbol bits consistently. But the type letters map to these symbol
# details when symbols are defined in the usual ways by a compiler.)
set -o pipefail -e
if [ "$(basename $0)" = "sh" ]
then
set -e
else
set -o pipefail -e
fi
show_address=false
zero_function_size=false
+1 -1
Ver Arquivo
@@ -62,7 +62,7 @@ MODULE_COMPILEFLAGS += -Ithird_party/ulib/lz4/include/lz4 -DWITH_LZ4_NOALLOC
$(BUILDDIR)/$(LOCAL_DIR)/vdso-syms.h: $(BUILDDIR)/ulib/magenta/libmagenta.so
@$(MKDIR)
@echo generating $@
$(NOECHO)$(call SCRIPTNAME, scripts/shlib-symbols) -a '$(NM)' $< > $@
$(NOECHO)$(SHELLEXEC) scripts/shlib-symbols -a '$(NM)' $< > $@
GENERATED += $(BUILDDIR)/$(LOCAL_DIR)/vdso-syms.h
# This generated linker script defines symbols for each vDSO entry point