]> granicus.if.org Git - multimarkdown/commitdiff
ADDED: Add support for Swift Package Maker; CHANGED: Restructure source directory
authorFletcher T. Penney <fletcher@fletcherpenney.net>
Sat, 25 Feb 2017 21:02:04 +0000 (16:02 -0500)
committerFletcher T. Penney <fletcher@fletcherpenney.net>
Sat, 25 Feb 2017 21:02:04 +0000 (16:02 -0500)
49 files changed:
.gitignore
CMakeLists.txt
Makefile
Package.swift [new file with mode: 0644]
Sources/libMultiMarkdown/beamer.c [moved from src/beamer.c with 100% similarity]
Sources/libMultiMarkdown/beamer.h [moved from src/beamer.h with 100% similarity]
Sources/libMultiMarkdown/char.c [moved from src/char.c with 100% similarity]
Sources/libMultiMarkdown/char.h [moved from src/char.h with 100% similarity]
Sources/libMultiMarkdown/char_lookup.c [moved from src/char_lookup.c with 100% similarity]
Sources/libMultiMarkdown/d_string.c [moved from src/d_string.c with 100% similarity]
Sources/libMultiMarkdown/html.c [moved from src/html.c with 100% similarity]
Sources/libMultiMarkdown/html.h [moved from src/html.h with 100% similarity]
Sources/libMultiMarkdown/i18n.h [moved from src/i18n.h with 100% similarity]
Sources/libMultiMarkdown/include/d_string.h [moved from src/d_string.h with 100% similarity]
Sources/libMultiMarkdown/include/libMultiMarkdown.h [moved from src/libMultiMarkdown.h with 100% similarity]
Sources/libMultiMarkdown/include/token.h [moved from src/token.h with 100% similarity]
Sources/libMultiMarkdown/latex.c [moved from src/latex.c with 100% similarity]
Sources/libMultiMarkdown/latex.h [moved from src/latex.h with 100% similarity]
Sources/libMultiMarkdown/lexer.c [moved from src/lexer.c with 100% similarity]
Sources/libMultiMarkdown/lexer.h [moved from src/lexer.h with 100% similarity]
Sources/libMultiMarkdown/lexer.re [moved from src/lexer.re with 100% similarity]
Sources/libMultiMarkdown/memoir.c [moved from src/memoir.c with 100% similarity]
Sources/libMultiMarkdown/memoir.h [moved from src/memoir.h with 100% similarity]
Sources/libMultiMarkdown/mmd.c [moved from src/mmd.c with 100% similarity]
Sources/libMultiMarkdown/mmd.h [moved from src/mmd.h with 100% similarity]
Sources/libMultiMarkdown/object_pool.c [moved from src/object_pool.c with 100% similarity]
Sources/libMultiMarkdown/object_pool.h [moved from src/object_pool.h with 100% similarity]
Sources/libMultiMarkdown/parser.c [moved from src/parser.c with 100% similarity]
Sources/libMultiMarkdown/parser.h [moved from src/parser.h with 100% similarity]
Sources/libMultiMarkdown/parser.out [moved from src/parser.out with 100% similarity]
Sources/libMultiMarkdown/parser.y [moved from src/parser.y with 100% similarity]
Sources/libMultiMarkdown/rng.c [moved from src/rng.c with 100% similarity]
Sources/libMultiMarkdown/scanners.c [moved from src/scanners.c with 100% similarity]
Sources/libMultiMarkdown/scanners.h [moved from src/scanners.h with 100% similarity]
Sources/libMultiMarkdown/scanners.re [moved from src/scanners.re with 100% similarity]
Sources/libMultiMarkdown/stack.c [moved from src/stack.c with 100% similarity]
Sources/libMultiMarkdown/stack.h [moved from src/stack.h with 100% similarity]
Sources/libMultiMarkdown/token.c [moved from src/token.c with 100% similarity]
Sources/libMultiMarkdown/token_pairs.c [moved from src/token_pairs.c with 100% similarity]
Sources/libMultiMarkdown/token_pairs.h [moved from src/token_pairs.h with 100% similarity]
Sources/libMultiMarkdown/transclude.c [moved from src/transclude.c with 100% similarity]
Sources/libMultiMarkdown/transclude.h [moved from src/transclude.h with 100% similarity]
Sources/libMultiMarkdown/uthash.h [moved from src/uthash.h with 100% similarity]
Sources/libMultiMarkdown/writer.c [moved from src/writer.c with 100% similarity]
Sources/libMultiMarkdown/writer.h [moved from src/writer.h with 100% similarity]
Sources/mmd-swift/main.swift [new file with mode: 0644]
Sources/multimarkdown/argtable3.c [moved from src/argtable3.c with 100% similarity]
Sources/multimarkdown/argtable3.h [moved from src/argtable3.h with 100% similarity]
Sources/multimarkdown/main.c [moved from src/main.c with 100% similarity]

