Skip to content

Commit 074ed6d

Browse files
committed
ldc-build-runtime: Add --installWithLibSuffix option
To simplify copying the libraries to an existing LDC installation.
1 parent c138058 commit 074ed6d

File tree

7 files changed

+43
-37
lines changed

7 files changed

+43
-37
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ runs:
8080
cd ..
8181
arch='${{ inputs.arch }}'
8282
triple="$arch-apple-macos$MACOSX_DEPLOYMENT_TARGET"
83-
echo "DFLAGS=-mtriple=$triple -L-L$PWD/build-cross-libs/lib -Xcc=-target -Xcc=$triple -Xcc=-isysroot -Xcc=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" >> $GITHUB_ENV
83+
echo "DFLAGS=-mtriple=$triple -L-L$PWD/bootstrap-ldc/lib-cross -Xcc=-target -Xcc=$triple -Xcc=-isysroot -Xcc=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" >> $GITHUB_ENV
8484
echo "CROSS_TRIPLE=$triple" >> $GITHUB_ENV
8585
echo "CROSS_CMAKE_FLAGS=-DCMAKE_OSX_ARCHITECTURES=$arch" >> $GITHUB_ENV
8686
@@ -113,9 +113,9 @@ runs:
113113
cmakeFlags+=" -DANDROID_STL=c++_static"
114114
cmakeFlags+=" -DCMAKE_TOOLCHAIN_FILE=$PWD/android-ndk/build/cmake/android.toolchain.cmake"
115115
cmakeFlags+=" -DANDROID_USE_LEGACY_TOOLCHAIN_FILE=OFF"
116-
cmakeFlags+=" -DLDC_LINK_MANUALLY=ON -DD_LINKER_ARGS='-L$PWD/build-cross-libs/lib;-lphobos2-ldc;-ldruntime-ldc'"
116+
cmakeFlags+=" -DLDC_LINK_MANUALLY=ON -DD_LINKER_ARGS='-L$PWD/bootstrap-ldc/lib-cross;-lphobos2-ldc;-ldruntime-ldc'"
117117
118-
echo "DFLAGS=-mtriple=$triple -L-L$PWD/build-cross-libs/lib -gcc=$PWD/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/$triple-clang" >> $GITHUB_ENV
118+
echo "DFLAGS=-mtriple=$triple -L-L$PWD/bootstrap-ldc/lib-cross -gcc=$PWD/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/$triple-clang" >> $GITHUB_ENV
119119
echo "CROSS_TRIPLE=$triple" >> $GITHUB_ENV
120120
echo "CROSS_CMAKE_FLAGS=$cmakeFlags" >> $GITHUB_ENV
121121
@@ -137,9 +137,10 @@ runs:
137137
IFS=$'\n' flags=( $(xargs -n1 <<<"$flags" | cut -b3-) )
138138
139139
bootstrap-ldc/bin/ldc-build-runtime --ninja \
140-
--buildDir="build-cross-libs" \
140+
--buildDir="build-cross-runtime" \
141141
--dFlags="${DFLAGS// /;}" \
142142
--ldcSrcDir="$PWD/ldc" \
143+
--installWithLibSuffix="-cross" \
143144
"${flags[@]}"
144145
145146
- name: Cross-compile LDC executables

