Skip to content

Commit

Permalink
Start using a local package for SPM dependecies, add clojure support #20
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Jul 10, 2024
1 parent 7556492 commit c4dd226
Show file tree
Hide file tree
Showing 13 changed files with 135 additions and 193 deletions.
2 changes: 0 additions & 2 deletions Configurations/Edit-Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
#include "Configurations/Edit.xcconfig"

OTHER_LDFLAGS[config=Debug] = -ObjC -fprofile-instr-generate
2 changes: 0 additions & 2 deletions Configurations/Edit.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ INFOPLIST_KEY_NSMainNibFile = MainMenu
INFOPLIST_KEY_NSPrincipalClass = NSApplication
LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/Frameworks
LD_RUNPATH_SEARCH_PATHS[sdk=macosx*] = $(inherited) @executable_path/../Frameworks
OTHER_LDFLAGS[config=Debug] = -ObjC -fprofile-instr-generate
OTHER_LDFLAGS[config=Release] = -ObjC
PRODUCT_MODULE_NAME = Chime
PRODUCT_NAME = Chime
SKIP_INSTALL = NO
Expand Down
17 changes: 13 additions & 4 deletions Configurations/NonSwiftWorkaround.xcconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
// This is a workaround for a ridiculous problem related to non-Swift SPM dependencies. However, the linker will be unhappy if these modulemap files don't exist. So dependency management can get a little tricky.
// - "Internal" is for TextStory
// - "tree-sitter" is for SwiftTreeSitter
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/Internal.modulemap -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/tree-sitter.modulemap -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterGo.modulemap -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterMarkdown.modulemap -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterMarkdownInline.modulemap -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterOCaml.modulemap -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterSwift.modulemap
// This is necessary because the static libraries that depend on these modules do not link to them. If they did, they would all build, but EditKit would fail because it needs to use -all_load, and Xcode incorrectly links SPM packages twice. FB14262567

// TextStory
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/Internal.modulemap

// SwiftTreeSitter
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/tree-sitter.modulemap

// All the tree-sitter parsers
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterClojure.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterGo.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterMarkdown.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterMarkdownInline.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterOCaml.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterSwift.modulemap
3 changes: 0 additions & 3 deletions Configurations/TreeSitterParsers.xcconfig

This file was deleted.

8 changes: 8 additions & 0 deletions Dependencies/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
/.build
/Packages
xcuserdata/
DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
33 changes: 33 additions & 0 deletions Dependencies/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// swift-tools-version: 5.10

import PackageDescription

// This package defines all of the SPM dependencies for the project. It is used as an alternative to the Xcode SPM dependency editor.
// I have not yet migrated everything in here.

let package = Package(
name: "Dependencies",
products: [
// I don't think many dependencies will need to use this same approach.
.library(name: "TreeSitterParsers", targets: ["TreeSitterParsers"]),
],
dependencies: [
.package(url: "https://github.com/mattmassicotte/tree-sitter-clojure", branch: "feature/spm"),
.package(url: "https://github.com/tree-sitter/tree-sitter-go", branch: "master"),
.package(url: "https://github.com/tree-sitter-grammars/tree-sitter-markdown", branch: "split_parser"),
.package(url: "https://github.com/tree-sitter/tree-sitter-ocaml", branch: "master"),
.package(url: "https://github.com/alex-pinkus/tree-sitter-swift", branch: "with-generated-files"),
],
targets: [
.target(
name: "TreeSitterParsers",
dependencies: [
.product(name: "TreeSitterClojure", package: "tree-sitter-clojure"),
.product(name: "TreeSitterGo", package: "tree-sitter-go"),
.product(name: "TreeSitterMarkdown", package: "tree-sitter-markdown"),
.product(name: "TreeSitterOCaml", package: "tree-sitter-ocaml"),
.product(name: "TreeSitterSwift", package: "tree-sitter-swift"),
]
),
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@_exported import TreeSitterClojure
@_exported import TreeSitterGo
@_exported import TreeSitterMarkdown
@_exported import TreeSitterMarkdownInline
@_exported import TreeSitterOCaml
@_exported import TreeSitterSwift
Loading

0 comments on commit c4dd226

Please sign in to comment.