Skip to content

Commit

Permalink
merge waneck-changes from nightly-travis branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed Sep 12, 2017
1 parent 0cecc83 commit a0577b7
Show file tree
Hide file tree
Showing 12 changed files with 223 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*.exe
.*.swp
/out
/installer

/extra/hxclasses
/extra/*.swf
Expand Down Expand Up @@ -68,6 +69,7 @@ build.bat
/.vscode
tests/unit/compile.php.hxml
/extra/*.xml
!/extra/build-haxesetup.xml
tests/optimization/testopt.js
tests/misc/pythonImport/native_python/__pycache__
tests/unit/unit.py
Expand Down
50 changes: 49 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ INSTALL_BIN_DIR=$(INSTALL_DIR)/bin
INSTALL_LIB_DIR=$(INSTALL_DIR)/lib/haxe
INSTALL_STD_DIR=$(INSTALL_DIR)/share/haxe/std
PACKAGE_OUT_DIR=out
INSTALLER_TMP_DIR=installer
PACKAGE_SRC_EXTENSION=.tar.gz

MAKEFILENAME?=Makefile
Expand Down Expand Up @@ -155,7 +156,7 @@ quickcpp: build_src build_pass_4 copy_haxetoolkit

CPP_OS := $(shell uname)
ifeq ($(CPP_OS),Linux)
copy_haxetoolkit:
copy_haxetoolkit:
sudo cp haxe /usr/bin/haxe
else
copy_haxetoolkit: /cygdrive/c/HaxeToolkit/haxe/haxe.exe
Expand Down Expand Up @@ -249,6 +250,53 @@ deploy_doc:
scp $(PACKAGE_OUT_DIR)/$(PACKAGE_FILE_NAME)_doc.zip [email protected]:/data/haxeapi/www/v/dev/api-latest.zip
ssh [email protected] "cd /data/haxeapi/www/v/dev && find . ! -name 'api-latest.zip' -maxdepth 1 -mindepth 1 -exec rm -rf {} + && unzip -q -o api-latest.zip"

# Installer

package_installer_mac:
$(eval DOCFILE := $(shell pwd)/$(PACKAGE_OUT_DIR)/$(PACKAGE_FILE_NAME)_doc.zip)
$(eval OUTFILE := $(shell pwd)/$(PACKAGE_OUT_DIR)/$(PACKAGE_FILE_NAME)_installer.tar.gz)
$(eval PACKFILE := $(shell pwd)/$(PACKAGE_OUT_DIR)/$(PACKAGE_FILE_NAME)_bin.tar.gz)
$(eval VERSION := $(shell haxe -version 2>&1))
$(eval NEKOVER := $(shell neko -version 2>&1))
bash -c "rm -rf $(INSTALLER_TMP_DIR)/{resources,pkg,tgz,haxe.tar.gz}"
mkdir $(INSTALLER_TMP_DIR)/resources
# neko - unpack to change the dir name
cd $(INSTALLER_TMP_DIR)/resources && tar -zxvf ../neko-osx64.tar.gz
mv $(INSTALLER_TMP_DIR)/resources/neko* $(INSTALLER_TMP_DIR)/resources/neko
cd $(INSTALLER_TMP_DIR)/resources && tar -zcvf neko.tar.gz neko
# haxe - unpack to change the dir name
cd $(INSTALLER_TMP_DIR)/resources && tar -zxvf $(PACKFILE)
mv $(INSTALLER_TMP_DIR)/resources/haxe* $(INSTALLER_TMP_DIR)/resources/haxe
cd $(INSTALLER_TMP_DIR)/resources && tar -zcvf haxe.tar.gz haxe
# scripts
cp -rf extra/mac-installer/* $(INSTALLER_TMP_DIR)/resources
cd $(INSTALLER_TMP_DIR)/resources && tar -zcvf scripts.tar.gz scripts
# installer structure
mkdir -p $(INSTALLER_TMP_DIR)/pkg
cd $(INSTALLER_TMP_DIR)/pkg && xar -xf ../resources/installer-structure.pkg .
mkdir $(INSTALLER_TMP_DIR)/tgz; mv $(INSTALLER_TMP_DIR)/resources/*.tar.gz $(INSTALLER_TMP_DIR)/tgz
cd $(INSTALLER_TMP_DIR)/tgz; find . | cpio -o --format odc | gzip -c > ../pkg/files.pkg/Payload
cd $(INSTALLER_TMP_DIR)/pkg/files.pkg && bash -c "INSTKB=$$(du -sk ../../tgz | awk '{print $$1;}'); \
du -sk ../../tgz; \
echo $$INSTKB ; \
INSTKBH=`expr $$INSTKB - 4`; \
echo $$INSTKBH ;\
sed -i '' 's/%%INSTKB%%/$$INSTKBH/g' PackageInfo ;\
sed -i '' 's/%%VERSION%%/$(VERSION)/g' PackageInfo ;\
sed -i '' 's/%%VERSTRING%%/$(VERSION)/g' PackageInfo ;\
sed -i '' 's/%%VERLONG%%/$(VERSION)/g' PackageInfo ;\
sed -i '' 's/%%NEKOVER%%/$(NEKOVER)/g' PackageInfo ;\
cd .. ;\
sed -i '' 's/%%VERSION%%/$(VERSION)/g' Distribution ;\
sed -i '' 's/%%VERSTRING%%/$(VERSION)/g' Distribution ;\
sed -i '' 's/%%VERLONG%%/$(VERSION)/g' Distribution ;\
sed -i '' 's/%%NEKOVER%%/$(NEKOVER)/g' Distribution ;\
sed -i '' 's/%%INSTKB%%/$$INSTKBH/g' Distribution"
# repackage
cd $(INSTALLER_TMP_DIR)/pkg; xar --compression none -cf ../$(PACKAGE_FILE_NAME).pkg *
# tar
cd $(INSTALLER_TMP_DIR); tar -zcvf $(OUTFILE) $(PACKAGE_FILE_NAME).pkg

# Clean

clean: clean_libs clean_haxe clean_tools clean_package
Expand Down
28 changes: 28 additions & 0 deletions Makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,31 @@ package_choco:
cd out/choco && choco pack
mv out/choco/haxe.*.nupkg out
rm -rf out/choco

package_installer_win:
$(eval OUTFILE := $(PACKAGE_OUT_DIR)/$(PACKAGE_FILE_NAME)_installer.zip)
$(eval VERSION := $(shell haxe -version 2>&1 | cut -d ' ' -f1))
rm -rf $(INSTALLER_TMP_DIR)/resources
# neko
mkdir $(INSTALLER_TMP_DIR)/resources
cd $(INSTALLER_TMP_DIR) && 7z x -y neko-win.zip
rm $(INSTALLER_TMP_DIR)/neko-win.zip
mv $(INSTALLER_TMP_DIR)/neko* $(INSTALLER_TMP_DIR)/resources/neko
# haxe
7z x -y $(PACKAGE_OUT_DIR)/$(PACKAGE_FILE_NAME)_bin.zip -o$(INSTALLER_TMP_DIR)/resources
mv $(INSTALLER_TMP_DIR)/resources/haxe* $(INSTALLER_TMP_DIR)/resources/haxe
# haxesetup.exe
haxelib path hxcpp || haxelib install hxcpp
cd extra; haxelib run hxcpp build-haxesetup.xml
cp extra/haxesetup.exe $(INSTALLER_TMP_DIR)/resources/haxe
# extra
cp extra/*.nsi $(INSTALLER_TMP_DIR)
cp extra/*.nsh $(INSTALLER_TMP_DIR)
cp -rf extra/images $(INSTALLER_TMP_DIR)
# nsis
sed -i "s/%%VERSION%%/$(VERSION)/g" $(INSTALLER_TMP_DIR)/installer.nsi
sed -i "s/%%VERSTRING%%/$(VERSION)/g" $(INSTALLER_TMP_DIR)/installer.nsi
sed -i "s/%%VERLONG%%/$(VERSION)/g" $(INSTALLER_TMP_DIR)/installer.nsi
cd $(INSTALLER_TMP_DIR) && makensis installer.nsi
7z a -r -tzip $(OUTFILE) $(INSTALLER_TMP_DIR)/*.exe
dir $(PACKAGE_OUT_DIR)
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ install:
# Install neko
- choco install neko --prerelease --ignore-dependencies -s 'https://ci.appveyor.com/nuget/neko' -y
- choco install chocolatey-core.extension php --ignore-dependencies -y
- choco install nsis.portable
- choco install wget
- echo extension=php_openssl.dll >> C:\tools\php71\php.ini
- RefreshEnv
- neko -version
Expand Down
16 changes: 16 additions & 0 deletions extra/build-haxesetup.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<xml>

<include name="${HXCPP}/build-tool/BuildCommon.xml"/>
<set name="static_link" value="1" />
<set name="no_console" value="1" />

<files id="haxesetup">
<file name="setup.cpp" />
</files>

<target id="default" output="haxesetup" tool="linker" toolid="exe">
<lib name="advapi32.lib" />
<files id="haxesetup" />
</target>

</xml>
Binary file added extra/mac-installer/installer-structure.pkg
Binary file not shown.
13 changes: 13 additions & 0 deletions extra/mac-installer/scripts/haxe-postinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
rm -f /usr/bin/haxe
rm -f /usr/local/bin/haxe
rm -f /usr/bin/haxedoc
rm -f /usr/local/bin/haxedoc
rm -f /usr/bin/haxelib
rm -f /usr/local/bin/haxelib
rm -f ~/.haxelib
rm -f $HOME/.haxelib
ln -s /usr/local/lib/haxe/haxe /usr/local/bin/haxe
cp /usr/local/lib/haxe/haxelib /usr/local/bin/haxelib
mkdir -p /usr/local/lib/haxe/lib
chmod 777 /usr/local/lib/haxe/lib
8 changes: 8 additions & 0 deletions extra/mac-installer/scripts/haxe-preinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

#ensure no conflicting version is left there
rm -rf /usr/lib/haxe/std
rm -rf /usr/lib/haxe/doc
rm -f /usr/lib/haxe/haxe
rm -rf /usr/local/lib/haxe/std
rm -rf /usr/local/lib/haxe/doc
18 changes: 18 additions & 0 deletions extra/mac-installer/scripts/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
cd $(dirname $0)
# haxe
chmod +x *
./haxe-preinstall.sh
rm -f /usr/lib/haxe
rm -f /usr/local/lib/haxe
mkdir -p /usr/local/lib/haxe
mkdir -p /usr/local/bin
cp -Rf ../haxe/* /usr/local/lib/haxe
./haxe-postinstall.sh
./neko-preinstall.sh
rm -f /usr/local/lib/neko
mkdir -p /usr/local/lib/neko
cp -Rf ../neko/* /usr/local/lib/neko
./neko-postinstall.sh
cd ../
rm -Rf /tmp/haxe
19 changes: 19 additions & 0 deletions extra/mac-installer/scripts/neko-postinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
rm -f /usr/bin/neko
rm -f /usr/bin/nekoc
rm -f /usr/bin/nekoml
rm -f /usr/bin/nekotools
rm -f /usr/lib/libneko.dylib
rm -f /usr/local/bin/neko
rm -f /usr/local/bin/nekoc
rm -f /usr/local/bin/nekoml
rm -f /usr/local/bin/nekotools
rm -f /usr/local/lib/libneko*.dylib

ln -s /usr/local/lib/neko/neko /usr/local/bin/neko
ln -s /usr/local/lib/neko/nekoc /usr/local/bin/nekoc
ln -s /usr/local/lib/neko/nekoml /usr/local/bin/nekoml
ln -s /usr/local/lib/neko/nekotools /usr/local/bin/nekotools
ln -s /usr/local/lib/neko/libneko.dylib /usr/local/lib/libneko.dylib
ln -s /usr/local/lib/neko/libneko.2.dylib /usr/local/lib/libneko.2.dylib
ln -s /usr/local/lib/neko/libneko.2.1.0.dylib /usr/local/lib/libneko.2.1.0.dylib
3 changes: 3 additions & 0 deletions extra/mac-installer/scripts/neko-preinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
rm -rf /usr/lib/neko
rm -rf /usr/local/lib/neko
77 changes: 65 additions & 12 deletions tests/RunCi.hx
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,13 @@ class RunCi {
static function deploy():Void {

var doDocs = isDeployApiDocsRequired();
var doNightlies = isDeployNightlies();
var doNightlies = isDeployNightlies(),
doInstaller = doNightlies && shouldDeployInstaller();

if (doDocs || doNightlies) {
changeDirectory(repoDir);
if (doDocs) {
if (Sys.systemName() != 'Windows') {
if (systemName != 'Windows') {
// generate doc
runCommand("make", ["-s", "install_dox"]);
runCommand("make", ["-s", "package_doc"]);
Expand All @@ -591,7 +592,12 @@ class RunCi {
}
}
if (doNightlies) {
deployNightlies();
if (doInstaller && !doDocs && systemName != 'Windows') {
// generate doc
runCommand("make", ["-s", "install_dox"]);
runCommand("make", ["-s", "package_doc"]);
}
deployNightlies(doInstaller);
}
}
}
Expand Down Expand Up @@ -625,6 +631,17 @@ class RunCi {
}
}

static function shouldDeployInstaller() {
if (systemName == 'Linux') {
return false;
}
if (gitInfo.branch == 'nightly-travis') {
return true;
}
var rev = Sys.getEnv('ADD_REVISION');
return rev != null && rev != "0";
}

static function isDeployApiDocsRequired () {
return gitInfo.branch == "development" &&
Sys.getEnv("DEPLOY_API_DOCS") != null &&
Expand All @@ -647,7 +664,7 @@ class RunCi {
/**
Deploy source package to hxbuilds s3
*/
static function deployNightlies():Void {
static function deployNightlies(doInstaller:Bool):Void {
var gitTime = commandResult("git", ["show", "-s", "--format=%ct", "HEAD"]).stdout;
var tzd = {
var z = Date.fromTime(0);
Expand All @@ -664,7 +681,11 @@ class RunCi {
) {
if (ci == TravisCI) {
runCommand("make", ["-s", "package_unix"]);
if (Sys.systemName() == 'Linux') {
if (doInstaller) {
getLatestNeko();
runCommand("make", ["-s", 'package_installer_mac']);
}
if (systemName == 'Linux') {
// source
for (file in sys.FileSystem.readDirectory('out')) {
if (file.startsWith('haxe') && file.endsWith('_src.tar.gz')) {
Expand All @@ -674,17 +695,32 @@ class RunCi {
}
}
for (file in sys.FileSystem.readDirectory('out')) {
if (file.startsWith('haxe') && file.endsWith('_bin.tar.gz')) {
var name = Sys.systemName() == "Linux" ? 'linux64' : 'mac';
submitToS3(name, 'out/$file');
break;
if (file.startsWith('haxe')) {
if (file.endsWith('_bin.tar.gz')) {
var name = systemName == "Linux" ? 'linux64' : 'mac';
submitToS3(name, 'out/$file');
} else if (file.endsWith('_installer.tar.gz')) {
submitToS3('mac-installer', 'out/$file');
}
}
}
} else {
if (doInstaller) {
getLatestNeko();
var cygRoot = Sys.getEnv("CYG_ROOT");
if (cygRoot != null) {
runCommand('$cygRoot/bin/bash', ['-lc', "cd \"$OLDPWD\" && make -s -f Makefile.win package_installer_win"]);
} else {
runCommand("make", ['-f', 'Makefile.win', "-s", 'package_installer_win']);
}
}
for (file in sys.FileSystem.readDirectory('out')) {
if (file.startsWith('haxe') && file.endsWith('_bin.zip')) {
submitToS3('windows', 'out/$file');
break;
if (file.startsWith('haxe')) {
if (file.endsWith('_bin.zip')) {
submitToS3('windows', 'out/$file');
} else if (file.endsWith('_installer.zip')) {
submitToS3('windows-installer', 'out/$file');
}
}
}
}
Expand All @@ -693,6 +729,23 @@ class RunCi {
}
}

static function getLatestNeko() {
if (!FileSystem.exists('installer')) {
FileSystem.createDirectory('installer');
}
var src = 'http://nekovm.org/media/neko-2.1.0-';
var suffix = systemName == 'Windows' ? 'win.zip' : 'osx64.tar.gz';
src += suffix;
runCommand("wget", [src, '-O', 'installer/neko-$suffix'], true);
}

static function createNsiInstaller() {
if (!FileSystem.exists('installer')) {
FileSystem.createDirectory('installer');
}
getLatestNeko();
}

static function fileExtension(file:String) {
file = haxe.io.Path.withoutDirectory(file);
var idx = file.indexOf('.');
Expand Down

0 comments on commit a0577b7

Please sign in to comment.