Bug 1804298: Add a moz.yaml for fdlibm and make it vendor-able r=arai

Remove the old update scripts so we can use ./mach vendor
to vendor it.

Differential Revision: https://phabricator.services.mozilla.com/D163970
This commit is contained in:
Tom Ritter 2022-12-07 18:08:13 +00:00
Родитель 531fc4de6f
Коммит ead4517cc3
6 изменённых файлов: 112 добавлений и 178 удалений

Просмотреть файл

@ -1,19 +0,0 @@
This is the fdlibm library imported from
https://github.com/freebsd/freebsd
Upstream code can be viewed at
https://github.com/freebsd/freebsd/tree/master/lib/msun/src
Each file is downloaded separately, as cloning whole repository takes so much
resources.
The in-tree copy is updated by running
sh update.sh
or
sh update.sh <sha-commit>
from within the modules/fdlibm directory.
Current version: [commit 369ea0520a3061c07400d7cd32172efb6af39815 (2022-08-04T17:33:34Z)].
patches 01-18 fixes files to be usable within mozilla-central tree.
See https://bugzilla.mozilla.org/show_bug.cgi?id=933257

Просмотреть файл

@ -1,119 +0,0 @@
#!/bin/sh
set -e
BASE_URL=https://raw.githubusercontent.com/freebsd/freebsd-src/"${1}"/lib/msun/src
download_source() {
REMOTE_FILENAME=$1
LOCAL_FILENAME=$2
while true; do
curl -o "src/${LOCAL_FILENAME}" "${BASE_URL}/${REMOTE_FILENAME}" && break
done
}
mkdir -p src
# headers
download_source math.h fdlibm.h
download_source math_private.h math_private.h
# Math.acos
download_source e_acos.c e_acos.cpp
# Math.acosh
download_source e_acosh.c e_acosh.cpp
# Math.asin
download_source e_asin.c e_asin.cpp
# Math.asinh
download_source s_asinh.c s_asinh.cpp
# Math.atan
download_source s_atan.c s_atan.cpp
# Math.atanh
download_source e_atanh.c e_atanh.cpp
# Math.atan2
download_source e_atan2.c e_atan2.cpp
# Math.cbrt
download_source s_cbrt.c s_cbrt.cpp
# Math.ceil
download_source s_ceil.c s_ceil.cpp
download_source s_ceilf.c s_ceilf.cpp
# Math.cos
download_source s_cos.c s_cos.cpp
download_source k_cos.c k_cos.cpp
# Math.cosh
download_source e_cosh.c e_cosh.cpp
# Math.exp
download_source e_exp.c e_exp.cpp
# Math.expm1
download_source s_expm1.c s_expm1.cpp
# Math.floor and Math.round
download_source s_floor.c s_floor.cpp
# Math.fround
download_source s_floorf.c s_floorf.cpp
# Math.hypot
download_source e_hypot.c e_hypot.cpp
# Math.log
download_source e_log.c e_log.cpp
# Math.log1p
download_source s_log1p.c s_log1p.cpp
# Math.log10
download_source e_log10.c e_log10.cpp
download_source k_log.h k_log.h
# Math.log2
download_source e_log2.c e_log2.cpp
# Math.pow (not used due to poor performance)
# Math.sin
download_source s_sin.c s_sin.cpp
download_source k_sin.c k_sin.cpp
# Math.sinh
download_source e_sinh.c e_sinh.cpp
# Math.sqrt (not used due to poor performance)
# Math.tan
download_source s_tan.c s_tan.cpp
download_source k_tan.c k_tan.cpp
# Math.tanh
download_source s_tanh.c s_tanh.cpp
# Math.trunc
download_source s_trunc.c s_trunc.cpp
download_source s_truncf.c s_truncf.cpp
# dependencies
download_source e_rem_pio2.c e_rem_pio2.cpp
download_source k_rem_pio2.c k_rem_pio2.cpp
download_source k_exp.c k_exp.cpp
download_source s_copysign.c s_copysign.cpp
download_source s_fabs.c s_fabs.cpp
download_source s_scalbn.c s_scalbn.cpp
# These are not not used in Math.* functions, but used internally.
download_source e_pow.c e_pow.cpp
download_source s_nearbyint.c s_nearbyint.cpp
download_source s_rint.c s_rint.cpp
download_source s_rintf.c s_rintf.cpp

