Skip to content

Commit

Permalink
ADDED: Add support for Swift Package Maker; CHANGED: Restructure sour…
Browse files Browse the repository at this point in the history
…ce directory
  • Loading branch information
fletcher committed Feb 25, 2017
1 parent 1671b38 commit 3d7935f
Show file tree
Hide file tree
Showing 49 changed files with 91 additions and 42 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ test/parser_test.c
test/parser_test.h
test/parser_test.out
test/a.out

/.build
/Packages
/mmd-swift.xcodeproj
85 changes: 43 additions & 42 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ project (${My_Project_Title})
# =================

# Search for included files here
include_directories( ${PROJECT_SOURCE_DIR}/src )
include_directories( ${PROJECT_SOURCE_DIR}/Sources/libMultiMarkdown)
include_directories( ${PROJECT_SOURCE_DIR}/Sources/libMultiMarkdown/include)
include_directories( ${PROJECT_SOURCE_DIR}/Sources/multimarkdown)
include_directories( ${PROJECT_SOURCE_DIR}/test )
include_directories(${PROJECT_BINARY_DIR})

Expand Down Expand Up @@ -170,46 +172,44 @@ configure_file (

# src_files are the primary files, and will be included in doxygen documentation
set(src_files
src/argtable3.c
src/beamer.c
src/char.c
src/d_string.c
src/html.c
src/latex.c
src/lexer.c
src/memoir.c
src/mmd.c
src/object_pool.c
src/parser.c
src/rng.c
src/scanners.c
src/stack.c
src/token.c
src/token_pairs.c
src/transclude.c
src/writer.c
Sources/libMultiMarkdown/beamer.c
Sources/libMultiMarkdown/char.c
Sources/libMultiMarkdown/d_string.c
Sources/libMultiMarkdown/html.c
Sources/libMultiMarkdown/latex.c
Sources/libMultiMarkdown/lexer.c
Sources/libMultiMarkdown/memoir.c
Sources/libMultiMarkdown/mmd.c
Sources/libMultiMarkdown/object_pool.c
Sources/libMultiMarkdown/parser.c
Sources/libMultiMarkdown/rng.c
Sources/libMultiMarkdown/scanners.c
Sources/libMultiMarkdown/stack.c
Sources/libMultiMarkdown/token.c
Sources/libMultiMarkdown/token_pairs.c
Sources/libMultiMarkdown/transclude.c
Sources/libMultiMarkdown/writer.c
)

# Primary header files, also for doxygen documentation
set(header_files
src/argtable3.h
src/beamer.h
src/char.h
src/d_string.h
src/html.h
src/latex.h
src/lexer.h
src/libMultiMarkdown.h
src/memoir.h
src/mmd.h
src/object_pool.h
src/scanners.h
src/stack.h
src/token.h
src/token_pairs.h
src/transclude.h
src/uthash.h
src/writer.h
Sources/libMultiMarkdown/beamer.h
Sources/libMultiMarkdown/char.h
Sources/libMultiMarkdown/include/d_string.h
Sources/libMultiMarkdown/html.h
Sources/libMultiMarkdown/latex.h
Sources/libMultiMarkdown/lexer.h
Sources/libMultiMarkdown/include/libMultiMarkdown.h
Sources/libMultiMarkdown/memoir.h
Sources/libMultiMarkdown/mmd.h
Sources/libMultiMarkdown/object_pool.h
Sources/libMultiMarkdown/scanners.h
Sources/libMultiMarkdown/stack.h
Sources/libMultiMarkdown/include/token.h
Sources/libMultiMarkdown/token_pairs.h
Sources/libMultiMarkdown/transclude.h
Sources/libMultiMarkdown/uthash.h
Sources/libMultiMarkdown/writer.h
)

set (scripts
Expand Down Expand Up @@ -294,7 +294,7 @@ else()
# Process source files to look for tests to run
add_custom_command (
OUTPUT ${PROJECT_BINARY_DIR}/AllTests.c
COMMAND sh ${PROJECT_SOURCE_DIR}/test/make-tests.sh ${PROJECT_SOURCE_DIR}/src/*.c > ${PROJECT_BINARY_DIR}/AllTests.c
COMMAND sh ${PROJECT_SOURCE_DIR}/test/make-tests.sh ${PROJECT_SOURCE_DIR}/Sources/libMultiMarkdown/*.c > ${PROJECT_BINARY_DIR}/AllTests.c
)

enable_testing()
Expand Down Expand Up @@ -392,17 +392,18 @@ else ()
endif ()


ADD_PUBLIC_HEADER(libMultiMarkdown src/libMultiMarkdown.h)
ADD_PUBLIC_HEADER(libMultiMarkdown src/d_string.h)
ADD_PUBLIC_HEADER(libMultiMarkdown Sources/libMultiMarkdown/include/libMultiMarkdown.h)
ADD_PUBLIC_HEADER(libMultiMarkdown Sources/libMultiMarkdown/include/d_string.h)

# remove the extra "lib" from "liblibFOO"
SET_TARGET_PROPERTIES(libMultiMarkdown PROPERTIES PREFIX "")

# Create a command-line app?
# if (NOT DEFINED TEST)
add_executable(multimarkdown
src/d_string.c
src/main.c
Sources/libMultiMarkdown/d_string.c
Sources/multimarkdown/main.c
Sources/multimarkdown/argtable3.c
)
#
# Link the library to the app?
Expand Down
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ xcode-debug: $(XCODE_DEBUG_BUILD_DIR)
cd $(XCODE_DEBUG_BUILD_DIR); \
cmake -G Xcode -DTEST=1 ..

# Build Swift debug variant
.PHONY : swift
swift: $(BUILD_DIR)
swift build -c debug --build-path ${BUILD_DIR} -Xcc -fbracket-depth=264

# Build Swift release variant
.PHONY : swift-release
swift-release: $(BUILD_DIR)
swift build -c release --build-path ${BUILD_DIR} -Xcc -fbracket-depth=264 -Xcc -DNDEBUG=1

# Cross-compile for Windows using MinGW on *nix
.PHONY : windows
windows: $(BUILD_DIR)
Expand Down
9 changes: 9 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import PackageDescription

let package = Package(
name: "mmd-swift",
targets: [
Target(name: "mmd-swift", dependencies: ["libMultiMarkdown"])
],
exclude: ["tests", "Tests", "Sources/multimarkdown"]
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions Sources/mmd-swift/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/// Trivial example of using libMultiMarkdown within a Swift
/// project. Needs a lot of work to be functional.

import libMultiMarkdown


token_pool_init()


let text = "This is a *test* string"
let output = d_string_new("")
let format = Int16(FORMAT_HTML.rawValue)

let e = mmd_engine_create_with_string(text, 0)


mmd_engine_parse_string(e)
mmd_export_token_tree(output, e, format)
token_pool_drain()


let str = String(cString: output!.pointee.str!)
print(str)

token_pool_free()
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 3d7935f

Please sign in to comment.