Skip to content

Commit

Permalink
Implement argv[0], optimize gradle config.
Browse files Browse the repository at this point in the history
  • Loading branch information
dim-s committed Apr 21, 2017
1 parent afc3e55 commit fd14fd2
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 14 deletions.
11 changes: 0 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
def javaVersion = '1.7';
def projectVersion = '0.9.0';

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
}
}

allprojects {
apply plugin: 'idea'
apply plugin: 'signing'
apply plugin: 'java'
apply plugin: 'maven'

project.group = 'org.develnext.jphp'
project.version = projectVersion
Expand Down Expand Up @@ -46,7 +36,6 @@ allprojects {
}

configure(subprojects) {
apply plugin: 'maven'
apply plugin: 'java'

sourceCompatibility = javaVersion
Expand Down
2 changes: 2 additions & 0 deletions jphp-core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
apply plugin: 'maven'

sourceSets {
main.java.srcDirs = ['src']
main.resources.srcDirs = ['resources']
Expand Down
9 changes: 8 additions & 1 deletion jphp-core/src/php/runtime/launcher/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import java.io.*;
import java.net.URL;
import java.net.URLDecoder;
import java.util.*;

public class Launcher {
Expand Down Expand Up @@ -322,7 +323,13 @@ public void run(boolean mustBootstrap, boolean disableExtensions) throws Throwab
initModule(bootstrap);

ArrayMemory argv = ArrayMemory.ofStrings(this.args);
argv.unshift(Memory.NULL);

String path = URLDecoder.decode(
Launcher.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath(),
"UTF-8"
);

argv.unshift(StringMemory.valueOf(path));

environment.getGlobals().put("argv", argv);
environment.getGlobals().put("argc", LongMemory.valueOf(argv.size()));
Expand Down
2 changes: 2 additions & 0 deletions jphp-debugger/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
apply plugin: 'maven'

dependencies {
compile project(':jphp-core')
compile 'commons-codec:commons-codec:1.10'
Expand Down
2 changes: 2 additions & 0 deletions jphp-json-ext/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
apply plugin: 'maven'

dependencies {
compile project(':jphp-runtime')
compile 'com.google.code.gson:gson:2.7'
Expand Down
2 changes: 1 addition & 1 deletion jphp-jsoup-ext/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

apply plugin: 'maven'

dependencies {
compile project(':jphp-runtime')
Expand Down
1 change: 1 addition & 0 deletions jphp-mail-ext/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
apply plugin: 'maven'

dependencies {
compile project(':jphp-runtime')
Expand Down
2 changes: 2 additions & 0 deletions jphp-runtime/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
apply plugin: 'maven'

sourceSets {
main.java.srcDirs = ['src']
}
Expand Down
2 changes: 2 additions & 0 deletions jphp-scripting/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
apply plugin: 'maven'

sourceSets {
main {
java {
Expand Down
1 change: 1 addition & 0 deletions jphp-sql-ext/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
apply plugin: 'maven'

dependencies {
compile project(':jphp-runtime')
Expand Down
1 change: 1 addition & 0 deletions jphp-xml-ext/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
apply plugin: 'maven'

dependencies {
compile project(':jphp-runtime')
Expand Down
2 changes: 2 additions & 0 deletions jphp-zend-ext/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
apply plugin: 'maven'

sourceSets {
test.resources.srcDirs = ["src/main/tests"]
}
Expand Down
2 changes: 1 addition & 1 deletion sandbox/src/JPHP-INF/.bootstrap.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?echo "Hello World";
<?var_dump($argv);
Expand Down

0 comments on commit fd14fd2

Please sign in to comment.