mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/34410 ### Summary Currently, the iOS jobs are not being run on PRs anymore. This is because all iOS jobs have specified the `org-member` as a context which used to include all pytorch members. But seems like recently this rule has changed. It turns out that only users from the admin group or builder group can have access right to the context values. https://circleci.com/gh/organizations/pytorch/settings#contexts/2b885fc9-ef3a-4b86-8f5a-2e6e22bd0cfe This PR will remove `org-member` from the iOS simulator build which doesn't require code signing. For the arm64 builds, they'll only be run on master, not on PRs anymore. ### Test plan - The iOS simulator job should be able to appear in the PR workflow Test Plan: Imported from OSS Differential Revision: D20347270 Pulled By: xta0 fbshipit-source-id: 23f37d40160c237dc280e0e82f879c1d601f72ac
80 lines
2.8 KiB
Ruby
80 lines
2.8 KiB
Ruby
require 'optparse'
|
|
require 'xcodeproj'
|
|
|
|
options = {}
|
|
option_parser = OptionParser.new do |opts|
|
|
opts.banner = 'Tools for building PyTorch iOS framework on MacOS'
|
|
opts.on('-i', '--install_path ', 'path to the cmake install folder') { |value|
|
|
options[:install] = value
|
|
}
|
|
opts.on('-x', '--xcodeproj_path ', 'path to the XCode project file') { |value|
|
|
options[:xcodeproj] = value
|
|
}
|
|
opts.on('-p', '--platform ', 'platform for the current build, OS or SIMULATOR') { |value|
|
|
options[:platform] = value
|
|
}
|
|
opts.on('-c', '--provisioning_profile ', 'provisioning profile for code signing') { |value|
|
|
options[:profile] = value
|
|
}
|
|
opts.on('-t', '--team_id ', 'development team ID') { |value|
|
|
options[:team_id] = value
|
|
}
|
|
end.parse!
|
|
puts options.inspect
|
|
|
|
install_path = File.expand_path(options[:install])
|
|
if not Dir.exist? (install_path)
|
|
raise "path don't exist:#{install_path}!"
|
|
end
|
|
xcodeproj_path = File.expand_path(options[:xcodeproj])
|
|
if not File.exist? (xcodeproj_path)
|
|
raise "path don't exist:#{xcodeproj_path}!"
|
|
end
|
|
|
|
project = Xcodeproj::Project.open(xcodeproj_path)
|
|
target = project.targets.first #TestApp
|
|
header_search_path = ['$(inherited)', "#{install_path}/include"]
|
|
libraries_search_path = ['$(inherited)', "#{install_path}/lib"]
|
|
other_linker_flags = ['$(inherited)', "-all_load"]
|
|
|
|
target.build_configurations.each do |config|
|
|
config.build_settings['HEADER_SEARCH_PATHS'] = header_search_path
|
|
config.build_settings['LIBRARY_SEARCH_PATHS'] = libraries_search_path
|
|
config.build_settings['OTHER_LDFLAGS'] = other_linker_flags
|
|
config.build_settings['ENABLE_BITCODE'] = 'No'
|
|
dev_team_id = options[:team_id]
|
|
if not dev_team_id and options[:platform] == 'OS'
|
|
raise "Please sepecify a valid development team id for code signing"
|
|
end
|
|
config.build_settings['DEVELOPMENT_TEAM'] = dev_team_id
|
|
end
|
|
|
|
# link static libraries
|
|
target.frameworks_build_phases.clear
|
|
libs = ['libc10.a', 'libclog.a', 'libnnpack.a', 'libXNNPACK.a', 'libeigen_blas.a', 'libcpuinfo.a', 'libpytorch_qnnpack.a', 'libtorch_cpu.a', 'libtorch.a']
|
|
for lib in libs do
|
|
path = "#{install_path}/lib/#{lib}"
|
|
if File.exist?(path)
|
|
libref = project.frameworks_group.new_file(path)
|
|
target.frameworks_build_phases.add_file_reference(libref)
|
|
end
|
|
end
|
|
project.save
|
|
|
|
sdk = nil
|
|
if options[:platform] == 'SIMULATOR'
|
|
sdk = 'iphonesimulator'
|
|
elsif options[:platform] == 'OS'
|
|
sdk = 'iphoneos'
|
|
else
|
|
raise "unsupported platform #{options[:platform]}"
|
|
end
|
|
|
|
profile = options[:profile]
|
|
if not profile and options[:platform] == 'OS'
|
|
raise "no provisioning profile found!"
|
|
end
|
|
|
|
# run xcodebuild
|
|
exec "xcodebuild clean build -project #{xcodeproj_path} -target #{target.name} -sdk #{sdk} -configuration Release PROVISIONING_PROFILE_SPECIFIER=#{profile}"
|