Skip to content

Commit 483581d

Browse files
committed
Make ldc-build-runtime --installWithSuffix install a .conf file
Either the default `50-target-default.conf` (overwriting the existing one) if the suffix is empty, or a `55-target<suffix>.conf` one, which still needs the triple regex patched and potentially some extra switches for cross-compilation/linking.
1 parent 144e6b7 commit 483581d

File tree

6 files changed

+21
-14
lines changed

6 files changed

+21
-14
lines changed

.github/actions/3-build-cross/action.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ runs:
144144
--installWithSuffix "" \
145145
CMAKE_INSTALL_PREFIX="$PWD/install" \
146146
INCLUDE_INSTALL_DIR="$PWD/install/import" \
147-
CONF_INST_DIR="$PWD/install/etc" \
148147
"${flags[@]}"
149148
150149
- name: Cross-compile LDC executables

.github/actions/5a-android-x86/action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ runs:
2424
bootstrap-ldc/bin/ldc-build-runtime --ninja \
2525
--dFlags="-mtriple=$triple" \
2626
--ldcSrcDir="$PWD/ldc" \
27-
--installWithSuffix="-$arch" \
27+
--installWithSuffix="-android-$arch" \
2828
CMAKE_INSTALL_PREFIX="$PWD/installed" \
2929
"${flags[@]}" \
3030
ANDROID_ABI="$abi" # override the one in CROSS_CMAKE_FLAGS
31+
32+
# patch triple regex in .conf file
33+
sed -i "s|default:|\"$arch-.*-linux-android\":|" installed/etc/ldc2.conf/55-target-android-$arch.conf
34+
cat installed/etc/ldc2.conf/55-target-android-$arch.conf

.github/actions/5a-ios/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ runs:
3232
CMAKE_OSX_DEPLOYMENT_TARGET="$deployment_target" \
3333
BUILD_LTO_LIBS=ON
3434
35+
# overwrite the generated .conf file (need to patch triple regex and append cross-compile flags)
3536
cat > installed/etc/ldc2.conf/55-target-ios-$arch.conf <<EOF
3637
"${arch}-apple-ios":
3738
{

.github/actions/merge-windows/action.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,13 @@ runs:
7979
ldc2-multilib\bin\ldc-build-runtime --ninja ^
8080
--dFlags=-mtriple=aarch64-windows-msvc ^
8181
"--ldcSrcDir=%CD%" ^
82-
--installWithSuffix=arm64 ^
82+
--installWithSuffix=-windows-arm64 ^
8383
BUILD_LTO_LIBS=ON
84-
- name: Add arm64 section to ldc2.conf
84+
- name: Patch triple regex in arm64 .conf file
8585
shell: pwsh
8686
run: |
8787
cd ldc2-multilib
88-
$conf = '"(aarch|arm)64-.*-windows-msvc":
89-
{
90-
lib-dirs = [
91-
"%%ldcbinarypath%%/../libarm64",
92-
];
93-
};
94-
'
95-
Set-Content etc\ldc2.conf\55-target-windows-arm64.conf $conf
88+
(cat etc\ldc2.conf\55-target-windows-arm64.conf).replace('default:', '"(aarch|arm)64-.*-windows-msvc":') | Set-Content etc\ldc2.conf\55-target-windows-arm64.conf
9689
cat etc\ldc2.conf\*
9790
- name: Run arm64 hello-world cross-compilation smoke tests
9891
shell: cmd

runtime/CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,18 @@ if(SHARED_LIBS_SUPPORTED)
280280
set(install_rpath "${install_libdir}")
281281
endif()
282282

283-
makeConfSection(NAME "50-target-default"
283+
# LIB_SUFFIX is (ab)used by ldc-build-runtime and set to the optional `--installWithSuffix`.
284+
# If set and non-empty, change the name of the generated .conf file.
285+
set(conf_base_name "50-target-default")
286+
if(NOT "${LIB_SUFFIX}" STREQUAL "")
287+
if(LIB_SUFFIX MATCHES "^-")
288+
set(conf_base_name "55-target${LIB_SUFFIX}")
289+
else()
290+
set(conf_base_name "55-target-${LIB_SUFFIX}")
291+
endif()
292+
endif()
293+
294+
makeConfSection(NAME "${conf_base_name}.conf"
284295
SECTION "default"
285296

286297
BUILD

runtime/ldc-build-runtime.d.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ void runCMake() {
170170
args ~= [
171171
"-DCMAKE_INSTALL_PREFIX=" ~ config.ldcExecutable.dirName.dirName,
172172
"-DLIB_SUFFIX=" ~ config.installWithSuffix,
173-
"-DCONF_INST_DIR=", // don't install/overwrite existing etc/ldc2.conf!
174173
];
175174
}
176175

0 commit comments

Comments
 (0)