1+ parameters :
2+ # Note: Make sure llvm_repo is the same as the one in Extension/cgmanifest.json
3+ # 'RepositoryUrl' for llvm-project.
4+ llvm_repo : https://github.com/llvm/llvm-project.git
5+
6+ # Note: Make sure llvm_commit is the same as the one in Extension/cgmanifest.json
7+ # 'CommitHash' for llvm-project.
8+ llvm_commit : 0d44201451f03ba907cdb268ddddfc3fa38a0ebd
9+
10+ llvm_build_type : Release
11+
12+ llvm_arch : x86_64
13+
14+ llvm_additional_parameters : " -DLLDB_USE_SYSTEM_DEBUGSERVER=ON -DLLDB_RELOCATABLE_PYTHON=1 -DLLDB_INCLUDE_TESTS=OFF -DLLDB_BUILD_FRAMEWORK=1"
15+
16+ # Note: Make sure lldb_mi_repo is the same as the one in Extension/cgmanifest.json
17+ # 'CommitHash' for lldb-mi.
18+ lldb_mi_repo : https://github.com/lldb-tools/lldb-mi.git
19+
20+ # Note: Make sure lldb_mi_commit is the same as the one in Extension/cgmanifest.json
21+ # 'CommitHash' for lldb-mi.
22+ lldb_mi_commit : 2388bd74133bc21eac59b2e2bf97f2a30770a315
23+
24+ lldb_mi_additional_parameters : " -DUSE_LLDB_FRAMEWORK=1"
25+
26+ jobs :
27+ - job : LLDB_MI_${{ parameters.llvm_arch }}
28+ timeoutInMinutes : 360
29+ pool :
30+ ${{if eq(parameters['llvm_arch'], 'arm64')}} :
31+ name : cpptoolsMacM1pool
32+ ${{ else }} :
33+ vmImage : macOS-latest
34+ steps :
35+ - task : CmdLine@2
36+ displayName : ' Install Dependencies'
37+ inputs :
38+ script : brew install cmake ninja swig
39+ continueOnError : true
40+
41+ - task : CmdLine@2
42+ displayName : ' Make sure buildspace does not exist'
43+ inputs :
44+ script : rm -rf $(Build.StagingDirectory)/buildspace
45+ condition : always()
46+
47+ - task : CmdLine@2
48+ displayName : ' Build LLVM Project'
49+ inputs :
50+ script : |
51+ log_and_exec_cmd() {
52+ echo "##[command] $1"
53+ $1
54+ }
55+
56+ log_and_exec_cmd "sudo rm -rf /Library/Developer/CommandLineTools"
57+ log_and_exec_cmd "sudo xcode-select --switch /Applications/XCode.app"
58+
59+ log_and_exec_cmd "cd $(Build.StagingDirectory)"
60+ log_and_exec_cmd "mkdir $(Build.StagingDirectory)/buildspace"
61+
62+ log_and_exec_cmd "git clone ${{ parameters.llvm_repo }} llvm-project"
63+ log_and_exec_cmd "cd llvm-project"
64+ log_and_exec_cmd "git checkout ${{ parameters.llvm_commit }}"
65+
66+ log_and_exec_cmd "./lldb/scripts/macos-setup-codesign.sh"
67+
68+ log_and_exec_cmd "cd .."
69+ log_and_exec_cmd "mkdir $(Build.StagingDirectory)/buildspace/llvm-inst"
70+ log_and_exec_cmd "mkdir $(Build.StagingDirectory)/buildspace/llvm-build"
71+ log_and_exec_cmd "cd $(Build.StagingDirectory)/buildspace/llvm-build"
72+
73+ log_and_exec_cmd "cmake -DLLVM_ENABLE_PROJECTS=clang;lldb -DCMAKE_BUILD_TYPE=${{ parameters.llvm_build_type }} -DCMAKE_INSTALL_PREFIX=$(Build.StagingDirectory)/buildspace/llvm-inst/ -DCMAKE_OSX_ARCHITECTURES=${{ parameters.llvm_arch }} ${{ parameters.llvm_additional_parameters }} -GNinja $(Build.StagingDirectory)/llvm-project/llvm"
74+ if [[ $? -ne 0 ]]
75+ then
76+ echo "##[error] cmake llvm failed"
77+ cat $(Build.SourcesDirectory)/buildspace/llvm-build/CMakeFiles/CMakeError.log
78+ exit 1
79+ fi
80+
81+ log_and_exec_cmd ninja
82+ if [[ $? -ne 0 ]]
83+ then
84+ echo "##[error] ninja failed"
85+ exit 1
86+ fi
87+
88+ ### Workaround for https://github.com/llvm/llvm-project/issues/108
89+ log_and_exec_cmd "ninja install"
90+
91+ # Remove conflicting LLDB.framework file.
92+ log_and_exec_cmd "rm -rf $(Build.StagingDirectory)/buildspace/llvm-inst/Library/Frameworks/LLDB.framework"
93+
94+ # Build lldb/sources/API first
95+ log_and_exec_cmd "cmake -P $(Build.StagingDirectory)/buildspace/llvm-build/tools/lldb/source/API/cmake_install.cmake"
96+ ### End of Workaround
97+
98+ log_and_exec_cmd "ninja install"
99+ if [[ $? -ne 0 ]]
100+ then
101+ echo "##[error] ninja install failed"
102+ exit 1
103+ fi
104+
105+ echo "##[section] Build LLDB-MI"
106+ # Download lldb-mi and build it against our custom installation.
107+ log_and_exec_cmd "cd $(Build.StagingDirectory)/buildspace"
108+ log_and_exec_cmd "git clone ${{ parameters.lldb_mi_repo }} lldb-mi"
109+ log_and_exec_cmd "cd lldb-mi"
110+ log_and_exec_cmd "git checkout ${{ parameters.lldb_mi_commit }}"
111+
112+ # Create a separate build directory for building lldb-mi.
113+ log_and_exec_cmd "mkdir build"
114+ log_and_exec_cmd "cd build"
115+ log_and_exec_cmd "cmake -DCMAKE_PREFIX_PATH=$(Build.StagingDirectory)/buildspace/llvm-inst/ -DCMAKE_OSX_ARCHITECTURES=${{ parameters.llvm_arch }} ${{ parameters.lldb_mi_additional_parameters }} -GNinja .."
116+ log_and_exec_cmd "ninja"
117+ if [[ $? -ne 0 ]]
118+ then
119+ echo "##[error] ninja failed"
120+ exit 1
121+ fi
122+
123+ log_and_exec_cmd "mkdir $(Build.StagingDirectory)/publish"
124+ log_and_exec_cmd "cd $(Build.StagingDirectory)/publish"
125+
126+ log_and_exec_cmd "mkdir -p ./debugAdapters/lldb-mi_${{ parameters.llvm_arch }}/bin"
127+
128+ log_and_exec_cmd "cp $(Build.StagingDirectory)/buildspace/lldb-mi/build/src/lldb-mi ./debugAdapters/lldb-mi_${{ parameters.llvm_arch }}/bin/."
129+
130+ # Set rpath for finding LLDB.Framework
131+ log_and_exec_cmd "install_name_tool -add_rpath @rpath/LLDB.framework/Versions/A/LLDB ./debugAdapters/lldb-mi_${{ parameters.llvm_arch }}/bin/lldb-mi"
132+
133+ # Set rpath for App Store XCode LLDB.Framework
134+ log_and_exec_cmd "install_name_tool -add_rpath /Applications/Xcode.app/Contents/SharedFrameworks/ ./debugAdapters/lldb-mi_${{ parameters.llvm_arch }}/bin/lldb-mi"
135+
136+ # Set rpath for XCode CLI LLDB.Framework
137+ log_and_exec_cmd "install_name_tool -add_rpath /Library/Developer/CommandLineTools/Library/PrivateFrameworks/ ./debugAdapters/lldb-mi_${{ parameters.llvm_arch }}/bin/lldb-mi"
138+
139+ # Set rpath next to the lldb-mi executable LLDB.Framework
140+ log_and_exec_cmd "install_name_tool -add_rpath @executable_path/. ./debugAdapters/lldb-mi_${{ parameters.llvm_arch }}/bin/lldb-mi"
141+
142+ # Add entitlements
143+ log_and_exec_cmd "codesign -s - -f --entitlements $(Build.SourcesDirectory)/Build/lldb-mi/debugger-entitlements.plist ./debugAdapters/lldb-mi_${{ parameters.llvm_arch }}/bin/lldb-mi"
144+
145+ # Grab NOTICE.TXT
146+ cp $(Build.SourcesDirectory)/Build/lldb-mi/NOTICE.TXT ./debugAdapters/lldb-mi_${{ parameters.llvm_arch }}/.
147+
148+ zip -r $(Build.StagingDirectory)/lldb-mi_${{ parameters.llvm_arch }}.zip ./debugAdapters
149+
150+ - task : PublishPipelineArtifact@1
151+ displayName : ' Publish LLDB-MI'
152+ inputs :
153+ targetPath : ' $(Build.StagingDirectory)/lldb-mi_${{ parameters.llvm_arch }}.zip'
154+ artifactName : ' unsigned_lldb-mi_${{ parameters.llvm_arch }}'
155+
156+ - task : CmdLine@2
157+ displayName : ' Clean up'
158+ inputs :
159+ script : rm -rf $(Build.StagingDirectory)/buildspace
160+ condition : always()
0 commit comments