Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-carlborg committed Nov 30, 2018
0 parents commit 46fcd0f
Show file tree
Hide file tree
Showing 25 changed files with 1,796 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.dub
docs.json
__dummy.html
docs/
dlp.so
dlp.dylib
dlp.dll
dlp.a
dlp.lib
dlp-test-*
*.exe
*.o
*.obj
*.lst
*.a
*.lib
/dlp
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "vendor/dmd"]
path = vendor/dmd
url = https://github.com/dlang/dmd
52 changes: 52 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
dist: trusty
git:
depth: false

language: d
d:
- dmd
- ldc-1.11.0

os:
- linux
- osx

env:
global: MACOSX_DEPLOYMENT_TARGET=10.9

matrix:
include:
# beta and nightly builds for DMD and LDC
- &entry
d: dmd-beta
os: linux
- <<: *entry
d: ldc-beta
- <<: *entry
d: dmd-nightly

# deployment
- &deploy
stage: deploy
if: tag IS present
d: ldc-beta
os: linux
script: ./tools/build_release.sh
deploy:
provider: releases
api_key:
secure: Sw5vEwezf+EzoxFeRNKk6PqsWv0HDXnC3JhVMwtaGNWAOdGc5rdZVcUIR88S5Q54eB16z1H+SHu9H/4SSdCschjjxsQmAqw/KicpjFw/puIgA96fpcQM+ixTbuXpw2YTfAn7jg9CWukDQ/3Wb70F8NV5hUPOpLPcyLloicp8Uy5LAmbvKIhegot/tzdRvKGaYjswHBFTThhiZEUFqZWMb/e/ge92Rp/Dhp+DdEb7XnPiqI/B6JRJs96KIdCj2o23GKFb83brIza8i6dsMybFLRiKhtrm1SgrFwyVdF9NRFe6/uDUJFJC8A6dWfhiYl24Pp3qCBU2SrlCEqdecBTx9SyjHfjJMvhlCYOxLNxvv86sGbmpfIIt/J0S+kAbi9tgcsGjtJhvnrHTPOy3Qd1mhg/+IrXccLSoL3zSvv7SNqPnxmA43skBdcswghjPBJyNtUk09WWnPUvcRAD6iBitQDC/ZYYC1+nkuMzGJ22tAiKlQ48tWI955kP9ClTf/pZrSMlXOuCAIaiUh7+iuR4O68XXF0AfWabGV5JV1TzNqTT4IofsdbCZbajjApVbUqvc/LB0zHzaTcchfLbUE7TS+Chc8cym+W8ebXvGN57L/7/jaaYbdtu++8bMaqDQidKo6B4krVtUxZoCTDkMHSKfxws1vThmWEZKzErNgsd//fE=
draft: true
tag_name: $TRAVIS_TAG
file_glob: true
file: dlp*.tar.xz
skip_cleanup: true
on:
repo: jacob-carlborg/dlp
tags: true
- <<: *deploy
os: osx

allow_failures:
- <<: *entry
d: dmd-nightly
58 changes: 58 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
platform:
- x64
- x86

environment:
DVersion: stable

matrix:
- d: dmd
- d: ldc

init:
- ps: |
if ($env:PLATFORM -eq 'x86')
{
$env:arch = 'x86'
$env:vcvarsall_arg = 'x86'
}
else
{
$env:arch = 'x86_64'
$env:vcvarsall_arg = 'x86_amd64'
}
install:
- ps: git submodule -q update --init --recursive
- ps: tools/install_dc.ps1

build_script:
- echo dummy build script - dont remove me

before_test:
- '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall" %vcvarsall_arg%'

test_script:
- ps: |
if ($env:APPVEYOR_REPO_TAG -eq 'true')
{
tools/build_release.ps1
}
else
{
dub test --verror --arch=$env:arch --compiler=$env:DC
}
artifacts:
- path: dlp*.7z

