Coder Social home page Coder Social logo

Comments (6)

dabrahams avatar dabrahams commented on July 26, 2024 1

Because SPM doesn't support arbitrary build actions, right now I have a simple makefile that I use for my project:

# This Makefile is a thin layer on top of Swift package manager that handles the
# building of the citron parser generator binary and the generation of
# Sources/Parser.swift from Sources/Parser.citron.
GRAMMAR = ./Sources/Parser
CC = cc
SWIFTC = swiftc
BIN = ./bin
CITRON_SRC = ./citron/src
CITRON = ${BIN}/citron
SWIFT_FLAGS =
LCOV_FILE = ./.build/coverage.lcov
SHELL=/bin/bash

build: ${GRAMMAR}.swift
	swift build --enable-test-discovery ${SWIFT_FLAGS}

test: ${GRAMMAR}.swift
	swift test --enable-test-discovery ${SWIFT_FLAGS}

test-lcov: ${GRAMMAR}.swift
	swift build --build-tests --enable-code-coverage
	$$(swift test --enable-test-discovery --enable-code-coverage --verbose \
	   ${SWIFT_FLAGS} 2>&1 \
	   | tee /dev/tty | grep 'llvm-cov export' \
	   | sed -e 's/ export / export -format=lcov /') > "${LCOV_FILE}"

${CITRON}: ${CITRON_SRC}/citron.c
	mkdir -p ${BIN} && ${CC} $^ -o $@

clean:
	rm -rf ${GRAMMAR}.swift ./.build

${GRAMMAR}.swift: ${CITRON} ${GRAMMAR}.citron
	rm -f $@
	${CITRON} ${GRAMMAR}.citron -o $@
	chmod -w $@

from citron.

dabrahams avatar dabrahams commented on July 26, 2024

Another reason: I tried to define my own Error type and it broke CitronParser.swift which (reasonably) uses Swift.Error without qualification. If it were in its own module I wouldn't have had that problem.

from citron.

roop avatar roop commented on July 26, 2024

I think CitronLexer and CitronParser can be spawned off into separate SPM modules, but I'm not quite sure what do with citron.c. I think it should be in an executable module, but I'm not sure how it can get used by the consuming project.

How do you envisage running the citron executable when using Citron through SPM? (Maybe you'll have a Makefile or Xcode run phase?) Does making citron.c part of an executable module help?

from citron.

roop avatar roop commented on July 26, 2024

@dabrahams Can you please check if PR #13 (merged to master) suffices for your needs?

from citron.

dabrahams avatar dabrahams commented on July 26, 2024

Good start; I got this warning when using it as a package though:

'citron' /Users/dabrahams/src/barcon/.build/checkouts/citron: warning: found 1 file(s) which are unhandled; explicitly declare them as resources or exclude from the target
/Users/dabrahams/src/barcon/.build/checkouts/citron/Sources/CitronParserModule/LICENSE.txt

from citron.

roop avatar roop commented on July 26, 2024

Sorry about that. Hopefully, commit 05da734 in master should fix that.

from citron.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.