index ff8594afa0792338ffca54f35f13dbbb1c37ac53..cab183678099234b215dc8e15d3e029c94590b59 100644 (file)
@@ -28,3 +28,7 @@ test/parser_test.c
 test/parser_test.h
 test/parser_test.out
 test/a.out
+
+/.build
+/Packages
+/mmd-swift.xcodeproj
\ No newline at end of file
index 211f59183b02affd8b773c10b4b63c73462aa636..b1d22b0757712f9082064d660156dfd2e269b073 100644 (file)
@@ -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})
 
@@ -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
@@ -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()
@@ -392,8 +392,8 @@ 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 "")
@@ -401,8 +401,9 @@ 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?
index 5be146ff36f1e17d220a65fd75db060234f46932..3c9d966f1110b546c09e945a61555fcb256dca94 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -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)
diff --git a/Package.swift b/Package.swift
new file mode 100644 (file)
index 0000000..c042eac
--- /dev/null
@@ -0,0 +1,9 @@
+import PackageDescription
+
+let package = Package(
+    name: "mmd-swift",
+    targets: [
+       Target(name: "mmd-swift", dependencies: ["libMultiMarkdown"])
+    ],
+    exclude: ["tests", "Tests", "Sources/multimarkdown"]
+)
similarity index 100%
rename from src/char.c
rename to Sources/libMultiMarkdown/char.c
similarity index 100%
rename from src/char.h
rename to Sources/libMultiMarkdown/char.h
similarity index 100%
rename from src/html.c
rename to Sources/libMultiMarkdown/html.c
similarity index 100%
rename from src/html.h
rename to Sources/libMultiMarkdown/html.h
similarity index 100%
rename from src/i18n.h
rename to Sources/libMultiMarkdown/i18n.h
similarity index 100%
rename from src/latex.c
rename to Sources/libMultiMarkdown/latex.c
similarity index 100%
rename from src/latex.h
rename to Sources/libMultiMarkdown/latex.h
similarity index 100%
rename from src/lexer.c
rename to Sources/libMultiMarkdown/lexer.c
similarity index 100%
rename from src/lexer.h
rename to Sources/libMultiMarkdown/lexer.h
similarity index 100%
rename from src/mmd.c
rename to Sources/libMultiMarkdown/mmd.c
similarity index 100%
rename from src/mmd.h
rename to Sources/libMultiMarkdown/mmd.h
similarity index 100%
rename from src/rng.c
rename to Sources/libMultiMarkdown/rng.c
similarity index 100%
rename from src/stack.c
rename to Sources/libMultiMarkdown/stack.c
similarity index 100%
rename from src/stack.h
rename to Sources/libMultiMarkdown/stack.h
similarity index 100%
rename from src/token.c
rename to Sources/libMultiMarkdown/token.c
diff --git a/Sources/mmd-swift/main.swift b/Sources/mmd-swift/main.swift
new file mode 100644 (file)
index 0000000..f8c3781
--- /dev/null
@@ -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()
similarity index 100%
rename from src/main.c
rename to Sources/multimarkdown/main.c