deploy:
description: ''
provider: GitHub
auth_token:
secure: YuE5X5DFwdA7qB+OFY93l7sCWVBQ77cqKSsAtAoTrK9rMiJogtd4dK0hAh1kOmbk
artifact: /dlp.+\.7z/
draft: true
on:
appveyor_repo_tag: true
d: ldc
31 changes: 31 additions & 0 deletions dub.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name "dlp"
description "Tool for processing the D language"
authors "Jacob Carlborg"
copyright "Copyright © 2018, Jacob Carlborg"
license "BSL-1.0"

targetType "executable"
mainSourceFile "source/dlp/driver/main.d"
dependency "dmd" path="vendor/dmd"

preGenerateCommands "$PACKAGE_DIR/tools/generate_version.sh" platform="posix"
preGenerateCommands "$PACKAGE_DIR/tools/generate_version.bat" platform="windows"

preBuildCommands "cl /nologo /EHsc /TP /c vendor/dmd/src/dmd/backend/strtold.c /Fotmp/strtold.obj /I vendor/dmd/src/dmd/root" platform="windows-x86_64-dmd"
preBuildCommands "cl /nologo /EHsc /TP /c vendor/dmd/src/dmd/backend/strtold.c /Fotmp/strtold.obj /I vendor/dmd/src/dmd/root" platform="windows-ldc"

stringImportPaths "tmp"

lflags "tmp/strtold.obj" platform="windows-x86_64-dmd"
lflags "tmp/strtold.obj" platform="windows-ldc"

buildType "release" {
buildOptions "optimize" "inline" platform="posix"
buildOptions "optimize" "inline" platform="windows-ldc"
buildOptions "optimize" platform="windows-dmd"

dflags "-flto=full" platform="posix-ldc"

lflags "-static" platform="linux-ldc"
lflags "-dead_strip" platform="osx"
}
8 changes: 8 additions & 0 deletions dub.selections.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"fileVersion": 1,
"versions": {
"dmd": {
"path": "vendor/dmd"
}
}
}
54 changes: 54 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# DLP - D Language Processing

DLP is a tool collecting commands/tasks related to processing the
D programming language. It uses the DMD frontend as a library to process D code.

## Requirements

To run this tool you need to have druntime and Phobos installed. This is easiest
accomplished by installing the DMD compiler: https://dlang.org/download.html.

## Download

For the latest release see: [releases/latest](https://github.com/jacob-carlborg/dlp/releases/latest).
Pre-compiled binaries are available for macOS and Linux as 64 bit binaries and
Windows as 32 and 64 bit binaries. The Linux binaries are completely statically
linked and should work on all distros. The macOS binaries should work on macOS
Mavericks (10.9) and later.

## Commands

* **leaf-functions** - Prints all leaf functions to standard out. A leaf
function is a function that doesn't call any other functions, or doesn't have
a body.

### Usage

```
$ cat test.d
void main()
{
}
$ dlp leaf-functions test
test.d(1): test.d.main
```

## Building

Building is done using Dub.

1. Clone the repository using:
```
git clone --recursive https://github.com/jacob-carlborg/dlp.git
```
1. Run `dub build` to build the project
## Running the Tests
Running the tests is done using Dub.
1. Clone the repository using:
```
git clone --recursive https://github.com/jacob-carlborg/dlp.git
```
1. Run `dub test` to run the tests
25 changes: 25 additions & 0 deletions source/dlp/core/algorithm.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module dlp.core.algorithm;

template flatMap(func...)
if (func.length >= 1)
{
import std.range : isInputRange;
import std.traits : Unqual;

auto flatMap(Range)(Range range) if (isInputRange!(Unqual!Range))
{
import std.algorithm : map, joiner;

return range.map!func.joiner;
}
}

///
unittest
{
import std.algorithm : equal;

[1, 2, 3, 4]
.flatMap!(e => [e, -e])
.equal([1, -1, 2, -2, 3, -3, 4, -4]);
}
Loading

0 comments on commit 46fcd0f

Please sign in to comment.