* Copy stuff from RNM and refactor

* Disable ccache

* gitignore ccache

* fix

* fix

* fix

* fix

* fix

* fix

* fix
This commit is contained in:
Saad Najmi 2024-05-22 14:30:06 -07:00 коммит произвёл GitHub
Родитель fd17528077
Коммит af9059cf80
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
11 изменённых файлов: 142 добавлений и 118 удалений

2
.ado/Brewfile Normal file
Просмотреть файл

@ -0,0 +1,2 @@
brew "xcbeautify"
brew "ccache"

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

@ -79,43 +79,36 @@ jobs:
- template: templates/setup-repo-min-build.yml
- template: templates/apple-ensure-valid-cocoapods.yml
- template: templates/apple-tools-setup.yml
- script: |
set -eox pipefail
yarn bundle:macos
workingDirectory: apps/fluent-tester
displayName: 'yarn bundle macos'
- bash: |
echo "pod install $(platform)"
pod install
workingDirectory: apps/fluent-tester/$(platform)
displayName: 'pod install $(platform)'
set -eox pipefail
pod install --verbose
workingDirectory: apps/fluent-tester/macos
displayName: 'pod install'
- bash: |
sudo xcode-select --switch '$(xcode_path)'
displayName: Switch Xcode version $(xcode_version)
failOnStderr: true
- script: |
brew install xcbeautify
displayName: 'Install xcbeautify'
- bash: |
echo "yarn $(platform)"
yarn $(platform)
workingDirectory: apps/fluent-tester
displayName: 'yarn $(platform)'
- task: CmdLine@2
displayName: Build macOS
inputs:
script: |
set -eox pipefail
./.ado/scripts/xcodebuild.sh apps/fluent-tester/macos/FluentTester.xcworkspace macosx ReactTestApp build
env:
CCACHE_DISABLE: 1
- template: templates/e2e-testing-macos.yml
- job: iOSPR
displayName: iOS PR
pool:
vmImage: macos-13-arm64
variables:
platform: 'ios'
timeoutInMinutes: 120 # how long to run the job before automatically cancelling
vmImage: $(VmImageApple)
timeoutInMinutes: 60 # how long to run the job before automatically cancelling
cancelTimeoutInMinutes: 5 # how much time to give 'run always even if cancelled tasks' before killing them
steps:
@ -124,47 +117,28 @@ jobs:
- template: templates/setup-repo-min-build.yml
- template: templates/apple-ensure-valid-cocoapods.yml
- template: templates/apple-tools-setup.yml
- script: |
set -eox pipefail
yarn bundle:ios
workingDirectory: apps/fluent-tester
displayName: 'yarn bundle ios'
- bash: |
echo "pod install $(platform)"
pod install
workingDirectory: apps/fluent-tester/$(platform)
displayName: 'pod install $(platform)'
set -eox pipefail
pod install --verbose
workingDirectory: apps/fluent-tester/ios
displayName: 'pod install'
- bash: |
sudo xcode-select --switch '$(xcode_path)'
displayName: Switch Xcode version $(xcode_version)
failOnStderr: true
- script: |
brew install xcbeautify
displayName: 'Install xcbeautify'
- script: |
xcrun simctl list
displayName: 'List Simulators'
- script: |
xcrun --sdk iphonesimulator --show-sdk-version
displayName: 'Determine iOS SDK version'
# - script: |
# NEW_DEVICE=$(xcrun simctl create "Test Phone" "$(ios_simulator)" iOS$(ios_version))
# echo "🤖 Created ${NEW_DEVICE}"
# xcrun simctl boot ${NEW_DEVICE}
# displayName: 'Boot Simulator'
- bash: |
echo "yarn $(platform)"
yarn $(platform) --simulator "$(ios_simulator)" --no-packager
workingDirectory: apps/fluent-tester
displayName: 'yarn $(platform)'
- task: CmdLine@2
displayName: Build iOS
inputs:
script: |
set -eox pipefail
./.ado/scripts/xcodebuild.sh apps/fluent-tester/ios/FluentTester.xcworkspace iphonesimulator ReactTestApp build
env:
CCACHE_DISABLE: 1
# Disable iOS E2E tests as they fail on macOS-13 images
# - template: templates/e2e-testing-ios.yml

77
.ado/scripts/xcodebuild.sh Executable file
Просмотреть файл

