Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellacosse committed Nov 13, 2023
1 parent 6ef1700 commit d8440d2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
* @Jigsaw-Code/outline-dev

/outline/tun2socks/ @Jigsaw-Code/outline-networking-owners
/src/tun2socks/ @Jigsaw-Code/outline-networking-owners
/src/cordova/plugin/ @Jigsaw-Code/outline-networking-owners
/third_party/ @Jigsaw-Code/outline-networking-owners
/tools/ @Jigsaw-Code/outline-networking-owners
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.18
require (
github.com/Jigsaw-Code/outline-sdk v0.0.7
github.com/Jigsaw-Code/outline-sdk/x v0.0.0-20230807220427-893de7fdc6b8
github.com/crazy-max/xgo v0.26.0
github.com/crazy-max/xgo v0.30.0
github.com/eycorsican/go-tun2socks v1.16.11
github.com/stretchr/testify v1.8.4
golang.org/x/mobile v0.0.0-20230906132913-2077a3224571
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ github.com/Jigsaw-Code/outline-sdk/x v0.0.0-20230807220427-893de7fdc6b8 h1:BxOHm
github.com/Jigsaw-Code/outline-sdk/x v0.0.0-20230807220427-893de7fdc6b8/go.mod h1:tBqJXpVm+kym+EAUdwNodcFxy872FfjVErfj8Br+gs0=
github.com/crazy-max/xgo v0.26.0 h1:vK4OfeXJoDGvnjlzdTCgPbeWLKENbzj84DTpU/VRonM=
github.com/crazy-max/xgo v0.26.0/go.mod h1:m/aqfKaN/cYzfw+Pzk7Mk0tkmShg3/rCS4Zdhdugi4o=
github.com/crazy-max/xgo v0.30.0 h1:2uunjwLBrVu5LKIS1dIDXz9U5OIX4H5LEsC3P6wFTto=
github.com/crazy-max/xgo v0.30.0/go.mod h1:m/aqfKaN/cYzfw+Pzk7Mk0tkmShg3/rCS4Zdhdugi4o=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/eycorsican/go-tun2socks v1.16.11 h1:+hJDNgisrYaGEqoSxhdikMgMJ4Ilfwm/IZDrWRrbaH8=
Expand Down
2 changes: 1 addition & 1 deletion src/build/spawn_stream.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const spawnStream = (command, ...parameters) =>
const stdout = [];
const stderr = [];

console.debug(`Running [${[command, ...parameters.map(e => `'${e}'`)].join(' ')}]`);
console.debug(chalk.gray(`Running [${[command, ...parameters.map(e => `'${e}'`)].join(' ')}]...`));
const childProcess = spawn(command, parameters, {env: process.env});

const forEachMessageLine = (buffer, callback) => {
Expand Down
43 changes: 17 additions & 26 deletions src/tun2socks/build.action.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,79 +12,70 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import url from 'url';
import fs from 'node:fs/promises';

import {spawnStream} from '../build/spawn_stream.mjs';
import {getBuildParameters} from '../build/get_build_parameters.mjs';
import {getRootDir} from '../build/get_root_dir.mjs';

/**
* @description TODO: Add description
* @description Builds the tun2socks library for the specified platform.
*
* @param {string[]} parameters
*/
export async function main(...parameters) {
const {platform} = getBuildParameters(parameters);

const outputDir = `${getRootDir()}/build/${platform}/tun2socks`;
const outputDir = `${getRootDir()}/build/${platform}`;

await fs.mkdir(outputDir, {recursive: true});

switch (platform) {
case 'android':
return spawnStream(
'gomobile',
'-a',
'bind',
'-androidapi=33',
'-ldflags=-w',
'-tags=android',
'-target=android',
'-work',
`-o=${outputDir}`,
`-o=${outputDir}/tun2socks.aar`,
'github.com/Jigsaw-Code/outline-client/src/tun2socks/outline/tun2socks',
'github.com/Jigsaw-Code/outline-client/src/tun2socks/outline/shadowsocks'
);
case 'ios':
return spawnStream(
'gomobile',
'-bundleid=org.outline.tun2socks',
'-iosversion=13.1',
"-ldflags='-s -w'",
'-target=ios,iossimulator',
`-o=${outputDir}`,
'github.com/Jigsaw-Code/outline-client/src/tun2socks/outline/tun2socks',
'github.com/Jigsaw-Code/outline-client/src/tun2socks/outline/shadowsocks'
);
case 'macos':
case 'maccatalyst':
process.env.MACOSX_DEPLOYMENT_TARGET = '10.14';

return spawnStream(
'gomobile',
'bind',
'-bundleid=org.outline.tun2socks',
'-iosversion=13.1',
"-ldflags='-s -w'",
'-target=macos,maccatalyst',
`-o=${outputDir}`,
`-target=${platform}`,
`-o=${outputDir}/tun2socks.xcframework`,
'github.com/Jigsaw-Code/outline-client/src/tun2socks/outline/tun2socks',
'github.com/Jigsaw-Code/outline-client/src/tun2socks/outline/shadowsocks'
);
case 'windows':
return spawnStream(
'xgo',
'-targets=windows/386',
"-ldflags='-s -w -X main.version=v1.16.11'",
`-dest=${outputDir}`,
`-dest=${outputDir}/tun2socks.exe`,
'-pkg=outline/electron',
`${getRootDir()}/src/tun2socks`
'github.com/Jigsaw-Code/outline-client/src/tun2socks'
);
case 'linux':
return spawnStream(
'xgo',
'-targets=linux/amd64',
"-ldflags='-s -w -X main.version=v1.16.11'",
`-dest=${outputDir}`,
`-dest=${outputDir}/tun2socks`,
'-pkg=outline/electron',
`${getRootDir()}/src/tun2socks`
'github.com/Jigsaw-Code/outline-client/src/tun2socks'
);
}
}

if (import.meta.url === url.pathToFileURL(process.argv[1]).href) {
await main(...process.argv.slice(2));
}

0 comments on commit d8440d2

Please sign in to comment.