Skip to content

Commit 674f81a

Browse files
authored
Merge pull request #852 from compnerd/identity
libllbuild: make the library static and internalise it
2 parents 8e9a448 + a2bfbc1 commit 674f81a

File tree

8 files changed

+27
-11
lines changed

8 files changed

+27
-11
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ else()
5151
endif()
5252
endif()
5353

54-
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
54+
set(THREADS_PREFER_PTHREAD_FLAG FALSE)
5555
find_package(Threads REQUIRED)
5656

5757
find_package(SQLite3 REQUIRED)

cmake/modules/Utility.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ endfunction()
1010

1111
macro(add_llbuild_library name)
1212
cmake_parse_arguments(ARG
13-
"SHARED" "OUTPUT_NAME" ""
13+
"SHARED;STATIC" "OUTPUT_NAME" ""
1414
${ARGN})
1515
set(ALL_FILES ${ARG_UNPARSED_ARGUMENTS})
1616

@@ -42,8 +42,10 @@ macro(add_llbuild_library name)
4242
endif()
4343
endif(MSVC_IDE OR XCODE)
4444

45-
if (ARG_SHARED)
45+
if(ARG_SHARED)
4646
add_library(${name} SHARED ${ALL_FILES})
47+
elseif(ARG_STATIC)
48+
add_library(${name} STATIC ${ALL_FILES})
4749
else()
4850
add_library(${name} ${ALL_FILES})
4951
endif()

examples/c-api/buildsystem/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ static void usage() {
3232
exit(0);
3333
}
3434

35+
#if !defined(__linux__)
3536
static const char* basename(const char* path) {
3637
const char* result = strrchr(path, '/');
3738
return result ? result : path;
3839
}
40+
#endif
3941

4042
#if defined(_WIN32)
4143
static wchar_t* convertToMultiByte(const char* s) {

products/libllbuild/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ set(SOURCES
99

1010
add_llbuild_library(libllbuild
1111
${SOURCES}
12-
SHARED
12+
STATIC
1313
OUTPUT_NAME llbuild)
14-
target_compile_definitions(libllbuild PRIVATE
15-
_WINDLL)
1614

1715
set_property(TARGET libllbuild PROPERTY MACOSX_RPATH ON)
1816

@@ -24,8 +22,6 @@ target_link_libraries(libllbuild PRIVATE
2422
llvmSupport
2523
SQLite::SQLite3)
2624

27-
set_property(GLOBAL APPEND PROPERTY LLBuild_EXPORTS libllbuild)
28-
2925
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
3026
set_target_properties(libllbuild PROPERTIES LINK_FLAGS "/INCREMENTAL:NO")
3127
endif()

products/llbuildSwift/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ else()
7070
endif()
7171
set_target_properties(llbuildSwift PROPERTIES
7272
Swift_MODULE_NAME llbuildSwift
73-
INTERFACE_LINK_LIBRARIES libllbuild
74-
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR})
73+
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR};${PROJECT_SOURCE_DIR}/products/libllbuild/include")
7574

7675
install(TARGETS llbuildSwift
7776
ARCHIVE DESTINATION lib/swift/pm/llbuild COMPONENT libllbuildSwift

tests/Examples/buildsystem-capi.llbuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Check that the BuildSystem C API example builds and runs correctly.
22
#
3-
# RUN: %clang -o %t.exe %{srcroot}/examples/c-api/buildsystem/main.c -I %{srcroot}/products/libllbuild/include -lllbuild -L %{llbuild-lib-dir} -Werror
3+
# RUN: %clangxx -o %t.exe -x c++ %{srcroot}/examples/c-api/buildsystem/main.c -I %{srcroot}/products/libllbuild/include -lllbuild -lllbuildBuildSystem -lllbuildCore -lllbuildBasic -lllvmSupport -lLLVMDemangle -L %{llbuild-lib-dir} -Werror -Xlinker %{sqlite} %{curses} %{threads} %{dl}
44
# RUN: env DYLD_LIBRARY_PATH=%{llbuild-lib-dir} LD_LIBRARY_PATH=%{llbuild-lib-dir} %t.exe %s > %t.out
55
# RUN: %{FileCheck} %s --input-file %t.out
66
#

tests/lit.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ config.substitutions.append( ('%{llbuild-lib-dir}', llbuild_lib_dir) )
128128
config.substitutions.append( ('%{llbuild-output-dir}', llbuild_output_dir) )
129129
config.substitutions.append( ('%{llbuild-tools-dir}', llbuild_tools_dir) )
130130
config.substitutions.append( ('%{srcroot}', llbuild_src_root) )
131+
config.substitutions.append( ('%{sqlite}', config.sqlite_library) )
132+
config.substitutions.append( ('%{curses}', config.curses_library) )
133+
config.substitutions.append( ('%{threads}', config.threads_library) )
134+
config.substitutions.append( ('%{dl}', config.dl_library) )
131135

132136
if config.osx_sysroot:
133137
config.substitutions.append( ('%{swiftc-platform-flags}', "-sdk " + config.osx_sysroot) )
@@ -138,6 +142,7 @@ config.substitutions.append( ('%{build-dir}', llbuild_obj_root) )
138142
config.substitutions.append( ('%{env}', lit.util.which('env')) )
139143
config.substitutions.append( ('%{sort}', lit.util.which('sort')) )
140144
config.substitutions.append( ('%{sh-invoke}', os.environ.get("PREFIX", "") + '/bin/sh') )
145+
config.substitutions.append( ('%clangxx', inferSwiftBinary('clang++')) )
141146
config.substitutions.append( ('%clang', inferSwiftBinary('clang')) )
142147

143148
###

tests/lit.site.cfg.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- Python -*-
22

33
import os
4+
import sys
45

56
## Autogenerated by llbuild configuration.
67
# Do not edit!
@@ -16,6 +17,17 @@ config.filecheck_path = "@FILECHECK_EXECUTABLE@"
1617
config.swiftc_path = "@CMAKE_Swift_COMPILER@"
1718
config.osx_sysroot = "@CMAKE_OSX_SYSROOT@"
1819

20+
config.sqlite_library = "@SQLite3_LIBRARY@"
21+
if sys.platform == 'Windows':
22+
config.curses_library = ''
23+
else:
24+
config.curses_library = '-lcurses'
25+
config.threads_library = "@CMAKE_THREAD_LIBS_INIT@"
26+
if "@CMAKE_DL_LIBS@":
27+
config.dl_library = "-l@CMAKE_DL_LIBS@"
28+
else:
29+
config.dl_library = ''
30+
1931
# Support substitution of the tools_dir with user parameters. This is
2032
# used when we can't determine the tool dir at configuration time.
2133
try:

0 commit comments

Comments
 (0)