.github/actions/5-install/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ runs:
2323
mkdir -p install/bin
2424
cp build-cross/bin/{ldc2,ldmd2,ldc-build-runtime,ldc-profdata,ldc-profgen,ldc-prune-cache,timetrace2txt} install/bin/
2525
cp build-cross/bin/ldc-build-plugin install/bin/ || true
26-
cp -R build-cross-libs/lib install/
26+
cp -R bootstrap-ldc/lib-cross install/lib
2727
cp build-cross/lib/{libldc_rt.*,libLTO.dylib,LLVMgold-ldc.so} install/lib/ || true
2828
mkdir install/etc
2929
cp build-cross/bin/ldc2_install.conf install/etc/ldc2.conf

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@ runs:
2222
2323
# use bootstrap-ldc, which is guaranteed to be native
2424
bootstrap-ldc/bin/ldc-build-runtime --ninja \
25-
--buildDir="build-libs-$arch" \
2625
--dFlags="-mtriple=$triple" \
2726
--ldcSrcDir="$PWD/ldc" \
27+
--installWithLibSuffix="-$arch" CMAKE_INSTALL_PREFIX="$PWD/installed" \
2828
"${flags[@]}" \
2929
ANDROID_ABI="$abi" # override the one in CROSS_CMAKE_FLAGS
30-
31-
mkdir "installed/lib-$arch"
32-
cp "build-libs-$arch"/lib/* "installed/lib-$arch/"

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,15 @@ runs:
2323
fi
2424
2525
installed/bin/ldc-build-runtime --ninja \
26-
--buildDir=build-libs-ios \
2726
--dFlags="-mtriple=$triple" \
2827
--ldcSrcDir="$PWD/ldc" \
28+
--installWithLibSuffix="-ios-$arch" \
2929
CMAKE_SYSTEM_NAME=iOS \
3030
CMAKE_OSX_SYSROOT="$sysroot" \
3131
CMAKE_OSX_ARCHITECTURES="$arch" \
3232
CMAKE_OSX_DEPLOYMENT_TARGET="$deployment_target" \
3333
BUILD_LTO_LIBS=ON
3434
35-
mkdir "installed/lib-ios-$arch"
36-
cp -a build-libs-ios/lib/*.{a,dylib,o} "installed/lib-ios-$arch/"
37-
3835
section="
3936
\"$arch-apple-ios\":
4037
{

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,10 @@ runs:
7676
call "%VSDIR%\Common7\Tools\VsDevCmd.bat" -arch=arm64 -host_arch=x64 || exit /b
7777
echo on
7878
ldc2-multilib\bin\ldc-build-runtime --ninja ^
79-
--buildDir=build-libs-arm64 ^
8079
--dFlags=-mtriple=aarch64-windows-msvc ^
8180
"--ldcSrcDir=%CD%" ^
81+
--installWithLibSuffix=arm64 ^
8282
BUILD_LTO_LIBS=ON
83-
- name: Copy arm64 libraries
84-
shell: bash
85-
run: |
86-
set -eux
87-
cp -R build-libs-arm64/lib ldc2-multilib/libarm64
88-
rm ldc2-multilib/libarm64/*.{exp,ilk}
89-
rm ldc2-multilib/libarm64/{druntime,phobos2}-ldc-shared.pdb
9083
- name: Add arm64 section to ldc2.conf
9184
shell: pwsh
9285
run: |

runtime/CMakeLists.txt

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -876,33 +876,39 @@ foreach(libname ${libs_to_install})
876876
# import .lib in regular lib dir
877877
install(FILES $<TARGET_LINKER_FILE:${libname}>
878878
DESTINATION ${destination_dir})
879-
# .dll in bin dir
879+
# when included from the LDC parent build, install .dll and .pdb into bin/
880+
if(LDC_EXE)
881+
set(destination_dir ${CMAKE_INSTALL_PREFIX}/bin)
882+
endif()
883+
# .dll in bin or lib dir
880884
install(FILES $<TARGET_FILE:${libname}>
881-
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
882-
# .pdb of debug DLLs in bin dir
885+
DESTINATION ${destination_dir})
886+
# .pdb of debug DLLs in bin or lib dir
883887
if(${libname} MATCHES "-debug")
884888
install(FILES $<TARGET_PDB_FILE:${libname}>
885-
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
889+
DESTINATION ${destination_dir})
886890
endif()
887891
else()
888892
install(TARGETS ${libname}
889893
DESTINATION ${destination_dir})
890894
endif()
891895
endforeach()
892896

893-
set(DRUNTIME_PACKAGES core etc ldc)
897+
# only install the imports when included from the LDC parent build
898+
if(LDC_EXE)
899+
set(DRUNTIME_PACKAGES core etc ldc)
894900

895-
install(FILES ${RUNTIME_DIR}/src/object.d ${RUNTIME_DIR}/src/__importc_builtins.di ${RUNTIME_DIR}/src/importc.h DESTINATION ${INCLUDE_INSTALL_DIR})
896-
foreach(p ${DRUNTIME_PACKAGES})
897-
install(DIRECTORY ${RUNTIME_DIR}/src/${p} DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.d")
898-
install(DIRECTORY ${RUNTIME_DIR}/src/${p} DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.di")
899-
endforeach()
900-
if(PHOBOS2_DIR)
901-
install(DIRECTORY ${PHOBOS2_DIR}/std DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.d")
902-
install(DIRECTORY ${PHOBOS2_DIR}/etc DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.d")
901+
install(FILES ${RUNTIME_DIR}/src/object.d ${RUNTIME_DIR}/src/__importc_builtins.di ${RUNTIME_DIR}/src/importc.h DESTINATION ${INCLUDE_INSTALL_DIR})
902+
foreach(p ${DRUNTIME_PACKAGES})
903+
install(DIRECTORY ${RUNTIME_DIR}/src/${p} DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.d")
904+
install(DIRECTORY ${RUNTIME_DIR}/src/${p} DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.di")
905+
endforeach()
906+
if(PHOBOS2_DIR)
907+
install(DIRECTORY ${PHOBOS2_DIR}/std DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.d")
908+
install(DIRECTORY ${PHOBOS2_DIR}/etc DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.d")
909+
endif()
910+
install(FILES ${GCCBUILTINS} DESTINATION ${INCLUDE_INSTALL_DIR}/ldc)
903911
endif()
904-
install(FILES ${GCCBUILTINS} DESTINATION ${INCLUDE_INSTALL_DIR}/ldc)
905-
906912

907913
#
908914
# Test targets.

runtime/ldc-build-runtime.d.in

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct Config {
2222
uint numBuildJobs;
2323
bool systemZlib;
2424
string[string] cmakeVars;
25+
string installWithLibSuffix;
2526
}
2627

2728
version (Windows) enum exeSuffix = ".exe";
@@ -165,6 +166,12 @@ void runCMake() {
165166
if (config.cFlags.length) args ~= "-DRT_CFLAGS=" ~ config.cFlags.join(" ");
166167
if (config.linkerFlags.length) args ~= "-DLD_FLAGS=" ~ config.linkerFlags.join(" ");
167168
if (config.systemZlib) args ~= "-DPHOBOS_SYSTEM_ZLIB=ON";
169+
if (config.installWithLibSuffix.length) {
170+
args ~= [
171+
"-DCMAKE_INSTALL_PREFIX=" ~ config.ldcExecutable.dirName.dirName,
172+
"-DLIB_SUFFIX=" ~ config.installWithLibSuffix,
173+
];
174+
}
168175

169176
foreach (pair; config.cmakeVars.byPair)
170177
args ~= "-D" ~ pair[0] ~ '=' ~ pair[1];
@@ -180,7 +187,8 @@ void runCMake() {
180187
void build() {
181188
const wd = WorkingDirScope(config.buildDir);
182189

183-
string[] args = [ config.ninja ? "ninja" : "make" ];
190+
const buildTool = config.ninja ? "ninja" : "make";
191+
string[] args = [ buildTool ];
184192
if (config.numBuildJobs != 0) {
185193
import std.conv : to;
186194
args ~= "-j" ~ config.numBuildJobs.to!string;
@@ -190,6 +198,9 @@ void build() {
190198
args ~= "all-test-runners";
191199

192200
exec(args);
201+
202+
if (config.installWithLibSuffix.length)
203+
exec([buildTool, "install"]);
193204
}
194205

195206
/**
@@ -331,6 +342,7 @@ void parseCommandLine(string[] args) {
331342
"linkerFlags", "Extra C linker flags for shared libraries and testrunner executables (separated by ';')", &config.linkerFlags,
332343
"j", "Number of parallel build jobs", &config.numBuildJobs,
333344
"systemZlib", "Use system zlib instead of Phobos' vendored version", &config.systemZlib,
345+
"installWithLibSuffix", "Install the built libraries to '<directory containing LDC executable>/../lib<installWithLibSuffix>'", &config.installWithLibSuffix,
334346
);
335347

336348
// getopt() has removed all consumed args from `args`

0 commit comments

Comments
 (0)