94
modules/fdlibm/moz.yaml Normal file
Просмотреть файл

@ -0,0 +1,94 @@
# Version of this schema
schema: 1
bugzilla:
product: "Core"
component: "JavaScript Engine"
origin:
name: "fdlibm"
description: "The fdlibm library imported from freebsd"
url: "https://github.com/freebsd/freebsd/tree/master/lib/msun/src"
# Human-readable identifier for this version/release
# Generally "version NNN", "tag SSS", "bookmark SSS"
release: "commit 369ea0520a3061c07400d7cd32172efb6af39815 (2022-08-04T17:33:34Z)"
# Revision to pull in
# Must be a long or short commit SHA (long preferred)
revision: 369ea0520a3061c07400d7cd32172efb6af39815
license: "BSD-2-Clause"
license-file: LICENSE
vendoring:
url: https://github.com/freebsd/freebsd/
flavor: individual-files
source-hosting: github
vendor-directory: modules/fdlibm/src
individual-files-default-upstream: 'lib/msun/src/'
individual-files-default-destination: '{vendor_dir}/'
individual-files-list:
- math_private.h
- math.h
- e_acos.c
- e_acosh.c
- e_asin.c
- e_atan2.c
- e_atanh.c
- e_cosh.c
- e_exp.c
- e_hypot.c
- e_log10.c
- e_log2.c
- e_log.c
- e_pow.c
- e_rem_pio2.c
- e_sinh.c
- k_cos.c
- k_exp.c
- k_log.h
- k_rem_pio2.c
- k_sin.c
- k_tan.c
- s_asinh.c
- s_atan.c
- s_cbrt.c
- s_ceil.c
- s_ceilf.c
- s_copysign.c
- s_cos.c
- s_expm1.c
- s_fabs.c
- s_floor.c
- s_floorf.c
- s_log1p.c
- s_nearbyint.c
- s_rint.c
- s_rintf.c
- s_scalbn.c
- s_sin.c
- s_tan.c
- s_tanh.c
- s_trunc.c
- s_truncf.c
update-actions:
- action: 'move-file'
from: '{vendor_dir}/math.h'
to: '{vendor_dir}/fdlibm.h'
- action: 'run-script'
script: '{yaml_dir}/rename_c_to_cpp.sh'
cwd: '{vendor_dir}'
patches:
- 'patches/*.patch'
updatebot:
maintainer-phab: arai
maintainer-bz: arai.unmht@gmail.com
tasks:
- type: vendoring
enabled: false

Просмотреть файл

@ -0,0 +1,7 @@
#!/bin/sh
set -e
for i in *.c; do
mv "$i" "${i}pp"
done

Просмотреть файл

@ -0,0 +1,11 @@
Copyright 1992-2022 The FreeBSD Project.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project.

Просмотреть файл

@ -1,40 +0,0 @@
#!/bin/sh
# Script to update the mozilla in-tree copy of the fdlibm library.
# Run this within the /modules/fdlibm directory of the source tree.
set -e
API_BASE_URL=https://api.github.com/repos/freebsd/freebsd-src
get_commit() {
curl -s "${API_BASE_URL}/commits?path=lib/msun/src&per_page=1" \
| python3 -c 'import json, sys; print(json.loads(sys.stdin.read())[0]["sha"])'
}
get_date() {
curl -s "${API_BASE_URL}/commits/${COMMIT}" \
| python3 -c 'import json, sys; print(json.loads(sys.stdin.read())["commit"]["committer"]["date"])'
}
mv ./src/moz.build ./src_moz.build
rm -rf src
if [ "$#" -eq 0 ]; then
COMMIT=$(get_commit)
else
COMMIT="$1"
fi
sh ./import.sh "${COMMIT}"
mv ./src_moz.build ./src/moz.build
COMMITDATE=$(get_date)
for FILE in $(ls patches/*.patch | sort); do
echo "Applying ${FILE} ..."
patch -p3 --no-backup-if-mismatch < ${FILE}
done
hg add src
perl -p -i -e "s/\[commit [0-9a-f]{40} \(.{1,100}\)\]/[commit ${COMMIT} (${COMMITDATE})]/" README.mozilla
echo "###"
echo "### Updated fdlibm/src to ${COMMIT}."
echo "### Remember to verify and commit the changes to source control!"
echo "###"