Skip to content

Commit

Permalink
fix(bindings/swift): reorg the package to correct its name (#2479)
Browse files Browse the repository at this point in the history
  • Loading branch information
unixzii authored Jun 18, 2023
1 parent 268b94a commit 95e7a19
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 13 deletions.
9 changes: 5 additions & 4 deletions bindings/swift/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc

/include
/lib
/OpenDAL/.build
/OpenDAL/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
/OpenDAL/.swiftpm/config/registries.json
/OpenDAL/Sources/COpenDAL/include
/OpenDAL/Sources/COpenDAL/lib
12 changes: 6 additions & 6 deletions bindings/swift/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@
# under the License.

C_BINDING_SRC_DIR=../c
SWIFT_PKG_DIR=./OpenDAL
ROOT_DIR=../..

INCLUDE_DIR=./include
LIB_DIR=./lib
INCLUDE_DIR=$(SWIFT_PKG_DIR)/Sources/COpenDAL/include
LIB_DIR=$(SWIFT_PKG_DIR)/Sources/COpenDAL/lib
DIRS=$(INCLUDE_DIR) $(LIB_DIR)

.PHONY: all
all: build-swift

.PHONY: build-c
build-c: $(DIRS)
cd $(C_BINDING_SRC_DIR)
cargo build --release --manifest-path $(C_BINDING_SRC_DIR)/Cargo.toml
cp $(C_BINDING_SRC_DIR)/include/* $(INCLUDE_DIR)
cp $(ROOT_DIR)/target/release/libopendal_c.a $(LIB_DIR)

.PHONY: build-swift
build-swift: build-c
swift build
cd $(SWIFT_PKG_DIR) && swift build

.PHONY: test
test: build-c
swift test
cd $(SWIFT_PKG_DIR) && swift test

$(DIRS):
mkdir $@
mkdir -p $@

.PHONY: clean
clean:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
// specific language governing permissions and limitations
// under the License.

import Foundation
import PackageDescription

let packageRoot = (#file as NSString).deletingLastPathComponent

let package = Package(
name: "OpenDAL",
products: [
Expand All @@ -32,8 +35,7 @@ let package = Package(
name: "OpenDAL",
dependencies: ["COpenDAL"],
linkerSettings: [
.unsafeFlags(["-L./lib"]),
.linkedLibrary("opendal_c"),
.unsafeFlags(["-L\(packageRoot)/Sources/COpenDAL/lib"]),
]),
.testTarget(
name: "OpenDALTests",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// under the License.

module COpenDAL [system] {
header "../../include/opendal.h"
header "include/opendal.h"
link "opendal_c"

export *
Expand Down

0 comments on commit 95e7a19

Please sign in to comment.