@ -0,0 +1,77 @@
#!/bin/bash
set -eox pipefail
workspace=$1
sdk=$2
scheme=$3
action=$4
shift 4
if [[ $sdk == iphoneos || $sdk == iphonesimulator ]]; then
if [[ $action == 'test' || $action == 'test-without-building' ]]; then
device=$(xcrun simctl list devices iPhone available)
re='iPhone [0-9]+ \(([-0-9A-Fa-f]+)\)'
[[ $device =~ $re ]] || exit 1
shift || true
destination="-destination \"platform=iOS Simulator,id=${BASH_REMATCH[1]}\""
else
destination='-destination "generic/platform=iOS Simulator"'
fi
elif [[ $sdk == macosx ]]; then
destination=''
elif [[ $sdk == xros || $sdk == xrsimulator ]]; then
if [[ $action == 'test' || $action == 'test-without-building' ]]; then
device=$(xcrun simctl list devices visionOS available)
re='Apple Vision Pro \(([-0-9A-Fa-f]+)\)'
[[ $device =~ $re ]] || exit 1
shift || true
destination="-destination \"platform=visionOS Simulator,id=${BASH_REMATCH[1]}\""
else
destination='-destination "generic/platform=visionOS Simulator"'
fi
else
echo "Cannot detect sdk: $sdk"
exit 1
fi
build_cmd=$(
echo xcodebuild \
-workspace "$workspace" \
-scheme "$scheme" \
-sdk "$sdk" \
"$destination" \
-derivedDataPath $(dirname $workspace)/build \
CODE_SIGNING_ALLOWED=NO \
COMPILER_INDEX_STORE_ENABLE=NO \
"$action" \
"$@" \
)
if [[ "$CCACHE_DISABLE" != "1" ]]; then
if ! command -v ccache 1> /dev/null; then
brew install ccache
fi
CCACHE_HOME=$(dirname $(dirname $(which ccache)))/opt/ccache
export CCACHE_DIR="$(git rev-parse --show-toplevel)/.ccache"
export CC="${CCACHE_HOME}/libexec/clang"
export CXX="${CCACHE_HOME}/libexec/clang++"
export CMAKE_C_COMPILER_LAUNCHER=$(which ccache)
export CMAKE_CXX_COMPILER_LAUNCHER=$(which ccache)
ccache --zero-stats 1> /dev/null
fi
if ! command -v xcbeautify 1> /dev/null; then
brew install xcbeautify
fi
eval "$build_cmd" | xcbeautify --report junit
if [[ "$CCACHE_DISABLE" != "1" ]]; then
ccache --show-stats --verbose
fi

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

@ -1,10 +0,0 @@
# Cocoapods 1.15.0 doesn't work with React Native
steps:
- task: CmdLine@2
displayName: Install Cocoapods 1.15.2 if needed
inputs:
script: |
POD_VERSION=$(pod --version)
if [ $POD_VERSION = 1.15.0 ]; then
gem install cocoapods -v 1.15.2
fi

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

@ -0,0 +1,26 @@
steps:
- task: NodeTool@0
inputs:
versionSpec: '18.x'
- task: CmdLine@2
displayName: 'brew bundle'
inputs:
script: |
brew bundle --file .ado/Brewfile
cat .ado/Brewfile.lock.json
# Cocoapods 1.15.0 doesn't work with React Native
- task: CmdLine@2
displayName: Install Cocoapods 1.15.2 if needed
inputs:
script: |
POD_VERSION=$(pod --version)
if [ $POD_VERSION = 1.15.0 ]; then
gem install cocoapods -v 1.15.2
fi
- bash: |
sudo xcode-select --switch $(xcode_version)
displayName: Use $(xcode_friendly_name)
failOnStderr: true

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

@ -1,11 +1,7 @@
variables:
- name: VmImageApple
value: macos-13
- name: xcode_version
value: macos-latest-internal
- name: xcode_friendly_name
value: 'Xcode 15.2'
- name: xcode_path
- name: xcode_version
value: '/Applications/Xcode_15.2.app'
- name: ios_version
value: '17.2.0'
- name: ios_simulator
value: 'iPhone 15 (17.2.0)'

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

@ -1,23 +0,0 @@
#include "publish_staticanalysis.xcconfig"
// For publish builds, only provide line tables for symbolizing crashes
CLANG_DEBUG_INFORMATION_LEVEL[config=Release]=line-tables-only
// The following build setting caused build errors, so it is commented out and placed in every podspec instead
// OTHER_SWIFT_FLAGS=-gline-tables-only
// Optimize for size in publish builds
SWIFT_OPTIMIZATION_LEVEL[config=Release]=-Osize
// Build for all architectures, not just the active one
ONLY_ACTIVE_ARCH=NO
// react-native/react_native_pods.rb sometimes makes our lives difficult
EXCLUDED_ARCHS =
// Specify the exact Swift version used for reproducibility
SWIFT_VERSION = 5.0
// Turn off Sanitizers for Release Builds
CLANG_ADDRESS_SANITIZER = NO
CLANG_UNDEFINED_BEHAVIOR_SANITIZER = NO

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

@ -1,4 +0,0 @@
#include "publish_overrides.xcconfig"
// Explicitly build arm64e for iOS device builds in case our clients need it
ARCHS = $(ARCHS_STANDARD) arm64e

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

@ -1,4 +0,0 @@
#include "publish_overrides.xcconfig"
// Explicitly build arm64 and x86_64 machines
ARCHS = arm64 x86_64

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

@ -1,13 +0,0 @@
RUN_CLANG_STATIC_ANALYZER = YES
CLANG_STATIC_ANALYZER_MODE = deep
// Required security settings for production code (do not override at target/project level, with the possible
// exception of legacy test code)
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES
CLANG_ANALYZER_SECURITY_KEYCHAIN_API = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_UNCHECKEDRETURN = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_GETPW_GETS = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_MKSTEMP = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_VFORK = YES

5
.gitignore поставляемый
Просмотреть файл

@ -112,4 +112,7 @@ apps/*/.vscode/.react/
!**/.yarn/plugins
!**/.yarn/releases
!**/.yarn/sdks
!**/.yarn/versions
!**/.yarn/versions
# Ccache
.ccache